Search in sources :

Example 1 with ClaimPropertyDTO

use of org.wso2.carbon.identity.claim.metadata.mgt.dto.ClaimPropertyDTO in project carbon-identity-framework by wso2.

the class ClaimDataAdminClient method getRegex.

public String getRegex(LocalClaimDTO[] localClaimDTO, String claimURI) {
    String pattern = "";
    for (LocalClaimDTO localClaim : localClaimDTO) {
        if (claimURI.equals(localClaim.getLocalClaimURI())) {
            ClaimPropertyDTO[] claimPropertyDTOs = localClaim.getClaimProperties();
            if (claimPropertyDTOs != null) {
                for (ClaimPropertyDTO claimPropertyDTO : claimPropertyDTOs) {
                    if (ClaimConstants.REGULAR_EXPRESSION_PROPERTY.equals(claimPropertyDTO.getPropertyName())) {
                        pattern = claimPropertyDTO.getPropertyValue();
                        pattern = "/" + pattern + "/";
                        break;
                    }
                }
            }
        }
    }
    return pattern;
}
Also used : ClaimPropertyDTO(org.wso2.carbon.identity.claim.metadata.mgt.stub.dto.ClaimPropertyDTO) LocalClaimDTO(org.wso2.carbon.identity.claim.metadata.mgt.stub.dto.LocalClaimDTO)

Example 2 with ClaimPropertyDTO

use of org.wso2.carbon.identity.claim.metadata.mgt.dto.ClaimPropertyDTO in project carbon-identity-framework by wso2.

the class ClaimMetadataUtils method convertLocalClaimToLocalClaimDTO.

public static LocalClaimDTO convertLocalClaimToLocalClaimDTO(LocalClaim localClaim) {
    LocalClaimDTO localClaimDTO = new LocalClaimDTO();
    localClaimDTO.setLocalClaimURI(localClaim.getClaimURI());
    // Convert List<AttributeMapping> to AttributeMappingDTO[]
    List<AttributeMapping> attributeMappings = localClaim.getMappedAttributes();
    AttributeMappingDTO[] attributeMappingDTOs = new AttributeMappingDTO[attributeMappings.size()];
    int i = 0;
    for (AttributeMapping attributeMapping : attributeMappings) {
        AttributeMappingDTO attributeMappingDTO = new AttributeMappingDTO();
        attributeMappingDTO.setUserStoreDomain(attributeMapping.getUserStoreDomain());
        attributeMappingDTO.setAttributeName(attributeMapping.getAttributeName());
        attributeMappingDTOs[i] = attributeMappingDTO;
        i++;
    }
    localClaimDTO.setAttributeMappings(attributeMappingDTOs);
    // Convert Map<String, String> to ClaimPropertyDTO[]
    Map<String, String> claimProperties = localClaim.getClaimProperties();
    ClaimPropertyDTO[] claimPropertyDTOs = new ClaimPropertyDTO[claimProperties.size()];
    int j = 0;
    for (Map.Entry<String, String> claimPropertyEntry : claimProperties.entrySet()) {
        ClaimPropertyDTO claimProperty = new ClaimPropertyDTO();
        claimProperty.setPropertyName(claimPropertyEntry.getKey());
        claimProperty.setPropertyValue(claimPropertyEntry.getValue());
        claimPropertyDTOs[j] = claimProperty;
        j++;
    }
    localClaimDTO.setClaimProperties(claimPropertyDTOs);
    return localClaimDTO;
}
Also used : ClaimPropertyDTO(org.wso2.carbon.identity.claim.metadata.mgt.dto.ClaimPropertyDTO) AttributeMappingDTO(org.wso2.carbon.identity.claim.metadata.mgt.dto.AttributeMappingDTO) AttributeMapping(org.wso2.carbon.identity.claim.metadata.mgt.model.AttributeMapping) HashMap(java.util.HashMap) Map(java.util.Map) LocalClaimDTO(org.wso2.carbon.identity.claim.metadata.mgt.dto.LocalClaimDTO)

Example 3 with ClaimPropertyDTO

use of org.wso2.carbon.identity.claim.metadata.mgt.dto.ClaimPropertyDTO in project carbon-identity-framework by wso2.

the class ClaimMetadataUtils method convertLocalClaimDTOToLocalClaim.

public static LocalClaim convertLocalClaimDTOToLocalClaim(LocalClaimDTO localClaimDTO) {
    // TODO : Validate if localClaimDTO null???
    LocalClaim localClaim = new LocalClaim(localClaimDTO.getLocalClaimURI());
    // Convert AttributeMappingDTO[] to List<AttributeMapping>
    if (localClaimDTO.getAttributeMappings() != null) {
        List<AttributeMapping> attributeMappings = new ArrayList<>();
        for (AttributeMappingDTO attributeMappingDTO : localClaimDTO.getAttributeMappings()) {
            attributeMappings.add(new AttributeMapping(attributeMappingDTO.getUserStoreDomain(), attributeMappingDTO.getAttributeName()));
        }
        localClaim.setMappedAttributes(attributeMappings);
    }
    // Convert ClaimPropertyDTO[] to Map<String, String>
    if (localClaimDTO.getClaimProperties() != null) {
        Map<String, String> claimProperties = new HashMap<>();
        for (ClaimPropertyDTO claimPropertyDTO : localClaimDTO.getClaimProperties()) {
            claimProperties.put(claimPropertyDTO.getPropertyName(), claimPropertyDTO.getPropertyValue());
        }
        localClaim.setClaimProperties(claimProperties);
    }
    return localClaim;
}
Also used : ClaimPropertyDTO(org.wso2.carbon.identity.claim.metadata.mgt.dto.ClaimPropertyDTO) AttributeMappingDTO(org.wso2.carbon.identity.claim.metadata.mgt.dto.AttributeMappingDTO) HashMap(java.util.HashMap) AttributeMapping(org.wso2.carbon.identity.claim.metadata.mgt.model.AttributeMapping) ArrayList(java.util.ArrayList) LocalClaim(org.wso2.carbon.identity.claim.metadata.mgt.model.LocalClaim)

