Search in sources :

Example 1 with FederatedAssociation

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]);
}
Also used : FederatedAssociation(org.wso2.carbon.identity.user.profile.mgt.association.federation.model.FederatedAssociation) ArrayList(java.util.ArrayList)

Example 2 with FederatedAssociation

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);
    }
}
Also used : AssociatedAccountDTO(org.wso2.carbon.identity.user.profile.mgt.AssociatedAccountDTO) FederatedAssociation(org.wso2.carbon.identity.user.profile.mgt.association.federation.model.FederatedAssociation) UserProfileException(org.wso2.carbon.identity.user.profile.mgt.UserProfileException) ArrayList(java.util.ArrayList) AssociatedIdentityProvider(org.wso2.carbon.identity.user.profile.mgt.association.federation.model.AssociatedIdentityProvider)

Example 3 with FederatedAssociation

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;
}
Also used : FederatedAssociationDTO(org.wso2.carbon.identity.rest.api.user.association.v1.dto.FederatedAssociationDTO) IdpDTO(org.wso2.carbon.identity.rest.api.user.association.v1.dto.IdpDTO)

Aggregations

ArrayList (java.util.ArrayList)2 FederatedAssociation (org.wso2.carbon.identity.user.profile.mgt.association.federation.model.FederatedAssociation)2 FederatedAssociationDTO (org.wso2.carbon.identity.rest.api.user.association.v1.dto.FederatedAssociationDTO)1 IdpDTO (org.wso2.carbon.identity.rest.api.user.association.v1.dto.IdpDTO)1 AssociatedAccountDTO (org.wso2.carbon.identity.user.profile.mgt.AssociatedAccountDTO)1 UserProfileException (org.wso2.carbon.identity.user.profile.mgt.UserProfileException)1 AssociatedIdentityProvider (org.wso2.carbon.identity.user.profile.mgt.association.federation.model.AssociatedIdentityProvider)1