@Override
 public Account getAccountByKeys(String access, String secretKey) {
   try {
     Credential credential =
         create()
             .selectFrom(CREDENTIAL)
             .where(CREDENTIAL.STATE.eq(CommonStatesConstants.ACTIVE))
             .and(CREDENTIAL.PUBLIC_VALUE.eq(access))
             .and(CREDENTIAL.KIND.in(SUPPORTED_TYPES.get()))
             .fetchOne();
     if (credential == null) {
       return null;
     }
     boolean secretIsCorrect =
         ApiContext.getContext()
             .getTransformationService()
             .compare(secretKey, credential.getSecretValue());
     if (secretIsCorrect) {
       return create()
           .selectFrom(ACCOUNT)
           .where(
               ACCOUNT
                   .ID
                   .eq(credential.getAccountId())
                   .and(ACCOUNT.STATE.eq(CommonStatesConstants.ACTIVE)))
           .fetchOneInto(AccountRecord.class);
     } else {
       return null;
     }
   } catch (InvalidResultException e) {
     throw new ClientVisibleException(ResponseCodes.CONFLICT, "MultipleKeys");
   }
 }
 @Override
 public Account getAccountByLogin(String publicValue, String secretValue) {
   Credential credential =
       create()
           .selectFrom(CREDENTIAL)
           .where(CREDENTIAL.STATE.eq(CommonStatesConstants.ACTIVE))
           .and(
               CREDENTIAL
                   .PUBLIC_VALUE
                   .eq(publicValue)
                   .and(CREDENTIAL.KIND.equalIgnoreCase(CredentialConstants.KIND_PASSWORD)))
           .fetchOne();
   if (credential == null) {
     return null;
   }
   boolean secretIsCorrect =
       ApiContext.getContext()
           .getTransformationService()
           .compare(secretValue, credential.getSecretValue());
   if (secretIsCorrect) {
     return create()
         .selectFrom(ACCOUNT)
         .where(
             ACCOUNT
                 .ID
                 .eq(credential.getAccountId())
                 .and(ACCOUNT.STATE.eq(CommonStatesConstants.ACTIVE)))
         .fetchOneInto(AccountRecord.class);
   } else {
     return null;
   }
 }
 @Override
 public Account getByUsername(String username) {
   try {
     return create()
         .select(ACCOUNT.fields())
         .from(ACCOUNT)
         .join(CREDENTIAL)
         .on(CREDENTIAL.ACCOUNT_ID.eq(ACCOUNT.ID))
         .where(
             ACCOUNT
                 .STATE
                 .eq(CommonStatesConstants.ACTIVE)
                 .and(CREDENTIAL.STATE.eq(CommonStatesConstants.ACTIVE))
                 .and(CREDENTIAL.PUBLIC_VALUE.eq(username)))
         .and(CREDENTIAL.KIND.eq(CredentialConstants.KIND_PASSWORD))
         .fetchOneInto(AccountRecord.class);
   } catch (InvalidResultException e) {
     throw new ClientVisibleException(ResponseCodes.CONFLICT, "MultipleOfUsername");
   }
 }