use of org.wso2.carbon.identity.claim.metadata.mgt.stub.dto.AttributeMappingDTO 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.AttributeMappingDTO 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.AttributeMappingDTO in project product-is by wso2.
the class ClaimMappingsOnSecondaryUserStoreTestCase method testUserstoreDeletion.
@Test(groups = "wso2.is", description = "Check userstore delete", dependsOnMethods = { "testAddJDBCUserStore" })
public void testUserstoreDeletion() throws Exception {
addLocalClaims();
userStoreConfigAdminServiceClient.deleteUserStore(DOMAIN_ID);
for (LocalClaimDTO localClaimDTO : claimMetadataManagementServiceClient.getLocalClaims()) {
for (AttributeMappingDTO attributeMappingDTO : localClaimDTO.getAttributeMappings()) {
Assert.assertNotEquals(attributeMappingDTO.getUserStoreDomain(), DOMAIN_ID);
}
}
}
use of org.wso2.carbon.identity.claim.metadata.mgt.stub.dto.AttributeMappingDTO 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.claim.metadata.mgt.stub.dto.AttributeMappingDTO in project carbon-identity-framework by wso2.
the class ClaimMetadataUtilsTest method setUpLocalClaims.
private void setUpLocalClaims() {
String localClaimURI1 = "testLocalClaimURI1";
String localClaimURI2 = "testLocalClaimURI2";
{
localClaim1 = new LocalClaim(localClaimURI1);
AttributeMapping attributeMapping1 = new AttributeMapping(UserCoreConstants.PRIMARY_DEFAULT_DOMAIN_NAME, "uid");
AttributeMapping attributeMapping2 = new AttributeMapping("AD", "sAMAccountName");
List<AttributeMapping> attributeMappingList = new ArrayList<>();
attributeMappingList.add(attributeMapping1);
attributeMappingList.add(attributeMapping2);
Map<String, String> claimPropertiesMap = new HashMap<>();
claimPropertiesMap.put(ClaimConstants.DISPLAY_NAME_PROPERTY, "username");
claimPropertiesMap.put(ClaimConstants.READ_ONLY_PROPERTY, "true");
localClaim2 = new LocalClaim(localClaimURI2, attributeMappingList, claimPropertiesMap);
localClaims = new LocalClaim[] { localClaim1, localClaim2 };
}
{
localClaimDTO1 = new LocalClaimDTO();
localClaimDTO1.setLocalClaimURI(localClaimURI1);
AttributeMappingDTO attributeMappingDTO1 = new AttributeMappingDTO();
attributeMappingDTO1.setUserStoreDomain(UserCoreConstants.PRIMARY_DEFAULT_DOMAIN_NAME);
attributeMappingDTO1.setAttributeName("uid");
AttributeMappingDTO attributeMappingDTO2 = new AttributeMappingDTO();
attributeMappingDTO2.setUserStoreDomain("AD");
attributeMappingDTO2.setAttributeName("sAMAccountName");
AttributeMappingDTO[] attributeMappingDTOs = new AttributeMappingDTO[] { attributeMappingDTO1, attributeMappingDTO2 };
ClaimPropertyDTO claimPropertyDTO1 = new ClaimPropertyDTO();
claimPropertyDTO1.setPropertyName(ClaimConstants.DISPLAY_NAME_PROPERTY);
claimPropertyDTO1.setPropertyValue("username");
ClaimPropertyDTO claimPropertyDTO2 = new ClaimPropertyDTO();
claimPropertyDTO2.setPropertyName(ClaimConstants.READ_ONLY_PROPERTY);
claimPropertyDTO2.setPropertyValue("true");
ClaimPropertyDTO[] claimPropertyDTOs = new ClaimPropertyDTO[] { claimPropertyDTO1, claimPropertyDTO2 };
localClaimDTO2 = new LocalClaimDTO();
localClaimDTO2.setLocalClaimURI(localClaimURI2);
localClaimDTO2.setAttributeMappings(attributeMappingDTOs);
localClaimDTO2.setClaimProperties(claimPropertyDTOs);
localClaimDTOs = new LocalClaimDTO[] { localClaimDTO1, localClaimDTO2 };
}
}
Aggregations