From cabd548d446c83c21e70c8e955aabd33265c32a0 Mon Sep 17 00:00:00 2001 From: BimsaraBodaragama Date: Sat, 25 Jan 2025 17:28:20 +0530 Subject: [PATCH] address comments. --- .../pom.xml | 10 +--------- .../common/UserSharingMgtConstants.java | 6 ++++-- .../common/UserSharingMgtServiceHolder.java | 8 ++++---- .../pom.xml | 2 +- .../management/v1/core/UsersApiServiceCore.java | 13 +++++++------ .../management/v1/impl/UsersApiServiceImpl.java | 2 +- .../main/resources/organization-user-share.yaml | 16 ++++++---------- .../pom.xml | 2 +- 8 files changed, 25 insertions(+), 34 deletions(-) diff --git a/components/org.wso2.carbon.identity.api.server.organization.user.sharing.management/org.wso2.carbon.identity.api.server.organization.user.sharing.management.common/pom.xml b/components/org.wso2.carbon.identity.api.server.organization.user.sharing.management/org.wso2.carbon.identity.api.server.organization.user.sharing.management.common/pom.xml index 4b5c4319d7..8ca83fe324 100644 --- a/components/org.wso2.carbon.identity.api.server.organization.user.sharing.management/org.wso2.carbon.identity.api.server.organization.user.sharing.management.common/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.organization.user.sharing.management/org.wso2.carbon.identity.api.server.organization.user.sharing.management.common/pom.xml @@ -29,14 +29,6 @@ jar - - org.wso2.carbon.multitenancy - org.wso2.carbon.tenant.mgt - - - org.wso2.carbon.extension.identity.verification - org.wso2.carbon.extension.identity.verification.provider - org.wso2.carbon.identity.organization.management org.wso2.carbon.identity.organization.management.organization.user.sharing @@ -109,4 +101,4 @@ 8 UTF-8 - \ No newline at end of file + diff --git a/components/org.wso2.carbon.identity.api.server.organization.user.sharing.management/org.wso2.carbon.identity.api.server.organization.user.sharing.management.common/src/main/java/org/wso2/carbon/identity/api/server/organization/user/sharing/management/common/UserSharingMgtConstants.java b/components/org.wso2.carbon.identity.api.server.organization.user.sharing.management/org.wso2.carbon.identity.api.server.organization.user.sharing.management.common/src/main/java/org/wso2/carbon/identity/api/server/organization/user/sharing/management/common/UserSharingMgtConstants.java index 1e6bff557c..d509718e06 100644 --- a/components/org.wso2.carbon.identity.api.server.organization.user.sharing.management/org.wso2.carbon.identity.api.server.organization.user.sharing.management.common/src/main/java/org/wso2/carbon/identity/api/server/organization/user/sharing/management/common/UserSharingMgtConstants.java +++ b/components/org.wso2.carbon.identity.api.server.organization.user.sharing.management/org.wso2.carbon.identity.api.server.organization.user.sharing.management.common/src/main/java/org/wso2/carbon/identity/api/server/organization/user/sharing/management/common/UserSharingMgtConstants.java @@ -23,9 +23,11 @@ */ public class UserSharingMgtConstants { - public static final String ERROR_PREFIX = "OUI-"; + public static final String ERROR_PREFIX = "USM-"; public static final String ERROR_FAIL_STATUS = "Failed"; + public static final String USER_IDS = "userIds"; + /** * Enum for shared user invitation management related errors. * Error Code - code to identify the error. @@ -83,7 +85,7 @@ public enum ErrorMessage { ERROR_CODE_INVALID_USER_INFORMATION("60014", "Unable to create an invitation to all the users given in the list.", "User invitation creation failed for the users: %s"), - ERROR_CODE_INVALID_GROUP("60014", + ERROR_CODE_INVALID_GROUP("60015", "Invalid group list provided.", "The provided group lists are not valid."), diff --git a/components/org.wso2.carbon.identity.api.server.organization.user.sharing.management/org.wso2.carbon.identity.api.server.organization.user.sharing.management.common/src/main/java/org/wso2/carbon/identity/api/server/organization/user/sharing/management/common/UserSharingMgtServiceHolder.java b/components/org.wso2.carbon.identity.api.server.organization.user.sharing.management/org.wso2.carbon.identity.api.server.organization.user.sharing.management.common/src/main/java/org/wso2/carbon/identity/api/server/organization/user/sharing/management/common/UserSharingMgtServiceHolder.java index 2bfca9e97e..f3ea6fff3a 100644 --- a/components/org.wso2.carbon.identity.api.server.organization.user.sharing.management/org.wso2.carbon.identity.api.server.organization.user.sharing.management.common/src/main/java/org/wso2/carbon/identity/api/server/organization/user/sharing/management/common/UserSharingMgtServiceHolder.java +++ b/components/org.wso2.carbon.identity.api.server.organization.user.sharing.management/org.wso2.carbon.identity.api.server.organization.user.sharing.management.common/src/main/java/org/wso2/carbon/identity/api/server/organization/user/sharing/management/common/UserSharingMgtServiceHolder.java @@ -29,9 +29,9 @@ public class UserSharingMgtServiceHolder { private static UserSharingPolicyHandlerService userSharingPolicyHandlerService; /** - * Get Invitation Core osgi service. + * Get User Sharing Policy Handler Service. * - * @return InvitationCoreService. + * @return UserSharingPolicyHandlerService. */ public static UserSharingPolicyHandlerService getUserSharingPolicyHandlerService() { @@ -39,9 +39,9 @@ public static UserSharingPolicyHandlerService getUserSharingPolicyHandlerService } /** - * Set Invitation Core osgi service. + * Set User Sharing Policy Handler Service. * - * @param userSharingPolicyHandlerService InvitationCoreService. + * @param userSharingPolicyHandlerService UserSharingPolicyHandlerService. */ public static void setUserSharingPolicyHandlerService( UserSharingPolicyHandlerService userSharingPolicyHandlerService) { diff --git a/components/org.wso2.carbon.identity.api.server.organization.user.sharing.management/org.wso2.carbon.identity.api.server.organization.user.sharing.management.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.organization.user.sharing.management/org.wso2.carbon.identity.api.server.organization.user.sharing.management.v1/pom.xml index 9a0e50130f..d4dabbe83e 100644 --- a/components/org.wso2.carbon.identity.api.server.organization.user.sharing.management/org.wso2.carbon.identity.api.server.organization.user.sharing.management.v1/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.organization.user.sharing.management/org.wso2.carbon.identity.api.server.organization.user.sharing.management.v1/pom.xml @@ -180,4 +180,4 @@ 8 UTF-8 - \ No newline at end of file + diff --git a/components/org.wso2.carbon.identity.api.server.organization.user.sharing.management/org.wso2.carbon.identity.api.server.organization.user.sharing.management.v1/src/main/java/org/wso2/carbon/identity/api/server/organization/user/sharing/management/v1/core/UsersApiServiceCore.java b/components/org.wso2.carbon.identity.api.server.organization.user.sharing.management/org.wso2.carbon.identity.api.server.organization.user.sharing.management.v1/src/main/java/org/wso2/carbon/identity/api/server/organization/user/sharing/management/v1/core/UsersApiServiceCore.java index b1f3b2ac1b..cf45ef461b 100644 --- a/components/org.wso2.carbon.identity.api.server.organization.user.sharing.management/org.wso2.carbon.identity.api.server.organization.user.sharing.management.v1/src/main/java/org/wso2/carbon/identity/api/server/organization/user/sharing/management/v1/core/UsersApiServiceCore.java +++ b/components/org.wso2.carbon.identity.api.server.organization.user.sharing.management/org.wso2.carbon.identity.api.server.organization.user.sharing.management.v1/src/main/java/org/wso2/carbon/identity/api/server/organization/user/sharing/management/v1/core/UsersApiServiceCore.java @@ -48,6 +48,8 @@ import javax.ws.rs.core.Response; +import static org.wso2.carbon.identity.api.server.organization.user.sharing.management.common.UserSharingMgtConstants.USER_IDS; + import static javax.ws.rs.core.Response.Status.BAD_REQUEST; /** @@ -70,7 +72,7 @@ public void shareUser(UserShareRequestBody userShareRequestBody) { // Set user criteria. Map userCriteria = new HashMap<>(); UserCriteriaType userIds = new UserIdList(userShareRequestBody.getUserCriteria().getUserIds()); - userCriteria.put("userIds", userIds); + userCriteria.put(USER_IDS, userIds); selectiveUserShareDO.setUserCriteria(userCriteria); // Set organizations. @@ -118,7 +120,7 @@ public void shareUserWithAll(UserShareWithAllRequestBody userShareWithAllRequest // Set user criteria. Map userCriteria = new HashMap<>(); UserCriteriaType userIds = new UserIdList(userShareWithAllRequestBody.getUserCriteria().getUserIds()); - userCriteria.put("userIds", userIds); + userCriteria.put(USER_IDS, userIds); generalUserShareDO.setUserCriteria(userCriteria); // Set policy. @@ -159,7 +161,7 @@ public void unshareUser(UserUnshareRequestBody userUnshareRequestBody) { // Set user criteria. Map userCriteria = new HashMap<>(); UserCriteriaType userIds = new UserIdList(userUnshareRequestBody.getUserCriteria().getUserIds()); - userCriteria.put("userIds", userIds); + userCriteria.put(USER_IDS, userIds); selectiveUserUnshareDO.setUserCriteria(userCriteria); // Set organizations. @@ -187,7 +189,7 @@ public void unshareUserWithAll(UserUnshareWithAllRequestBody userUnshareWithAllR // Set user criteria. Map userCriteria = new HashMap<>(); UserCriteriaType userIds = new UserIdList(userUnshareWithAllRequestBody.getUserCriteria().getUserIds()); - userCriteria.put("userIds", userIds); + userCriteria.put(USER_IDS, userIds); generalUserUnshareDO.setUserCriteria(userCriteria); try { @@ -287,5 +289,4 @@ private String includeData(UserSharingMgtConstants.ErrorMessage error, String da } return error.getDescription(); } - -} \ No newline at end of file +} diff --git a/components/org.wso2.carbon.identity.api.server.organization.user.sharing.management/org.wso2.carbon.identity.api.server.organization.user.sharing.management.v1/src/main/java/org/wso2/carbon/identity/api/server/organization/user/sharing/management/v1/impl/UsersApiServiceImpl.java b/components/org.wso2.carbon.identity.api.server.organization.user.sharing.management/org.wso2.carbon.identity.api.server.organization.user.sharing.management.v1/src/main/java/org/wso2/carbon/identity/api/server/organization/user/sharing/management/v1/impl/UsersApiServiceImpl.java index 8116fbf0bf..25ef923ddc 100644 --- a/components/org.wso2.carbon.identity.api.server.organization.user.sharing.management/org.wso2.carbon.identity.api.server.organization.user.sharing.management.v1/src/main/java/org/wso2/carbon/identity/api/server/organization/user/sharing/management/v1/impl/UsersApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.server.organization.user.sharing.management/org.wso2.carbon.identity.api.server.organization.user.sharing.management.v1/src/main/java/org/wso2/carbon/identity/api/server/organization/user/sharing/management/v1/impl/UsersApiServiceImpl.java @@ -84,4 +84,4 @@ public Response usersUserIdSharedRolesGet(String userId, String orgId, String af userId, orgId, after, before, limit, filter, recursive); return Response.ok().entity(response).build(); } -} \ No newline at end of file +} diff --git a/components/org.wso2.carbon.identity.api.server.organization.user.sharing.management/org.wso2.carbon.identity.api.server.organization.user.sharing.management.v1/src/main/resources/organization-user-share.yaml b/components/org.wso2.carbon.identity.api.server.organization.user.sharing.management/org.wso2.carbon.identity.api.server.organization.user.sharing.management.v1/src/main/resources/organization-user-share.yaml index 618a259fb5..f64ad2eda5 100644 --- a/components/org.wso2.carbon.identity.api.server.organization.user.sharing.management/org.wso2.carbon.identity.api.server.organization.user.sharing.management.v1/src/main/resources/organization-user-share.yaml +++ b/components/org.wso2.carbon.identity.api.server.organization.user.sharing.management/org.wso2.carbon.identity.api.server.organization.user.sharing.management.v1/src/main/resources/organization-user-share.yaml @@ -12,16 +12,12 @@ info: name: Apache 2.0 url: 'http://www.apache.org/licenses/LICENSE-2.0.html' servers: - # Added by API Auto Mocking Plugin - - description: SwaggerHub API Auto Mocking - url: https://virtserver.swaggerhub.com/DinukaBimsaraBodaragama/user-sahred-access-API-4/1.0.2 - url: 'https://{server-url}/t/{tenant-domain}/api/server/v1' variables: tenant-domain: default: "carbon.super" server-url: default: "localhost:9443" - paths: /users/share: post: @@ -31,7 +27,7 @@ paths: description: | This API shares one or more users across specified organizations, assigning roles based on the provided policy. The policy defines the sharing scope for each organization, including whether access extends to child organizations. - Permission required: `internal_user_shared_access_add` + Scope(Permission) required: `internal_user_shared_access_add` operationId: processUserSharing requestBody: content: @@ -83,7 +79,7 @@ paths: description: | This API shares users across all organizations, applying the provided roles to each organization. The policy determines the scope of sharing, including whether it applies to all current organizations or future organizations as well. - Permission required: `internal_user_shared_access_add` + Scope(Permission) required: `internal_user_shared_access_add` operationId: processUserSharingAll requestBody: content: @@ -135,7 +131,7 @@ paths: This API removes shared access for one or more users from specified organizations. The payload includes the list of user IDs and the organizations from which the users should be unshared. - Permission required: `internal_user_shared_access_delete` + Scope(Permission) required: `internal_user_shared_access_delete` operationId: processUserUnsharing requestBody: content: @@ -179,7 +175,7 @@ paths: description: | This API removes all shared access for one or more users, unsharing them from all organizations. - Permission required: `internal_user_shared_access_delete` + Scope(Permission) required: `internal_user_shared_access_delete` operationId: removeUserSharing requestBody: content: @@ -220,7 +216,7 @@ paths: description: | This API retrieves the list of organizations where the specified user has shared access, with support for pagination and filtering. - Permission required: `internal_user_shared_access_view` + Scope(Permission) required: `internal_user_shared_access_view` parameters: - in: path name: userId @@ -282,7 +278,7 @@ paths: description: | This API fetches the roles assigned to the specified user within a particular organization, with support for pagination, filtering, and recursion. - Permission required: `internal_user_shared_access_view` + Scope(Permission) required: `internal_user_shared_access_view` parameters: - in: path name: userId diff --git a/components/org.wso2.carbon.identity.api.server.organization.user.sharing.management/pom.xml b/components/org.wso2.carbon.identity.api.server.organization.user.sharing.management/pom.xml index 8cf23d15f8..94b8175799 100644 --- a/components/org.wso2.carbon.identity.api.server.organization.user.sharing.management/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.organization.user.sharing.management/pom.xml @@ -33,4 +33,4 @@ org.wso2.carbon.identity.api.server.organization.user.sharing.management.common - \ No newline at end of file +