Search in sources :

Example 6 with ClaimAttributeMapping

use of org.wso2.carbon.identity.api.server.userstore.v1.model.ClaimAttributeMapping in project identity-api-server by wso2.

the class ServerUserStoreService method getClaimAttributeMappings.

/**
 * To list the claim attribute mappings for specific user store domain.
 *
 * @param tenantDomain        the tenant domain.
 * @param userstoreDomainName the user store domain name.
 * @return List<ClaimAttributeMapping>.
 */
private List<ClaimAttributeMapping> getClaimAttributeMappings(String tenantDomain, String userstoreDomainName) {
    ClaimMetadataManagementService claimMetadataManagementService = UserStoreConfigServiceHolder.getInstance().getClaimMetadataManagementService();
    List<ClaimAttributeMapping> claimAttributeMappingList = new ArrayList<>();
    try {
        List<LocalClaim> localClaimList = claimMetadataManagementService.getLocalClaims(tenantDomain);
        for (LocalClaim localClaim : localClaimList) {
            if (localClaim.getMappedAttribute(userstoreDomainName) != null) {
                ClaimAttributeMapping mapping = new ClaimAttributeMapping();
                mapping.setClaimURI(localClaim.getClaimURI());
                mapping.setMappedAttribute(localClaim.getMappedAttribute(userstoreDomainName));
                claimAttributeMappingList.add(mapping);
            }
        }
        return claimAttributeMappingList;
    } catch (ClaimMetadataException e) {
        throw handleClaimManagementException(e, UserStoreConstants.ErrorMessage.ERROR_CODE_ERROR_RETRIEVING_CLAIM_MAPPING);
    }
}
Also used : ClaimAttributeMapping(org.wso2.carbon.identity.api.server.userstore.v1.model.ClaimAttributeMapping) ClaimMetadataException(org.wso2.carbon.identity.claim.metadata.mgt.exception.ClaimMetadataException) ArrayList(java.util.ArrayList) LocalClaim(org.wso2.carbon.identity.claim.metadata.mgt.model.LocalClaim) ClaimMetadataManagementService(org.wso2.carbon.identity.claim.metadata.mgt.ClaimMetadataManagementService)

Aggregations

ArrayList (java.util.ArrayList)6 ClaimAttributeMapping (org.wso2.carbon.identity.api.server.userstore.v1.model.ClaimAttributeMapping)6 LocalClaim (org.wso2.carbon.identity.claim.metadata.mgt.model.LocalClaim)4 UserStoreConfigService (org.wso2.carbon.identity.user.store.configuration.UserStoreConfigService)3 IdentityUserStoreMgtException (org.wso2.carbon.identity.user.store.configuration.utils.IdentityUserStoreMgtException)3 AddUserStorePropertiesRes (org.wso2.carbon.identity.api.server.userstore.v1.model.AddUserStorePropertiesRes)2 UserStoreConfigurationsRes (org.wso2.carbon.identity.api.server.userstore.v1.model.UserStoreConfigurationsRes)2 UserStoreDTO (org.wso2.carbon.identity.user.store.configuration.dto.UserStoreDTO)2 UserStoreException (org.wso2.carbon.user.api.UserStoreException)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ClaimMetadataManagementService (org.wso2.carbon.identity.claim.metadata.mgt.ClaimMetadataManagementService)1 ClaimMetadataException (org.wso2.carbon.identity.claim.metadata.mgt.exception.ClaimMetadataException)1 AttributeMapping (org.wso2.carbon.identity.claim.metadata.mgt.model.AttributeMapping)1 PropertyDTO (org.wso2.carbon.identity.user.store.configuration.dto.PropertyDTO)1 RealmConfiguration (org.wso2.carbon.user.api.RealmConfiguration)1 RealmService (org.wso2.carbon.user.core.service.RealmService)1