@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()); }
/** {@inheritDoc} */ @Override public void from(io.cattle.platform.core.model.Credential from) { setId(from.getId()); setName(from.getName()); setAccountId(from.getAccountId()); setKind(from.getKind()); setUuid(from.getUuid()); setDescription(from.getDescription()); setState(from.getState()); setCreated(from.getCreated()); setRemoved(from.getRemoved()); setRemoveTime(from.getRemoveTime()); setData(from.getData()); setPublicValue(from.getPublicValue()); setSecretValue(from.getSecretValue()); setRegistryId(from.getRegistryId()); }