use of org.wso2.carbon.identity.user.profile.mgt.association.federation.model.FederatedAssociation in project carbon-identity-framework by wso2.
the class UserProfileAdmin method getAssociatedAccounts.
private AssociatedAccountDTO[] getAssociatedAccounts(User user) throws FederatedAssociationManagerException, UserProfileException {
FederatedAssociation[] federatedAssociations = getFederatedAssociationManager().getFederatedAssociationsOfUser(user);
List<AssociatedAccountDTO> associatedAccountDTOS = new ArrayList<>();
for (FederatedAssociation federatedAssociation : federatedAssociations) {
String identityProviderName = getIdentityProviderName(getTenantDomain(), federatedAssociation.getIdp().getId());
associatedAccountDTOS.add(new AssociatedAccountDTO(federatedAssociation.getId(), identityProviderName, federatedAssociation.getFederatedUserId()));
}
return associatedAccountDTOS.toArray(new AssociatedAccountDTO[0]);
}
use of org.wso2.carbon.identity.user.profile.mgt.association.federation.model.FederatedAssociation in project carbon-identity-framework by wso2.
the class FederatedAssociationManagerImpl method getFederatedAssociationsOfUser.
@Override
public FederatedAssociation[] getFederatedAssociationsOfUser(User user) throws FederatedAssociationManagerException {
validateUserObject(user);
int tenantId = getValidatedTenantId(user);
validateUserExistence(user, tenantId);
try {
List<FederatedAssociation> federatedAssociations = new ArrayList<>();
List<AssociatedAccountDTO> associatedAccountDTOS = UserProfileMgtDAO.getInstance().getAssociatedFederatedAccountsForUser(tenantId, user.getUserStoreDomain(), user.getUserName());
for (AssociatedAccountDTO associatedAccount : associatedAccountDTOS) {
AssociatedIdentityProvider idp = getAssociatedIdentityProvider(user.getTenantDomain(), associatedAccount.getIdentityProviderName());
federatedAssociations.add(new FederatedAssociation(associatedAccount.getId(), idp, associatedAccount.getUsername()));
}
return federatedAssociations.toArray(new FederatedAssociation[0]);
} catch (UserProfileException e) {
if (log.isDebugEnabled()) {
String msg = "Error while retrieving federated account associations of user: " + user.toFullQualifiedUsername();
log.debug(msg);
}
throw handleFederatedAssociationManagerServerException(ERROR_WHILE_RETRIEVING_FEDERATED_ASSOCIATION_OF_USER, e, true);
}
}
use of org.wso2.carbon.identity.user.profile.mgt.association.federation.model.FederatedAssociation in project identity-api-user by wso2.
the class UserAssociationService method getFederatedAssociationDTO.
private FederatedAssociationDTO getFederatedAssociationDTO(FederatedAssociation federatedAssociation) {
FederatedAssociationDTO federatedAssociationDTO = new FederatedAssociationDTO();
federatedAssociationDTO.setId(federatedAssociation.getId());
federatedAssociationDTO.setFederatedUserId(federatedAssociation.getFederatedUserId());
IdpDTO idpDTO = new IdpDTO();
idpDTO.setId(federatedAssociation.getIdp().getId());
idpDTO.setName(federatedAssociation.getIdp().getName());
if (federatedAssociation.getIdp().getDisplayName() == null) {
idpDTO.setDisplayName(StringUtils.EMPTY);
} else {
idpDTO.setDisplayName(federatedAssociation.getIdp().getDisplayName());
}
if (federatedAssociation.getIdp().getImageUrl() == null) {
idpDTO.setImageUrl(StringUtils.EMPTY);
} else {
idpDTO.setImageUrl(federatedAssociation.getIdp().getImageUrl());
}
federatedAssociationDTO.setIdp(idpDTO);
return federatedAssociationDTO;
}
Aggregations