use of org.wso2.carbon.identity.claim.metadata.mgt.stub.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;
}
use of org.wso2.carbon.identity.claim.metadata.mgt.stub.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;
}
use of org.wso2.carbon.identity.claim.metadata.mgt.stub.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;
}
use of org.wso2.carbon.identity.claim.metadata.mgt.stub.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;
}
use of org.wso2.carbon.identity.claim.metadata.mgt.stub.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;
}
Aggregations