Search in sources :

Example 1 with AssociatedIdentityProvider

use of org.wso2.carbon.identity.user.profile.mgt.association.federation.model.AssociatedIdentityProvider 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)

Aggregations

ArrayList (java.util.ArrayList)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 FederatedAssociation (org.wso2.carbon.identity.user.profile.mgt.association.federation.model.FederatedAssociation)1