From 3281176ddd2dd7dee6b0a9907e597df992516e80 Mon Sep 17 00:00:00 2001 From: Thilina Shashimal Senarath Date: Tue, 29 Aug 2023 12:03:12 +0530 Subject: [PATCH 01/10] add app role changes --- .../pom.xml | 5 + .../ApplicationManagementConstants.java | 10 + .../ApplicationManagementServiceHolder.java | 22 + .../ApplicationRoleMgtOSGiServiceFactory.java | 52 ++ .../pom.xml | 5 + .../management/v1/ApplicationsApi.java | 218 ++++++ .../management/v1/ApplicationsApiService.java | 25 + .../v1/GroupAssignedRoleResponse.java | 110 +++ .../v1/PaginatedAppRoleResponse.java | 140 ++++ .../management/v1/PaginationLink.java | 119 ++++ .../application/management/v1/Permission.java | 121 ++++ .../application/management/v1/Role.java | 152 +++++ .../management/v1/RoleAssignPatchModel.java | 109 +++ .../management/v1/RoleAssignedGroup.java | 140 ++++ .../management/v1/RoleAssignedUser.java | 140 ++++ .../management/v1/RoleCreationModel.java | 133 ++++ .../management/v1/RolePatchModel.java | 161 +++++ .../management/v1/RolePatchOp.java | 132 ++++ .../management/v1/RolePatchOpValue.java | 98 +++ .../v1/UserAssignedRoleResponse.java | 110 +++ .../ApplicationRoleMgtEndpointConstants.java | 103 +++ .../ApplicationRoleManagementService.java | 447 +++++++++++++ .../ApplicationRoleMgtEndpointException.java | 38 ++ .../v1/impl/ApplicationsApiServiceImpl.java | 88 +++ .../util/ApplicationRoleMgtEndpointUtil.java | 107 +++ .../cxf/applications-server-v1-cxf.xml | 8 +- .../src/main/resources/applications.yaml | 627 +++++++++++++++++- pom.xml | 8 +- 28 files changed, 3425 insertions(+), 3 deletions(-) create mode 100644 components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.common/src/main/java/org/wso2/carbon/identity/api/server/application/management/common/factory/ApplicationRoleMgtOSGiServiceFactory.java create mode 100644 components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/GroupAssignedRoleResponse.java create mode 100644 components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/PaginatedAppRoleResponse.java create mode 100644 components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/PaginationLink.java create mode 100644 components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/Permission.java create mode 100644 components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/Role.java create mode 100644 components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignPatchModel.java create mode 100644 components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedGroup.java create mode 100644 components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedUser.java create mode 100644 components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleCreationModel.java create mode 100644 components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RolePatchModel.java create mode 100644 components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RolePatchOp.java create mode 100644 components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RolePatchOpValue.java create mode 100644 components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/UserAssignedRoleResponse.java create mode 100644 components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/constants/ApplicationRoleMgtEndpointConstants.java create mode 100644 components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/ApplicationRoleManagementService.java create mode 100644 components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/exception/ApplicationRoleMgtEndpointException.java create mode 100644 components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/util/ApplicationRoleMgtEndpointUtil.java diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.common/pom.xml b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.common/pom.xml index ef8579295e..d5a711cbb4 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.common/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.common/pom.xml @@ -81,5 +81,10 @@ org.wso2.carbon.identity.auth.attribute.handler provided + + org.wso2.carbon.identity.framework + org.wso2.carbon.identity.application.role.mgt + provided + diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.common/src/main/java/org/wso2/carbon/identity/api/server/application/management/common/ApplicationManagementConstants.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.common/src/main/java/org/wso2/carbon/identity/api/server/application/management/common/ApplicationManagementConstants.java index 5de79a136f..0b051edb7d 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.common/src/main/java/org/wso2/carbon/identity/api/server/application/management/common/ApplicationManagementConstants.java +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.common/src/main/java/org/wso2/carbon/identity/api/server/application/management/common/ApplicationManagementConstants.java @@ -42,6 +42,7 @@ private ApplicationManagementConstants() { public static final String INBOUND_PROTOCOL_SAML_PATH_COMPONENT = "/saml"; public static final String INBOUND_PROTOCOL_PASSIVE_STS_PATH_COMPONENT = "/passive-sts"; public static final String INBOUND_PROTOCOL_WS_TRUST_PATH_COMPONENT = "/ws-trust"; + public static final String ROLES_PATH_COMPONENT = "/roles"; private static final Map OAUTH_GRANT_TYPE_NAMES = new LinkedHashMap<>(); public static final String DEFAULT_NAME_ID_FORMAT = "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified"; @@ -52,6 +53,15 @@ private ApplicationManagementConstants() { public static final String CLIENT_ID = "clientId"; public static final String ISSUER = "issuer"; + public static final String URL_SEPERATOR = "/"; + public static final String TENANT_URL_SEPERATOR = "/t/"; + public static final String SCIM2_ENDPOINT = "/scim2"; + + public static final String USERS = "/Users"; + public static final String GROUPS = "/Groups"; + + public static final String LOCAL_IDP = "LOCAL"; + public static final String NON_EXISTING_USER_CODE = "30007 - "; /** diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.common/src/main/java/org/wso2/carbon/identity/api/server/application/management/common/ApplicationManagementServiceHolder.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.common/src/main/java/org/wso2/carbon/identity/api/server/application/management/common/ApplicationManagementServiceHolder.java index 16628ebaeb..8b851255c0 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.common/src/main/java/org/wso2/carbon/identity/api/server/application/management/common/ApplicationManagementServiceHolder.java +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.common/src/main/java/org/wso2/carbon/identity/api/server/application/management/common/ApplicationManagementServiceHolder.java @@ -16,6 +16,7 @@ package org.wso2.carbon.identity.api.server.application.management.common; import org.wso2.carbon.identity.application.mgt.ApplicationManagementService; +import org.wso2.carbon.identity.application.role.mgt.ApplicationRoleManager; import org.wso2.carbon.identity.cors.mgt.core.CORSManagementService; import org.wso2.carbon.identity.oauth.OAuthAdminServiceImpl; import org.wso2.carbon.identity.oauth.config.OAuthServerConfiguration; @@ -37,6 +38,7 @@ public class ApplicationManagementServiceHolder { private static TemplateManager templateManager; private static CORSManagementService corsManagementService; private static RealmService realmService; + private static ApplicationRoleManager applicationRoleManagerService; public static ApplicationManagementService getApplicationManagementService() { @@ -127,4 +129,24 @@ public static void setRealmService(RealmService realmService) { ApplicationManagementServiceHolder.realmService = realmService; } + + /** + * Get ApplicationRoleManager. + * + * @return ApplicationRoleManager. + */ + public static ApplicationRoleManager getApplicationRoleManagerService() { + + return applicationRoleManagerService; + } + + /** + * Set ApplicationRoleManager. + * + * @param applicationRoleManagerService ApplicationRoleManager. + */ + public static void setApplicationRoleManagerService(ApplicationRoleManager applicationRoleManagerService) { + + ApplicationManagementServiceHolder.applicationRoleManagerService = applicationRoleManagerService; + } } diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.common/src/main/java/org/wso2/carbon/identity/api/server/application/management/common/factory/ApplicationRoleMgtOSGiServiceFactory.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.common/src/main/java/org/wso2/carbon/identity/api/server/application/management/common/factory/ApplicationRoleMgtOSGiServiceFactory.java new file mode 100644 index 0000000000..24086de970 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.common/src/main/java/org/wso2/carbon/identity/api/server/application/management/common/factory/ApplicationRoleMgtOSGiServiceFactory.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.application.management.common.factory; + +import org.springframework.beans.factory.config.AbstractFactoryBean; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.identity.application.role.mgt.ApplicationRoleManager; +/** + * Factory Beans serves as a factory for creating other beans within the IOC container. This factory bean is used to + * instantiate the Application role Manager type of object inside the container. + */ +public class ApplicationRoleMgtOSGiServiceFactory extends AbstractFactoryBean { + + private static ApplicationRoleManager applicationRoleMgtService; + + @Override + public Class getObjectType() { + + return Object.class; + } + + @Override + protected ApplicationRoleManager createInstance() throws Exception { + + if (applicationRoleMgtService == null) { + ApplicationRoleManager taskOperationService = (ApplicationRoleManager) PrivilegedCarbonContext. + getThreadLocalCarbonContext().getOSGiService(ApplicationRoleManager.class, null); + + if (taskOperationService == null) { + throw new Exception("Unable to retrieve application role management service."); + } + applicationRoleMgtService = taskOperationService; + } + return applicationRoleMgtService; + } +} \ No newline at end of file diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/pom.xml index 4338069c41..1b74124c2d 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/pom.xml @@ -153,6 +153,11 @@ cxf-rt-rs-extension-search provided + + org.wso2.carbon.identity.framework + org.wso2.carbon.identity.application.role.mgt + provided + diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/ApplicationsApi.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/ApplicationsApi.java index 0cf8a91191..3eac18fc65 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/ApplicationsApi.java +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/ApplicationsApi.java @@ -39,15 +39,22 @@ import org.wso2.carbon.identity.api.server.application.management.v1.CustomInboundProtocolMetaData; import org.wso2.carbon.identity.api.server.application.management.v1.Error; import java.io.File; +import org.wso2.carbon.identity.api.server.application.management.v1.GroupAssignedRoleResponse; import org.wso2.carbon.identity.api.server.application.management.v1.InboundProtocolListItem; import org.wso2.carbon.identity.api.server.application.management.v1.OIDCMetaData; import org.wso2.carbon.identity.api.server.application.management.v1.OpenIDConnectConfiguration; +import org.wso2.carbon.identity.api.server.application.management.v1.PaginatedAppRoleResponse; import org.wso2.carbon.identity.api.server.application.management.v1.PassiveStsConfiguration; import org.wso2.carbon.identity.api.server.application.management.v1.ProvisioningConfiguration; import org.wso2.carbon.identity.api.server.application.management.v1.ResidentApplication; +import org.wso2.carbon.identity.api.server.application.management.v1.Role; +import org.wso2.carbon.identity.api.server.application.management.v1.RoleAssignPatchModel; +import org.wso2.carbon.identity.api.server.application.management.v1.RoleCreationModel; +import org.wso2.carbon.identity.api.server.application.management.v1.RolePatchModel; import org.wso2.carbon.identity.api.server.application.management.v1.SAML2Configuration; import org.wso2.carbon.identity.api.server.application.management.v1.SAML2ServiceProvider; import org.wso2.carbon.identity.api.server.application.management.v1.SAMLMetaData; +import org.wso2.carbon.identity.api.server.application.management.v1.UserAssignedRoleResponse; import org.wso2.carbon.identity.api.server.application.management.v1.WSTrustConfiguration; import org.wso2.carbon.identity.api.server.application.management.v1.WSTrustMetaData; import org.wso2.carbon.identity.api.server.application.management.v1.ApplicationsApiService; @@ -92,6 +99,30 @@ public Response changeApplicationOwner(@ApiParam(value = "ID of the application. return delegate.changeApplicationOwner(applicationId, applicationOwner ); } + @Valid + @POST + @Path("/{applicationId}/roles") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + @ApiOperation(value = "Create an application role with collected permissions ", notes = "Create a new application role with or without permissions
Permission required:
* /permission/admin/manage/identity/applicationmgt/update
Scope required:
* internal_application_mgt_update ", response = Role.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Application Roles", }) + @ApiResponses(value = { + @ApiResponse(code = 201, message = "Successfully created.", response = Role.class), + @ApiResponse(code = 400, message = "Bad Request", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden", response = Void.class), + @ApiResponse(code = 409, message = "Conflict", response = Error.class), + @ApiResponse(code = 500, message = "Server Error", response = Error.class) + }) + public Response createAppRole(@ApiParam(value = "Application ID",required=true) @PathParam("applicationId") String applicationId, @ApiParam(value = "Role name and Permissions to add to the role" ) @Valid RoleCreationModel roleCreationModel) { + + return delegate.createAppRole(applicationId, roleCreationModel ); + } + @Valid @POST @@ -142,6 +173,29 @@ public Response createApplicationTemplate(@ApiParam(value = "This represents the return delegate.createApplicationTemplate(applicationTemplateModel ); } + @Valid + @DELETE + @Path("/{applicationId}/roles/{roleId}") + + @Produces({ "application/json" }) + @ApiOperation(value = "Delete an application role ", notes = "Delete a role
Permission required:
* /permission/admin/manage/identity/applicationmgt/update
Scope required:
* internal_application_mgt_update ", response = Void.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Application Roles", }) + @ApiResponses(value = { + @ApiResponse(code = 204, message = "Delete Success", response = Void.class), + @ApiResponse(code = 400, message = "", response = Void.class), + @ApiResponse(code = 401, message = "Unauthorized", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden", response = Void.class), + @ApiResponse(code = 500, message = "Server Error", response = Error.class) + }) + public Response deleteAppRole(@ApiParam(value = "Application ID",required=true) @PathParam("applicationId") String applicationId, @ApiParam(value = "Role ID",required=true) @PathParam("roleId") String roleId) { + + return delegate.deleteAppRole(applicationId, roleId ); + } + @Valid @DELETE @Path("/{applicationId}") @@ -381,6 +435,29 @@ public Response getAdaptiveAuthTemplates() { return delegate.getAdaptiveAuthTemplates(); } + @Valid + @GET + @Path("/{applicationId}/roles") + + @Produces({ "application/json" }) + @ApiOperation(value = "Get all roles of the application ", notes = "Get all roles of the application
Permission required:
* /permission/admin/manage/identity/applicationmgt/view
Scope required:
* internal_application_mgt_view ", response = PaginatedAppRoleResponse.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Application Roles", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "OK", response = PaginatedAppRoleResponse.class), + @ApiResponse(code = 400, message = "Bad Request", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden", response = Void.class), + @ApiResponse(code = 500, message = "Server Error", response = Error.class) + }) + public Response getAllAppRoles(@ApiParam(value = "Application ID",required=true) @PathParam("applicationId") String applicationId, @Valid@ApiParam(value = "Previous Cursor") @QueryParam("before") String before, @Valid@ApiParam(value = "Next Cursor") @QueryParam("after") String after) { + + return delegate.getAllAppRoles(applicationId, before, after ); + } + @Valid @GET @Path("/templates") @@ -434,6 +511,78 @@ public Response getAllApplications( @Valid @Min(1)@ApiParam(value = "Maximum return delegate.getAllApplications(limit, offset, filter, sortOrder, sortBy, attributes ); } + @Valid + @GET + @Path("/{applicationId}/roles/{roleId}") + + @Produces({ "application/json" }) + @ApiOperation(value = "Get role and associated permissions ", notes = "Get a role of the application and its associated permissions
Permission required:
* /permission/admin/manage/identity/applicationmgt/update
Scope required:
* internal_application_mgt_update ", response = Role.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Application Roles", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "OK", response = Role.class), + @ApiResponse(code = 400, message = "Bad Request", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden", response = Void.class), + @ApiResponse(code = 404, message = "Not Found", response = Error.class), + @ApiResponse(code = 500, message = "Server Error", response = Error.class) + }) + public Response getAppRole(@ApiParam(value = "Application ID",required=true) @PathParam("applicationId") String applicationId, @ApiParam(value = "Role ID",required=true) @PathParam("roleId") String roleId) { + + return delegate.getAppRole(applicationId, roleId ); + } + + @Valid + @GET + @Path("/{applicationId}/roles/{roleId}/identity-providers/{idpId}/assigned-groups") + + @Produces({ "application/json" }) + @ApiOperation(value = "Get role and assigned groups ", notes = "Get a role of the application and its assigned groups
Permission required:
* /permission/admin/manage/identity/rolemgt/view
Scope required:
* internal_role_mgt_view ", response = GroupAssignedRoleResponse.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Application Roles", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "OK", response = GroupAssignedRoleResponse.class), + @ApiResponse(code = 400, message = "Bad Request", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden", response = Void.class), + @ApiResponse(code = 404, message = "Not Found", response = Error.class), + @ApiResponse(code = 500, message = "Server Error", response = Error.class) + }) + public Response getAppRoleGroups(@ApiParam(value = "Application ID",required=true) @PathParam("applicationId") String applicationId, @ApiParam(value = "Role ID",required=true) @PathParam("roleId") String roleId, @ApiParam(value = "IDP ID",required=true) @PathParam("idpId") String idpId) { + + return delegate.getAppRoleGroups(applicationId, roleId, idpId ); + } + + @Valid + @GET + @Path("/{applicationId}/roles/{roleId}/assigned-users") + + @Produces({ "application/json" }) + @ApiOperation(value = "Get role and assigned users ", notes = "Get a role of the application and its assigned users
Permission required:
* /permission/admin/manage/identity/usermgt/view
Scope required:
* internal_user_mgt_view ", response = UserAssignedRoleResponse.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Application Roles", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "OK", response = UserAssignedRoleResponse.class), + @ApiResponse(code = 400, message = "Bad Request", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden", response = Void.class), + @ApiResponse(code = 404, message = "Not Found", response = Error.class), + @ApiResponse(code = 500, message = "Server Error", response = Error.class) + }) + public Response getAppRoleUsers(@ApiParam(value = "Application ID",required=true) @PathParam("applicationId") String applicationId, @ApiParam(value = "Role ID",required=true) @PathParam("roleId") String roleId) { + + return delegate.getAppRoleUsers(applicationId, roleId ); + } + @Valid @GET @Path("/{applicationId}") @@ -838,6 +987,75 @@ public Response importApplicationForUpdate(@Multipart(value = "file", required = return delegate.importApplicationForUpdate(fileInputStream, fileDetail ); } + @Valid + @PATCH + @Path("/{applicationId}/roles/{roleId}") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + @ApiOperation(value = "Update an application role ", notes = "Update role name and permissions
Permission required:
* /permission/admin/manage/identity/applicationmgt/update
Scope required:
* internal_application_mgt_update ", response = Role.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Application Roles", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "OK", response = Role.class), + @ApiResponse(code = 400, message = "Bad Request", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden", response = Void.class), + @ApiResponse(code = 500, message = "Server Error", response = Error.class) + }) + public Response patchAppRole(@ApiParam(value = "Application ID",required=true) @PathParam("applicationId") String applicationId, @ApiParam(value = "Role ID",required=true) @PathParam("roleId") String roleId, @ApiParam(value = "" ) @Valid RolePatchModel rolePatchModel) { + + return delegate.patchAppRole(applicationId, roleId, rolePatchModel ); + } + + @Valid + @PATCH + @Path("/{applicationId}/roles/{roleId}/identity-providers/{idpId}/assigned-groups") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + @ApiOperation(value = "Assign groups to an application role ", notes = "Assign groups to an application role
Permission required:
* /permission/admin/manage/identity/rolemgt/update
Scope required:
* internal_role_mgt_update ", response = GroupAssignedRoleResponse.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Application Roles", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "OK", response = GroupAssignedRoleResponse.class), + @ApiResponse(code = 400, message = "Bad Request", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden", response = Void.class), + @ApiResponse(code = 500, message = "Server Error", response = Error.class) + }) + public Response patchAppRoleAssignedGroups(@ApiParam(value = "Application ID",required=true) @PathParam("applicationId") String applicationId, @ApiParam(value = "Role ID",required=true) @PathParam("roleId") String roleId, @ApiParam(value = "IDP ID",required=true) @PathParam("idpId") String idpId, @ApiParam(value = "" ) @Valid RoleAssignPatchModel roleAssignPatchModel) { + + return delegate.patchAppRoleAssignedGroups(applicationId, roleId, idpId, roleAssignPatchModel ); + } + + @Valid + @PATCH + @Path("/{applicationId}/roles/{roleId}/assigned-users") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + @ApiOperation(value = "Assign users to an application role ", notes = "Assign users to an application role
Permission required:
* /permission/admin/manage/identity/usermgt/update
Scope required:
* internal_user_mgt_update ", response = UserAssignedRoleResponse.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Application Roles", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "OK", response = UserAssignedRoleResponse.class), + @ApiResponse(code = 400, message = "Bad Request", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden", response = Void.class), + @ApiResponse(code = 500, message = "Server Error", response = Error.class) + }) + public Response patchAppRoleAssignedUsers(@ApiParam(value = "Application ID",required=true) @PathParam("applicationId") String applicationId, @ApiParam(value = "Role ID",required=true) @PathParam("roleId") String roleId, @ApiParam(value = "" ) @Valid RoleAssignPatchModel roleAssignPatchModel) { + + return delegate.patchAppRoleAssignedUsers(applicationId, roleId, roleAssignPatchModel ); + } + @Valid @PATCH @Path("/{applicationId}") diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/ApplicationsApiService.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/ApplicationsApiService.java index 46d2d8f59d..a4600b6416 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/ApplicationsApiService.java +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/ApplicationsApiService.java @@ -39,15 +39,22 @@ import org.wso2.carbon.identity.api.server.application.management.v1.CustomInboundProtocolMetaData; import org.wso2.carbon.identity.api.server.application.management.v1.Error; import java.io.File; +import org.wso2.carbon.identity.api.server.application.management.v1.GroupAssignedRoleResponse; import org.wso2.carbon.identity.api.server.application.management.v1.InboundProtocolListItem; import org.wso2.carbon.identity.api.server.application.management.v1.OIDCMetaData; import org.wso2.carbon.identity.api.server.application.management.v1.OpenIDConnectConfiguration; +import org.wso2.carbon.identity.api.server.application.management.v1.PaginatedAppRoleResponse; import org.wso2.carbon.identity.api.server.application.management.v1.PassiveStsConfiguration; import org.wso2.carbon.identity.api.server.application.management.v1.ProvisioningConfiguration; import org.wso2.carbon.identity.api.server.application.management.v1.ResidentApplication; +import org.wso2.carbon.identity.api.server.application.management.v1.Role; +import org.wso2.carbon.identity.api.server.application.management.v1.RoleAssignPatchModel; +import org.wso2.carbon.identity.api.server.application.management.v1.RoleCreationModel; +import org.wso2.carbon.identity.api.server.application.management.v1.RolePatchModel; import org.wso2.carbon.identity.api.server.application.management.v1.SAML2Configuration; import org.wso2.carbon.identity.api.server.application.management.v1.SAML2ServiceProvider; import org.wso2.carbon.identity.api.server.application.management.v1.SAMLMetaData; +import org.wso2.carbon.identity.api.server.application.management.v1.UserAssignedRoleResponse; import org.wso2.carbon.identity.api.server.application.management.v1.WSTrustConfiguration; import org.wso2.carbon.identity.api.server.application.management.v1.WSTrustMetaData; import javax.ws.rs.core.Response; @@ -57,10 +64,14 @@ public interface ApplicationsApiService { public Response changeApplicationOwner(String applicationId, ApplicationOwner applicationOwner); + public Response createAppRole(String applicationId, RoleCreationModel roleCreationModel); + public Response createApplication(ApplicationModel applicationModel, String template); public Response createApplicationTemplate(ApplicationTemplateModel applicationTemplateModel); + public Response deleteAppRole(String applicationId, String roleId); + public Response deleteApplication(String applicationId); public Response deleteApplicationTemplate(String templateId); @@ -83,8 +94,16 @@ public interface ApplicationsApiService { public Response getAllApplicationTemplates(Integer limit, Integer offset, SearchContext searchContext); + public Response getAllAppRoles(String applicationId, String before, String after); + public Response getAllApplications(Integer limit, Integer offset, String filter, String sortOrder, String sortBy, String attributes); + public Response getAppRole(String applicationId, String roleId); + + public Response getAppRoleGroups(String applicationId, String roleId, String idpId); + + public Response getAppRoleUsers(String applicationId, String roleId); + public Response getApplication(String applicationId); public Response getApplicationTemplate(String templateId); @@ -119,6 +138,12 @@ public interface ApplicationsApiService { public Response importApplicationForUpdate(InputStream fileInputStream, Attachment fileDetail); + public Response patchAppRole(String applicationId, String roleId, RolePatchModel rolePatchModel); + + public Response patchAppRoleAssignedGroups(String applicationId, String roleId, String idpId, RoleAssignPatchModel roleAssignPatchModel); + + public Response patchAppRoleAssignedUsers(String applicationId, String roleId, RoleAssignPatchModel roleAssignPatchModel); + public Response patchApplication(String applicationId, ApplicationPatchModel applicationPatchModel); public Response regenerateOAuthClientSecret(String applicationId); diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/GroupAssignedRoleResponse.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/GroupAssignedRoleResponse.java new file mode 100644 index 0000000000..5d5165e364 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/GroupAssignedRoleResponse.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.application.management.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.ArrayList; +import java.util.List; +import org.wso2.carbon.identity.api.server.application.management.v1.RoleAssignedGroup; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class GroupAssignedRoleResponse { + + private List assignedGroups = null; + + + /** + **/ + public GroupAssignedRoleResponse assignedGroups(List assignedGroups) { + + this.assignedGroups = assignedGroups; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("assignedGroups") + @Valid + public List getAssignedGroups() { + return assignedGroups; + } + public void setAssignedGroups(List assignedGroups) { + this.assignedGroups = assignedGroups; + } + + public GroupAssignedRoleResponse addAssignedGroupsItem(RoleAssignedGroup assignedGroupsItem) { + if (this.assignedGroups == null) { + this.assignedGroups = new ArrayList<>(); + } + this.assignedGroups.add(assignedGroupsItem); + return this; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GroupAssignedRoleResponse groupAssignedRoleResponse = (GroupAssignedRoleResponse) o; + return Objects.equals(this.assignedGroups, groupAssignedRoleResponse.assignedGroups); + } + + @Override + public int hashCode() { + return Objects.hash(assignedGroups); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class GroupAssignedRoleResponse {\n"); + + sb.append(" assignedGroups: ").append(toIndentedString(assignedGroups)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/PaginatedAppRoleResponse.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/PaginatedAppRoleResponse.java new file mode 100644 index 0000000000..b24fac7ee5 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/PaginatedAppRoleResponse.java @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.application.management.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.ArrayList; +import java.util.List; +import org.wso2.carbon.identity.api.server.application.management.v1.PaginationLink; +import org.wso2.carbon.identity.api.server.application.management.v1.Role; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class PaginatedAppRoleResponse { + + private List links = new ArrayList<>(); + + private List roles = null; + + + /** + **/ + public PaginatedAppRoleResponse links(List links) { + + this.links = links; + return this; + } + + @ApiModelProperty(required = true, value = "") + @JsonProperty("links") + @Valid + @NotNull(message = "Property links cannot be null.") + + public List getLinks() { + return links; + } + public void setLinks(List links) { + this.links = links; + } + + public PaginatedAppRoleResponse addLinksItem(PaginationLink linksItem) { + this.links.add(linksItem); + return this; + } + + /** + **/ + public PaginatedAppRoleResponse roles(List roles) { + + this.roles = roles; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("roles") + @Valid + public List getRoles() { + return roles; + } + public void setRoles(List roles) { + this.roles = roles; + } + + public PaginatedAppRoleResponse addRolesItem(Role rolesItem) { + if (this.roles == null) { + this.roles = new ArrayList<>(); + } + this.roles.add(rolesItem); + return this; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PaginatedAppRoleResponse paginatedAppRoleResponse = (PaginatedAppRoleResponse) o; + return Objects.equals(this.links, paginatedAppRoleResponse.links) && + Objects.equals(this.roles, paginatedAppRoleResponse.roles); + } + + @Override + public int hashCode() { + return Objects.hash(links, roles); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class PaginatedAppRoleResponse {\n"); + + sb.append(" links: ").append(toIndentedString(links)).append("\n"); + sb.append(" roles: ").append(toIndentedString(roles)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/PaginationLink.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/PaginationLink.java new file mode 100644 index 0000000000..b86d650023 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/PaginationLink.java @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.application.management.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class PaginationLink { + + private String rel; + private String href; + + /** + **/ + public PaginationLink rel(String rel) { + + this.rel = rel; + return this; + } + + @ApiModelProperty(example = "before", value = "") + @JsonProperty("rel") + @Valid + public String getRel() { + return rel; + } + public void setRel(String rel) { + this.rel = rel; + } + + /** + **/ + public PaginationLink href(String href) { + + this.href = href; + return this; + } + + @ApiModelProperty(example = "/t/{tenant-name}/applications/{application-id}/roles?after=NDoy", value = "") + @JsonProperty("href") + @Valid + public String getHref() { + return href; + } + public void setHref(String href) { + this.href = href; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PaginationLink paginationLink = (PaginationLink) o; + return Objects.equals(this.rel, paginationLink.rel) && + Objects.equals(this.href, paginationLink.href); + } + + @Override + public int hashCode() { + return Objects.hash(rel, href); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class PaginationLink {\n"); + + sb.append(" rel: ").append(toIndentedString(rel)).append("\n"); + sb.append(" href: ").append(toIndentedString(href)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/Permission.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/Permission.java new file mode 100644 index 0000000000..ba44e24887 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/Permission.java @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.application.management.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class Permission { + + private String name; + private String displayName; + + /** + **/ + public Permission name(String name) { + + this.name = name; + return this; + } + + @ApiModelProperty(example = "deploy_component", required = true, value = "") + @JsonProperty("name") + @Valid + @NotNull(message = "Property name cannot be null.") + + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + /** + **/ + public Permission displayName(String displayName) { + + this.displayName = displayName; + return this; + } + + @ApiModelProperty(example = "Deploy Component", value = "") + @JsonProperty("displayName") + @Valid + public String getDisplayName() { + return displayName; + } + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Permission permission = (Permission) o; + return Objects.equals(this.name, permission.name) && + Objects.equals(this.displayName, permission.displayName); + } + + @Override + public int hashCode() { + return Objects.hash(name, displayName); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class Permission {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/Role.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/Role.java new file mode 100644 index 0000000000..25ed0584c0 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/Role.java @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.application.management.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.ArrayList; +import java.util.List; +import org.wso2.carbon.identity.api.server.application.management.v1.Permission; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class Role { + + private String id; + private String name; + private List permissions = null; + + + /** + **/ + public Role id(String id) { + + this.id = id; + return this; + } + + @ApiModelProperty(example = "85e3f4b8-0d22-4181-b1e3-1651f71b88bd", value = "") + @JsonProperty("id") + @Valid + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + + /** + **/ + public Role name(String name) { + + this.name = name; + return this; + } + + @ApiModelProperty(example = "administrator", value = "") + @JsonProperty("name") + @Valid + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + /** + **/ + public Role permissions(List permissions) { + + this.permissions = permissions; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("permissions") + @Valid + public List getPermissions() { + return permissions; + } + public void setPermissions(List permissions) { + this.permissions = permissions; + } + + public Role addPermissionsItem(Permission permissionsItem) { + if (this.permissions == null) { + this.permissions = new ArrayList<>(); + } + this.permissions.add(permissionsItem); + return this; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Role role = (Role) o; + return Objects.equals(this.id, role.id) && + Objects.equals(this.name, role.name) && + Objects.equals(this.permissions, role.permissions); + } + + @Override + public int hashCode() { + return Objects.hash(id, name, permissions); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class Role {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" permissions: ").append(toIndentedString(permissions)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignPatchModel.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignPatchModel.java new file mode 100644 index 0000000000..51f9f6b6f0 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignPatchModel.java @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.application.management.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.ArrayList; +import java.util.List; +import org.wso2.carbon.identity.api.server.application.management.v1.RolePatchOp; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class RoleAssignPatchModel { + + private List operations = new ArrayList<>(); + + + /** + **/ + public RoleAssignPatchModel operations(List operations) { + + this.operations = operations; + return this; + } + + @ApiModelProperty(required = true, value = "") + @JsonProperty("operations") + @Valid + @NotNull(message = "Property operations cannot be null.") + + public List getOperations() { + return operations; + } + public void setOperations(List operations) { + this.operations = operations; + } + + public RoleAssignPatchModel addOperationsItem(RolePatchOp operationsItem) { + this.operations.add(operationsItem); + return this; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RoleAssignPatchModel roleAssignPatchModel = (RoleAssignPatchModel) o; + return Objects.equals(this.operations, roleAssignPatchModel.operations); + } + + @Override + public int hashCode() { + return Objects.hash(operations); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class RoleAssignPatchModel {\n"); + + sb.append(" operations: ").append(toIndentedString(operations)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedGroup.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedGroup.java new file mode 100644 index 0000000000..b2f3821e09 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedGroup.java @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.application.management.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class RoleAssignedGroup { + + private String $ref; + private String display; + private String value; + + /** + **/ + public RoleAssignedGroup $ref(String $ref) { + + this.$ref = $ref; + return this; + } + + @ApiModelProperty(example = "https://localhost:9443/scim2/Groups/3a12bae9-4386-44be-befd-caf349297f45", value = "") + @JsonProperty("$ref") + @Valid + public String get$Ref() { + return $ref; + } + public void set$Ref(String $ref) { + this.$ref = $ref; + } + + /** + **/ + public RoleAssignedGroup display(String display) { + + this.display = display; + return this; + } + + @ApiModelProperty(example = "display", value = "") + @JsonProperty("display") + @Valid + public String getDisplay() { + return display; + } + public void setDisplay(String display) { + this.display = display; + } + + /** + **/ + public RoleAssignedGroup value(String value) { + + this.value = value; + return this; + } + + @ApiModelProperty(example = "e44dbc52-dcc3-443d-96f5-fe9dc208e9d8", value = "") + @JsonProperty("value") + @Valid + public String getValue() { + return value; + } + public void setValue(String value) { + this.value = value; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RoleAssignedGroup roleAssignedGroup = (RoleAssignedGroup) o; + return Objects.equals(this.$ref, roleAssignedGroup.$ref) && + Objects.equals(this.display, roleAssignedGroup.display) && + Objects.equals(this.value, roleAssignedGroup.value); + } + + @Override + public int hashCode() { + return Objects.hash($ref, display, value); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class RoleAssignedGroup {\n"); + + sb.append(" $ref: ").append(toIndentedString($ref)).append("\n"); + sb.append(" display: ").append(toIndentedString(display)).append("\n"); + sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedUser.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedUser.java new file mode 100644 index 0000000000..8e649bbb5b --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedUser.java @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.application.management.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class RoleAssignedUser { + + private String $ref; + private String display; + private String value; + + /** + **/ + public RoleAssignedUser $ref(String $ref) { + + this.$ref = $ref; + return this; + } + + @ApiModelProperty(example = "https://localhost:9443/scim2/Users/3a12bae9-4386-44be-befd-caf349297f45", value = "") + @JsonProperty("$ref") + @Valid + public String get$Ref() { + return $ref; + } + public void set$Ref(String $ref) { + this.$ref = $ref; + } + + /** + **/ + public RoleAssignedUser display(String display) { + + this.display = display; + return this; + } + + @ApiModelProperty(example = "display", value = "") + @JsonProperty("display") + @Valid + public String getDisplay() { + return display; + } + public void setDisplay(String display) { + this.display = display; + } + + /** + **/ + public RoleAssignedUser value(String value) { + + this.value = value; + return this; + } + + @ApiModelProperty(example = "e44dbc52-dcc3-443d-96f5-fe9dc208e9d8", value = "") + @JsonProperty("value") + @Valid + public String getValue() { + return value; + } + public void setValue(String value) { + this.value = value; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RoleAssignedUser roleAssignedUser = (RoleAssignedUser) o; + return Objects.equals(this.$ref, roleAssignedUser.$ref) && + Objects.equals(this.display, roleAssignedUser.display) && + Objects.equals(this.value, roleAssignedUser.value); + } + + @Override + public int hashCode() { + return Objects.hash($ref, display, value); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class RoleAssignedUser {\n"); + + sb.append(" $ref: ").append(toIndentedString($ref)).append("\n"); + sb.append(" display: ").append(toIndentedString(display)).append("\n"); + sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleCreationModel.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleCreationModel.java new file mode 100644 index 0000000000..3575ba36bb --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleCreationModel.java @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.application.management.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.ArrayList; +import java.util.List; +import org.wso2.carbon.identity.api.server.application.management.v1.Permission; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class RoleCreationModel { + + private String name; + private List permissions = null; + + + /** + **/ + public RoleCreationModel name(String name) { + + this.name = name; + return this; + } + + @ApiModelProperty(example = "administrator", required = true, value = "") + @JsonProperty("name") + @Valid + @NotNull(message = "Property name cannot be null.") + + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + /** + **/ + public RoleCreationModel permissions(List permissions) { + + this.permissions = permissions; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("permissions") + @Valid + public List getPermissions() { + return permissions; + } + public void setPermissions(List permissions) { + this.permissions = permissions; + } + + public RoleCreationModel addPermissionsItem(Permission permissionsItem) { + if (this.permissions == null) { + this.permissions = new ArrayList<>(); + } + this.permissions.add(permissionsItem); + return this; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RoleCreationModel roleCreationModel = (RoleCreationModel) o; + return Objects.equals(this.name, roleCreationModel.name) && + Objects.equals(this.permissions, roleCreationModel.permissions); + } + + @Override + public int hashCode() { + return Objects.hash(name, permissions); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class RoleCreationModel {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" permissions: ").append(toIndentedString(permissions)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RolePatchModel.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RolePatchModel.java new file mode 100644 index 0000000000..0fa2b84084 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RolePatchModel.java @@ -0,0 +1,161 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.application.management.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.ArrayList; +import java.util.List; +import org.wso2.carbon.identity.api.server.application.management.v1.Permission; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class RolePatchModel { + + private String name; + private List addedPermissions = new ArrayList<>(); + + private List removedPermissions = new ArrayList<>(); + + + /** + **/ + public RolePatchModel name(String name) { + + this.name = name; + return this; + } + + @ApiModelProperty(example = "uuid", required = true, value = "") + @JsonProperty("name") + @Valid + @NotNull(message = "Property name cannot be null.") + + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + /** + **/ + public RolePatchModel addedPermissions(List addedPermissions) { + + this.addedPermissions = addedPermissions; + return this; + } + + @ApiModelProperty(required = true, value = "") + @JsonProperty("addedPermissions") + @Valid + @NotNull(message = "Property addedPermissions cannot be null.") + + public List getAddedPermissions() { + return addedPermissions; + } + public void setAddedPermissions(List addedPermissions) { + this.addedPermissions = addedPermissions; + } + + public RolePatchModel addAddedPermissionsItem(Permission addedPermissionsItem) { + this.addedPermissions.add(addedPermissionsItem); + return this; + } + + /** + **/ + public RolePatchModel removedPermissions(List removedPermissions) { + + this.removedPermissions = removedPermissions; + return this; + } + + @ApiModelProperty(required = true, value = "") + @JsonProperty("removedPermissions") + @Valid + @NotNull(message = "Property removedPermissions cannot be null.") + + public List getRemovedPermissions() { + return removedPermissions; + } + public void setRemovedPermissions(List removedPermissions) { + this.removedPermissions = removedPermissions; + } + + public RolePatchModel addRemovedPermissionsItem(Permission removedPermissionsItem) { + this.removedPermissions.add(removedPermissionsItem); + return this; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RolePatchModel rolePatchModel = (RolePatchModel) o; + return Objects.equals(this.name, rolePatchModel.name) && + Objects.equals(this.addedPermissions, rolePatchModel.addedPermissions) && + Objects.equals(this.removedPermissions, rolePatchModel.removedPermissions); + } + + @Override + public int hashCode() { + return Objects.hash(name, addedPermissions, removedPermissions); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class RolePatchModel {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" addedPermissions: ").append(toIndentedString(addedPermissions)).append("\n"); + sb.append(" removedPermissions: ").append(toIndentedString(removedPermissions)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RolePatchOp.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RolePatchOp.java new file mode 100644 index 0000000000..5a122a8979 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RolePatchOp.java @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.application.management.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.ArrayList; +import java.util.List; +import org.wso2.carbon.identity.api.server.application.management.v1.RolePatchOpValue; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class RolePatchOp { + + private String op; + private List value = new ArrayList<>(); + + + /** + **/ + public RolePatchOp op(String op) { + + this.op = op; + return this; + } + + @ApiModelProperty(example = "add", required = true, value = "") + @JsonProperty("op") + @Valid + @NotNull(message = "Property op cannot be null.") + + public String getOp() { + return op; + } + public void setOp(String op) { + this.op = op; + } + + /** + **/ + public RolePatchOp value(List value) { + + this.value = value; + return this; + } + + @ApiModelProperty(required = true, value = "") + @JsonProperty("value") + @Valid + @NotNull(message = "Property value cannot be null.") + + public List getValue() { + return value; + } + public void setValue(List value) { + this.value = value; + } + + public RolePatchOp addValueItem(RolePatchOpValue valueItem) { + this.value.add(valueItem); + return this; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RolePatchOp rolePatchOp = (RolePatchOp) o; + return Objects.equals(this.op, rolePatchOp.op) && + Objects.equals(this.value, rolePatchOp.value); + } + + @Override + public int hashCode() { + return Objects.hash(op, value); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class RolePatchOp {\n"); + + sb.append(" op: ").append(toIndentedString(op)).append("\n"); + sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RolePatchOpValue.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RolePatchOpValue.java new file mode 100644 index 0000000000..49fc9f29c4 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RolePatchOpValue.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.application.management.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class RolePatchOpValue { + + private String value; + + /** + **/ + public RolePatchOpValue value(String value) { + + this.value = value; + return this; + } + + @ApiModelProperty(example = "e44dbc52-dcc3-443d-96f5-fe9dc208e9d8", value = "") + @JsonProperty("value") + @Valid + public String getValue() { + return value; + } + public void setValue(String value) { + this.value = value; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RolePatchOpValue rolePatchOpValue = (RolePatchOpValue) o; + return Objects.equals(this.value, rolePatchOpValue.value); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class RolePatchOpValue {\n"); + + sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/UserAssignedRoleResponse.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/UserAssignedRoleResponse.java new file mode 100644 index 0000000000..9a4f4fd5ba --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/UserAssignedRoleResponse.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.application.management.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.ArrayList; +import java.util.List; +import org.wso2.carbon.identity.api.server.application.management.v1.RoleAssignedUser; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class UserAssignedRoleResponse { + + private List assignedUsers = null; + + + /** + **/ + public UserAssignedRoleResponse assignedUsers(List assignedUsers) { + + this.assignedUsers = assignedUsers; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("assignedUsers") + @Valid + public List getAssignedUsers() { + return assignedUsers; + } + public void setAssignedUsers(List assignedUsers) { + this.assignedUsers = assignedUsers; + } + + public UserAssignedRoleResponse addAssignedUsersItem(RoleAssignedUser assignedUsersItem) { + if (this.assignedUsers == null) { + this.assignedUsers = new ArrayList<>(); + } + this.assignedUsers.add(assignedUsersItem); + return this; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UserAssignedRoleResponse userAssignedRoleResponse = (UserAssignedRoleResponse) o; + return Objects.equals(this.assignedUsers, userAssignedRoleResponse.assignedUsers); + } + + @Override + public int hashCode() { + return Objects.hash(assignedUsers); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class UserAssignedRoleResponse {\n"); + + sb.append(" assignedUsers: ").append(toIndentedString(assignedUsers)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/constants/ApplicationRoleMgtEndpointConstants.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/constants/ApplicationRoleMgtEndpointConstants.java new file mode 100644 index 0000000000..a53c76e143 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/constants/ApplicationRoleMgtEndpointConstants.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.application.management.v1.constants; + +/** + * Application role management endpoint constants. + */ +public class ApplicationRoleMgtEndpointConstants { + + public static final String APP_ROLE_MGT_ERROR_CODE_PREFIX = "APP-ROLE-"; + /** + * Application role management error message constants. + */ + public enum ErrorMessage { + + // Server Errors. + ERROR_CODE_INSERT_ROLE("65001", "Error occurred while adding the role.", + "Error occurred while adding the role: %s to application: %s."), + ERROR_CODE_GET_ROLE_BY_ID("65002", "Error occurred while retrieving the role.", + "Error occurred while retrieving the role: %s."), + ERROR_CODE_CHECKING_ROLE_EXISTENCE("65003", "Error occurred while checking the role existence.", + "Error occurred while checking whether the role: %s exists in application: %s."), + ERROR_CODE_GET_ROLES_BY_APPLICATION("65004", "Error occurred while retrieving the roles of the application", + "Error occurred while retrieving the roles of application: %s."), + ERROR_CODE_UPDATE_ROLE("65005", "Error occurred while updating the role.", + "Error occurred while updating the role: %s of application: %s."), + ERROR_CODE_DELETE_ROLE("65006", "Error occurred while deleting the role.", + "Error occurred while deleting the role: %s."), + ERROR_CODE_UPDATE_ROLE_ASSIGNED_USERS("65007", "Error occurred while updating assigned users to " + + "the role.", "Error occurred while updating assigned users to the roleId: %s."), + ERROR_CODE_GET_ROLE_ASSIGNED_USERS("65008", "Error occurred while retrieving assigned users of " + + "the role.", "Error occurred while retrieving users of the roleId: %s."), + ERROR_CODE_UPDATE_ROLE_ASSIGNED_GROUPS("65007", "Error occurred while updating assigned groups " + + "to the role.", "Error occurred while updating assigned groups to the roleId: %s."), + ERROR_CODE_GET_ROLE_ASSIGNED_GROUPS("65008", "Error occurred while retrieving assigned groups " + + "of the role.", "Error occurred while retrieving assigned groups of the roleId: %s."), + ERROR_CODE_GET_ROLES_BY_USER_ID("65009", "Error occurred while retrieving the app roles by " + + "userID", "Error occurred while retrieving the app roles by userID: %s."), + ERROR_CODE_GET_ROLES_BY_GROUP_ID("65010", "Error occurred while retrieving the app role by " + + "groupID", "Error occurred while retrieving the app role by groupID: %s."), + + // Client Errors. + ERROR_CODE_DUPLICATE_ROLE("60001", "Role already exists.", + "Role with name: %s already exists in application: %s."), + ERROR_CODE_ROLE_NOT_FOUND("60002", "Role doesn't exist.", + "Role with id: %s doesn't exist."), + ERROR_CODE_USER_ALREADY_ASSIGNED("60003", "Unable to assign user to app role.", + "User already assign for the roleId: %s."), + ERROR_CODE_GROUP_ALREADY_ASSIGNED("60004", "Unable to assign group to app role.", + "Group already assign for the roleId: %s."), + ERROR_CODE_USER_NOT_FOUND("60005", "Unable to assign user to app role.", + "User not found for the userId: %s."), + ERROR_CODE_GROUP_NOT_FOUND("60006", "Unable to assign group to app role.", + "Group not found for the groupId: %s."), + ERROR_CODE_IDP_NOT_FOUND("60007", "IDP doesn't exist.", + "IDP with id: %s doesn't exist."), + ERROR_CODE_INVALID_PATCH_OPERATION("60008", "Invalid patch operation.", + "Invalid patch operation"), + ; + + private final String code; + private final String message; + private final String description; + + ErrorMessage(String code, String message, String description) { + + this.code = code; + this.message = message; + this.description = description; + } + + public String getCode() { + + return APP_ROLE_MGT_ERROR_CODE_PREFIX + code; + } + + public String getMessage() { + + return message; + } + + public String getDescription() { + + return description; + } + } +} \ No newline at end of file diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/ApplicationRoleManagementService.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/ApplicationRoleManagementService.java new file mode 100644 index 0000000000..a4ba1abfef --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/ApplicationRoleManagementService.java @@ -0,0 +1,447 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.application.management.v1.core; + +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.identity.api.server.application.management.common.ApplicationManagementServiceHolder; +import org.wso2.carbon.identity.api.server.application.management.v1.GroupAssignedRoleResponse; +import org.wso2.carbon.identity.api.server.application.management.v1.Role; +import org.wso2.carbon.identity.api.server.application.management.v1.RoleAssignPatchModel; +import org.wso2.carbon.identity.api.server.application.management.v1.RoleAssignedGroup; +import org.wso2.carbon.identity.api.server.application.management.v1.RoleAssignedUser; +import org.wso2.carbon.identity.api.server.application.management.v1.RoleCreationModel; +import org.wso2.carbon.identity.api.server.application.management.v1.RolePatchModel; +import org.wso2.carbon.identity.api.server.application.management.v1.RolePatchOp; +import org.wso2.carbon.identity.api.server.application.management.v1.RolePatchOpValue; +import org.wso2.carbon.identity.api.server.application.management.v1.UserAssignedRoleResponse; +import org.wso2.carbon.identity.api.server.application.management.v1.util.ApplicationRoleMgtEndpointUtil; +import org.wso2.carbon.identity.api.server.common.ContextLoader; +import org.wso2.carbon.identity.application.role.mgt.ApplicationRoleManager; +import org.wso2.carbon.identity.application.role.mgt.exceptions.ApplicationRoleManagementException; +import org.wso2.carbon.identity.application.role.mgt.model.ApplicationRole; +import org.wso2.carbon.identity.application.role.mgt.model.Group; +import org.wso2.carbon.identity.application.role.mgt.model.User; +import org.wso2.carbon.identity.core.ServiceURLBuilder; +import org.wso2.carbon.identity.core.URLBuilderException; +import org.wso2.carbon.identity.core.util.IdentityTenantUtil; +import org.wso2.carbon.identity.core.util.IdentityUtil; +import org.wso2.carbon.utils.multitenancy.MultitenantConstants; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +import java.util.stream.Collectors; +import javax.ws.rs.core.Response; + +import static org.wso2.carbon.identity.api.server.application.management.common.ApplicationManagementConstants.GROUPS; +import static org.wso2.carbon.identity.api.server.application.management.common.ApplicationManagementConstants.LOCAL_IDP; +import static org.wso2.carbon.identity.api.server.application.management.common.ApplicationManagementConstants.SCIM2_ENDPOINT; +import static org.wso2.carbon.identity.api.server.application.management.common.ApplicationManagementConstants.TENANT_URL_SEPERATOR; +import static org.wso2.carbon.identity.api.server.application.management.common.ApplicationManagementConstants.URL_SEPERATOR; +import static org.wso2.carbon.identity.api.server.application.management.common.ApplicationManagementConstants.USERS; +import static org.wso2.carbon.identity.api.server.application.management.v1.constants.ApplicationRoleMgtEndpointConstants.ErrorMessage.ERROR_CODE_INVALID_PATCH_OPERATION; +import static org.wso2.carbon.identity.organization.management.service.constant.OrganizationManagementConstants.PATCH_OP_ADD; +import static org.wso2.carbon.identity.organization.management.service.constant.OrganizationManagementConstants.PATCH_OP_REMOVE; + +/** + * Application role management service. + */ +public class ApplicationRoleManagementService { + + /** + * Add a new role to the application. + * + * @param applicationId Application ID. + * @param role Role. + * @return Created role. + */ + public Role addApplicationRole(String applicationId, RoleCreationModel role) { + + // Filter names of the permissions in role.getPermissions() to List[] permissions + List permissions = null; + if (role.getPermissions() != null) { + permissions = + role.getPermissions().stream().map(permission -> permission.getName()).collect(Collectors.toList()); + } + String roleId = UUID.randomUUID().toString(); + try { + getApplicationRoleManager().addApplicationRole( + new ApplicationRole(roleId, role.getName(), permissions != null ? + permissions.toArray(new String[0]) : new String[0], + applicationId)); + + Role createdRole = new Role(); + createdRole.setId(roleId); + createdRole.setName(role.getName()); + createdRole.setPermissions(role.getPermissions()); + return createdRole; + } catch (ApplicationRoleManagementException e) { + throw ApplicationRoleMgtEndpointUtil.handleApplicationRoleMgtException(e); + } + } + + /** + * Get a role by ID. + * + * @param applicationId Application ID. + * @param roleId Role ID. + * @return Role. + */ + public Role getApplicationRole(String applicationId, String roleId) { + + ApplicationRole applicationRole = null; + try { + applicationRole = getApplicationRoleManager().getApplicationRoleById(roleId); + Role role = new Role(); + role.setId(roleId); + role.setName(applicationRole.getRoleName()); + // TODO set permissions. + return role; + } catch (ApplicationRoleManagementException e) { + throw ApplicationRoleMgtEndpointUtil.handleApplicationRoleMgtException(e); + } + } + + /** + * Get all roles of an application. + * + * @param applicationId Application ID. + * @param before Filter to get roles created before a given date. (optional) + * @param after Filter to get roles created after a given date. (optional) + * @param limit Maximum number of roles to return. (optional) + * @param filter Filter expression for filtering fields in the response. (optional) + * @param sort Sort expression for sorting the response. (optional) + * @return List of roles. + */ + public List getApplicationRoles(String applicationId, String before, String after, Integer limit, + String filter, String sort) { + + List applicationRoles = null; + try { + applicationRoles = getApplicationRoleManager().getApplicationRoles(applicationId); + return applicationRoles.stream().map(applicationRole -> { + Role role = new Role(); + role.setId(applicationRole.getRoleId()); + role.setName(applicationRole.getRoleName()); + // TODO set permissions. + return role; + }).collect(Collectors.toList()); + } catch (ApplicationRoleManagementException e) { + throw ApplicationRoleMgtEndpointUtil.handleApplicationRoleMgtException(e); + } + } + + /** + * Delete a role by ID. + * + * @param applicationId Application ID. + * @param roleId Role ID. + */ + public void deleteApplicationRole(String applicationId, String roleId) { + + try { + getApplicationRoleManager().deleteApplicationRole(roleId); + } catch (ApplicationRoleManagementException e) { + throw ApplicationRoleMgtEndpointUtil.handleApplicationRoleMgtException(e); + } + } + + /** + * Update a role by ID. + * + * @param applicationId Application ID. + * @param roleId Role ID. + * @param roleUpdate Role update. + */ + public void updateApplicationRole(String applicationId, String roleId, RolePatchModel roleUpdate) { + + List addedPermission = null; + List removedPermission = null; + if (roleUpdate.getAddedPermissions() != null) { + addedPermission = roleUpdate.getAddedPermissions().stream() + .map(permission -> permission.getName()).collect(Collectors.toList()); + } + if (roleUpdate.getRemovedPermissions() != null) { + removedPermission = roleUpdate.getRemovedPermissions().stream() + .map(permission -> permission.getName()).collect(Collectors.toList()); + } + try { + getApplicationRoleManager().updateApplicationRole(applicationId, roleId, roleUpdate.getName(), + addedPermission, removedPermission); + } catch (ApplicationRoleManagementException e) { + throw ApplicationRoleMgtEndpointUtil.handleApplicationRoleMgtException(e); + } + } + + /** + * Update a app role assigned user by ID. + * + * @param applicationId Application ID. + * @param roleId Role ID. + * @param roleAssignUpdateModel Role assign update. + */ + public UserAssignedRoleResponse updateApplicationRoleAssignedUsers(String applicationId, String roleId, + RoleAssignPatchModel roleAssignUpdateModel) { + + try { + List patchOperationList = roleAssignUpdateModel.getOperations(); + List addUsers = new ArrayList<>(); + List removedUsers = new ArrayList<>(); + + for (RolePatchOp rolePatchOp : patchOperationList) { + List values = rolePatchOp.getValue(); + String patchOp = rolePatchOp.getOp(); + if ((CollectionUtils.isNotEmpty(values) && StringUtils.equalsIgnoreCase(patchOp, PATCH_OP_ADD))) { + for (RolePatchOpValue value : values) { + addUsers.add(value.getValue()); + } + } else if ((CollectionUtils.isNotEmpty(values) && + StringUtils.equalsIgnoreCase(patchOp, PATCH_OP_REMOVE))) { + for (RolePatchOpValue value : values) { + removedUsers.add(value.getValue()); + } + } else { + // Invalid patch operations cannot be sent due to swagger validation. + // But, if values are not passed along with ADD operations, an error is thrown. + throw ApplicationRoleMgtEndpointUtil.handleException(Response.Status.BAD_REQUEST, + ERROR_CODE_INVALID_PATCH_OPERATION); + } + } + String tenantDomain = ContextLoader.getTenantDomainFromContext(); + ApplicationRole applicationRole = getApplicationRoleManager().updateApplicationRoleAssignedUsers(roleId, + addUsers, removedUsers); + UserAssignedRoleResponse response = new UserAssignedRoleResponse(); + List users = getUsersForResponseObject(applicationRole.getAssignedUsers(), + tenantDomain); + response.setAssignedUsers(users); + return response; + } catch (ApplicationRoleManagementException e) { + throw ApplicationRoleMgtEndpointUtil.handleApplicationRoleMgtException(e); + } + } + + /** + * Get app role's assigned users by ID. + * + * @param applicationId Application ID. + * @param roleId Role ID. + */ + public UserAssignedRoleResponse getApplicationRoleAssignedUsers(String applicationId, String roleId) { + + ApplicationRole applicationRole = null; + try { + String tenantDomain = ContextLoader.getTenantDomainFromContext(); + applicationRole = getApplicationRoleManager().getApplicationRoleAssignedUsers(roleId); + UserAssignedRoleResponse response = new UserAssignedRoleResponse(); + List users = getUsersForResponseObject(applicationRole.getAssignedUsers(), + tenantDomain); + response.setAssignedUsers(users); + return response; + } catch (ApplicationRoleManagementException e) { + throw ApplicationRoleMgtEndpointUtil.handleApplicationRoleMgtException(e); + } + } + + /** + * Update a app role assigned groups by ID. + * + * @param applicationId Application ID. + * @param roleId Role ID. + * @param roleAssignUpdateModel Role assign update. + */ + public GroupAssignedRoleResponse updateApplicationRoleAssignedGroups(String applicationId, String roleId, + String idpId, + RoleAssignPatchModel roleAssignUpdateModel) { + + try { + List patchOperationList = roleAssignUpdateModel.getOperations(); + List addGroups = new ArrayList<>(); + List removedGroups = new ArrayList<>(); + + for (RolePatchOp rolePatchOp : patchOperationList) { + List values = rolePatchOp.getValue(); + String patchOp = rolePatchOp.getOp().toString(); + if ((CollectionUtils.isNotEmpty(values) && StringUtils.equalsIgnoreCase(patchOp, PATCH_OP_ADD))) { + for (RolePatchOpValue value : values) { + addGroups.add(value.getValue()); + } + } else if ((CollectionUtils.isNotEmpty(values) && + StringUtils.equalsIgnoreCase(patchOp, PATCH_OP_REMOVE))) { + for (RolePatchOpValue value : values) { + removedGroups.add(value.getValue()); + } + } else { + // Invalid patch operations cannot be sent due to swagger validation. + // But, if values are not passed along with ADD operations, an error is thrown. + throw ApplicationRoleMgtEndpointUtil.handleException(Response.Status.BAD_REQUEST, + ERROR_CODE_INVALID_PATCH_OPERATION); + } + } + ApplicationRole applicationRole = getApplicationRoleManager().updateApplicationRoleAssignedGroups(roleId, + idpId, addGroups, removedGroups); + String tenantDomain = ContextLoader.getTenantDomainFromContext(); + GroupAssignedRoleResponse response = new GroupAssignedRoleResponse(); + List groups = getGroupsForResponseObject(applicationRole.getAssignedGroups(), + tenantDomain); + response.setAssignedGroups(groups); + return response; + } catch (ApplicationRoleManagementException e) { + throw ApplicationRoleMgtEndpointUtil.handleApplicationRoleMgtException(e); + } + } + + /** + * Get app role's assigned groups by ID. + * + * @param applicationId Application ID. + * @param roleId Role ID. + */ + public GroupAssignedRoleResponse getApplicationRoleAssignedGroups(String applicationId, String roleId, String idp) { + + ApplicationRole applicationRole = null; + try { + String tenantDomain = ContextLoader.getTenantDomainFromContext(); + applicationRole = getApplicationRoleManager().getApplicationRoleAssignedGroups(roleId, idp); + GroupAssignedRoleResponse response = new GroupAssignedRoleResponse(); + List groups = getGroupsForResponseObject(applicationRole.getAssignedGroups(), + tenantDomain); + response.setAssignedGroups(groups); + return response; + } catch (ApplicationRoleManagementException e) { + throw ApplicationRoleMgtEndpointUtil.handleApplicationRoleMgtException(e); + } + } + + private ApplicationRoleManager getApplicationRoleManager() { + + return ApplicationManagementServiceHolder.getApplicationRoleManagerService(); + } + + /** + * Set the users for the response if they exist. + * + * @param roleAssignedUsers The users assigned to a role. + * @param tenantDomain tenantDomain. + * @return The ApplicationRoleGetResponseUser list. + */ + private List getUsersForResponseObject(List roleAssignedUsers, + String tenantDomain) { + + List users = new ArrayList<>(); + for (User basicUser : roleAssignedUsers) { + String uri = getSCIMUserURL(basicUser.getId(), tenantDomain); + + RoleAssignedUser user = new RoleAssignedUser(); + user.value(basicUser.getId()); + user.display(basicUser.getUserName()); + user.$ref(uri); + users.add(user); + } + return users; + } + + /** + * Set the groups for the response if they exist. + * + * @param roleAssignedGroups The groups assigned to a role. + * @param tenantDomain tenantDomain. + * @return The ApplicationRoleGetResponseUser list. + */ + private List getGroupsForResponseObject(List roleAssignedGroups, + String tenantDomain) { + + List groups = new ArrayList<>(); + for (Group group : roleAssignedGroups) { + String uri = getSCIMGroupURL(group.getGroupId(), tenantDomain); + + RoleAssignedGroup assignedGroup = new RoleAssignedGroup(); + assignedGroup.value(group.getGroupId()); + assignedGroup.display(group.getGroupName()); + if (LOCAL_IDP.equals(group.getIdpName())) { + assignedGroup.$ref(uri); + } + groups.add(assignedGroup); + } + return groups; + } + + private String getSCIMUserURL(String id, String tenantDomain) { + return org.apache.commons.lang.StringUtils.isNotBlank(id) ? getSCIMUserURL(tenantDomain) + URL_SEPERATOR + + id : null; + } + + private String getSCIMUserURL(String tenantDomain) { + + String scimURL = getSCIMURL(tenantDomain); + return scimURL + USERS; + } + + private String getSCIMGroupURL(String id, String tenantDomain) { + return org.apache.commons.lang.StringUtils.isNotBlank(id) ? getSCIMGroupURL(tenantDomain) + URL_SEPERATOR + + id : null; + } + + private String getSCIMGroupURL(String tenantDomain) { + + String scimURL = getSCIMURL(tenantDomain); + return scimURL + GROUPS; + } + + private String getSCIMURL(String tenantDomain) { + + String scimURL; + try { + if (IdentityTenantUtil.isTenantQualifiedUrlsEnabled()) { + scimURL = ServiceURLBuilder.create().addPath(SCIM2_ENDPOINT).build() + .getAbsolutePublicURL(); + } else { + String serverUrl = ServiceURLBuilder.create().build().getAbsolutePublicURL(); + if (isNotASuperTenantFlow(tenantDomain)) { + scimURL = serverUrl + "/t/" + tenantDomain + SCIM2_ENDPOINT; + } else { + scimURL = serverUrl + SCIM2_ENDPOINT; + } + } + return scimURL; + } catch (URLBuilderException e) { + // Fallback to legacy approach during error scenarios to maintain backward compatibility. + return getSCIMURLLegacy(); + } + } + + private String getSCIMURLLegacy() { + + String scimURL; + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); + if (isNotASuperTenantFlow(tenantDomain)) { + scimURL = IdentityUtil.getServerURL( + TENANT_URL_SEPERATOR + tenantDomain + SCIM2_ENDPOINT, + true, true); + } else { + scimURL = IdentityUtil.getServerURL(SCIM2_ENDPOINT, true, true); + } + return scimURL; + } + + private boolean isNotASuperTenantFlow(String tenantDomain) { + return !MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain); + } +} \ No newline at end of file diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/exception/ApplicationRoleMgtEndpointException.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/exception/ApplicationRoleMgtEndpointException.java new file mode 100644 index 0000000000..51efdf0ec8 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/exception/ApplicationRoleMgtEndpointException.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.application.management.v1.exception; + +import org.wso2.carbon.identity.api.server.application.management.v1.Error; +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +/** + * Application role management endpoint exception. + */ +public class ApplicationRoleMgtEndpointException extends WebApplicationException { + + + public ApplicationRoleMgtEndpointException(Response.Status status, Error error) { + + super(Response.status(status).entity(error).header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .build()); + } +} \ No newline at end of file diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/impl/ApplicationsApiServiceImpl.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/impl/ApplicationsApiServiceImpl.java index 8c57c012cc..a903dbd752 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/impl/ApplicationsApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/impl/ApplicationsApiServiceImpl.java @@ -34,17 +34,27 @@ import org.wso2.carbon.identity.api.server.application.management.v1.PassiveStsConfiguration; import org.wso2.carbon.identity.api.server.application.management.v1.ProvisioningConfiguration; import org.wso2.carbon.identity.api.server.application.management.v1.ResidentApplication; +import org.wso2.carbon.identity.api.server.application.management.v1.Role; +import org.wso2.carbon.identity.api.server.application.management.v1.RoleAssignPatchModel; +import org.wso2.carbon.identity.api.server.application.management.v1.RoleCreationModel; +import org.wso2.carbon.identity.api.server.application.management.v1.RolePatchModel; import org.wso2.carbon.identity.api.server.application.management.v1.SAML2Configuration; import org.wso2.carbon.identity.api.server.application.management.v1.SAML2ServiceProvider; import org.wso2.carbon.identity.api.server.application.management.v1.WSTrustConfiguration; +import org.wso2.carbon.identity.api.server.application.management.v1.core.ApplicationRoleManagementService; import org.wso2.carbon.identity.api.server.application.management.v1.core.ServerApplicationManagementService; import org.wso2.carbon.identity.api.server.application.management.v1.core.ServerApplicationMetadataService; import org.wso2.carbon.identity.api.server.application.management.v1.core.TransferResource; import org.wso2.carbon.identity.api.server.common.Constants; import org.wso2.carbon.identity.api.server.common.ContextLoader; +import org.wso2.carbon.identity.api.server.common.error.APIError; +import org.wso2.carbon.identity.api.server.common.error.ErrorResponse; import java.io.InputStream; +import java.io.UnsupportedEncodingException; import java.net.URI; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; import java.util.List; import javax.ws.rs.core.Response; @@ -60,6 +70,9 @@ public class ApplicationsApiServiceImpl implements ApplicationsApiService { @Autowired private ServerApplicationMetadataService applicationMetadataService; + @Autowired + private ApplicationRoleManagementService applicationRoleManagementService; + @Override public Response getAllApplications(Integer limit, Integer offset, String filter, String sortOrder, String sortBy, String requiredAttributes) { @@ -69,6 +82,26 @@ public Response getAllApplications(Integer limit, Integer offset, String filter, return Response.ok().entity(listResponse).build(); } + @Override + public Response getAppRole(String applicationId, String roleId) { + + return Response.ok().entity(applicationRoleManagementService.getApplicationRole(applicationId, roleId)).build(); + } + + @Override + public Response getAppRoleGroups(String applicationId, String roleId, String idpId) { + + return Response.ok().entity(applicationRoleManagementService + .getApplicationRoleAssignedGroups(applicationId, roleId, idpId)).build(); + } + + @Override + public Response getAppRoleUsers(String applicationId, String roleId) { + + return Response.ok().entity(applicationRoleManagementService + .getApplicationRoleAssignedUsers(applicationId, roleId)).build(); + } + @Override public Response getApplication(String applicationId) { @@ -95,6 +128,24 @@ public Response changeApplicationOwner(String applicationId, ApplicationOwner ap return Response.ok().build(); } + @Override + public Response createAppRole(String applicationId, RoleCreationModel roleCreationModel) { + + Role role = applicationRoleManagementService.addApplicationRole(applicationId, roleCreationModel); + URI location; + try { + location = ContextLoader.buildURIForHeader(Constants.V1_API_PATH_COMPONENT + + ApplicationManagementConstants.APPLICATION_MANAGEMENT_PATH_COMPONENT + "/" + applicationId + "/" + + ApplicationManagementConstants.ROLES_PATH_COMPONENT + "/" + + URLEncoder.encode(role.getId(), StandardCharsets.UTF_8.name())); + } catch (UnsupportedEncodingException e) { + ErrorResponse errorResponse = + new ErrorResponse.Builder().withMessage("Error due to unsupported encoding.").build(); + throw new APIError(Response.Status.METHOD_NOT_ALLOWED, errorResponse); + } + return Response.created(location).entity(role).build(); + } + @Override public Response createApplication(ApplicationModel applicationModel, String template) { @@ -109,6 +160,13 @@ public Response createApplicationTemplate(ApplicationTemplateModel applicationTe return Response.created(getTemplateResourceLocation(templateId)).build(); } + @Override + public Response deleteAppRole(String applicationId, String roleId) { + + applicationRoleManagementService.deleteApplicationRole(applicationId, roleId); + return Response.noContent().build(); + } + @Override public Response deleteApplication(String applicationId) { @@ -242,6 +300,29 @@ public Response importApplicationForUpdate(InputStream fileInputStream, Attachme return Response.ok().location(getResourceLocation(resourceId)).build(); } + @Override + public Response patchAppRole(String applicationId, String roleId, RolePatchModel rolePatchModel) { + + applicationRoleManagementService.updateApplicationRole(applicationId, roleId, rolePatchModel); + return Response.ok().build(); + } + + @Override + public Response patchAppRoleAssignedGroups(String applicationId, String roleId, String idpId, + RoleAssignPatchModel roleAssignPatchModel) { + + return Response.ok().entity(applicationRoleManagementService.updateApplicationRoleAssignedGroups(applicationId, + roleId, idpId, roleAssignPatchModel)).build(); + } + + @Override + public Response patchAppRoleAssignedUsers(String applicationId, String roleId, + RoleAssignPatchModel roleAssignPatchModel) { + + return Response.ok().entity(applicationRoleManagementService.updateApplicationRoleAssignedUsers(applicationId, + roleId, roleAssignPatchModel)).build(); + } + @Override public Response getInboundAuthenticationConfigurations(String applicationId) { @@ -368,6 +449,13 @@ public Response getAllApplicationTemplates(Integer limit, Integer offset, Search searchContext)).build(); } + @Override + public Response getAllAppRoles(String applicationId, String before, String after) { + + return Response.ok().entity(applicationRoleManagementService.getApplicationRoles(applicationId, before, + after, null, null, null)).build(); + } + private URI getResourceLocation(String resourceId) { return ContextLoader.buildURIForHeader(Constants.V1_API_PATH_COMPONENT + diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/util/ApplicationRoleMgtEndpointUtil.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/util/ApplicationRoleMgtEndpointUtil.java new file mode 100644 index 0000000000..b687f95fa3 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/util/ApplicationRoleMgtEndpointUtil.java @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.application.management.v1.util; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.identity.api.server.application.management.v1.Error; +import org.wso2.carbon.identity.api.server.application.management.v1.constants.ApplicationRoleMgtEndpointConstants; +import org.wso2.carbon.identity.api.server.application.management.v1.exception.ApplicationRoleMgtEndpointException; +import org.wso2.carbon.identity.application.role.mgt.exceptions.ApplicationRoleManagementClientException; +import org.wso2.carbon.identity.application.role.mgt.exceptions.ApplicationRoleManagementException; + +import javax.ws.rs.core.Response; + +import static org.wso2.carbon.identity.api.server.application.management.v1.constants.ApplicationRoleMgtEndpointConstants.ErrorMessage.ERROR_CODE_GROUP_ALREADY_ASSIGNED; +import static org.wso2.carbon.identity.api.server.application.management.v1.constants.ApplicationRoleMgtEndpointConstants.ErrorMessage.ERROR_CODE_GROUP_NOT_FOUND; +import static org.wso2.carbon.identity.api.server.application.management.v1.constants.ApplicationRoleMgtEndpointConstants.ErrorMessage.ERROR_CODE_IDP_NOT_FOUND; +import static org.wso2.carbon.identity.api.server.application.management.v1.constants.ApplicationRoleMgtEndpointConstants.ErrorMessage.ERROR_CODE_USER_ALREADY_ASSIGNED; +import static org.wso2.carbon.identity.api.server.application.management.v1.constants.ApplicationRoleMgtEndpointConstants.ErrorMessage.ERROR_CODE_USER_NOT_FOUND; +import static org.wso2.carbon.identity.api.server.common.Constants.ERROR_CODE_DELIMITER; + +/** + * Application role management endpoint util. + */ +public class ApplicationRoleMgtEndpointUtil { + + private static final Log log = LogFactory.getLog(ApplicationRoleMgtEndpointUtil.class); + + public static ApplicationRoleMgtEndpointException handleException(Response.Status status, + ApplicationRoleMgtEndpointConstants.ErrorMessage + error) { + + return new ApplicationRoleMgtEndpointException(status, getError(error.getCode(), error.getMessage(), + error.getDescription())); + } + + public static ApplicationRoleMgtEndpointException handleException(Response.Status status, + ApplicationRoleMgtEndpointConstants.ErrorMessage + error, String data) { + + return new ApplicationRoleMgtEndpointException(status, getError(error.getCode(), error.getMessage(), + String.format(error.getDescription(), data))); + } + public static ApplicationRoleMgtEndpointException handleException(Response.Status status, String errorCode, + String message, String description) { + + return new ApplicationRoleMgtEndpointException(status, getError(errorCode, message, description)); + } + public static ApplicationRoleMgtEndpointException handleApplicationRoleMgtException( + ApplicationRoleManagementException e) { + + Response.Status status = Response.Status.INTERNAL_SERVER_ERROR; + if (e instanceof ApplicationRoleManagementClientException) { + + if (e.getErrorCode().equals(ERROR_CODE_USER_NOT_FOUND.getCode()) || + e.getErrorCode().equals(ERROR_CODE_GROUP_NOT_FOUND.getCode()) || + e.getErrorCode().equals(ERROR_CODE_IDP_NOT_FOUND.getCode()) + ) { + status = Response.Status.NOT_FOUND; + } else if (e.getErrorCode().equals(ERROR_CODE_USER_ALREADY_ASSIGNED.getCode()) || + e.getErrorCode().equals(ERROR_CODE_GROUP_ALREADY_ASSIGNED.getCode())) { + status = Response.Status.CONFLICT; + } else { + status = Response.Status.BAD_REQUEST; + } + } else { + log.error(e.getMessage(), e); + } + String errorCode = e.getErrorCode(); + errorCode = errorCode.contains(ERROR_CODE_DELIMITER) ? errorCode : + ApplicationRoleMgtEndpointConstants.APP_ROLE_MGT_ERROR_CODE_PREFIX + errorCode; + return handleException(status, errorCode, e.getMessage(), e.getDescription()); + } + + /** + * Returns a generic error object. + * + * @param errorCode Error code. + * @param errorMessage Error message. + * @param errorDescription Error description. + * @return A generic error with the specified details. + */ + public static Error getError(String errorCode, String errorMessage, String errorDescription) { + + Error error = new Error(); + error.setCode(errorCode); + error.setMessage(errorMessage); + error.setDescription(errorDescription); + return error; + } +} \ No newline at end of file diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/resources/META-INF/cxf/applications-server-v1-cxf.xml b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/resources/META-INF/cxf/applications-server-v1-cxf.xml index 142d89d26c..5e55ea7d57 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/resources/META-INF/cxf/applications-server-v1-cxf.xml +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/resources/META-INF/cxf/applications-server-v1-cxf.xml @@ -50,7 +50,10 @@ class="org.wso2.carbon.identity.api.server.application.management.common.ApplicationManagementServiceHolder"> - + + + + + diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/resources/applications.yaml b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/resources/applications.yaml index a4a43de4ee..d6eec00e13 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/resources/applications.yaml +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/resources/applications.yaml @@ -2194,6 +2194,490 @@ paths: schema: $ref: '#/components/schemas/Error' + '/applications/{applicationId}/roles': + post: + tags: + - Application Roles + summary: | + Create an application role with collected permissions + description: > + Create a new application role with or without permissions
+ Permission required:
+ * /permission/admin/manage/identity/applicationmgt/update
+ Scope required:
+ * internal_application_mgt_update + operationId: createAppRole + parameters: + - name: applicationId + in: path + description: Application ID + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/RoleCreationModel' + description: Role name and Permissions to add to the role + responses: + 201: + description: Successfully created. + content: + application/json: + schema: + $ref: '#/components/schemas/Role' + 400: + description: Bad Request + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 401: + description: Unauthorized + 403: + description: Forbidden + 409: + description: Conflict + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 500: + description: Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + get: + tags: + - Application Roles + summary: | + Get all roles of the application + description: > + Get all roles of the application
+ Permission required:
+ * /permission/admin/manage/identity/applicationmgt/view
+ Scope required:
+ * internal_application_mgt_view + operationId: getAllAppRoles + parameters: + - name: applicationId + in: path + description: Application ID + required: true + schema: + type: string + - name: before + in: query + description: Previous Cursor + schema: + type: string + - name: after + in: query + description: Next Cursor + schema: + type: string + responses: + 200: + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/PaginatedAppRoleResponse' + 400: + description: Bad Request + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 401: + description: Unauthorized + 403: + description: Forbidden + 500: + description: Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/applications/{applicationId}/roles/{roleId}': + get: + tags: + - Application Roles + summary: | + Get role and associated permissions + description: > + Get a role of the application and its associated permissions
+ Permission required:
+ * /permission/admin/manage/identity/applicationmgt/update
+ Scope required:
+ * internal_application_mgt_update + operationId: getAppRole + parameters: + - name: applicationId + in: path + description: Application ID + required: true + schema: + type: string + - name: roleId + in: path + description: Role ID + required: true + schema: + type: string + responses: + 200: + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/Role' + 400: + description: Bad Request + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 401: + description: Unauthorized + 403: + description: Forbidden + 404: + description: Not Found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 500: + description: Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + patch: + tags: + - Application Roles + summary: | + Update an application role + description: > + Update role name and permissions
+ Permission required:
+ * /permission/admin/manage/identity/applicationmgt/update
+ Scope required:
+ * internal_application_mgt_update + operationId: patchAppRole + parameters: + - name: applicationId + in: path + description: Application ID + required: true + schema: + type: string + - name: roleId + in: path + description: Role ID + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/RolePatchModel' + responses: + 200: + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/Role' + 400: + description: Bad Request + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 401: + description: Unauthorized + 403: + description: Forbidden + 500: + description: Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + delete: + tags: + - Application Roles + summary: | + Delete an application role + description: > + Delete a role
+ Permission required:
+ * /permission/admin/manage/identity/applicationmgt/update
+ Scope required:
+ * internal_application_mgt_update + operationId: deleteAppRole + parameters: + - name: applicationId + in: path + description: Application ID + required: true + schema: + type: string + - name: roleId + in: path + description: Role ID + required: true + schema: + type: string + responses: + 204: + description: Delete Success + 400: + $ref: '#/components/schemas/Error' + 401: + description: Unauthorized + 403: + description: Forbidden + 500: + description: Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/applications/{applicationId}/roles/{roleId}/assigned-users': + get: + tags: + - Application Roles + summary: | + Get role and assigned users + description: > + Get a role of the application and its assigned users
+ Permission required:
+ * /permission/admin/manage/identity/usermgt/view
+ Scope required:
+ * internal_user_mgt_view + operationId: getAppRoleUsers + parameters: + - name: applicationId + in: path + description: Application ID + required: true + schema: + type: string + - name: roleId + in: path + description: Role ID + required: true + schema: + type: string + responses: + 200: + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/UserAssignedRoleResponse' + 400: + description: Bad Request + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 401: + description: Unauthorized + 403: + description: Forbidden + 404: + description: Not Found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 500: + description: Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + patch: + tags: + - Application Roles + summary: | + Assign users to an application role + description: > + Assign users to an application role
+ Permission required:
+ * /permission/admin/manage/identity/usermgt/update
+ Scope required:
+ * internal_user_mgt_update + operationId: patchAppRoleAssignedUsers + parameters: + - name: applicationId + in: path + description: Application ID + required: true + schema: + type: string + - name: roleId + in: path + description: Role ID + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/RoleAssignPatchModel' + responses: + 200: + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/UserAssignedRoleResponse' + 400: + description: Bad Request + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 401: + description: Unauthorized + 403: + description: Forbidden + 500: + description: Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/applications/{applicationId}/roles/{roleId}/identity-providers/{idpId}/assigned-groups': + get: + tags: + - Application Roles + summary: | + Get role and assigned groups + description: > + Get a role of the application and its assigned groups
+ Permission required:
+ * /permission/admin/manage/identity/rolemgt/view
+ Scope required:
+ * internal_role_mgt_view + operationId: getAppRoleGroups + parameters: + - name: applicationId + in: path + description: Application ID + required: true + schema: + type: string + - name: roleId + in: path + description: Role ID + required: true + schema: + type: string + - name: idpId + in: path + description: IDP ID + required: true + schema: + type: string + responses: + 200: + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/GroupAssignedRoleResponse' + 400: + description: Bad Request + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 401: + description: Unauthorized + 403: + description: Forbidden + 404: + description: Not Found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 500: + description: Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + patch: + tags: + - Application Roles + summary: | + Assign groups to an application role + description: > + Assign groups to an application role
+ Permission required:
+ * /permission/admin/manage/identity/rolemgt/update
+ Scope required:
+ * internal_role_mgt_update + operationId: patchAppRoleAssignedGroups + parameters: + - name: applicationId + in: path + description: Application ID + required: true + schema: + type: string + - name: roleId + in: path + description: Role ID + required: true + schema: + type: string + - name: idpId + in: path + description: IDP ID + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/RoleAssignPatchModel' + responses: + 200: + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/GroupAssignedRoleResponse' + 400: + description: Bad Request + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 401: + description: Unauthorized + 403: + description: Forbidden + 500: + description: Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + components: parameters: limitQueryParam: @@ -3507,7 +3991,148 @@ components: example: "85e3f4b8-0d22-4181-b1e3-1651f71b88bd" required: - id - + RoleCreationModel: + type: object + required: + - name + properties: + name: + type: string + example: administrator + permissions: + type: array + items: + $ref: '#/components/schemas/Permission' + Role: + type: object + properties: + id: + type: string + example: "85e3f4b8-0d22-4181-b1e3-1651f71b88bd" + name: + type: string + example: administrator + permissions: + type: array + items: + $ref: '#/components/schemas/Permission' + Permission: + type: object + required: + - name + properties: + name: + type: string + example: 'deploy_component' + displayName: + type: string + example: "Deploy Component" + PaginatedAppRoleResponse: + type: object + required: + - links + properties: + links: + type: array + items: + $ref: '#/components/schemas/PaginationLink' + roles: + type: array + items: + $ref: '#/components/schemas/Role' + PaginationLink: + type: object + properties: + rel: + type: string + example: before + href: + type: string + example: /t/{tenant-name}/applications/{application-id}/roles?after=NDoy + RolePatchModel: + type: object + required: + - name + - addedPermissions + - removedPermissions + properties: + name: + type: string + example: uuid + addedPermissions: + type: array + items: + $ref: '#/components/schemas/Permission' + removedPermissions: + type: array + items: + $ref: '#/components/schemas/Permission' + RoleAssignPatchModel: + type: object + required: + - operations + properties: + operations: + type: array + items: + $ref: '#/components/schemas/RolePatchOp' + RolePatchOp: + type: object + required: + - op + - value + properties: + op: + type: string + example: 'add' + value: + type: array + items: + $ref: '#/components/schemas/RolePatchOpValue' + RolePatchOpValue: + type: object + properties: + value: + type: string + example: 'e44dbc52-dcc3-443d-96f5-fe9dc208e9d8' + UserAssignedRoleResponse: + type: object + properties: + assignedUsers: + type: array + items: + $ref: '#/components/schemas/RoleAssignedUser' + GroupAssignedRoleResponse: + type: object + properties: + assignedGroups: + type: array + items: + $ref: '#/components/schemas/RoleAssignedGroup' + RoleAssignedUser: + type: object + properties: + $ref: + type: string + example: 'https://localhost:9443/scim2/Users/3a12bae9-4386-44be-befd-caf349297f45' + display: + type: string + example: 'display' + value: + type: string + example: 'e44dbc52-dcc3-443d-96f5-fe9dc208e9d8' + RoleAssignedGroup: + type: object + properties: + $ref: + type: string + example: 'https://localhost:9443/scim2/Groups/3a12bae9-4386-44be-befd-caf349297f45' + display: + type: string + example: 'display' + value: + type: string + example: 'e44dbc52-dcc3-443d-96f5-fe9dc208e9d8' Error: type: object properties: diff --git a/pom.xml b/pom.xml index 8bde15147d..e914914ba8 100644 --- a/pom.xml +++ b/pom.xml @@ -197,6 +197,12 @@ + + org.wso2.carbon.identity.framework + org.wso2.carbon.identity.application.role.mgt + ${carbon.identity.framework.version} + provided + org.wso2.carbon.identity.framework org.wso2.carbon.identity.application.common @@ -689,7 +695,7 @@ 1.4 1.2.4 1.8.57 - 5.25.198 + 5.25.287-SNAPSHOT 3.0.5 5.2.0 **/gen/**/* From 0b78abd4b658d0643f6d7c837caab74c6251f0ec Mon Sep 17 00:00:00 2001 From: Thilina Shashimal Senarath Date: Tue, 29 Aug 2023 13:08:36 +0530 Subject: [PATCH 02/10] add app role bean --- .../common/factory/ApplicationRoleMgtOSGiServiceFactory.java | 2 +- .../v1/constants/ApplicationRoleMgtEndpointConstants.java | 2 +- .../management/v1/core/ApplicationRoleManagementService.java | 2 +- .../v1/exception/ApplicationRoleMgtEndpointException.java | 2 +- .../management/v1/util/ApplicationRoleMgtEndpointUtil.java | 2 +- .../main/resources/META-INF/cxf/applications-server-v1-cxf.xml | 1 + 6 files changed, 6 insertions(+), 5 deletions(-) diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.common/src/main/java/org/wso2/carbon/identity/api/server/application/management/common/factory/ApplicationRoleMgtOSGiServiceFactory.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.common/src/main/java/org/wso2/carbon/identity/api/server/application/management/common/factory/ApplicationRoleMgtOSGiServiceFactory.java index 24086de970..e7b8f9f562 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.common/src/main/java/org/wso2/carbon/identity/api/server/application/management/common/factory/ApplicationRoleMgtOSGiServiceFactory.java +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.common/src/main/java/org/wso2/carbon/identity/api/server/application/management/common/factory/ApplicationRoleMgtOSGiServiceFactory.java @@ -49,4 +49,4 @@ protected ApplicationRoleManager createInstance() throws Exception { } return applicationRoleMgtService; } -} \ No newline at end of file +} diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/constants/ApplicationRoleMgtEndpointConstants.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/constants/ApplicationRoleMgtEndpointConstants.java index a53c76e143..ab35f41141 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/constants/ApplicationRoleMgtEndpointConstants.java +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/constants/ApplicationRoleMgtEndpointConstants.java @@ -100,4 +100,4 @@ public String getDescription() { return description; } } -} \ No newline at end of file +} diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/ApplicationRoleManagementService.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/ApplicationRoleManagementService.java index a4ba1abfef..0d54b47170 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/ApplicationRoleManagementService.java +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/ApplicationRoleManagementService.java @@ -444,4 +444,4 @@ private String getSCIMURLLegacy() { private boolean isNotASuperTenantFlow(String tenantDomain) { return !MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain); } -} \ No newline at end of file +} diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/exception/ApplicationRoleMgtEndpointException.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/exception/ApplicationRoleMgtEndpointException.java index 51efdf0ec8..79845cabb4 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/exception/ApplicationRoleMgtEndpointException.java +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/exception/ApplicationRoleMgtEndpointException.java @@ -35,4 +35,4 @@ public ApplicationRoleMgtEndpointException(Response.Status status, Error error) super(Response.status(status).entity(error).header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .build()); } -} \ No newline at end of file +} diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/util/ApplicationRoleMgtEndpointUtil.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/util/ApplicationRoleMgtEndpointUtil.java index b687f95fa3..1ccf5d9d7a 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/util/ApplicationRoleMgtEndpointUtil.java +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/util/ApplicationRoleMgtEndpointUtil.java @@ -104,4 +104,4 @@ public static Error getError(String errorCode, String errorMessage, String error error.setDescription(errorDescription); return error; } -} \ No newline at end of file +} diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/resources/META-INF/cxf/applications-server-v1-cxf.xml b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/resources/META-INF/cxf/applications-server-v1-cxf.xml index 5e55ea7d57..aa270f0dec 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/resources/META-INF/cxf/applications-server-v1-cxf.xml +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/resources/META-INF/cxf/applications-server-v1-cxf.xml @@ -20,6 +20,7 @@ + Date: Thu, 31 Aug 2023 16:08:48 +0530 Subject: [PATCH 03/10] change update return --- .../management/v1/core/ApplicationRoleManagementService.java | 4 ++-- .../management/v1/impl/ApplicationsApiServiceImpl.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/ApplicationRoleManagementService.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/ApplicationRoleManagementService.java index 0d54b47170..38d402f3cb 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/ApplicationRoleManagementService.java +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/ApplicationRoleManagementService.java @@ -171,7 +171,7 @@ public void deleteApplicationRole(String applicationId, String roleId) { * @param roleId Role ID. * @param roleUpdate Role update. */ - public void updateApplicationRole(String applicationId, String roleId, RolePatchModel roleUpdate) { + public ApplicationRole updateApplicationRole(String applicationId, String roleId, RolePatchModel roleUpdate) { List addedPermission = null; List removedPermission = null; @@ -184,7 +184,7 @@ public void updateApplicationRole(String applicationId, String roleId, RolePatch .map(permission -> permission.getName()).collect(Collectors.toList()); } try { - getApplicationRoleManager().updateApplicationRole(applicationId, roleId, roleUpdate.getName(), + return getApplicationRoleManager().updateApplicationRole(applicationId, roleId, roleUpdate.getName(), addedPermission, removedPermission); } catch (ApplicationRoleManagementException e) { throw ApplicationRoleMgtEndpointUtil.handleApplicationRoleMgtException(e); diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/impl/ApplicationsApiServiceImpl.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/impl/ApplicationsApiServiceImpl.java index a903dbd752..63e7b2f2d4 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/impl/ApplicationsApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/impl/ApplicationsApiServiceImpl.java @@ -303,8 +303,8 @@ public Response importApplicationForUpdate(InputStream fileInputStream, Attachme @Override public Response patchAppRole(String applicationId, String roleId, RolePatchModel rolePatchModel) { - applicationRoleManagementService.updateApplicationRole(applicationId, roleId, rolePatchModel); - return Response.ok().build(); + return Response.ok().entity(applicationRoleManagementService.updateApplicationRole(applicationId, roleId, + rolePatchModel)).build(); } @Override From 0ee35f5eb5d295ffba27c103f94149fa22374901 Mon Sep 17 00:00:00 2001 From: Thilina Shashimal Senarath Date: Fri, 1 Sep 2023 10:21:58 +0530 Subject: [PATCH 04/10] get retuned app role --- .../v1/core/ApplicationRoleManagementService.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/ApplicationRoleManagementService.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/ApplicationRoleManagementService.java index 38d402f3cb..ad4e6cc79d 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/ApplicationRoleManagementService.java +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/ApplicationRoleManagementService.java @@ -18,6 +18,7 @@ package org.wso2.carbon.identity.api.server.application.management.v1.core; +import edu.emory.mathcs.backport.java.util.Arrays; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.wso2.carbon.context.PrivilegedCarbonContext; @@ -83,15 +84,17 @@ public Role addApplicationRole(String applicationId, RoleCreationModel role) { } String roleId = UUID.randomUUID().toString(); try { - getApplicationRoleManager().addApplicationRole( + ApplicationRole appRole = getApplicationRoleManager().addApplicationRole( new ApplicationRole(roleId, role.getName(), permissions != null ? permissions.toArray(new String[0]) : new String[0], applicationId)); Role createdRole = new Role(); - createdRole.setId(roleId); - createdRole.setName(role.getName()); - createdRole.setPermissions(role.getPermissions()); + createdRole.setId(appRole.getRoleId()); + createdRole.setName(appRole.getRoleName()); + if (appRole.getPermissions() != null) { + createdRole.setPermissions(Arrays.asList(appRole.getPermissions())); + } return createdRole; } catch (ApplicationRoleManagementException e) { throw ApplicationRoleMgtEndpointUtil.handleApplicationRoleMgtException(e); From d890e8d5ab2b63ae60ed35e06d9dd3c544bbf6dd Mon Sep 17 00:00:00 2001 From: Thilina Shashimal Senarath Date: Mon, 4 Sep 2023 12:13:47 +0530 Subject: [PATCH 05/10] fix add role return --- .../management/v1/core/ApplicationRoleManagementService.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/ApplicationRoleManagementService.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/ApplicationRoleManagementService.java index ad4e6cc79d..f389512b27 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/ApplicationRoleManagementService.java +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/ApplicationRoleManagementService.java @@ -110,9 +110,8 @@ public Role addApplicationRole(String applicationId, RoleCreationModel role) { */ public Role getApplicationRole(String applicationId, String roleId) { - ApplicationRole applicationRole = null; try { - applicationRole = getApplicationRoleManager().getApplicationRoleById(roleId); + ApplicationRole applicationRole = getApplicationRoleManager().getApplicationRoleById(roleId); Role role = new Role(); role.setId(roleId); role.setName(applicationRole.getRoleName()); From 2f45c4c82aa7bf6f2d111da04c69ae61278d94a6 Mon Sep 17 00:00:00 2001 From: Thilina Shashimal Senarath Date: Tue, 5 Sep 2023 15:18:16 +0530 Subject: [PATCH 06/10] add permission assigning to app role --- .../ApplicationRoleManagementService.java | 34 ++++++++++++++++--- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/ApplicationRoleManagementService.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/ApplicationRoleManagementService.java index f389512b27..7c9c0f1ba8 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/ApplicationRoleManagementService.java +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/ApplicationRoleManagementService.java @@ -24,6 +24,7 @@ import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.identity.api.server.application.management.common.ApplicationManagementServiceHolder; import org.wso2.carbon.identity.api.server.application.management.v1.GroupAssignedRoleResponse; +import org.wso2.carbon.identity.api.server.application.management.v1.Permission; import org.wso2.carbon.identity.api.server.application.management.v1.Role; import org.wso2.carbon.identity.api.server.application.management.v1.RoleAssignPatchModel; import org.wso2.carbon.identity.api.server.application.management.v1.RoleAssignedGroup; @@ -115,7 +116,13 @@ public Role getApplicationRole(String applicationId, String roleId) { Role role = new Role(); role.setId(roleId); role.setName(applicationRole.getRoleName()); - // TODO set permissions. + List permissions = new ArrayList<>(); + for (String scope : applicationRole.getPermissions()) { + Permission permission = new Permission(); + permission.setName(scope); + permissions.add(permission); + } + role.setPermissions(permissions); return role; } catch (ApplicationRoleManagementException e) { throw ApplicationRoleMgtEndpointUtil.handleApplicationRoleMgtException(e); @@ -143,7 +150,13 @@ public List getApplicationRoles(String applicationId, String before, Strin Role role = new Role(); role.setId(applicationRole.getRoleId()); role.setName(applicationRole.getRoleName()); - // TODO set permissions. + List permissions = new ArrayList<>(); + for (String scope : applicationRole.getPermissions()) { + Permission permission = new Permission(); + permission.setName(scope); + permissions.add(permission); + } + role.setPermissions(permissions); return role; }).collect(Collectors.toList()); } catch (ApplicationRoleManagementException e) { @@ -173,7 +186,7 @@ public void deleteApplicationRole(String applicationId, String roleId) { * @param roleId Role ID. * @param roleUpdate Role update. */ - public ApplicationRole updateApplicationRole(String applicationId, String roleId, RolePatchModel roleUpdate) { + public Role updateApplicationRole(String applicationId, String roleId, RolePatchModel roleUpdate) { List addedPermission = null; List removedPermission = null; @@ -186,8 +199,19 @@ public ApplicationRole updateApplicationRole(String applicationId, String roleId .map(permission -> permission.getName()).collect(Collectors.toList()); } try { - return getApplicationRoleManager().updateApplicationRole(applicationId, roleId, roleUpdate.getName(), - addedPermission, removedPermission); + ApplicationRole applicationRole = getApplicationRoleManager().updateApplicationRole(applicationId, + roleId, roleUpdate.getName(), addedPermission, removedPermission); + Role role = new Role(); + role.setId(roleId); + role.setName(applicationRole.getRoleName()); + List permissions = new ArrayList<>(); + for (String scope : applicationRole.getPermissions()) { + Permission permission = new Permission(); + permission.setName(scope); + permissions.add(permission); + } + role.setPermissions(permissions); + return role; } catch (ApplicationRoleManagementException e) { throw ApplicationRoleMgtEndpointUtil.handleApplicationRoleMgtException(e); } From 3b310a2cdc070ab139dbef469b855537514b9959 Mon Sep 17 00:00:00 2001 From: Thilina Shashimal Senarath Date: Tue, 5 Sep 2023 22:03:14 +0530 Subject: [PATCH 07/10] add app role bean --- .../management/v1/ApplicationsApi.java | 37 ++--- .../management/v1/ApplicationsApiService.java | 11 +- ...e.java => GroupsAssignedRoleResponse.java} | 12 +- .../management/v1/RoleAssignedGroup.java | 25 +++- .../v1/RoleAssignedGroupsPatchModel.java | 109 +++++++++++++++ .../v1/RoleAssignedGroupsPatchOp.java | 132 ++++++++++++++++++ .../v1/RoleAssignedGroupsPatchOpValue.java | 119 ++++++++++++++++ ....java => RoleAssignedUsersPatchModel.java} | 20 +-- ...hOp.java => RoleAssignedUsersPatchOp.java} | 24 ++-- ...ava => RoleAssignedUsersPatchOpValue.java} | 10 +- ...se.java => UsersAssignedRoleResponse.java} | 12 +- .../ApplicationRoleManagementService.java | 71 +++++----- .../v1/impl/ApplicationsApiServiceImpl.java | 11 +- .../src/main/resources/applications.yaml | 73 +++++++--- 14 files changed, 541 insertions(+), 125 deletions(-) rename components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/{GroupAssignedRoleResponse.java => GroupsAssignedRoleResponse.java} (84%) create mode 100644 components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedGroupsPatchModel.java create mode 100644 components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedGroupsPatchOp.java create mode 100644 components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedGroupsPatchOpValue.java rename components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/{RoleAssignPatchModel.java => RoleAssignedUsersPatchModel.java} (77%) rename components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/{RolePatchOp.java => RoleAssignedUsersPatchOp.java} (78%) rename components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/{RolePatchOpValue.java => RoleAssignedUsersPatchOpValue.java} (86%) rename components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/{UserAssignedRoleResponse.java => UsersAssignedRoleResponse.java} (85%) diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/ApplicationsApi.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/ApplicationsApi.java index 3eac18fc65..34acb5aea4 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/ApplicationsApi.java +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/ApplicationsApi.java @@ -39,7 +39,7 @@ import org.wso2.carbon.identity.api.server.application.management.v1.CustomInboundProtocolMetaData; import org.wso2.carbon.identity.api.server.application.management.v1.Error; import java.io.File; -import org.wso2.carbon.identity.api.server.application.management.v1.GroupAssignedRoleResponse; +import org.wso2.carbon.identity.api.server.application.management.v1.GroupsAssignedRoleResponse; import org.wso2.carbon.identity.api.server.application.management.v1.InboundProtocolListItem; import org.wso2.carbon.identity.api.server.application.management.v1.OIDCMetaData; import org.wso2.carbon.identity.api.server.application.management.v1.OpenIDConnectConfiguration; @@ -48,13 +48,14 @@ import org.wso2.carbon.identity.api.server.application.management.v1.ProvisioningConfiguration; import org.wso2.carbon.identity.api.server.application.management.v1.ResidentApplication; import org.wso2.carbon.identity.api.server.application.management.v1.Role; -import org.wso2.carbon.identity.api.server.application.management.v1.RoleAssignPatchModel; +import org.wso2.carbon.identity.api.server.application.management.v1.RoleAssignedGroupsPatchModel; +import org.wso2.carbon.identity.api.server.application.management.v1.RoleAssignedUsersPatchModel; import org.wso2.carbon.identity.api.server.application.management.v1.RoleCreationModel; import org.wso2.carbon.identity.api.server.application.management.v1.RolePatchModel; import org.wso2.carbon.identity.api.server.application.management.v1.SAML2Configuration; import org.wso2.carbon.identity.api.server.application.management.v1.SAML2ServiceProvider; import org.wso2.carbon.identity.api.server.application.management.v1.SAMLMetaData; -import org.wso2.carbon.identity.api.server.application.management.v1.UserAssignedRoleResponse; +import org.wso2.carbon.identity.api.server.application.management.v1.UsersAssignedRoleResponse; import org.wso2.carbon.identity.api.server.application.management.v1.WSTrustConfiguration; import org.wso2.carbon.identity.api.server.application.management.v1.WSTrustMetaData; import org.wso2.carbon.identity.api.server.application.management.v1.ApplicationsApiService; @@ -537,24 +538,24 @@ public Response getAppRole(@ApiParam(value = "Application ID",required=true) @Pa @Valid @GET - @Path("/{applicationId}/roles/{roleId}/identity-providers/{idpId}/assigned-groups") + @Path("/{applicationId}/roles/{roleId}/assigned-groups") @Produces({ "application/json" }) - @ApiOperation(value = "Get role and assigned groups ", notes = "Get a role of the application and its assigned groups
Permission required:
* /permission/admin/manage/identity/rolemgt/view
Scope required:
* internal_role_mgt_view ", response = GroupAssignedRoleResponse.class, authorizations = { + @ApiOperation(value = "Get role and assigned groups ", notes = "Get a role of the application and its assigned groups
Permission required:
* /permission/admin/manage/identity/rolemgt/view
Scope required:
* internal_role_mgt_view ", response = GroupsAssignedRoleResponse.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { }) }, tags={ "Application Roles", }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "OK", response = GroupAssignedRoleResponse.class), + @ApiResponse(code = 200, message = "OK", response = GroupsAssignedRoleResponse.class), @ApiResponse(code = 400, message = "Bad Request", response = Error.class), @ApiResponse(code = 401, message = "Unauthorized", response = Void.class), @ApiResponse(code = 403, message = "Forbidden", response = Void.class), @ApiResponse(code = 404, message = "Not Found", response = Error.class), @ApiResponse(code = 500, message = "Server Error", response = Error.class) }) - public Response getAppRoleGroups(@ApiParam(value = "Application ID",required=true) @PathParam("applicationId") String applicationId, @ApiParam(value = "Role ID",required=true) @PathParam("roleId") String roleId, @ApiParam(value = "IDP ID",required=true) @PathParam("idpId") String idpId) { + public Response getAppRoleGroups(@ApiParam(value = "Application ID",required=true) @PathParam("applicationId") String applicationId, @ApiParam(value = "Role ID",required=true) @PathParam("roleId") String roleId, @Valid@ApiParam(value = "Idp ID") @QueryParam("idpId") String idpId) { return delegate.getAppRoleGroups(applicationId, roleId, idpId ); } @@ -564,14 +565,14 @@ public Response getAppRoleGroups(@ApiParam(value = "Application ID",required=tru @Path("/{applicationId}/roles/{roleId}/assigned-users") @Produces({ "application/json" }) - @ApiOperation(value = "Get role and assigned users ", notes = "Get a role of the application and its assigned users
Permission required:
* /permission/admin/manage/identity/usermgt/view
Scope required:
* internal_user_mgt_view ", response = UserAssignedRoleResponse.class, authorizations = { + @ApiOperation(value = "Get role and assigned users ", notes = "Get a role of the application and its assigned users
Permission required:
* /permission/admin/manage/identity/usermgt/view
Scope required:
* internal_user_mgt_view ", response = UsersAssignedRoleResponse.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { }) }, tags={ "Application Roles", }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "OK", response = UserAssignedRoleResponse.class), + @ApiResponse(code = 200, message = "OK", response = UsersAssignedRoleResponse.class), @ApiResponse(code = 400, message = "Bad Request", response = Error.class), @ApiResponse(code = 401, message = "Unauthorized", response = Void.class), @ApiResponse(code = 403, message = "Forbidden", response = Void.class), @@ -1012,25 +1013,25 @@ public Response patchAppRole(@ApiParam(value = "Application ID",required=true) @ @Valid @PATCH - @Path("/{applicationId}/roles/{roleId}/identity-providers/{idpId}/assigned-groups") + @Path("/{applicationId}/roles/{roleId}/assigned-groups") @Consumes({ "application/json" }) @Produces({ "application/json" }) - @ApiOperation(value = "Assign groups to an application role ", notes = "Assign groups to an application role
Permission required:
* /permission/admin/manage/identity/rolemgt/update
Scope required:
* internal_role_mgt_update ", response = GroupAssignedRoleResponse.class, authorizations = { + @ApiOperation(value = "Assign groups to an application role ", notes = "Assign groups to an application role
Permission required:
* /permission/admin/manage/identity/rolemgt/update
Scope required:
* internal_role_mgt_update ", response = GroupsAssignedRoleResponse.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { }) }, tags={ "Application Roles", }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "OK", response = GroupAssignedRoleResponse.class), + @ApiResponse(code = 200, message = "OK", response = GroupsAssignedRoleResponse.class), @ApiResponse(code = 400, message = "Bad Request", response = Error.class), @ApiResponse(code = 401, message = "Unauthorized", response = Void.class), @ApiResponse(code = 403, message = "Forbidden", response = Void.class), @ApiResponse(code = 500, message = "Server Error", response = Error.class) }) - public Response patchAppRoleAssignedGroups(@ApiParam(value = "Application ID",required=true) @PathParam("applicationId") String applicationId, @ApiParam(value = "Role ID",required=true) @PathParam("roleId") String roleId, @ApiParam(value = "IDP ID",required=true) @PathParam("idpId") String idpId, @ApiParam(value = "" ) @Valid RoleAssignPatchModel roleAssignPatchModel) { + public Response patchAppRoleAssignedGroups(@ApiParam(value = "Application ID",required=true) @PathParam("applicationId") String applicationId, @ApiParam(value = "Role ID",required=true) @PathParam("roleId") String roleId, @ApiParam(value = "" ) @Valid RoleAssignedGroupsPatchModel roleAssignedGroupsPatchModel) { - return delegate.patchAppRoleAssignedGroups(applicationId, roleId, idpId, roleAssignPatchModel ); + return delegate.patchAppRoleAssignedGroups(applicationId, roleId, roleAssignedGroupsPatchModel ); } @Valid @@ -1038,22 +1039,22 @@ public Response patchAppRoleAssignedGroups(@ApiParam(value = "Application ID",re @Path("/{applicationId}/roles/{roleId}/assigned-users") @Consumes({ "application/json" }) @Produces({ "application/json" }) - @ApiOperation(value = "Assign users to an application role ", notes = "Assign users to an application role
Permission required:
* /permission/admin/manage/identity/usermgt/update
Scope required:
* internal_user_mgt_update ", response = UserAssignedRoleResponse.class, authorizations = { + @ApiOperation(value = "Assign users to an application role ", notes = "Assign users to an application role
Permission required:
* /permission/admin/manage/identity/usermgt/update
Scope required:
* internal_user_mgt_update ", response = UsersAssignedRoleResponse.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { }) }, tags={ "Application Roles", }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "OK", response = UserAssignedRoleResponse.class), + @ApiResponse(code = 200, message = "OK", response = UsersAssignedRoleResponse.class), @ApiResponse(code = 400, message = "Bad Request", response = Error.class), @ApiResponse(code = 401, message = "Unauthorized", response = Void.class), @ApiResponse(code = 403, message = "Forbidden", response = Void.class), @ApiResponse(code = 500, message = "Server Error", response = Error.class) }) - public Response patchAppRoleAssignedUsers(@ApiParam(value = "Application ID",required=true) @PathParam("applicationId") String applicationId, @ApiParam(value = "Role ID",required=true) @PathParam("roleId") String roleId, @ApiParam(value = "" ) @Valid RoleAssignPatchModel roleAssignPatchModel) { + public Response patchAppRoleAssignedUsers(@ApiParam(value = "Application ID",required=true) @PathParam("applicationId") String applicationId, @ApiParam(value = "Role ID",required=true) @PathParam("roleId") String roleId, @ApiParam(value = "" ) @Valid RoleAssignedUsersPatchModel roleAssignedUsersPatchModel) { - return delegate.patchAppRoleAssignedUsers(applicationId, roleId, roleAssignPatchModel ); + return delegate.patchAppRoleAssignedUsers(applicationId, roleId, roleAssignedUsersPatchModel ); } @Valid diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/ApplicationsApiService.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/ApplicationsApiService.java index a4600b6416..924c8fd2a1 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/ApplicationsApiService.java +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/ApplicationsApiService.java @@ -39,7 +39,7 @@ import org.wso2.carbon.identity.api.server.application.management.v1.CustomInboundProtocolMetaData; import org.wso2.carbon.identity.api.server.application.management.v1.Error; import java.io.File; -import org.wso2.carbon.identity.api.server.application.management.v1.GroupAssignedRoleResponse; +import org.wso2.carbon.identity.api.server.application.management.v1.GroupsAssignedRoleResponse; import org.wso2.carbon.identity.api.server.application.management.v1.InboundProtocolListItem; import org.wso2.carbon.identity.api.server.application.management.v1.OIDCMetaData; import org.wso2.carbon.identity.api.server.application.management.v1.OpenIDConnectConfiguration; @@ -48,13 +48,14 @@ import org.wso2.carbon.identity.api.server.application.management.v1.ProvisioningConfiguration; import org.wso2.carbon.identity.api.server.application.management.v1.ResidentApplication; import org.wso2.carbon.identity.api.server.application.management.v1.Role; -import org.wso2.carbon.identity.api.server.application.management.v1.RoleAssignPatchModel; +import org.wso2.carbon.identity.api.server.application.management.v1.RoleAssignedGroupsPatchModel; +import org.wso2.carbon.identity.api.server.application.management.v1.RoleAssignedUsersPatchModel; import org.wso2.carbon.identity.api.server.application.management.v1.RoleCreationModel; import org.wso2.carbon.identity.api.server.application.management.v1.RolePatchModel; import org.wso2.carbon.identity.api.server.application.management.v1.SAML2Configuration; import org.wso2.carbon.identity.api.server.application.management.v1.SAML2ServiceProvider; import org.wso2.carbon.identity.api.server.application.management.v1.SAMLMetaData; -import org.wso2.carbon.identity.api.server.application.management.v1.UserAssignedRoleResponse; +import org.wso2.carbon.identity.api.server.application.management.v1.UsersAssignedRoleResponse; import org.wso2.carbon.identity.api.server.application.management.v1.WSTrustConfiguration; import org.wso2.carbon.identity.api.server.application.management.v1.WSTrustMetaData; import javax.ws.rs.core.Response; @@ -140,9 +141,9 @@ public interface ApplicationsApiService { public Response patchAppRole(String applicationId, String roleId, RolePatchModel rolePatchModel); - public Response patchAppRoleAssignedGroups(String applicationId, String roleId, String idpId, RoleAssignPatchModel roleAssignPatchModel); + public Response patchAppRoleAssignedGroups(String applicationId, String roleId, RoleAssignedGroupsPatchModel roleAssignedGroupsPatchModel); - public Response patchAppRoleAssignedUsers(String applicationId, String roleId, RoleAssignPatchModel roleAssignPatchModel); + public Response patchAppRoleAssignedUsers(String applicationId, String roleId, RoleAssignedUsersPatchModel roleAssignedUsersPatchModel); public Response patchApplication(String applicationId, ApplicationPatchModel applicationPatchModel); diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/GroupAssignedRoleResponse.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/GroupsAssignedRoleResponse.java similarity index 84% rename from components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/GroupAssignedRoleResponse.java rename to components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/GroupsAssignedRoleResponse.java index 5d5165e364..b5e523c06a 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/GroupAssignedRoleResponse.java +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/GroupsAssignedRoleResponse.java @@ -33,14 +33,14 @@ import javax.validation.Valid; import javax.xml.bind.annotation.*; -public class GroupAssignedRoleResponse { +public class GroupsAssignedRoleResponse { private List assignedGroups = null; /** **/ - public GroupAssignedRoleResponse assignedGroups(List assignedGroups) { + public GroupsAssignedRoleResponse assignedGroups(List assignedGroups) { this.assignedGroups = assignedGroups; return this; @@ -56,7 +56,7 @@ public void setAssignedGroups(List assignedGroups) { this.assignedGroups = assignedGroups; } - public GroupAssignedRoleResponse addAssignedGroupsItem(RoleAssignedGroup assignedGroupsItem) { + public GroupsAssignedRoleResponse addAssignedGroupsItem(RoleAssignedGroup assignedGroupsItem) { if (this.assignedGroups == null) { this.assignedGroups = new ArrayList<>(); } @@ -75,8 +75,8 @@ public boolean equals(java.lang.Object o) { if (o == null || getClass() != o.getClass()) { return false; } - GroupAssignedRoleResponse groupAssignedRoleResponse = (GroupAssignedRoleResponse) o; - return Objects.equals(this.assignedGroups, groupAssignedRoleResponse.assignedGroups); + GroupsAssignedRoleResponse groupsAssignedRoleResponse = (GroupsAssignedRoleResponse) o; + return Objects.equals(this.assignedGroups, groupsAssignedRoleResponse.assignedGroups); } @Override @@ -88,7 +88,7 @@ public int hashCode() { public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class GroupAssignedRoleResponse {\n"); + sb.append("class GroupsAssignedRoleResponse {\n"); sb.append(" assignedGroups: ").append(toIndentedString(assignedGroups)).append("\n"); sb.append("}"); diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedGroup.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedGroup.java index b2f3821e09..5a961d38c4 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedGroup.java +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedGroup.java @@ -35,6 +35,7 @@ public class RoleAssignedGroup { private String $ref; private String display; private String value; + private String idp; /** **/ @@ -90,6 +91,24 @@ public void setValue(String value) { this.value = value; } + /** + **/ + public RoleAssignedGroup idp(String idp) { + + this.idp = idp; + return this; + } + + @ApiModelProperty(example = "e44dbc52-dcc3-443d-96f5-fe9dc208e9d8", value = "") + @JsonProperty("idp") + @Valid + public String getIdp() { + return idp; + } + public void setIdp(String idp) { + this.idp = idp; + } + @Override @@ -104,12 +123,13 @@ public boolean equals(java.lang.Object o) { RoleAssignedGroup roleAssignedGroup = (RoleAssignedGroup) o; return Objects.equals(this.$ref, roleAssignedGroup.$ref) && Objects.equals(this.display, roleAssignedGroup.display) && - Objects.equals(this.value, roleAssignedGroup.value); + Objects.equals(this.value, roleAssignedGroup.value) && + Objects.equals(this.idp, roleAssignedGroup.idp); } @Override public int hashCode() { - return Objects.hash($ref, display, value); + return Objects.hash($ref, display, value, idp); } @Override @@ -121,6 +141,7 @@ public String toString() { sb.append(" $ref: ").append(toIndentedString($ref)).append("\n"); sb.append(" display: ").append(toIndentedString(display)).append("\n"); sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append(" idp: ").append(toIndentedString(idp)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedGroupsPatchModel.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedGroupsPatchModel.java new file mode 100644 index 0000000000..43072f2dea --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedGroupsPatchModel.java @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.application.management.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.ArrayList; +import java.util.List; +import org.wso2.carbon.identity.api.server.application.management.v1.RoleAssignedGroupsPatchOp; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class RoleAssignedGroupsPatchModel { + + private List operations = new ArrayList<>(); + + + /** + **/ + public RoleAssignedGroupsPatchModel operations(List operations) { + + this.operations = operations; + return this; + } + + @ApiModelProperty(required = true, value = "") + @JsonProperty("operations") + @Valid + @NotNull(message = "Property operations cannot be null.") + + public List getOperations() { + return operations; + } + public void setOperations(List operations) { + this.operations = operations; + } + + public RoleAssignedGroupsPatchModel addOperationsItem(RoleAssignedGroupsPatchOp operationsItem) { + this.operations.add(operationsItem); + return this; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RoleAssignedGroupsPatchModel roleAssignedGroupsPatchModel = (RoleAssignedGroupsPatchModel) o; + return Objects.equals(this.operations, roleAssignedGroupsPatchModel.operations); + } + + @Override + public int hashCode() { + return Objects.hash(operations); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class RoleAssignedGroupsPatchModel {\n"); + + sb.append(" operations: ").append(toIndentedString(operations)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedGroupsPatchOp.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedGroupsPatchOp.java new file mode 100644 index 0000000000..b69ed9a773 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedGroupsPatchOp.java @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.application.management.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.ArrayList; +import java.util.List; +import org.wso2.carbon.identity.api.server.application.management.v1.RoleAssignedGroupsPatchOpValue; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class RoleAssignedGroupsPatchOp { + + private String op; + private List value = new ArrayList<>(); + + + /** + **/ + public RoleAssignedGroupsPatchOp op(String op) { + + this.op = op; + return this; + } + + @ApiModelProperty(example = "add", required = true, value = "") + @JsonProperty("op") + @Valid + @NotNull(message = "Property op cannot be null.") + + public String getOp() { + return op; + } + public void setOp(String op) { + this.op = op; + } + + /** + **/ + public RoleAssignedGroupsPatchOp value(List value) { + + this.value = value; + return this; + } + + @ApiModelProperty(required = true, value = "") + @JsonProperty("value") + @Valid + @NotNull(message = "Property value cannot be null.") + + public List getValue() { + return value; + } + public void setValue(List value) { + this.value = value; + } + + public RoleAssignedGroupsPatchOp addValueItem(RoleAssignedGroupsPatchOpValue valueItem) { + this.value.add(valueItem); + return this; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RoleAssignedGroupsPatchOp roleAssignedGroupsPatchOp = (RoleAssignedGroupsPatchOp) o; + return Objects.equals(this.op, roleAssignedGroupsPatchOp.op) && + Objects.equals(this.value, roleAssignedGroupsPatchOp.value); + } + + @Override + public int hashCode() { + return Objects.hash(op, value); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class RoleAssignedGroupsPatchOp {\n"); + + sb.append(" op: ").append(toIndentedString(op)).append("\n"); + sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedGroupsPatchOpValue.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedGroupsPatchOpValue.java new file mode 100644 index 0000000000..861acbd496 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedGroupsPatchOpValue.java @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.application.management.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class RoleAssignedGroupsPatchOpValue { + + private String idpId; + private String groupId; + + /** + **/ + public RoleAssignedGroupsPatchOpValue idpId(String idpId) { + + this.idpId = idpId; + return this; + } + + @ApiModelProperty(example = "e44dbc52-dcc3-443d-96f5-fe9dc208e9d8", value = "") + @JsonProperty("idpId") + @Valid + public String getIdpId() { + return idpId; + } + public void setIdpId(String idpId) { + this.idpId = idpId; + } + + /** + **/ + public RoleAssignedGroupsPatchOpValue groupId(String groupId) { + + this.groupId = groupId; + return this; + } + + @ApiModelProperty(example = "e44dbc52-dcc3-443d-96f5-fe9dc208e9d8", value = "") + @JsonProperty("groupId") + @Valid + public String getGroupId() { + return groupId; + } + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RoleAssignedGroupsPatchOpValue roleAssignedGroupsPatchOpValue = (RoleAssignedGroupsPatchOpValue) o; + return Objects.equals(this.idpId, roleAssignedGroupsPatchOpValue.idpId) && + Objects.equals(this.groupId, roleAssignedGroupsPatchOpValue.groupId); + } + + @Override + public int hashCode() { + return Objects.hash(idpId, groupId); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class RoleAssignedGroupsPatchOpValue {\n"); + + sb.append(" idpId: ").append(toIndentedString(idpId)).append("\n"); + sb.append(" groupId: ").append(toIndentedString(groupId)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignPatchModel.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedUsersPatchModel.java similarity index 77% rename from components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignPatchModel.java rename to components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedUsersPatchModel.java index 51f9f6b6f0..a2e4cb75c5 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignPatchModel.java +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedUsersPatchModel.java @@ -24,7 +24,7 @@ import io.swagger.annotations.ApiModelProperty; import java.util.ArrayList; import java.util.List; -import org.wso2.carbon.identity.api.server.application.management.v1.RolePatchOp; +import org.wso2.carbon.identity.api.server.application.management.v1.RoleAssignedUsersPatchOp; import javax.validation.constraints.*; @@ -33,14 +33,14 @@ import javax.validation.Valid; import javax.xml.bind.annotation.*; -public class RoleAssignPatchModel { +public class RoleAssignedUsersPatchModel { - private List operations = new ArrayList<>(); + private List operations = new ArrayList<>(); /** **/ - public RoleAssignPatchModel operations(List operations) { + public RoleAssignedUsersPatchModel operations(List operations) { this.operations = operations; return this; @@ -51,14 +51,14 @@ public RoleAssignPatchModel operations(List operations) { @Valid @NotNull(message = "Property operations cannot be null.") - public List getOperations() { + public List getOperations() { return operations; } - public void setOperations(List operations) { + public void setOperations(List operations) { this.operations = operations; } - public RoleAssignPatchModel addOperationsItem(RolePatchOp operationsItem) { + public RoleAssignedUsersPatchModel addOperationsItem(RoleAssignedUsersPatchOp operationsItem) { this.operations.add(operationsItem); return this; } @@ -74,8 +74,8 @@ public boolean equals(java.lang.Object o) { if (o == null || getClass() != o.getClass()) { return false; } - RoleAssignPatchModel roleAssignPatchModel = (RoleAssignPatchModel) o; - return Objects.equals(this.operations, roleAssignPatchModel.operations); + RoleAssignedUsersPatchModel roleAssignedUsersPatchModel = (RoleAssignedUsersPatchModel) o; + return Objects.equals(this.operations, roleAssignedUsersPatchModel.operations); } @Override @@ -87,7 +87,7 @@ public int hashCode() { public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class RoleAssignPatchModel {\n"); + sb.append("class RoleAssignedUsersPatchModel {\n"); sb.append(" operations: ").append(toIndentedString(operations)).append("\n"); sb.append("}"); diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RolePatchOp.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedUsersPatchOp.java similarity index 78% rename from components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RolePatchOp.java rename to components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedUsersPatchOp.java index 5a122a8979..f167d47109 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RolePatchOp.java +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedUsersPatchOp.java @@ -24,7 +24,7 @@ import io.swagger.annotations.ApiModelProperty; import java.util.ArrayList; import java.util.List; -import org.wso2.carbon.identity.api.server.application.management.v1.RolePatchOpValue; +import org.wso2.carbon.identity.api.server.application.management.v1.RoleAssignedUsersPatchOpValue; import javax.validation.constraints.*; @@ -33,15 +33,15 @@ import javax.validation.Valid; import javax.xml.bind.annotation.*; -public class RolePatchOp { +public class RoleAssignedUsersPatchOp { private String op; - private List value = new ArrayList<>(); + private List value = new ArrayList<>(); /** **/ - public RolePatchOp op(String op) { + public RoleAssignedUsersPatchOp op(String op) { this.op = op; return this; @@ -61,7 +61,7 @@ public void setOp(String op) { /** **/ - public RolePatchOp value(List value) { + public RoleAssignedUsersPatchOp value(List value) { this.value = value; return this; @@ -72,14 +72,14 @@ public RolePatchOp value(List value) { @Valid @NotNull(message = "Property value cannot be null.") - public List getValue() { + public List getValue() { return value; } - public void setValue(List value) { + public void setValue(List value) { this.value = value; } - public RolePatchOp addValueItem(RolePatchOpValue valueItem) { + public RoleAssignedUsersPatchOp addValueItem(RoleAssignedUsersPatchOpValue valueItem) { this.value.add(valueItem); return this; } @@ -95,9 +95,9 @@ public boolean equals(java.lang.Object o) { if (o == null || getClass() != o.getClass()) { return false; } - RolePatchOp rolePatchOp = (RolePatchOp) o; - return Objects.equals(this.op, rolePatchOp.op) && - Objects.equals(this.value, rolePatchOp.value); + RoleAssignedUsersPatchOp roleAssignedUsersPatchOp = (RoleAssignedUsersPatchOp) o; + return Objects.equals(this.op, roleAssignedUsersPatchOp.op) && + Objects.equals(this.value, roleAssignedUsersPatchOp.value); } @Override @@ -109,7 +109,7 @@ public int hashCode() { public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class RolePatchOp {\n"); + sb.append("class RoleAssignedUsersPatchOp {\n"); sb.append(" op: ").append(toIndentedString(op)).append("\n"); sb.append(" value: ").append(toIndentedString(value)).append("\n"); diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RolePatchOpValue.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedUsersPatchOpValue.java similarity index 86% rename from components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RolePatchOpValue.java rename to components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedUsersPatchOpValue.java index 49fc9f29c4..8f951161d7 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RolePatchOpValue.java +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedUsersPatchOpValue.java @@ -30,13 +30,13 @@ import javax.validation.Valid; import javax.xml.bind.annotation.*; -public class RolePatchOpValue { +public class RoleAssignedUsersPatchOpValue { private String value; /** **/ - public RolePatchOpValue value(String value) { + public RoleAssignedUsersPatchOpValue value(String value) { this.value = value; return this; @@ -63,8 +63,8 @@ public boolean equals(java.lang.Object o) { if (o == null || getClass() != o.getClass()) { return false; } - RolePatchOpValue rolePatchOpValue = (RolePatchOpValue) o; - return Objects.equals(this.value, rolePatchOpValue.value); + RoleAssignedUsersPatchOpValue roleAssignedUsersPatchOpValue = (RoleAssignedUsersPatchOpValue) o; + return Objects.equals(this.value, roleAssignedUsersPatchOpValue.value); } @Override @@ -76,7 +76,7 @@ public int hashCode() { public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class RolePatchOpValue {\n"); + sb.append("class RoleAssignedUsersPatchOpValue {\n"); sb.append(" value: ").append(toIndentedString(value)).append("\n"); sb.append("}"); diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/UserAssignedRoleResponse.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/UsersAssignedRoleResponse.java similarity index 85% rename from components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/UserAssignedRoleResponse.java rename to components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/UsersAssignedRoleResponse.java index 9a4f4fd5ba..4ccd64e7c3 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/UserAssignedRoleResponse.java +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/UsersAssignedRoleResponse.java @@ -33,14 +33,14 @@ import javax.validation.Valid; import javax.xml.bind.annotation.*; -public class UserAssignedRoleResponse { +public class UsersAssignedRoleResponse { private List assignedUsers = null; /** **/ - public UserAssignedRoleResponse assignedUsers(List assignedUsers) { + public UsersAssignedRoleResponse assignedUsers(List assignedUsers) { this.assignedUsers = assignedUsers; return this; @@ -56,7 +56,7 @@ public void setAssignedUsers(List assignedUsers) { this.assignedUsers = assignedUsers; } - public UserAssignedRoleResponse addAssignedUsersItem(RoleAssignedUser assignedUsersItem) { + public UsersAssignedRoleResponse addAssignedUsersItem(RoleAssignedUser assignedUsersItem) { if (this.assignedUsers == null) { this.assignedUsers = new ArrayList<>(); } @@ -75,8 +75,8 @@ public boolean equals(java.lang.Object o) { if (o == null || getClass() != o.getClass()) { return false; } - UserAssignedRoleResponse userAssignedRoleResponse = (UserAssignedRoleResponse) o; - return Objects.equals(this.assignedUsers, userAssignedRoleResponse.assignedUsers); + UsersAssignedRoleResponse usersAssignedRoleResponse = (UsersAssignedRoleResponse) o; + return Objects.equals(this.assignedUsers, usersAssignedRoleResponse.assignedUsers); } @Override @@ -88,7 +88,7 @@ public int hashCode() { public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class UserAssignedRoleResponse {\n"); + sb.append("class UsersAssignedRoleResponse {\n"); sb.append(" assignedUsers: ").append(toIndentedString(assignedUsers)).append("\n"); sb.append("}"); diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/ApplicationRoleManagementService.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/ApplicationRoleManagementService.java index 7c9c0f1ba8..147322a02b 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/ApplicationRoleManagementService.java +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/ApplicationRoleManagementService.java @@ -23,17 +23,20 @@ import org.apache.commons.lang3.StringUtils; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.identity.api.server.application.management.common.ApplicationManagementServiceHolder; -import org.wso2.carbon.identity.api.server.application.management.v1.GroupAssignedRoleResponse; +import org.wso2.carbon.identity.api.server.application.management.v1.GroupsAssignedRoleResponse; import org.wso2.carbon.identity.api.server.application.management.v1.Permission; import org.wso2.carbon.identity.api.server.application.management.v1.Role; -import org.wso2.carbon.identity.api.server.application.management.v1.RoleAssignPatchModel; import org.wso2.carbon.identity.api.server.application.management.v1.RoleAssignedGroup; +import org.wso2.carbon.identity.api.server.application.management.v1.RoleAssignedGroupsPatchModel; +import org.wso2.carbon.identity.api.server.application.management.v1.RoleAssignedGroupsPatchOp; +import org.wso2.carbon.identity.api.server.application.management.v1.RoleAssignedGroupsPatchOpValue; import org.wso2.carbon.identity.api.server.application.management.v1.RoleAssignedUser; +import org.wso2.carbon.identity.api.server.application.management.v1.RoleAssignedUsersPatchModel; +import org.wso2.carbon.identity.api.server.application.management.v1.RoleAssignedUsersPatchOp; +import org.wso2.carbon.identity.api.server.application.management.v1.RoleAssignedUsersPatchOpValue; import org.wso2.carbon.identity.api.server.application.management.v1.RoleCreationModel; import org.wso2.carbon.identity.api.server.application.management.v1.RolePatchModel; -import org.wso2.carbon.identity.api.server.application.management.v1.RolePatchOp; -import org.wso2.carbon.identity.api.server.application.management.v1.RolePatchOpValue; -import org.wso2.carbon.identity.api.server.application.management.v1.UserAssignedRoleResponse; +import org.wso2.carbon.identity.api.server.application.management.v1.UsersAssignedRoleResponse; import org.wso2.carbon.identity.api.server.application.management.v1.util.ApplicationRoleMgtEndpointUtil; import org.wso2.carbon.identity.api.server.common.ContextLoader; import org.wso2.carbon.identity.application.role.mgt.ApplicationRoleManager; @@ -222,26 +225,27 @@ public Role updateApplicationRole(String applicationId, String roleId, RolePatch * * @param applicationId Application ID. * @param roleId Role ID. - * @param roleAssignUpdateModel Role assign update. + * @param roleAssignedUsersPatchModel Role assign update. */ - public UserAssignedRoleResponse updateApplicationRoleAssignedUsers(String applicationId, String roleId, - RoleAssignPatchModel roleAssignUpdateModel) { + public UsersAssignedRoleResponse updateApplicationRoleAssignedUsers(String applicationId, String roleId, + RoleAssignedUsersPatchModel + roleAssignedUsersPatchModel) { try { - List patchOperationList = roleAssignUpdateModel.getOperations(); + List patchOperationList = roleAssignedUsersPatchModel.getOperations(); List addUsers = new ArrayList<>(); List removedUsers = new ArrayList<>(); - for (RolePatchOp rolePatchOp : patchOperationList) { - List values = rolePatchOp.getValue(); + for (RoleAssignedUsersPatchOp rolePatchOp : patchOperationList) { + List values = rolePatchOp.getValue(); String patchOp = rolePatchOp.getOp(); if ((CollectionUtils.isNotEmpty(values) && StringUtils.equalsIgnoreCase(patchOp, PATCH_OP_ADD))) { - for (RolePatchOpValue value : values) { + for (RoleAssignedUsersPatchOpValue value : values) { addUsers.add(value.getValue()); } } else if ((CollectionUtils.isNotEmpty(values) && StringUtils.equalsIgnoreCase(patchOp, PATCH_OP_REMOVE))) { - for (RolePatchOpValue value : values) { + for (RoleAssignedUsersPatchOpValue value : values) { removedUsers.add(value.getValue()); } } else { @@ -254,7 +258,7 @@ public UserAssignedRoleResponse updateApplicationRoleAssignedUsers(String applic String tenantDomain = ContextLoader.getTenantDomainFromContext(); ApplicationRole applicationRole = getApplicationRoleManager().updateApplicationRoleAssignedUsers(roleId, addUsers, removedUsers); - UserAssignedRoleResponse response = new UserAssignedRoleResponse(); + UsersAssignedRoleResponse response = new UsersAssignedRoleResponse(); List users = getUsersForResponseObject(applicationRole.getAssignedUsers(), tenantDomain); response.setAssignedUsers(users); @@ -270,13 +274,13 @@ public UserAssignedRoleResponse updateApplicationRoleAssignedUsers(String applic * @param applicationId Application ID. * @param roleId Role ID. */ - public UserAssignedRoleResponse getApplicationRoleAssignedUsers(String applicationId, String roleId) { + public UsersAssignedRoleResponse getApplicationRoleAssignedUsers(String applicationId, String roleId) { ApplicationRole applicationRole = null; try { String tenantDomain = ContextLoader.getTenantDomainFromContext(); applicationRole = getApplicationRoleManager().getApplicationRoleAssignedUsers(roleId); - UserAssignedRoleResponse response = new UserAssignedRoleResponse(); + UsersAssignedRoleResponse response = new UsersAssignedRoleResponse(); List users = getUsersForResponseObject(applicationRole.getAssignedUsers(), tenantDomain); response.setAssignedUsers(users); @@ -291,28 +295,28 @@ public UserAssignedRoleResponse getApplicationRoleAssignedUsers(String applicati * * @param applicationId Application ID. * @param roleId Role ID. - * @param roleAssignUpdateModel Role assign update. + * @param roleAssignedGroupsPatchModel Role assign update. */ - public GroupAssignedRoleResponse updateApplicationRoleAssignedGroups(String applicationId, String roleId, - String idpId, - RoleAssignPatchModel roleAssignUpdateModel) { + public GroupsAssignedRoleResponse updateApplicationRoleAssignedGroups(String applicationId, String roleId, + RoleAssignedGroupsPatchModel + roleAssignedGroupsPatchModel) { try { - List patchOperationList = roleAssignUpdateModel.getOperations(); - List addGroups = new ArrayList<>(); + List patchOperationList = roleAssignedGroupsPatchModel.getOperations(); + List addGroups = new ArrayList<>(); List removedGroups = new ArrayList<>(); - for (RolePatchOp rolePatchOp : patchOperationList) { - List values = rolePatchOp.getValue(); - String patchOp = rolePatchOp.getOp().toString(); + for (RoleAssignedGroupsPatchOp roleAssignedGroupsPatchOp : patchOperationList) { + List values = roleAssignedGroupsPatchOp.getValue(); + String patchOp = roleAssignedGroupsPatchOp.getOp(); if ((CollectionUtils.isNotEmpty(values) && StringUtils.equalsIgnoreCase(patchOp, PATCH_OP_ADD))) { - for (RolePatchOpValue value : values) { - addGroups.add(value.getValue()); + for (RoleAssignedGroupsPatchOpValue value : values) { + addGroups.add(new Group(value.getGroupId(), value.getIdpId())); } } else if ((CollectionUtils.isNotEmpty(values) && StringUtils.equalsIgnoreCase(patchOp, PATCH_OP_REMOVE))) { - for (RolePatchOpValue value : values) { - removedGroups.add(value.getValue()); + for (RoleAssignedGroupsPatchOpValue value : values) { + removedGroups.add(value.getGroupId()); } } else { // Invalid patch operations cannot be sent due to swagger validation. @@ -322,9 +326,9 @@ public GroupAssignedRoleResponse updateApplicationRoleAssignedGroups(String appl } } ApplicationRole applicationRole = getApplicationRoleManager().updateApplicationRoleAssignedGroups(roleId, - idpId, addGroups, removedGroups); + addGroups, removedGroups); String tenantDomain = ContextLoader.getTenantDomainFromContext(); - GroupAssignedRoleResponse response = new GroupAssignedRoleResponse(); + GroupsAssignedRoleResponse response = new GroupsAssignedRoleResponse(); List groups = getGroupsForResponseObject(applicationRole.getAssignedGroups(), tenantDomain); response.setAssignedGroups(groups); @@ -340,13 +344,14 @@ public GroupAssignedRoleResponse updateApplicationRoleAssignedGroups(String appl * @param applicationId Application ID. * @param roleId Role ID. */ - public GroupAssignedRoleResponse getApplicationRoleAssignedGroups(String applicationId, String roleId, String idp) { + public GroupsAssignedRoleResponse getApplicationRoleAssignedGroups(String applicationId, String roleId, + String idp) { ApplicationRole applicationRole = null; try { String tenantDomain = ContextLoader.getTenantDomainFromContext(); applicationRole = getApplicationRoleManager().getApplicationRoleAssignedGroups(roleId, idp); - GroupAssignedRoleResponse response = new GroupAssignedRoleResponse(); + GroupsAssignedRoleResponse response = new GroupsAssignedRoleResponse(); List groups = getGroupsForResponseObject(applicationRole.getAssignedGroups(), tenantDomain); response.setAssignedGroups(groups); diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/impl/ApplicationsApiServiceImpl.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/impl/ApplicationsApiServiceImpl.java index 63e7b2f2d4..1f6f89375b 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/impl/ApplicationsApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/impl/ApplicationsApiServiceImpl.java @@ -35,7 +35,8 @@ import org.wso2.carbon.identity.api.server.application.management.v1.ProvisioningConfiguration; import org.wso2.carbon.identity.api.server.application.management.v1.ResidentApplication; import org.wso2.carbon.identity.api.server.application.management.v1.Role; -import org.wso2.carbon.identity.api.server.application.management.v1.RoleAssignPatchModel; +import org.wso2.carbon.identity.api.server.application.management.v1.RoleAssignedGroupsPatchModel; +import org.wso2.carbon.identity.api.server.application.management.v1.RoleAssignedUsersPatchModel; import org.wso2.carbon.identity.api.server.application.management.v1.RoleCreationModel; import org.wso2.carbon.identity.api.server.application.management.v1.RolePatchModel; import org.wso2.carbon.identity.api.server.application.management.v1.SAML2Configuration; @@ -308,16 +309,16 @@ public Response patchAppRole(String applicationId, String roleId, RolePatchModel } @Override - public Response patchAppRoleAssignedGroups(String applicationId, String roleId, String idpId, - RoleAssignPatchModel roleAssignPatchModel) { + public Response patchAppRoleAssignedGroups(String applicationId, String roleId, + RoleAssignedGroupsPatchModel roleAssignPatchModel) { return Response.ok().entity(applicationRoleManagementService.updateApplicationRoleAssignedGroups(applicationId, - roleId, idpId, roleAssignPatchModel)).build(); + roleId, roleAssignPatchModel)).build(); } @Override public Response patchAppRoleAssignedUsers(String applicationId, String roleId, - RoleAssignPatchModel roleAssignPatchModel) { + RoleAssignedUsersPatchModel roleAssignPatchModel) { return Response.ok().entity(applicationRoleManagementService.updateApplicationRoleAssignedUsers(applicationId, roleId, roleAssignPatchModel)).build(); diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/resources/applications.yaml b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/resources/applications.yaml index d6eec00e13..44f85683d1 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/resources/applications.yaml +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/resources/applications.yaml @@ -2481,7 +2481,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/UserAssignedRoleResponse' + $ref: '#/components/schemas/UsersAssignedRoleResponse' 400: description: Bad Request content: @@ -2533,14 +2533,14 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/RoleAssignPatchModel' + $ref: '#/components/schemas/RoleAssignedUsersPatchModel' responses: 200: description: OK content: application/json: schema: - $ref: '#/components/schemas/UserAssignedRoleResponse' + $ref: '#/components/schemas/UsersAssignedRoleResponse' 400: description: Bad Request content: @@ -2557,7 +2557,7 @@ paths: application/json: schema: $ref: '#/components/schemas/Error' - '/applications/{applicationId}/roles/{roleId}/identity-providers/{idpId}/assigned-groups': + '/applications/{applicationId}/roles/{roleId}/assigned-groups': get: tags: - Application Roles @@ -2584,9 +2584,8 @@ paths: schema: type: string - name: idpId - in: path - description: IDP ID - required: true + in: query + description: Idp ID schema: type: string responses: @@ -2595,7 +2594,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/GroupAssignedRoleResponse' + $ref: '#/components/schemas/GroupsAssignedRoleResponse' 400: description: Bad Request content: @@ -2643,24 +2642,18 @@ paths: required: true schema: type: string - - name: idpId - in: path - description: IDP ID - required: true - schema: - type: string requestBody: content: application/json: schema: - $ref: '#/components/schemas/RoleAssignPatchModel' + $ref: '#/components/schemas/RoleAssignedGroupsPatchModel' responses: 200: description: OK content: application/json: schema: - $ref: '#/components/schemas/GroupAssignedRoleResponse' + $ref: '#/components/schemas/GroupsAssignedRoleResponse' 400: description: Bad Request content: @@ -4067,7 +4060,16 @@ components: type: array items: $ref: '#/components/schemas/Permission' - RoleAssignPatchModel: + RoleAssignedGroupsPatchModel: + type: object + required: + - operations + properties: + operations: + type: array + items: + $ref: '#/components/schemas/RoleAssignedGroupsPatchOp' + RoleAssignedUsersPatchModel: type: object required: - operations @@ -4075,8 +4077,8 @@ components: operations: type: array items: - $ref: '#/components/schemas/RolePatchOp' - RolePatchOp: + $ref: '#/components/schemas/RoleAssignedUsersPatchOp' + RoleAssignedUsersPatchOp: type: object required: - op @@ -4088,21 +4090,43 @@ components: value: type: array items: - $ref: '#/components/schemas/RolePatchOpValue' - RolePatchOpValue: + $ref: '#/components/schemas/RoleAssignedUsersPatchOpValue' + RoleAssignedGroupsPatchOp: + type: object + required: + - op + - value + properties: + op: + type: string + example: 'add' + value: + type: array + items: + $ref: '#/components/schemas/RoleAssignedGroupsPatchOpValue' + RoleAssignedUsersPatchOpValue: type: object properties: value: type: string example: 'e44dbc52-dcc3-443d-96f5-fe9dc208e9d8' - UserAssignedRoleResponse: + RoleAssignedGroupsPatchOpValue: + type: object + properties: + idpId: + type: string + example: 'e44dbc52-dcc3-443d-96f5-fe9dc208e9d8' + groupId: + type: string + example: 'e44dbc52-dcc3-443d-96f5-fe9dc208e9d8' + UsersAssignedRoleResponse: type: object properties: assignedUsers: type: array items: $ref: '#/components/schemas/RoleAssignedUser' - GroupAssignedRoleResponse: + GroupsAssignedRoleResponse: type: object properties: assignedGroups: @@ -4133,6 +4157,9 @@ components: value: type: string example: 'e44dbc52-dcc3-443d-96f5-fe9dc208e9d8' + idp: + type: string + example: 'e44dbc52-dcc3-443d-96f5-fe9dc208e9d8' Error: type: object properties: From 20005c114c1370f1dea4dba07e31b23b14fe7177 Mon Sep 17 00:00:00 2001 From: Thilina Shashimal Senarath Date: Wed, 6 Sep 2023 12:23:47 +0530 Subject: [PATCH 08/10] add app role bean --- .../management/v1/RoleAssignedGroup.java | 85 ++++++++++++------- .../management/v1/RoleAssignedUser.java | 44 +++++----- .../v1/RoleAssignedUsersPatchOpValue.java | 22 ++--- .../ApplicationRoleManagementService.java | 14 +-- .../src/main/resources/applications.yaml | 19 +++-- 5 files changed, 105 insertions(+), 79 deletions(-) diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedGroup.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedGroup.java index 5a961d38c4..c4176af2f6 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedGroup.java +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedGroup.java @@ -33,9 +33,10 @@ public class RoleAssignedGroup { private String $ref; - private String display; - private String value; - private String idp; + private String name; + private String id; + private String idpId; + private String idpName; /** **/ @@ -57,56 +58,74 @@ public class RoleAssignedGroup { /** **/ - public RoleAssignedGroup display(String display) { + public RoleAssignedGroup name(String name) { - this.display = display; + this.name = name; return this; } - @ApiModelProperty(example = "display", value = "") - @JsonProperty("display") + @ApiModelProperty(example = "group name", value = "") + @JsonProperty("name") @Valid - public String getDisplay() { - return display; + public String getName() { + return name; } - public void setDisplay(String display) { - this.display = display; + public void setName(String name) { + this.name = name; } /** **/ - public RoleAssignedGroup value(String value) { + public RoleAssignedGroup id(String id) { - this.value = value; + this.id = id; return this; } @ApiModelProperty(example = "e44dbc52-dcc3-443d-96f5-fe9dc208e9d8", value = "") - @JsonProperty("value") + @JsonProperty("id") @Valid - public String getValue() { - return value; + public String getId() { + return id; } - public void setValue(String value) { - this.value = value; + public void setId(String id) { + this.id = id; } /** **/ - public RoleAssignedGroup idp(String idp) { + public RoleAssignedGroup idpId(String idpId) { - this.idp = idp; + this.idpId = idpId; return this; } @ApiModelProperty(example = "e44dbc52-dcc3-443d-96f5-fe9dc208e9d8", value = "") - @JsonProperty("idp") + @JsonProperty("idpId") @Valid - public String getIdp() { - return idp; + public String getIdpId() { + return idpId; } - public void setIdp(String idp) { - this.idp = idp; + public void setIdpId(String idpId) { + this.idpId = idpId; + } + + /** + **/ + public RoleAssignedGroup idpName(String idpName) { + + this.idpName = idpName; + return this; + } + + @ApiModelProperty(example = "idp name", value = "") + @JsonProperty("idpName") + @Valid + public String getIdpName() { + return idpName; + } + public void setIdpName(String idpName) { + this.idpName = idpName; } @@ -122,14 +141,15 @@ public boolean equals(java.lang.Object o) { } RoleAssignedGroup roleAssignedGroup = (RoleAssignedGroup) o; return Objects.equals(this.$ref, roleAssignedGroup.$ref) && - Objects.equals(this.display, roleAssignedGroup.display) && - Objects.equals(this.value, roleAssignedGroup.value) && - Objects.equals(this.idp, roleAssignedGroup.idp); + Objects.equals(this.name, roleAssignedGroup.name) && + Objects.equals(this.id, roleAssignedGroup.id) && + Objects.equals(this.idpId, roleAssignedGroup.idpId) && + Objects.equals(this.idpName, roleAssignedGroup.idpName); } @Override public int hashCode() { - return Objects.hash($ref, display, value, idp); + return Objects.hash($ref, name, id, idpId, idpName); } @Override @@ -139,9 +159,10 @@ public String toString() { sb.append("class RoleAssignedGroup {\n"); sb.append(" $ref: ").append(toIndentedString($ref)).append("\n"); - sb.append(" display: ").append(toIndentedString(display)).append("\n"); - sb.append(" value: ").append(toIndentedString(value)).append("\n"); - sb.append(" idp: ").append(toIndentedString(idp)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" idpId: ").append(toIndentedString(idpId)).append("\n"); + sb.append(" idpName: ").append(toIndentedString(idpName)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedUser.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedUser.java index 8e649bbb5b..a1f33a9ab1 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedUser.java +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedUser.java @@ -33,8 +33,8 @@ public class RoleAssignedUser { private String $ref; - private String display; - private String value; + private String name; + private String id; /** **/ @@ -56,38 +56,38 @@ public class RoleAssignedUser { /** **/ - public RoleAssignedUser display(String display) { + public RoleAssignedUser name(String name) { - this.display = display; + this.name = name; return this; } - @ApiModelProperty(example = "display", value = "") - @JsonProperty("display") + @ApiModelProperty(example = "username", value = "") + @JsonProperty("name") @Valid - public String getDisplay() { - return display; + public String getName() { + return name; } - public void setDisplay(String display) { - this.display = display; + public void setName(String name) { + this.name = name; } /** **/ - public RoleAssignedUser value(String value) { + public RoleAssignedUser id(String id) { - this.value = value; + this.id = id; return this; } @ApiModelProperty(example = "e44dbc52-dcc3-443d-96f5-fe9dc208e9d8", value = "") - @JsonProperty("value") + @JsonProperty("id") @Valid - public String getValue() { - return value; + public String getId() { + return id; } - public void setValue(String value) { - this.value = value; + public void setId(String id) { + this.id = id; } @@ -103,13 +103,13 @@ public boolean equals(java.lang.Object o) { } RoleAssignedUser roleAssignedUser = (RoleAssignedUser) o; return Objects.equals(this.$ref, roleAssignedUser.$ref) && - Objects.equals(this.display, roleAssignedUser.display) && - Objects.equals(this.value, roleAssignedUser.value); + Objects.equals(this.name, roleAssignedUser.name) && + Objects.equals(this.id, roleAssignedUser.id); } @Override public int hashCode() { - return Objects.hash($ref, display, value); + return Objects.hash($ref, name, id); } @Override @@ -119,8 +119,8 @@ public String toString() { sb.append("class RoleAssignedUser {\n"); sb.append(" $ref: ").append(toIndentedString($ref)).append("\n"); - sb.append(" display: ").append(toIndentedString(display)).append("\n"); - sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedUsersPatchOpValue.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedUsersPatchOpValue.java index 8f951161d7..582db84f06 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedUsersPatchOpValue.java +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RoleAssignedUsersPatchOpValue.java @@ -32,24 +32,24 @@ public class RoleAssignedUsersPatchOpValue { - private String value; + private String userId; /** **/ - public RoleAssignedUsersPatchOpValue value(String value) { + public RoleAssignedUsersPatchOpValue userId(String userId) { - this.value = value; + this.userId = userId; return this; } @ApiModelProperty(example = "e44dbc52-dcc3-443d-96f5-fe9dc208e9d8", value = "") - @JsonProperty("value") + @JsonProperty("userId") @Valid - public String getValue() { - return value; + public String getUserId() { + return userId; } - public void setValue(String value) { - this.value = value; + public void setUserId(String userId) { + this.userId = userId; } @@ -64,12 +64,12 @@ public boolean equals(java.lang.Object o) { return false; } RoleAssignedUsersPatchOpValue roleAssignedUsersPatchOpValue = (RoleAssignedUsersPatchOpValue) o; - return Objects.equals(this.value, roleAssignedUsersPatchOpValue.value); + return Objects.equals(this.userId, roleAssignedUsersPatchOpValue.userId); } @Override public int hashCode() { - return Objects.hash(value); + return Objects.hash(userId); } @Override @@ -78,7 +78,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class RoleAssignedUsersPatchOpValue {\n"); - sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append(" userId: ").append(toIndentedString(userId)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/ApplicationRoleManagementService.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/ApplicationRoleManagementService.java index 147322a02b..b605d016ae 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/ApplicationRoleManagementService.java +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/ApplicationRoleManagementService.java @@ -241,12 +241,12 @@ public UsersAssignedRoleResponse updateApplicationRoleAssignedUsers(String appli String patchOp = rolePatchOp.getOp(); if ((CollectionUtils.isNotEmpty(values) && StringUtils.equalsIgnoreCase(patchOp, PATCH_OP_ADD))) { for (RoleAssignedUsersPatchOpValue value : values) { - addUsers.add(value.getValue()); + addUsers.add(value.getUserId()); } } else if ((CollectionUtils.isNotEmpty(values) && StringUtils.equalsIgnoreCase(patchOp, PATCH_OP_REMOVE))) { for (RoleAssignedUsersPatchOpValue value : values) { - removedUsers.add(value.getValue()); + removedUsers.add(value.getUserId()); } } else { // Invalid patch operations cannot be sent due to swagger validation. @@ -381,8 +381,8 @@ private List getUsersForResponseObject(List roleAssigned String uri = getSCIMUserURL(basicUser.getId(), tenantDomain); RoleAssignedUser user = new RoleAssignedUser(); - user.value(basicUser.getId()); - user.display(basicUser.getUserName()); + user.id(basicUser.getId()); + user.name(basicUser.getUserName()); user.$ref(uri); users.add(user); } @@ -404,8 +404,10 @@ private List getGroupsForResponseObject(List roleAssig String uri = getSCIMGroupURL(group.getGroupId(), tenantDomain); RoleAssignedGroup assignedGroup = new RoleAssignedGroup(); - assignedGroup.value(group.getGroupId()); - assignedGroup.display(group.getGroupName()); + assignedGroup.id(group.getGroupId()); + assignedGroup.name(group.getGroupName()); + assignedGroup.idpId(group.getIdpId()); + assignedGroup.idpName(group.getIdpName()); if (LOCAL_IDP.equals(group.getIdpName())) { assignedGroup.$ref(uri); } diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/resources/applications.yaml b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/resources/applications.yaml index 44f85683d1..89a4be113f 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/resources/applications.yaml +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/resources/applications.yaml @@ -4107,7 +4107,7 @@ components: RoleAssignedUsersPatchOpValue: type: object properties: - value: + userId: type: string example: 'e44dbc52-dcc3-443d-96f5-fe9dc208e9d8' RoleAssignedGroupsPatchOpValue: @@ -4139,10 +4139,10 @@ components: $ref: type: string example: 'https://localhost:9443/scim2/Users/3a12bae9-4386-44be-befd-caf349297f45' - display: + name: type: string - example: 'display' - value: + example: 'username' + id: type: string example: 'e44dbc52-dcc3-443d-96f5-fe9dc208e9d8' RoleAssignedGroup: @@ -4151,15 +4151,18 @@ components: $ref: type: string example: 'https://localhost:9443/scim2/Groups/3a12bae9-4386-44be-befd-caf349297f45' - display: + name: type: string - example: 'display' - value: + example: 'group name' + id: type: string example: 'e44dbc52-dcc3-443d-96f5-fe9dc208e9d8' - idp: + idpId: type: string example: 'e44dbc52-dcc3-443d-96f5-fe9dc208e9d8' + idpName: + type: string + example: 'idp name' Error: type: object properties: From 3d3fd7ce53f2bd5edcdfc82b2f23a1a981b909c3 Mon Sep 17 00:00:00 2001 From: Thilina Shashimal Senarath Date: Wed, 6 Sep 2023 14:14:37 +0530 Subject: [PATCH 09/10] add builder pattern --- .../ApplicationRoleManagementService.java | 88 +++++++++++-------- 1 file changed, 49 insertions(+), 39 deletions(-) diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/ApplicationRoleManagementService.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/ApplicationRoleManagementService.java index b605d016ae..9497f50e42 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/ApplicationRoleManagementService.java +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/ApplicationRoleManagementService.java @@ -18,7 +18,6 @@ package org.wso2.carbon.identity.api.server.application.management.v1.core; -import edu.emory.mathcs.backport.java.util.Arrays; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.wso2.carbon.context.PrivilegedCarbonContext; @@ -94,11 +93,17 @@ public Role addApplicationRole(String applicationId, RoleCreationModel role) { applicationId)); Role createdRole = new Role(); - createdRole.setId(appRole.getRoleId()); - createdRole.setName(appRole.getRoleName()); + createdRole.id(appRole.getRoleId()) + .name(appRole.getRoleName()); + List addedPermissions = new ArrayList<>(); if (appRole.getPermissions() != null) { - createdRole.setPermissions(Arrays.asList(appRole.getPermissions())); + for (String name : appRole.getPermissions()) { + Permission permission = new Permission(); + permission.setName(name); + addedPermissions.add(permission); + } } + createdRole.setPermissions(addedPermissions); return createdRole; } catch (ApplicationRoleManagementException e) { throw ApplicationRoleMgtEndpointUtil.handleApplicationRoleMgtException(e); @@ -116,16 +121,18 @@ public Role getApplicationRole(String applicationId, String roleId) { try { ApplicationRole applicationRole = getApplicationRoleManager().getApplicationRoleById(roleId); - Role role = new Role(); - role.setId(roleId); - role.setName(applicationRole.getRoleName()); List permissions = new ArrayList<>(); - for (String scope : applicationRole.getPermissions()) { - Permission permission = new Permission(); - permission.setName(scope); - permissions.add(permission); + if (applicationRole.getPermissions() != null) { + for (String name : applicationRole.getPermissions()) { + Permission permission = new Permission(); + permission.setName(name); + permissions.add(permission); + } } - role.setPermissions(permissions); + Role role = new Role(); + role.id(roleId) + .name(applicationRole.getRoleName()) + .setPermissions(permissions); return role; } catch (ApplicationRoleManagementException e) { throw ApplicationRoleMgtEndpointUtil.handleApplicationRoleMgtException(e); @@ -146,20 +153,21 @@ public Role getApplicationRole(String applicationId, String roleId) { public List getApplicationRoles(String applicationId, String before, String after, Integer limit, String filter, String sort) { - List applicationRoles = null; try { - applicationRoles = getApplicationRoleManager().getApplicationRoles(applicationId); + List applicationRoles = getApplicationRoleManager().getApplicationRoles(applicationId); return applicationRoles.stream().map(applicationRole -> { - Role role = new Role(); - role.setId(applicationRole.getRoleId()); - role.setName(applicationRole.getRoleName()); List permissions = new ArrayList<>(); - for (String scope : applicationRole.getPermissions()) { - Permission permission = new Permission(); - permission.setName(scope); - permissions.add(permission); + if (applicationRole.getPermissions() != null) { + for (String name : applicationRole.getPermissions()) { + Permission permission = new Permission(); + permission.setName(name); + permissions.add(permission); + } } - role.setPermissions(permissions); + Role role = new Role(); + role.id(applicationRole.getRoleId()) + .name(applicationRole.getRoleName()) + .setPermissions(permissions); return role; }).collect(Collectors.toList()); } catch (ApplicationRoleManagementException e) { @@ -195,25 +203,27 @@ public Role updateApplicationRole(String applicationId, String roleId, RolePatch List removedPermission = null; if (roleUpdate.getAddedPermissions() != null) { addedPermission = roleUpdate.getAddedPermissions().stream() - .map(permission -> permission.getName()).collect(Collectors.toList()); + .map(Permission::getName).collect(Collectors.toList()); } if (roleUpdate.getRemovedPermissions() != null) { removedPermission = roleUpdate.getRemovedPermissions().stream() - .map(permission -> permission.getName()).collect(Collectors.toList()); + .map(Permission::getName).collect(Collectors.toList()); } try { ApplicationRole applicationRole = getApplicationRoleManager().updateApplicationRole(applicationId, roleId, roleUpdate.getName(), addedPermission, removedPermission); - Role role = new Role(); - role.setId(roleId); - role.setName(applicationRole.getRoleName()); List permissions = new ArrayList<>(); - for (String scope : applicationRole.getPermissions()) { - Permission permission = new Permission(); - permission.setName(scope); - permissions.add(permission); + if (applicationRole.getPermissions() != null) { + for (String name : applicationRole.getPermissions()) { + Permission permission = new Permission(); + permission.setName(name); + permissions.add(permission); + } } - role.setPermissions(permissions); + Role role = new Role(); + role.id(roleId) + .name(applicationRole.getRoleName()) + .setPermissions(permissions); return role; } catch (ApplicationRoleManagementException e) { throw ApplicationRoleMgtEndpointUtil.handleApplicationRoleMgtException(e); @@ -381,9 +391,9 @@ private List getUsersForResponseObject(List roleAssigned String uri = getSCIMUserURL(basicUser.getId(), tenantDomain); RoleAssignedUser user = new RoleAssignedUser(); - user.id(basicUser.getId()); - user.name(basicUser.getUserName()); - user.$ref(uri); + user.id(basicUser.getId()) + .name(basicUser.getUserName()) + .$ref(uri); users.add(user); } return users; @@ -404,10 +414,10 @@ private List getGroupsForResponseObject(List roleAssig String uri = getSCIMGroupURL(group.getGroupId(), tenantDomain); RoleAssignedGroup assignedGroup = new RoleAssignedGroup(); - assignedGroup.id(group.getGroupId()); - assignedGroup.name(group.getGroupName()); - assignedGroup.idpId(group.getIdpId()); - assignedGroup.idpName(group.getIdpName()); + assignedGroup.id(group.getGroupId()) + .name(group.getGroupName()) + .idpId(group.getIdpId()) + .idpName(group.getIdpName()); if (LOCAL_IDP.equals(group.getIdpName())) { assignedGroup.$ref(uri); } From ff4502c95e0626c42123d63c164cd4ea1ccccb6a Mon Sep 17 00:00:00 2001 From: Thilina Shashimal Senarath Date: Thu, 7 Sep 2023 12:14:33 +0530 Subject: [PATCH 10/10] add app role bean --- .../management/v1/RolePatchModel.java | 22 +++++++++---------- .../ApplicationRoleMgtEndpointConstants.java | 2 ++ .../util/ApplicationRoleMgtEndpointUtil.java | 5 ++++- .../src/main/resources/applications.yaml | 4 ---- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RolePatchModel.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RolePatchModel.java index 0fa2b84084..c3ece77d08 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RolePatchModel.java +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/application/management/v1/RolePatchModel.java @@ -36,9 +36,9 @@ public class RolePatchModel { private String name; - private List addedPermissions = new ArrayList<>(); + private List addedPermissions = null; - private List removedPermissions = new ArrayList<>(); + private List removedPermissions = null; /** @@ -49,11 +49,9 @@ public RolePatchModel name(String name) { return this; } - @ApiModelProperty(example = "uuid", required = true, value = "") + @ApiModelProperty(example = "uuid", value = "") @JsonProperty("name") @Valid - @NotNull(message = "Property name cannot be null.") - public String getName() { return name; } @@ -69,11 +67,9 @@ public RolePatchModel addedPermissions(List addedPermissions) { return this; } - @ApiModelProperty(required = true, value = "") + @ApiModelProperty(value = "") @JsonProperty("addedPermissions") @Valid - @NotNull(message = "Property addedPermissions cannot be null.") - public List getAddedPermissions() { return addedPermissions; } @@ -82,6 +78,9 @@ public void setAddedPermissions(List addedPermissions) { } public RolePatchModel addAddedPermissionsItem(Permission addedPermissionsItem) { + if (this.addedPermissions == null) { + this.addedPermissions = new ArrayList<>(); + } this.addedPermissions.add(addedPermissionsItem); return this; } @@ -94,11 +93,9 @@ public RolePatchModel removedPermissions(List removedPermissions) { return this; } - @ApiModelProperty(required = true, value = "") + @ApiModelProperty(value = "") @JsonProperty("removedPermissions") @Valid - @NotNull(message = "Property removedPermissions cannot be null.") - public List getRemovedPermissions() { return removedPermissions; } @@ -107,6 +104,9 @@ public void setRemovedPermissions(List removedPermissions) { } public RolePatchModel addRemovedPermissionsItem(Permission removedPermissionsItem) { + if (this.removedPermissions == null) { + this.removedPermissions = new ArrayList<>(); + } this.removedPermissions.add(removedPermissionsItem); return this; } diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/constants/ApplicationRoleMgtEndpointConstants.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/constants/ApplicationRoleMgtEndpointConstants.java index ab35f41141..e955131bd3 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/constants/ApplicationRoleMgtEndpointConstants.java +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/constants/ApplicationRoleMgtEndpointConstants.java @@ -72,6 +72,8 @@ public enum ErrorMessage { "IDP with id: %s doesn't exist."), ERROR_CODE_INVALID_PATCH_OPERATION("60008", "Invalid patch operation.", "Invalid patch operation"), + ERROR_CODE_SCOPE_ALREADY_ASSIGNED("60009", "Unable to assign scope to app role.", + "Scope already assign for the roleId: %s."), ; private final String code; diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/util/ApplicationRoleMgtEndpointUtil.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/util/ApplicationRoleMgtEndpointUtil.java index 1ccf5d9d7a..b5ccfa786e 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/util/ApplicationRoleMgtEndpointUtil.java +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/util/ApplicationRoleMgtEndpointUtil.java @@ -31,6 +31,7 @@ import static org.wso2.carbon.identity.api.server.application.management.v1.constants.ApplicationRoleMgtEndpointConstants.ErrorMessage.ERROR_CODE_GROUP_ALREADY_ASSIGNED; import static org.wso2.carbon.identity.api.server.application.management.v1.constants.ApplicationRoleMgtEndpointConstants.ErrorMessage.ERROR_CODE_GROUP_NOT_FOUND; import static org.wso2.carbon.identity.api.server.application.management.v1.constants.ApplicationRoleMgtEndpointConstants.ErrorMessage.ERROR_CODE_IDP_NOT_FOUND; +import static org.wso2.carbon.identity.api.server.application.management.v1.constants.ApplicationRoleMgtEndpointConstants.ErrorMessage.ERROR_CODE_SCOPE_ALREADY_ASSIGNED; import static org.wso2.carbon.identity.api.server.application.management.v1.constants.ApplicationRoleMgtEndpointConstants.ErrorMessage.ERROR_CODE_USER_ALREADY_ASSIGNED; import static org.wso2.carbon.identity.api.server.application.management.v1.constants.ApplicationRoleMgtEndpointConstants.ErrorMessage.ERROR_CODE_USER_NOT_FOUND; import static org.wso2.carbon.identity.api.server.common.Constants.ERROR_CODE_DELIMITER; @@ -74,7 +75,9 @@ public static ApplicationRoleMgtEndpointException handleApplicationRoleMgtExcept ) { status = Response.Status.NOT_FOUND; } else if (e.getErrorCode().equals(ERROR_CODE_USER_ALREADY_ASSIGNED.getCode()) || - e.getErrorCode().equals(ERROR_CODE_GROUP_ALREADY_ASSIGNED.getCode())) { + e.getErrorCode().equals(ERROR_CODE_GROUP_ALREADY_ASSIGNED.getCode()) || + e.getErrorCode().equals(ERROR_CODE_SCOPE_ALREADY_ASSIGNED.getCode()) + ) { status = Response.Status.CONFLICT; } else { status = Response.Status.BAD_REQUEST; diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/resources/applications.yaml b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/resources/applications.yaml index 89a4be113f..727ad011e6 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/resources/applications.yaml +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/resources/applications.yaml @@ -4044,10 +4044,6 @@ components: example: /t/{tenant-name}/applications/{application-id}/roles?after=NDoy RolePatchModel: type: object - required: - - name - - addedPermissions - - removedPermissions properties: name: type: string