Skip to content

Commit

Permalink
address comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
BimsaraBodaragama committed Jan 25, 2025
1 parent 51f83fa commit cabd548
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,6 @@
<packaging>jar</packaging>

<dependencies>
<dependency>
<groupId>org.wso2.carbon.multitenancy</groupId>
<artifactId>org.wso2.carbon.tenant.mgt</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.extension.identity.verification</groupId>
<artifactId>org.wso2.carbon.extension.identity.verification.provider</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.organization.management</groupId>
<artifactId>org.wso2.carbon.identity.organization.management.organization.user.sharing</artifactId>
Expand Down Expand Up @@ -109,4 +101,4 @@
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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."),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ 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() {

return userSharingPolicyHandlerService;
}

/**
* Set Invitation Core osgi service.
* Set User Sharing Policy Handler Service.
*
* @param userSharingPolicyHandlerService InvitationCoreService.
* @param userSharingPolicyHandlerService UserSharingPolicyHandlerService.
*/
public static void setUserSharingPolicyHandlerService(
UserSharingPolicyHandlerService userSharingPolicyHandlerService) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,4 @@
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -70,7 +72,7 @@ public void shareUser(UserShareRequestBody userShareRequestBody) {
// Set user criteria.
Map<String, UserCriteriaType> userCriteria = new HashMap<>();
UserCriteriaType userIds = new UserIdList(userShareRequestBody.getUserCriteria().getUserIds());
userCriteria.put("userIds", userIds);
userCriteria.put(USER_IDS, userIds);
selectiveUserShareDO.setUserCriteria(userCriteria);

// Set organizations.
Expand Down Expand Up @@ -118,7 +120,7 @@ public void shareUserWithAll(UserShareWithAllRequestBody userShareWithAllRequest
// Set user criteria.
Map<String, UserCriteriaType> userCriteria = new HashMap<>();
UserCriteriaType userIds = new UserIdList(userShareWithAllRequestBody.getUserCriteria().getUserIds());
userCriteria.put("userIds", userIds);
userCriteria.put(USER_IDS, userIds);
generalUserShareDO.setUserCriteria(userCriteria);

// Set policy.
Expand Down Expand Up @@ -159,7 +161,7 @@ public void unshareUser(UserUnshareRequestBody userUnshareRequestBody) {
// Set user criteria.
Map<String, UserCriteriaType> userCriteria = new HashMap<>();
UserCriteriaType userIds = new UserIdList(userUnshareRequestBody.getUserCriteria().getUserIds());
userCriteria.put("userIds", userIds);
userCriteria.put(USER_IDS, userIds);
selectiveUserUnshareDO.setUserCriteria(userCriteria);

// Set organizations.
Expand Down Expand Up @@ -187,7 +189,7 @@ public void unshareUserWithAll(UserUnshareWithAllRequestBody userUnshareWithAllR
// Set user criteria.
Map<String, UserCriteriaType> userCriteria = new HashMap<>();
UserCriteriaType userIds = new UserIdList(userUnshareWithAllRequestBody.getUserCriteria().getUserIds());
userCriteria.put("userIds", userIds);
userCriteria.put(USER_IDS, userIds);
generalUserUnshareDO.setUserCriteria(userCriteria);

try {
Expand Down Expand Up @@ -287,5 +289,4 @@ private String includeData(UserSharingMgtConstants.ErrorMessage error, String da
}
return error.getDescription();
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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.
<b>Permission required:</b> `internal_user_shared_access_add`
<b>Scope(Permission) required:</b> `internal_user_shared_access_add`
operationId: processUserSharing
requestBody:
content:
Expand Down Expand Up @@ -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.
<b>Permission required:</b> `internal_user_shared_access_add`
<b>Scope(Permission) required:</b> `internal_user_shared_access_add`
operationId: processUserSharingAll
requestBody:
content:
Expand Down Expand Up @@ -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.
<b>Permission required:</b> `internal_user_shared_access_delete`
<b>Scope(Permission) required:</b> `internal_user_shared_access_delete`
operationId: processUserUnsharing
requestBody:
content:
Expand Down Expand Up @@ -179,7 +175,7 @@ paths:
description: |
This API removes all shared access for one or more users, unsharing them from all organizations.
<b>Permission required:</b> `internal_user_shared_access_delete`
<b>Scope(Permission) required:</b> `internal_user_shared_access_delete`
operationId: removeUserSharing
requestBody:
content:
Expand Down Expand Up @@ -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.
<b>Permission required:</b> `internal_user_shared_access_view`
<b>Scope(Permission) required:</b> `internal_user_shared_access_view`
parameters:
- in: path
name: userId
Expand Down Expand Up @@ -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.
<b>Permission required:</b> `internal_user_shared_access_view`
<b>Scope(Permission) required:</b> `internal_user_shared_access_view`
parameters:
- in: path
name: userId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@
<module>org.wso2.carbon.identity.api.server.organization.user.sharing.management.common</module>
</modules>

</project>
</project>

0 comments on commit cabd548

Please sign in to comment.