Search in sources :

Example 36 with ClaimMapping

use of org.wso2.carbon.identity.application.common.model.xsd.ClaimMapping in project carbon-identity-framework by wso2.

the class ClaimAdminService method addNewClaimMapping.

/**
 * @param
 * @throws ClaimManagementException
 */
public void addNewClaimMapping(ClaimMappingDTO claimMappingDTO) throws ClaimManagementException {
    /*Convert the simple structure of ClaimMapping received, to the complex structure
        of ClaimMapping which is used in the back end. */
    ClaimMapping claimMapping = convertClaimMappingDTOToClaimMapping(claimMappingDTO);
    ClaimManagerHandler handler = ClaimManagerHandler.getInstance();
    ClaimMapping currentMapping = handler.getClaimMapping(claimMapping.getClaim().getClaimUri());
    if (currentMapping != null) {
        throw new ClaimManagementException("Duplicate claim exist in the system. Please pick a different Claim Uri");
    }
    handler.addNewClaimMapping(claimMapping);
}
Also used : ClaimMapping(org.wso2.carbon.user.api.ClaimMapping)

Example 37 with ClaimMapping

use of org.wso2.carbon.identity.application.common.model.xsd.ClaimMapping in project carbon-identity-framework by wso2.

the class ClaimAdminService method convertClaimMappingToClaimMappingDTO.

private ClaimMappingDTO convertClaimMappingToClaimMappingDTO(ClaimMapping claimMapping) {
    ClaimMappingDTO claimMappingDTO = new ClaimMappingDTO();
    claimMappingDTO.setClaim(convertClaimToClaimDTO(claimMapping.getClaim()));
    claimMappingDTO.setMappedAttribute(claimMapping.getMappedAttribute());
    Map<String, String> attributes = claimMapping.getMappedAttributes();
    if (attributes != null) {
        ClaimAttributeDTO[] attrDto = new ClaimAttributeDTO[attributes.size()];
        int i = 0;
        for (Map.Entry<String, String> entry : attributes.entrySet()) {
            ClaimAttributeDTO dto = new ClaimAttributeDTO();
            dto.setAttributeName(entry.getValue());
            dto.setDomainName(entry.getKey());
            attrDto[i++] = dto;
        }
        claimMappingDTO.setMappedAttributes(attrDto);
    }
    return claimMappingDTO;
}
Also used : ClaimMappingDTO(org.wso2.carbon.claim.mgt.dto.ClaimMappingDTO) ClaimAttributeDTO(org.wso2.carbon.claim.mgt.dto.ClaimAttributeDTO) HashMap(java.util.HashMap) Map(java.util.Map)

Example 38 with ClaimMapping

use of org.wso2.carbon.identity.application.common.model.xsd.ClaimMapping in project carbon-identity-framework by wso2.

the class ClaimAdminService method convertClaimMappingDTOToClaimMapping.

private ClaimMapping convertClaimMappingDTOToClaimMapping(ClaimMappingDTO claimMappingDTO) {
    ClaimMapping claimMapping = new ClaimMapping(convertClaimDTOToClaim(claimMappingDTO.getClaim()), claimMappingDTO.getMappedAttribute());
    ClaimAttributeDTO[] attributes = claimMappingDTO.getMappedAttributes();
    if (attributes != null) {
        for (ClaimAttributeDTO attribute : attributes) {
            if (attribute.getDomainName() != null) {
                claimMapping.setMappedAttribute(attribute.getDomainName(), attribute.getAttributeName());
            }
        }
    }
    return claimMapping;
}
Also used : ClaimMapping(org.wso2.carbon.user.api.ClaimMapping) ClaimAttributeDTO(org.wso2.carbon.claim.mgt.dto.ClaimAttributeDTO)

Example 39 with ClaimMapping

use of org.wso2.carbon.identity.application.common.model.xsd.ClaimMapping in project carbon-identity-framework by wso2.

the class ClaimAdminService method convertClaimMappingDTOArrayToClaimMappingArray.

private ClaimMapping[] convertClaimMappingDTOArrayToClaimMappingArray(ClaimMappingDTO[] claimMappingDTOs) {
    List<ClaimMapping> claimMappings = new ArrayList<ClaimMapping>();
    for (ClaimMappingDTO claimMappingDTO : claimMappingDTOs) {
        ClaimMapping claimMapping = convertClaimMappingDTOToClaimMapping(claimMappingDTO);
        claimMappings.add(claimMapping);
    }
    return claimMappings.toArray(new ClaimMapping[claimMappings.size()]);
}
Also used : ClaimMappingDTO(org.wso2.carbon.claim.mgt.dto.ClaimMappingDTO) ClaimMapping(org.wso2.carbon.user.api.ClaimMapping) ArrayList(java.util.ArrayList)

Example 40 with ClaimMapping

use of org.wso2.carbon.identity.application.common.model.xsd.ClaimMapping in project carbon-identity-framework by wso2.

the class ClaimAdminService method convertClaimMappingArrayToClaimMappingDTOArray.

private ClaimMappingDTO[] convertClaimMappingArrayToClaimMappingDTOArray(ClaimMapping[] claimMappings) {
    List<ClaimMappingDTO> claimMappingDTOList = new ArrayList<ClaimMappingDTO>();
    for (ClaimMapping claimMapping : claimMappings) {
        ClaimMappingDTO claimMappingDTO = convertClaimMappingToClaimMappingDTO(claimMapping);
        claimMappingDTOList.add(claimMappingDTO);
    }
    return claimMappingDTOList.toArray(new ClaimMappingDTO[claimMappingDTOList.size()]);
}
Also used : ClaimMappingDTO(org.wso2.carbon.claim.mgt.dto.ClaimMappingDTO) ClaimMapping(org.wso2.carbon.user.api.ClaimMapping) ArrayList(java.util.ArrayList)

Aggregations

ClaimMapping (org.wso2.carbon.identity.application.common.model.ClaimMapping)108 HashMap (java.util.HashMap)60 ArrayList (java.util.ArrayList)52 ClaimConfig (org.wso2.carbon.identity.application.common.model.ClaimConfig)27 Map (java.util.Map)26 ServiceProvider (org.wso2.carbon.identity.application.common.model.ServiceProvider)24 ClaimMapping (org.wso2.carbon.identity.application.common.model.xsd.ClaimMapping)24 ClaimMapping (org.wso2.carbon.user.api.ClaimMapping)24 Claim (org.wso2.carbon.identity.application.common.model.Claim)23 Test (org.testng.annotations.Test)22 Claim (org.wso2.carbon.identity.application.common.model.xsd.Claim)21 LocalClaim (org.wso2.carbon.identity.claim.metadata.mgt.model.LocalClaim)21 AuthenticatedUser (org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser)20 IdentityApplicationManagementException (org.wso2.carbon.identity.application.common.IdentityApplicationManagementException)20 List (java.util.List)17 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)17 UserStoreException (org.wso2.carbon.user.api.UserStoreException)17 Matchers.anyString (org.mockito.Matchers.anyString)16 IdentityProvider (org.wso2.carbon.identity.application.common.model.IdentityProvider)13 ClaimMetadataException (org.wso2.carbon.identity.claim.metadata.mgt.exception.ClaimMetadataException)13