Example 4 with ClaimPropertyDTO

use of org.wso2.carbon.identity.claim.metadata.mgt.dto.ClaimPropertyDTO in project carbon-identity-framework by wso2.

the class ClaimMetadataUtils method convertExternalClaimToExternalClaimDTO.

public static ExternalClaimDTO convertExternalClaimToExternalClaimDTO(ExternalClaim externalClaim) {
    ExternalClaimDTO externalClaimDTO = new ExternalClaimDTO();
    externalClaimDTO.setExternalClaimDialectURI(externalClaim.getClaimDialectURI());
    externalClaimDTO.setExternalClaimURI(externalClaim.getClaimURI());
    externalClaimDTO.setMappedLocalClaimURI(externalClaim.getMappedLocalClaim());
    // Convert Map<String, String> to ClaimPropertyDTO[]
    Map<String, String> claimProperties = externalClaim.getClaimProperties();
    ClaimPropertyDTO[] claimPropertyDTOs = new ClaimPropertyDTO[claimProperties.size()];
    int j = 0;
    for (Map.Entry<String, String> claimPropertyEntry : claimProperties.entrySet()) {
        ClaimPropertyDTO claimProperty = new ClaimPropertyDTO();
        claimProperty.setPropertyName(claimPropertyEntry.getKey());
        claimProperty.setPropertyValue(claimPropertyEntry.getValue());
        claimPropertyDTOs[j] = claimProperty;
        j++;
    }
    externalClaimDTO.setClaimProperties(claimPropertyDTOs);
    return externalClaimDTO;
}
Also used : ExternalClaimDTO(org.wso2.carbon.identity.claim.metadata.mgt.dto.ExternalClaimDTO) ClaimPropertyDTO(org.wso2.carbon.identity.claim.metadata.mgt.dto.ClaimPropertyDTO) HashMap(java.util.HashMap) Map(java.util.Map)

Example 5 with ClaimPropertyDTO

use of org.wso2.carbon.identity.claim.metadata.mgt.dto.ClaimPropertyDTO in project carbon-identity-framework by wso2.

the class ClaimMetadataUtils method convertExternalClaimDTOToExternalClaim.

public static ExternalClaim convertExternalClaimDTOToExternalClaim(ExternalClaimDTO externalClaimDTO) {
    // TODO : Validate if externalClaimDTO null???
    ExternalClaim externalClaim = new ExternalClaim(externalClaimDTO.getExternalClaimDialectURI(), externalClaimDTO.getExternalClaimURI(), externalClaimDTO.getMappedLocalClaimURI());
    // Convert ClaimPropertyDTO[] to Map<String, String>
    if (externalClaimDTO.getClaimProperties() != null) {
        Map<String, String> claimProperties = new HashMap<>();
        for (ClaimPropertyDTO claimPropertyDTO : externalClaimDTO.getClaimProperties()) {
            claimProperties.put(claimPropertyDTO.getPropertyName(), claimPropertyDTO.getPropertyValue());
        }
        externalClaim.setClaimProperties(claimProperties);
    }
    return externalClaim;
}
Also used : ClaimPropertyDTO(org.wso2.carbon.identity.claim.metadata.mgt.dto.ClaimPropertyDTO) HashMap(java.util.HashMap) ExternalClaim(org.wso2.carbon.identity.claim.metadata.mgt.model.ExternalClaim)

Aggregations

ClaimPropertyDTO (org.wso2.carbon.identity.claim.metadata.mgt.dto.ClaimPropertyDTO)12 Test (org.testng.annotations.Test)6 HashMap (java.util.HashMap)5 ExternalClaimDTO (org.wso2.carbon.identity.claim.metadata.mgt.dto.ExternalClaimDTO)4 LocalClaimDTO (org.wso2.carbon.identity.claim.metadata.mgt.dto.LocalClaimDTO)4 ExternalClaim (org.wso2.carbon.identity.claim.metadata.mgt.model.ExternalClaim)4 LocalClaim (org.wso2.carbon.identity.claim.metadata.mgt.model.LocalClaim)4 ClaimPropertyDTO (org.wso2.carbon.identity.claim.metadata.mgt.stub.dto.ClaimPropertyDTO)4 LocalClaimDTO (org.wso2.carbon.identity.claim.metadata.mgt.stub.dto.LocalClaimDTO)4 Map (java.util.Map)3 AttributeMappingDTO (org.wso2.carbon.identity.claim.metadata.mgt.dto.AttributeMappingDTO)3 AttributeMapping (org.wso2.carbon.identity.claim.metadata.mgt.model.AttributeMapping)3 AttributeMappingDTO (org.wso2.carbon.identity.claim.metadata.mgt.stub.dto.AttributeMappingDTO)3 ArrayList (java.util.ArrayList)2 ExternalClaimDTO (org.wso2.carbon.identity.claim.metadata.mgt.stub.dto.ExternalClaimDTO)2 List (java.util.List)1