use of org.wso2.carbon.identity.rest.api.server.claim.management.v1.dto.LocalClaimResDTO in project identity-api-server by wso2.
the class ServerClaimManagementService method getLocalClaimResDTO.
private LocalClaimResDTO getLocalClaimResDTO(LocalClaim localClaim) {
LocalClaimResDTO localClaimResDTO = new LocalClaimResDTO();
localClaimResDTO.setId(base64EncodeId(localClaim.getClaimURI()));
localClaimResDTO.setClaimURI(localClaim.getClaimURI());
localClaimResDTO.setDialectURI(localClaim.getClaimDialectURI());
Map<String, String> claimProperties = new HashMap<>(localClaim.getClaimProperties());
String description = claimProperties.remove(PROP_DESCRIPTION);
localClaimResDTO.setDescription(description);
if (description == null) {
localClaimResDTO.setDescription(StringUtils.EMPTY);
}
String propDisplayOrder = claimProperties.remove(PROP_DISPLAY_ORDER);
if (StringUtils.isNumeric(propDisplayOrder)) {
localClaimResDTO.setDisplayOrder(Integer.valueOf(propDisplayOrder));
} else {
localClaimResDTO.setDisplayOrder(0);
}
localClaimResDTO.setDisplayName(claimProperties.remove(PROP_DISPLAY_NAME));
localClaimResDTO.setReadOnly(Boolean.valueOf(claimProperties.remove(PROP_READ_ONLY)));
String regEx = claimProperties.remove(PROP_REG_EX);
localClaimResDTO.setRegEx(regEx);
if (regEx == null) {
localClaimResDTO.setRegEx(StringUtils.EMPTY);
}
localClaimResDTO.setRequired(Boolean.valueOf(claimProperties.remove(PROP_REQUIRED)));
localClaimResDTO.setSupportedByDefault(Boolean.valueOf(claimProperties.remove(PROP_SUPPORTED_BY_DEFAULT)));
List<AttributeMappingDTO> attributeMappingDTOs = new ArrayList<>();
for (AttributeMapping attributeMapping : localClaim.getMappedAttributes()) {
AttributeMappingDTO attributeMappingDTO = new AttributeMappingDTO();
attributeMappingDTO.setUserstore(attributeMapping.getUserStoreDomain());
attributeMappingDTO.setMappedAttribute(attributeMapping.getAttributeName());
attributeMappingDTOs.add(attributeMappingDTO);
}
localClaimResDTO.setAttributeMapping(attributeMappingDTOs);
localClaimResDTO.setProperties(mapToProperties(claimProperties));
return localClaimResDTO;
}
use of org.wso2.carbon.identity.rest.api.server.claim.management.v1.dto.LocalClaimResDTO in project identity-api-server by wso2.
the class ServerClaimManagementService method getLocalClaim.
/**
* Retrieve a local claim.
*
* @param claimId claimId.
* @return Local claim.
*/
public LocalClaimResDTO getLocalClaim(String claimId) {
try {
List<LocalClaim> localClaimList = getClaimMetadataManagementService().getLocalClaims(ContextLoader.getTenantDomainFromContext());
LocalClaim localClaim = extractLocalClaimFromClaimList(base64DecodeId(claimId), localClaimList);
if (localClaim == null) {
throw handleClaimManagementClientError(ERROR_CODE_LOCAL_CLAIM_NOT_FOUND, NOT_FOUND, claimId);
}
return getLocalClaimResDTO(localClaim);
} catch (ClaimMetadataException e) {
throw handleClaimManagementException(e, ERROR_CODE_ERROR_RETRIEVING_LOCAL_CLAIM, claimId);
}
}
Aggregations