From c91d22359132c4c33ca613eeb5b34135a98cc448 Mon Sep 17 00:00:00 2001 From: AnuradhaSK Date: Sun, 5 Jan 2025 22:38:09 +0530 Subject: [PATCH 1/2] add sharedProfileValueResolvingMethod as first class attribute to claim mgt API --- .../management/v1/dto/LocalClaimReqDTO.java | 24 ++++++++++++++++++- .../management/v1/dto/LocalClaimResDTO.java | 23 +++++++++++++++++- .../v1/core/ServerClaimManagementService.java | 16 +++++++++++++ .../src/main/resources/claim-management.yaml | 16 +++++++++++++ pom.xml | 2 +- 5 files changed, 78 insertions(+), 3 deletions(-) diff --git a/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.rest.api.server.claim.management.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/claim/management/v1/dto/LocalClaimReqDTO.java b/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.rest.api.server.claim.management.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/claim/management/v1/dto/LocalClaimReqDTO.java index a459ac03e6..3ce51dd684 100644 --- a/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.rest.api.server.claim.management.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/claim/management/v1/dto/LocalClaimReqDTO.java +++ b/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.rest.api.server.claim.management.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/claim/management/v1/dto/LocalClaimReqDTO.java @@ -66,7 +66,14 @@ public enum UniquenessScopeEnum { @Valid private UniquenessScopeEnum uniquenessScope = null; - @Valid + public enum SharedProfileValueResolvingMethodEnum { + FromOrigin, FromSharedProfile, FromFirstFoundInHierarchy, + }; + + @Valid + private SharedProfileValueResolvingMethodEnum sharedProfileValueResolvingMethod = null; + + @Valid @NotNull(message = "Property attributeMapping cannot be null.") private List attributeMapping = new ArrayList(); @@ -181,6 +188,20 @@ public void setUniquenessScope(UniquenessScopeEnum uniquenessScope) { this.uniquenessScope = uniquenessScope; } + /** + * Specifies claim value resolving method for shared user profile. + **/ + @ApiModelProperty(value = "Specifies claim value resolving method for shared user profile.") + @JsonProperty("sharedProfileValueResolvingMethod") + public SharedProfileValueResolvingMethodEnum getSharedProfileValueResolvingMethod() { + return sharedProfileValueResolvingMethod; + } + + public void setSharedProfileValueResolvingMethod( + SharedProfileValueResolvingMethodEnum sharedProfileValueResolvingMethod) { + this.sharedProfileValueResolvingMethod = sharedProfileValueResolvingMethod; + } + /** * Userstore attribute mappings. **/ @@ -220,6 +241,7 @@ public String toString() { sb.append(" required: ").append(required).append("\n"); sb.append(" supportedByDefault: ").append(supportedByDefault).append("\n"); sb.append(" uniquenessScope: ").append(uniquenessScope).append("\n"); + sb.append(" sharedProfileValueResolvingMethod: ").append(sharedProfileValueResolvingMethod).append("\n"); sb.append(" attributeMapping: ").append(attributeMapping).append("\n"); sb.append(" properties: ").append(properties).append("\n"); diff --git a/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.rest.api.server.claim.management.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/claim/management/v1/dto/LocalClaimResDTO.java b/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.rest.api.server.claim.management.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/claim/management/v1/dto/LocalClaimResDTO.java index 3b576aeff0..aebc53bc29 100644 --- a/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.rest.api.server.claim.management.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/claim/management/v1/dto/LocalClaimResDTO.java +++ b/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.rest.api.server.claim.management.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/claim/management/v1/dto/LocalClaimResDTO.java @@ -71,7 +71,13 @@ public enum UniquenessScopeEnum { @Valid private UniquenessScopeEnum uniquenessScope = null; - @Valid + public enum SharedProfileValueResolvingMethodEnum { + FromOrigin, FromSharedProfile, FromFirstFoundInHierarchy, + }; + @Valid + private SharedProfileValueResolvingMethodEnum sharedProfileValueResolvingMethod = null; + + @Valid private List attributeMapping = new ArrayList(); @Valid @@ -209,6 +215,20 @@ public void setUniquenessScope(UniquenessScopeEnum uniquenessScope) { this.uniquenessScope = uniquenessScope; } + /** + * Specifies claim value resolving method for shared user profile. + **/ + @ApiModelProperty(value = "Specifies claim value resolving method for shared user profile.") + @JsonProperty("sharedProfileValueResolvingMethod") + public SharedProfileValueResolvingMethodEnum getSharedProfileValueResolvingMethod() { + return sharedProfileValueResolvingMethod; + } + + public void setSharedProfileValueResolvingMethod( + SharedProfileValueResolvingMethodEnum sharedProfileValueResolvingMethod) { + this.sharedProfileValueResolvingMethod = sharedProfileValueResolvingMethod; + } + /** * Userstore attribute mappings. **/ @@ -251,6 +271,7 @@ public String toString() { sb.append(" required: ").append(required).append("\n"); sb.append(" supportedByDefault: ").append(supportedByDefault).append("\n"); sb.append(" uniquenessScope: ").append(uniquenessScope).append("\n"); + sb.append(" sharedProfileValueResolvingMethod: ").append(sharedProfileValueResolvingMethod).append("\n"); sb.append(" attributeMapping: ").append(attributeMapping).append("\n"); sb.append(" properties: ").append(properties).append("\n"); 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 c46f671351..6bc43143a8 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 @@ -1011,6 +1011,17 @@ private LocalClaimResDTO getLocalClaimResDTO(LocalClaim localClaim) { } } + String sharedProfileValueResolvingMethod = claimProperties.remove(ClaimConstants.SHARED_PROFILE_VALUE_RESOLVING_METHOD); + if (StringUtils.isNotBlank(sharedProfileValueResolvingMethod)) { + try { + localClaimResDTO.setSharedProfileValueResolvingMethod( + LocalClaimResDTO.SharedProfileValueResolvingMethodEnum.valueOf(sharedProfileValueResolvingMethod)); + } catch (IllegalArgumentException e) { + // If the value is not a valid enum value, treat it as null. + localClaimResDTO.setSharedProfileValueResolvingMethod(null); + } + } + List attributeMappingDTOs = new ArrayList<>(); for (AttributeMapping attributeMapping : localClaim.getMappedAttributes()) { AttributeMappingDTO attributeMappingDTO = new AttributeMappingDTO(); @@ -1063,6 +1074,11 @@ private LocalClaim createLocalClaim(LocalClaimReqDTO localClaimReqDTO) { claimProperties.put(PROP_UNIQUENESS_SCOPE, localClaimReqDTO.getUniquenessScope().toString()); } + if (localClaimReqDTO.getSharedProfileValueResolvingMethod() != null) { + claimProperties.put(ClaimConstants.SHARED_PROFILE_VALUE_RESOLVING_METHOD, + String.valueOf(localClaimReqDTO.getSharedProfileValueResolvingMethod())); + } + claimProperties.put(PROP_READ_ONLY, String.valueOf(localClaimReqDTO.getReadOnly())); claimProperties.put(PROP_REQUIRED, String.valueOf(localClaimReqDTO.getRequired())); claimProperties.put(PROP_SUPPORTED_BY_DEFAULT, String.valueOf(localClaimReqDTO.getSupportedByDefault())); diff --git a/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.rest.api.server.claim.management.v1/src/main/resources/claim-management.yaml b/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.rest.api.server.claim.management.v1/src/main/resources/claim-management.yaml index 348a24bdad..d27bb41d03 100644 --- a/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.rest.api.server.claim.management.v1/src/main/resources/claim-management.yaml +++ b/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.rest.api.server.claim.management.v1/src/main/resources/claim-management.yaml @@ -744,6 +744,14 @@ definitions: - WITHIN_USERSTORE - ACROSS_USERSTORES example: "NONE" + sharedProfileValueResolvingMethod: + type: string + description: Specifies claim value resolving method for shared user profile. + enum: + - FromOrigin + - FromSharedProfile + - FromFirstFoundInHierarchy + example: "FromOrigin" attributeMapping: type: array description: Userstore attribute mappings. @@ -812,6 +820,14 @@ definitions: - WITHIN_USERSTORE - ACROSS_USERSTORES example: "NONE" + sharedProfileValueResolvingMethod: + type: string + description: Specifies claim value resolving method for shared user profile. + enum: + - FromOrigin + - FromSharedProfile + - FromFirstFoundInHierarchy + example: "FromOrigin" attributeMapping: type: array description: Userstore attribute mappings. diff --git a/pom.xml b/pom.xml index 04cbb35422..2178ce27c2 100644 --- a/pom.xml +++ b/pom.xml @@ -821,7 +821,7 @@ 1.4 1.2.4 1.11.21 - 7.7.66 + 7.7.73 3.0.5 1.12.0 **/gen/**/* From 671313d2a2ee5a5436be3e47eafc5990eb6bb7db Mon Sep 17 00:00:00 2001 From: AnuradhaSK Date: Sun, 5 Jan 2025 23:33:08 +0530 Subject: [PATCH 2/2] fix checkstyle issue --- .../management/v1/core/ServerClaimManagementService.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 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 6bc43143a8..1f2846847e 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 @@ -1011,11 +1011,13 @@ private LocalClaimResDTO getLocalClaimResDTO(LocalClaim localClaim) { } } - String sharedProfileValueResolvingMethod = claimProperties.remove(ClaimConstants.SHARED_PROFILE_VALUE_RESOLVING_METHOD); + String sharedProfileValueResolvingMethod = + claimProperties.remove(ClaimConstants.SHARED_PROFILE_VALUE_RESOLVING_METHOD); if (StringUtils.isNotBlank(sharedProfileValueResolvingMethod)) { try { localClaimResDTO.setSharedProfileValueResolvingMethod( - LocalClaimResDTO.SharedProfileValueResolvingMethodEnum.valueOf(sharedProfileValueResolvingMethod)); + LocalClaimResDTO.SharedProfileValueResolvingMethodEnum.valueOf( + sharedProfileValueResolvingMethod)); } catch (IllegalArgumentException e) { // If the value is not a valid enum value, treat it as null. localClaimResDTO.setSharedProfileValueResolvingMethod(null);