@Override
 public Identity getIdentity(Long id) {
   Account account = getAccountById(id);
   if (account == null || account.getKind().equalsIgnoreCase(ProjectConstants.TYPE)) {
     return null;
   }
   Credential credential =
       create()
           .selectFrom(CREDENTIAL)
           .where(
               CREDENTIAL
                   .KIND
                   .equalIgnoreCase(CredentialConstants.KIND_PASSWORD)
                   .and(CREDENTIAL.ACCOUNT_ID.eq(id))
                   .and(CREDENTIAL.STATE.equalIgnoreCase(CommonStatesConstants.ACTIVE)))
           .fetchAny();
   String accountId =
       (String)
           ApiContext.getContext()
               .getIdFormatter()
               .formatId(objectManager.getType(Account.class), account.getId());
   return new Identity(
       ProjectConstants.RANCHER_ID,
       accountId,
       account.getName(),
       null,
       null,
       credential == null ? null : credential.getPublicValue());
 }
 @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;
   }
 }