use of org.wso2.carbon.identity.claim.metadata.mgt.dto.LocalClaimDTO 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.dto.LocalClaimDTO in project carbon-identity-framework by wso2.
the class ClaimMetadataManagementAdminService method updateLocalClaim.
@SuppressWarnings("unused")
public void updateLocalClaim(LocalClaimDTO localClaim) throws ClaimMetadataException {
try {
LocalClaim claim = ClaimMetadataUtils.convertLocalClaimDTOToLocalClaim(localClaim);
String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain();
IdentityClaimManagementServiceDataHolder.getInstance().getClaimManagementService().updateLocalClaim(claim, tenantDomain);
} catch (Throwable e) {
log.error(e.getMessage(), e);
throw new ClaimMetadataException(e.getMessage(), e);
}
}
use of org.wso2.carbon.identity.claim.metadata.mgt.dto.LocalClaimDTO in project carbon-identity-framework by wso2.
the class ClaimMetadataManagementAdminService method getLocalClaims.
@SuppressWarnings("unused")
public LocalClaimDTO[] getLocalClaims() throws ClaimMetadataException {
try {
String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain();
List<LocalClaim> localClaimList = IdentityClaimManagementServiceDataHolder.getInstance().getClaimManagementService().getLocalClaims(tenantDomain);
LocalClaim[] localClaims = localClaimList.toArray(new LocalClaim[0]);
LocalClaimDTO[] localClaimDTOS = ClaimMetadataUtils.convertLocalClaimsToLocalClaimDTOs(localClaims);
// Sort the local claims in the alphabetical order
Arrays.sort(localClaimDTOS, new Comparator<LocalClaimDTO>() {
@Override
public int compare(LocalClaimDTO o1, LocalClaimDTO o2) {
return o1.getLocalClaimURI().toLowerCase().compareTo(o2.getLocalClaimURI().toLowerCase());
}
});
return localClaimDTOS;
} catch (Throwable e) {
log.error(e.getMessage(), e);
throw new ClaimMetadataException(e.getMessage(), e);
}
}
use of org.wso2.carbon.identity.claim.metadata.mgt.dto.LocalClaimDTO 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.dto.LocalClaimDTO 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;
}
Aggregations