From fcb383d14d08091af87ec19e818195dc6616a79d Mon Sep 17 00:00:00 2001 From: Amanda Ariyaratne Date: Thu, 31 Oct 2024 11:12:47 +0530 Subject: [PATCH 1/4] add properties for external claims --- .../management/v1/dto/ExternalClaimResDTO.java | 18 ++++++++++++++++++ .../v1/core/ServerClaimManagementService.java | 1 + .../src/main/resources/claim-management.yaml | 5 +++++ 3 files changed, 24 insertions(+) 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/ExternalClaimResDTO.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/ExternalClaimResDTO.java index 8c4cd0d886..c9436ef1b5 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/ExternalClaimResDTO.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/ExternalClaimResDTO.java @@ -23,6 +23,8 @@ import javax.validation.Valid; import javax.validation.constraints.NotNull; import javax.validation.constraints.Pattern; +import java.util.ArrayList; +import java.util.List; /** * External claim response. @@ -42,6 +44,9 @@ public class ExternalClaimResDTO extends ClaimResDTO { @Valid private String mappedLocalClaimURI = null; + @Valid + private List properties = new ArrayList(); + /** * External claim ID. **/ @@ -90,6 +95,18 @@ public void setMappedLocalClaimURI(String mappedLocalClaimURI) { this.mappedLocalClaimURI = mappedLocalClaimURI; } + /** + * Define any additional properties if required. + **/ + @ApiModelProperty(value = "Define any additional properties if required.") + @JsonProperty("properties") + public List getProperties() { + return properties; + } + public void setProperties(List properties) { + this.properties = properties; + } + @Override public String toString() { @@ -101,6 +118,7 @@ public String toString() { sb.append(" claimURI: ").append(claimURI).append("\n"); sb.append(" claimDialectURI: ").append(claimDialectURI).append("\n"); sb.append(" mappedLocalClaimURI: ").append(mappedLocalClaimURI).append("\n"); + sb.append(" properties: ").append(properties).append("\n"); sb.append("}\n"); return sb.toString(); 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..4bfbb11332 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 @@ -944,6 +944,7 @@ private ExternalClaimResDTO getExternalClaimResDTO(ExternalClaim externalClaim) externalClaimResDTO.setClaimDialectURI(externalClaim.getClaimDialectURI()); externalClaimResDTO.setClaimURI(externalClaim.getClaimURI()); externalClaimResDTO.setMappedLocalClaimURI(externalClaim.getMappedLocalClaim()); + externalClaimResDTO.setProperties(mapToProperties(externalClaim.getClaimProperties())); return externalClaimResDTO; } 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..6231037ef2 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 @@ -910,6 +910,11 @@ definitions: type: string description: The local claim URI to map with the external claim. example: "http://wso2.org/claims/username" + properties: + type: array + description: Define any additional properties if required. + items: + $ref: '#/definitions/Property' #----------------------------------------------------- # Property Object From d61fc7c73b05c7637f134aa056ac669e3fd85187 Mon Sep 17 00:00:00 2001 From: Amanda Ariyaratne Date: Tue, 5 Nov 2024 17:52:32 +0530 Subject: [PATCH 2/4] add forbidden scenarios for claim mgt --- .../v1/core/ServerClaimManagementService.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 4bfbb11332..a23d180624 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 @@ -138,6 +138,7 @@ import static org.wso2.carbon.identity.api.server.common.Constants.XML_FILE_EXTENSION; import static org.wso2.carbon.identity.api.server.common.Constants.YAML_FILE_EXTENSION; import static org.wso2.carbon.identity.api.server.common.ContextLoader.buildURIForBody; +import static org.wso2.carbon.identity.claim.metadata.mgt.util.ClaimConstants.ErrorMessage.ERROR_CODE_NO_DELETE_SYSTEM_CLAIM; import static org.wso2.carbon.identity.organization.management.service.constant.OrganizationManagementConstants.ErrorMessages.ERROR_CODE_ORGANIZATION_NOT_FOUND_FOR_TENANT; import static javax.ws.rs.core.Response.Status.BAD_REQUEST; @@ -159,6 +160,12 @@ public class ServerClaimManagementService { ClaimConstants.ErrorMessage.ERROR_CODE_EXISTING_LOCAL_CLAIM_URI.getCode() ); + private static final List forbiddenErrorScenarios = Arrays.asList( + ClaimConstants.ErrorMessage.ERROR_CODE_NO_RENAME_SYSTEM_DIALECT.getCode(), + ClaimConstants.ErrorMessage.ERROR_CODE_NO_DELETE_SYSTEM_DIALECT.getCode(), + ClaimConstants.ErrorMessage.ERROR_CODE_NO_DELETE_SYSTEM_CLAIM.getCode() + ); + /** * Add a claim dialect. * @@ -1266,6 +1273,9 @@ private APIError handleClaimManagementException(ClaimMetadataException e, Consta if (isConflictScenario(e.getErrorCode())) { status = CONFLICT; } + if (isForbiddenScenario(e.getErrorCode())) { + status = FORBIDDEN; + } if (StringUtils.isNotBlank(e.getErrorCode()) && e.getErrorCode().contains(Constant.CLAIM_MANAGEMENT_PREFIX)) { return handleClaimManagementClientError(e.getErrorCode(), e.getMessage(), status, data); @@ -1288,6 +1298,11 @@ private boolean isConflictScenario(String errorCode) { return !StringUtils.isBlank(errorCode) && conflictErrorScenarios.contains(errorCode); } + private boolean isForbiddenScenario(String errorCode) { + + return !StringUtils.isBlank(errorCode) && forbiddenErrorScenarios.contains(errorCode); + } + private APIError handleClaimManagementClientError(Constant.ErrorMessage errorEnum, Response.Status status) { return handleClaimManagementClientError(errorEnum, status, StringUtils.EMPTY); From ebcb9d7103a3c1f5dffcefa495ac7c52cd8b87d0 Mon Sep 17 00:00:00 2001 From: Amanda Ariyaratne Date: Tue, 5 Nov 2024 17:55:28 +0530 Subject: [PATCH 3/4] remove unused import --- .../claim/management/v1/core/ServerClaimManagementService.java | 1 - 1 file changed, 1 deletion(-) 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 a23d180624..1afbe00801 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 @@ -138,7 +138,6 @@ import static org.wso2.carbon.identity.api.server.common.Constants.XML_FILE_EXTENSION; import static org.wso2.carbon.identity.api.server.common.Constants.YAML_FILE_EXTENSION; import static org.wso2.carbon.identity.api.server.common.ContextLoader.buildURIForBody; -import static org.wso2.carbon.identity.claim.metadata.mgt.util.ClaimConstants.ErrorMessage.ERROR_CODE_NO_DELETE_SYSTEM_CLAIM; import static org.wso2.carbon.identity.organization.management.service.constant.OrganizationManagementConstants.ErrorMessages.ERROR_CODE_ORGANIZATION_NOT_FOUND_FOR_TENANT; import static javax.ws.rs.core.Response.Status.BAD_REQUEST; From a8be5784311742c556db0be2b83c6d5d8fd897ba Mon Sep 17 00:00:00 2001 From: Amanda Ariyaratne Date: Tue, 12 Nov 2024 11:23:57 +0530 Subject: [PATCH 4/4] bump framework version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8f35524226..e345f22571 100644 --- a/pom.xml +++ b/pom.xml @@ -809,7 +809,7 @@ 1.4 1.2.4 1.11.11 - 7.5.117 + 7.6.4 3.0.5 1.12.0 **/gen/**/*