Skip to content

Commit

Permalink
Remove Profiles. claim properties once processed.
Browse files Browse the repository at this point in the history
  • Loading branch information
PasinduYeshan committed Jan 6, 2025
1 parent a0ba8d2 commit e1026ac
Showing 1 changed file with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.wso2.carbon.identity.core.util.IdentityUtil;
import org.wso2.carbon.identity.organization.management.service.exception.OrganizationManagementException;
import org.wso2.carbon.identity.rest.api.server.claim.management.v1.dto.AttributeMappingDTO;
import org.wso2.carbon.identity.rest.api.server.claim.management.v1.dto.AttributeProfileDTO;
import org.wso2.carbon.identity.rest.api.server.claim.management.v1.dto.ClaimDialectReqDTO;
import org.wso2.carbon.identity.rest.api.server.claim.management.v1.dto.ClaimDialectResDTO;
import org.wso2.carbon.identity.rest.api.server.claim.management.v1.dto.ClaimResDTO;
Expand All @@ -56,7 +57,6 @@
import org.wso2.carbon.identity.rest.api.server.claim.management.v1.dto.LinkDTO;
import org.wso2.carbon.identity.rest.api.server.claim.management.v1.dto.LocalClaimReqDTO;
import org.wso2.carbon.identity.rest.api.server.claim.management.v1.dto.LocalClaimResDTO;
import org.wso2.carbon.identity.rest.api.server.claim.management.v1.dto.AttributeProfileDTO;
import org.wso2.carbon.identity.rest.api.server.claim.management.v1.dto.ProfilesDTO;
import org.wso2.carbon.identity.rest.api.server.claim.management.v1.dto.PropertyDTO;
import org.wso2.carbon.identity.rest.api.server.claim.management.v1.model.ClaimDialectConfiguration;
Expand All @@ -80,6 +80,7 @@
import java.util.Arrays;
import java.util.Base64;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -1057,16 +1058,22 @@ private void addAttributeProfilesToLocalClaimRes(Map<String, String> claimProper
return;
}
ProfilesDTO attributeProfiles = new ProfilesDTO();
claimProperties.forEach((propertyKey, propertyValue) -> {
Iterator<Map.Entry<String, String>> claimPropertyIterator = claimProperties.entrySet().iterator();

while (claimPropertyIterator.hasNext()) {
Map.Entry<String, String> property = claimPropertyIterator.next();
String propertyKey = property.getKey();
String propertyValue = property.getValue();

if (StringUtils.isBlank(propertyKey) || StringUtils.isBlank(propertyValue)) {
return;
continue;
}
if (!StringUtils.startsWithIgnoreCase(propertyKey, PROP_PROFILES_PREFIX)) {
return;
continue;
}
String[] propertyKeyArray = propertyKey.split("\\.");
if (propertyKeyArray.length != 3) {
return;
continue;
}
String profileName = propertyKeyArray[1];
String claimPropertyName = propertyKeyArray[2];
Expand All @@ -1076,16 +1083,21 @@ private void addAttributeProfilesToLocalClaimRes(Map<String, String> claimProper

switch (claimPropertyName) {
case PROP_READ_ONLY:
claimPropertyIterator.remove();
profileAttributes.setReadOnly(Boolean.valueOf(propertyValue));
break;
case PROP_REQUIRED:
claimPropertyIterator.remove();
profileAttributes.setRequired(Boolean.valueOf(propertyValue));
break;
case PROP_SUPPORTED_BY_DEFAULT:
claimPropertyIterator.remove();
profileAttributes.setSupportedByDefault(Boolean.valueOf(propertyValue));
break;
default:
break;
}
});
}
localClaimResDTO.setProfiles(attributeProfiles);
}

Expand Down

0 comments on commit e1026ac

Please sign in to comment.