From e1026acdae8ea3b6515b29c5768af183570d5005 Mon Sep 17 00:00:00 2001 From: Pasindu Yeshan Date: Mon, 6 Jan 2025 19:32:12 +0530 Subject: [PATCH] Remove Profiles. claim properties once processed. --- .../v1/core/ServerClaimManagementService.java | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.rest.api.server.claim.management.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/claim/management/v1/core/ServerClaimManagementService.java b/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.rest.api.server.claim.management.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/claim/management/v1/core/ServerClaimManagementService.java index 3a28acab00..04020a8907 100644 --- a/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.rest.api.server.claim.management.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/claim/management/v1/core/ServerClaimManagementService.java +++ b/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.rest.api.server.claim.management.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/claim/management/v1/core/ServerClaimManagementService.java @@ -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; @@ -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; @@ -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; @@ -1057,16 +1058,22 @@ private void addAttributeProfilesToLocalClaimRes(Map claimProper return; } ProfilesDTO attributeProfiles = new ProfilesDTO(); - claimProperties.forEach((propertyKey, propertyValue) -> { + Iterator> claimPropertyIterator = claimProperties.entrySet().iterator(); + + while (claimPropertyIterator.hasNext()) { + Map.Entry 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]; @@ -1076,16 +1083,21 @@ private void addAttributeProfilesToLocalClaimRes(Map 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); }