diff --git a/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.api.server.claim.management.common/src/main/java/org/wso2/carbon/identity/api/server/claim/management/common/Constant.java b/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.api.server.claim.management.common/src/main/java/org/wso2/carbon/identity/api/server/claim/management/common/Constant.java index 75e33ecc37..b12bcd1022 100644 --- a/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.api.server.claim.management.common/src/main/java/org/wso2/carbon/identity/api/server/claim/management/common/Constant.java +++ b/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.api.server.claim.management.common/src/main/java/org/wso2/carbon/identity/api/server/claim/management/common/Constant.java @@ -278,4 +278,5 @@ public String toString() { public static final String PROP_REG_EX = "RegEx"; public static final String PROP_REQUIRED = "Required"; public static final String PROP_SUPPORTED_BY_DEFAULT = "SupportedByDefault"; + public static final String PROP_UNIQUENESS_SCOPE = "UniquenessScope"; } 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 2f2edc432e..a459ac03e6 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 @@ -60,6 +60,12 @@ public class LocalClaimReqDTO { @Valid private Boolean supportedByDefault = null; + public enum UniquenessScopeEnum { + NONE, WITHIN_USERSTORE, ACROSS_USERSTORES, + }; + @Valid + private UniquenessScopeEnum uniquenessScope = null; + @Valid @NotNull(message = "Property attributeMapping cannot be null.") private List attributeMapping = new ArrayList(); @@ -163,6 +169,18 @@ public void setSupportedByDefault(Boolean supportedByDefault) { this.supportedByDefault = supportedByDefault; } + /** + * Specifies the scope of uniqueness validation for the claim value. + **/ + @ApiModelProperty(value = "Specifies the scope of uniqueness validation for the claim value.") + @JsonProperty("uniquenessScope") + public UniquenessScopeEnum getUniquenessScope() { + return uniquenessScope; + } + public void setUniquenessScope(UniquenessScopeEnum uniquenessScope) { + this.uniquenessScope = uniquenessScope; + } + /** * Userstore attribute mappings. **/ @@ -201,6 +219,7 @@ public String toString() { sb.append(" regEx: ").append(regEx).append("\n"); sb.append(" required: ").append(required).append("\n"); sb.append(" supportedByDefault: ").append(supportedByDefault).append("\n"); + sb.append(" uniquenessScope: ").append(uniquenessScope).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 99aeca5f84..3b576aeff0 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 @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.List; 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.ClaimResDTO; import org.wso2.carbon.identity.rest.api.server.claim.management.v1.dto.PropertyDTO; import io.swagger.annotations.*; import com.fasterxml.jackson.annotation.*; @@ -64,6 +65,12 @@ public class LocalClaimResDTO extends ClaimResDTO { @Valid private Boolean supportedByDefault = null; + public enum UniquenessScopeEnum { + NONE, WITHIN_USERSTORE, ACROSS_USERSTORES, + }; + @Valid + private UniquenessScopeEnum uniquenessScope = null; + @Valid private List attributeMapping = new ArrayList(); @@ -190,6 +197,18 @@ public void setSupportedByDefault(Boolean supportedByDefault) { this.supportedByDefault = supportedByDefault; } + /** + * Specifies the scope of uniqueness validation for the claim value. + **/ + @ApiModelProperty(value = "Specifies the scope of uniqueness validation for the claim value.") + @JsonProperty("uniquenessScope") + public UniquenessScopeEnum getUniquenessScope() { + return uniquenessScope; + } + public void setUniquenessScope(UniquenessScopeEnum uniquenessScope) { + this.uniquenessScope = uniquenessScope; + } + /** * Userstore attribute mappings. **/ @@ -231,6 +250,7 @@ public String toString() { sb.append(" regEx: ").append(regEx).append("\n"); sb.append(" required: ").append(required).append("\n"); sb.append(" supportedByDefault: ").append(supportedByDefault).append("\n"); + sb.append(" uniquenessScope: ").append(uniquenessScope).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 4146a2dcdb..f6691737b2 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 @@ -130,6 +130,7 @@ import static org.wso2.carbon.identity.api.server.claim.management.common.Constant.PROP_REG_EX; import static org.wso2.carbon.identity.api.server.claim.management.common.Constant.PROP_REQUIRED; import static org.wso2.carbon.identity.api.server.claim.management.common.Constant.PROP_SUPPORTED_BY_DEFAULT; +import static org.wso2.carbon.identity.api.server.claim.management.common.Constant.PROP_UNIQUENESS_SCOPE; import static org.wso2.carbon.identity.api.server.common.Constants.JSON_FILE_EXTENSION; import static org.wso2.carbon.identity.api.server.common.Constants.MEDIA_TYPE_JSON; import static org.wso2.carbon.identity.api.server.common.Constants.MEDIA_TYPE_XML; @@ -994,6 +995,15 @@ private LocalClaimResDTO getLocalClaimResDTO(LocalClaim localClaim) { localClaimResDTO.setRequired(Boolean.valueOf(claimProperties.remove(PROP_REQUIRED))); localClaimResDTO.setSupportedByDefault(Boolean.valueOf(claimProperties.remove(PROP_SUPPORTED_BY_DEFAULT))); + String uniquenessScope = claimProperties.remove(PROP_UNIQUENESS_SCOPE); + if (StringUtils.isNotBlank(uniquenessScope)) { + try { + localClaimResDTO.setUniquenessScope(LocalClaimResDTO.UniquenessScopeEnum.valueOf(uniquenessScope)); + } catch (IllegalArgumentException e) { + localClaimResDTO.setUniquenessScope(LocalClaimResDTO.UniquenessScopeEnum.NONE); + } + } + List attributeMappingDTOs = new ArrayList<>(); for (AttributeMapping attributeMapping : localClaim.getMappedAttributes()) { AttributeMappingDTO attributeMappingDTO = new AttributeMappingDTO(); @@ -1042,6 +1052,10 @@ private LocalClaim createLocalClaim(LocalClaimReqDTO localClaimReqDTO) { claimProperties.put(PROP_DISPLAY_ORDER, "0"); } + if (localClaimReqDTO.getUniquenessScope() != null) { + claimProperties.put(PROP_UNIQUENESS_SCOPE, localClaimReqDTO.getUniquenessScope().toString()); + } + 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 c788734b40..6d9fd029f4 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 @@ -736,6 +736,14 @@ definitions: type: boolean description: Specifies if the claim will be prompted during user registration and displayed on the user profile. example: true + uniquenessScope: + type: string + description: Specifies the scope of uniqueness validation for the claim value. + enum: + - NONE + - WITHIN_USERSTORE + - ACROSS_USERSTORES + example: "NONE" attributeMapping: type: array description: Userstore attribute mappings. @@ -796,6 +804,14 @@ definitions: type: boolean description: Specifies if the claim will be prompted during user registration and displayed on the user profile. example: true + uniquenessScope: + type: string + description: Specifies the scope of uniqueness validation for the claim value. + enum: + - NONE + - WITHIN_USERSTORE + - ACROSS_USERSTORES + example: "NONE" attributeMapping: type: array description: Userstore attribute mappings.