From 58f687cd5cee4f4734ea6cc2b9f5f0d038cb2cbf Mon Sep 17 00:00:00 2001 From: Thamindu Aluthwala Date: Thu, 8 Feb 2024 13:43:38 +0530 Subject: [PATCH] Address review comments --- ...stractAuthorizedAPIManagementListener.java | 118 +++++++ .../mgt/listener/AdminRoleListener.java | 296 +----------------- .../ConsoleAuthorizedAPIListener.java | 64 +--- 3 files changed, 128 insertions(+), 350 deletions(-) create mode 100644 components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/listener/AbstractAuthorizedAPIManagementListener.java diff --git a/components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/listener/AbstractAuthorizedAPIManagementListener.java b/components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/listener/AbstractAuthorizedAPIManagementListener.java new file mode 100644 index 000000000000..8811d5ba4281 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/listener/AbstractAuthorizedAPIManagementListener.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2024, 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.application.mgt.listener; + +import org.wso2.carbon.identity.application.common.IdentityApplicationManagementException; +import org.wso2.carbon.identity.application.common.model.AuthorizedAPI; +import org.wso2.carbon.identity.application.common.model.AuthorizedScopes; + +import java.util.List; + +/** + * Authorized API management listener. + */ +public class AbstractAuthorizedAPIManagementListener implements AuthorizedAPIManagementListener { + + @Override + public int getExecutionOrderId() { + return 0; + } + + @Override + public int getDefaultOrderId() { + return 0; + } + + @Override + public boolean isEnable() { + return false; + } + + @Override + public void preAddAuthorizedAPI(String appId, AuthorizedAPI authorizedAPI, String tenantDomain) + throws IdentityApplicationManagementException { + + } + + @Override + public void postAddAuthorizedAPI(String appId, AuthorizedAPI authorizedAPI, String tenantDomain) + throws IdentityApplicationManagementException { + + } + + @Override + public void preDeleteAuthorizedAPI(String appId, String apiId, String tenantDomain) + throws IdentityApplicationManagementException { + + } + + @Override + public void postDeleteAuthorizedAPI(String appId, String apiId, String tenantDomain) + throws IdentityApplicationManagementException { + + } + + @Override + public void preGetAuthorizedAPIs(String appId, String tenantDomain) + throws IdentityApplicationManagementException { + + } + + @Override + public void postGetAuthorizedAPIs(List authorizedAPIList, String appId, String tenantDomain) + throws IdentityApplicationManagementException { + + } + + @Override + public void prePatchAuthorizedAPI(String appId, String apiId, List addedScopes, List removedScopes, + String tenantDomain) throws IdentityApplicationManagementException { + + } + + @Override + public void postPatchAuthorizedAPI(String appId, String apiId, List addedScopes, List removedScopes, + String tenantDomain) throws IdentityApplicationManagementException { + + } + + @Override + public void preGetAuthorizedScopes(String appId, String tenantDomain) + throws IdentityApplicationManagementException { + + } + + @Override + public void postGetAuthorizedScopes(List authorizedScopesList, String appId, String tenantDomain) + throws IdentityApplicationManagementException { + + } + + @Override + public void preGetAuthorizedAPI(String appId, String apiId, String tenantDomain) + throws IdentityApplicationManagementException { + + } + + @Override + public AuthorizedAPI postGetAuthorizedAPI(AuthorizedAPI authorizedAPI, String appId, String apiId, + String tenantDomain) throws IdentityApplicationManagementException { + return null; + } +} diff --git a/components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/listener/AdminRoleListener.java b/components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/listener/AdminRoleListener.java index 9067d83bcff4..a82ca0cfe2de 100644 --- a/components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/listener/AdminRoleListener.java +++ b/components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/listener/AdminRoleListener.java @@ -30,13 +30,9 @@ import org.wso2.carbon.identity.role.v2.mgt.core.RoleConstants; import org.wso2.carbon.identity.role.v2.mgt.core.RoleManagementService; import org.wso2.carbon.identity.role.v2.mgt.core.exception.IdentityRoleManagementException; -import org.wso2.carbon.identity.role.v2.mgt.core.listener.RoleManagementListener; -import org.wso2.carbon.identity.role.v2.mgt.core.model.GroupBasicInfo; -import org.wso2.carbon.identity.role.v2.mgt.core.model.IdpGroup; +import org.wso2.carbon.identity.role.v2.mgt.core.listener.AbstractRoleManagementListener; import org.wso2.carbon.identity.role.v2.mgt.core.model.Permission; import org.wso2.carbon.identity.role.v2.mgt.core.model.Role; -import org.wso2.carbon.identity.role.v2.mgt.core.model.RoleBasicInfo; -import org.wso2.carbon.identity.role.v2.mgt.core.model.UserBasicInfo; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.core.util.UserCoreUtil; @@ -46,18 +42,18 @@ import static org.wso2.carbon.identity.role.v2.mgt.core.RoleConstants.ORGANIZATION; /** - * Admin role listener to populate admin role permissions. + * Admin role listener to populate organization admin role and console application Administrator role permissions. */ -public class AdminRoleListener implements RoleManagementListener { +public class AdminRoleListener extends AbstractRoleManagementListener { @Override public int getExecutionOrderId() { - return 1; + return 2; } @Override public int getDefaultOrderId() { - return 1; + return 2; } @Override @@ -65,73 +61,6 @@ public boolean isEnable() { return true; } - @Override - public void preAddRole(String roleName, List userList, List groupList, List permissions, - String audience, String audienceId, String tenantDomain) - throws IdentityRoleManagementException { - - } - - @Override - public void postAddRole(RoleBasicInfo roleBasicInfo, String roleName, List userList, List groupList, - List permissions, String audience, String audienceId, String tenantDomain) - throws IdentityRoleManagementException { - - } - - @Override - public void preGetRoles(Integer limit, Integer offset, String sortBy, String sortOrder, String tenantDomain) - throws IdentityRoleManagementException { - - } - - @Override - public void preGetRoles(Integer limit, Integer offset, String sortBy, String sortOrder, String tenantDomain, - List requiredAttributes) throws IdentityRoleManagementException { - } - - @Override - public void postGetRoles(List roleBasicInfoList, Integer limit, Integer offset, String sortBy, - String sortOrder, String tenantDomain) throws IdentityRoleManagementException { - - } - - @Override - public void postGetRoles(List roleInfoList, Integer limit, Integer offset, String sortBy, String sortOrder, - String tenantDomain, List requiredAttributes) - throws IdentityRoleManagementException { - } - - @Override - public void preGetRoles(String filter, Integer limit, Integer offset, String sortBy, String sortOrder, - String tenantDomain) throws IdentityRoleManagementException { - - } - - @Override - public void preGetRoles(String filter, Integer limit, Integer offset, String sortBy, String sortOrder, - String tenantDomain, List requiredAttributes) - throws IdentityRoleManagementException { - } - - @Override - public void postGetRoles(List roleBasicInfoList, String filter, Integer limit, Integer offset, - String sortBy, String sortOrder, String tenantDomain) - throws IdentityRoleManagementException { - - } - - @Override - public void postGetRoles(List roleInfoList, String filter, Integer limit, Integer offset, String sortBy, - String sortOrder, String tenantDomain, List requiredAttributes) - throws IdentityRoleManagementException { - } - - @Override - public void preGetRole(String roleId, String tenantDomain) throws IdentityRoleManagementException { - - } - @Override public void postGetRole(Role role, String roleId, String tenantDomain) throws IdentityRoleManagementException { @@ -153,115 +82,6 @@ public void postGetRole(Role role, String roleId, String tenantDomain) throws Id IdentityUtil.getProperty("EnableResidentIdpBanner"); } - @Override - public void preGetRoleBasicInfo(String roleId, String tenantDomain) throws IdentityRoleManagementException { - - } - - @Override - public void postGetRoleBasicInfo(RoleBasicInfo roleBasicInfo, String roleId, String tenantDomain) - throws IdentityRoleManagementException { - - } - - @Override - public void preUpdateRoleName(String roleId, String newRoleName, String tenantDomain) - throws IdentityRoleManagementException { - - } - - @Override - public void postUpdateRoleName(String roleId, String newRoleName, String tenantDomain) - throws IdentityRoleManagementException { - - } - - @Override - public void preDeleteRole(String roleId, String tenantDomain) throws IdentityRoleManagementException { - - } - - @Override - public void postDeleteRole(String roleId, String tenantDomain) throws IdentityRoleManagementException { - - } - - @Override - public void preGetUserListOfRole(String roleId, String tenantDomain) throws IdentityRoleManagementException { - - } - - @Override - public void postGetUserListOfRole(List userBasicInfoList, String roleId, String tenantDomain) - throws IdentityRoleManagementException { - - } - - @Override - public void preUpdateUserListOfRole(String roleId, List newUserIDList, List deletedUserIDList, - String tenantDomain) throws IdentityRoleManagementException { - - } - - @Override - public void postUpdateUserListOfRole(String roleId, List newUserIDList, List deletedUserIDList, - String tenantDomain) throws IdentityRoleManagementException { - - } - - @Override - public void preGetGroupListOfRole(String roleId, String tenantDomain) throws IdentityRoleManagementException { - - } - - @Override - public void postGetGroupListOfRole(List groupBasicInfoList, String roleId, String tenantDomain) - throws IdentityRoleManagementException { - - } - - @Override - public void preUpdateGroupListOfRole(String roleId, List newGroupIDList, List deletedGroupIDList, - String tenantDomain) throws IdentityRoleManagementException { - - } - - @Override - public void postUpdateGroupListOfRole(String roleId, List newGroupIDList, List deletedGroupIDList, - String tenantDomain) throws IdentityRoleManagementException { - - } - - @Override - public void preGetIdpGroupListOfRole(String roleId, String tenantDomain) throws IdentityRoleManagementException { - - } - - @Override - public void postGetIdpGroupListOfRole(List idpGroups, String roleId, String tenantDomain) - throws IdentityRoleManagementException { - - } - - @Override - public void preUpdateIdpGroupListOfRole(String roleId, List newGroupIDList, - List deletedGroupIDList, String tenantDomain) - throws IdentityRoleManagementException { - - } - - @Override - public void postUpdateIdpGroupListOfRole(String roleId, List newGroupIDList, - List deletedGroupIDList, String tenantDomain) - throws IdentityRoleManagementException { - - } - - @Override - public void preGetPermissionListOfRole(String roleId, String tenantDomain) throws IdentityRoleManagementException { - - } - @Override public void postGetPermissionListOfRole(List permissionListOfRole, String roleId, String tenantDomain) throws IdentityRoleManagementException { @@ -285,112 +105,6 @@ public void postGetPermissionListOfRole(List permissionListOfRole, S } } - @Override - public void preUpdatePermissionsForRole(String roleId, List addedPermissions, - List deletedPermissions, String audience, String audienceId, - String tenantDomain) throws IdentityRoleManagementException { - - } - - @Override - public void postUpdatePermissionsForRole(String roleId, List addedPermissions, - List deletedPermissions, String audience, String audienceId, - String tenantDomain) throws IdentityRoleManagementException { - - } - - @Override - public void preGetRolesCount(String tenantDomain) throws IdentityRoleManagementException { - - } - - @Override - public void postGetRolesCount(int count, String tenantDomain) throws IdentityRoleManagementException { - - } - - @Override - public void preGetRoleListOfUser(String userId, String tenantDomain) throws IdentityRoleManagementException { - - } - - @Override - public void postGetRoleListOfUser(List roleBasicInfoList, String userId, String tenantDomain) - throws IdentityRoleManagementException { - - } - - @Override - public void preGetRoleListOfGroups(List groupIds, String tenantDomain) - throws IdentityRoleManagementException { - - } - - @Override - public void postGetRoleListOfGroups(List roleBasicInfoList, List groupIds, - String tenantDomain) throws IdentityRoleManagementException { - - } - - @Override - public void preGetRoleListOfIdpGroups(List groupIds, String tenantDomain) - throws IdentityRoleManagementException { - - } - - @Override - public void postGetRoleListOfIdpGroups(List roleBasicInfoList, List groupIds, - String tenantDomain) throws IdentityRoleManagementException { - - } - - @Override - public void preGetRoleIdListOfUser(String userId, String tenantDomain) throws IdentityRoleManagementException { - - } - - @Override - public void postGetRoleIdListOfUser(List roleIds, String userId, String tenantDomain) - throws IdentityRoleManagementException { - - } - - @Override - public void preGetRoleIdListOfGroups(List groupIds, String tenantDomain) - throws IdentityRoleManagementException { - - } - - @Override - public void postGetRoleIdListOfGroups(List roleIds, String tenantDomain) - throws IdentityRoleManagementException { - - } - - @Override - public void preGetRoleIdListOfIdpGroups(List groupIds, String tenantDomain) - throws IdentityRoleManagementException { - - } - - @Override - public void postGetRoleIdListOfIdpGroups(List roleIds, List groupIds, String tenantDomain) - throws IdentityRoleManagementException { - - } - - @Override - public void preDeleteRolesByApplication(String applicationId, String tenantDomain) - throws IdentityRoleManagementException { - - } - - @Override - public void postDeleteRolesByApplication(String applicationId, String tenantDomain) - throws IdentityRoleManagementException { - - } - public void postGetPermissionListOfRoles(List permissions, List roleIds, String tenantDomain) throws IdentityRoleManagementException { diff --git a/components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/listener/ConsoleAuthorizedAPIListener.java b/components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/listener/ConsoleAuthorizedAPIListener.java index f248f1f8ab85..85963f5bb3e2 100644 --- a/components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/listener/ConsoleAuthorizedAPIListener.java +++ b/components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/listener/ConsoleAuthorizedAPIListener.java @@ -34,51 +34,21 @@ /** * Console authorized API listener. */ -public class ConsoleAuthorizedAPIListener implements AuthorizedAPIManagementListener { +public class ConsoleAuthorizedAPIListener extends AbstractAuthorizedAPIManagementListener { @Override public int getExecutionOrderId() { - return 0; + return 1; } @Override public int getDefaultOrderId() { - return 0; + return 1; } @Override public boolean isEnable() { - return false; - } - - @Override - public void preAddAuthorizedAPI(String appId, AuthorizedAPI authorizedAPI, String tenantDomain) - throws IdentityApplicationManagementException { - - } - - @Override - public void postAddAuthorizedAPI(String appId, AuthorizedAPI authorizedAPI, String tenantDomain) - throws IdentityApplicationManagementException { - - } - - @Override - public void preDeleteAuthorizedAPI(String appId, String apiId, String tenantDomain) - throws IdentityApplicationManagementException { - - } - - @Override - public void postDeleteAuthorizedAPI(String appId, String apiId, String tenantDomain) - throws IdentityApplicationManagementException { - - } - - @Override - public void preGetAuthorizedAPIs(String appId, String tenantDomain) - throws IdentityApplicationManagementException { - + return true; } @Override @@ -106,24 +76,6 @@ public void postGetAuthorizedAPIs(List authorizedAPIList, String } } - @Override - public void prePatchAuthorizedAPI(String appId, String apiId, List addedScopes, List removedScopes, - String tenantDomain) throws IdentityApplicationManagementException { - - } - - @Override - public void postPatchAuthorizedAPI(String appId, String apiId, List addedScopes, List removedScopes, - String tenantDomain) throws IdentityApplicationManagementException { - - } - - @Override - public void preGetAuthorizedScopes(String appId, String tenantDomain) - throws IdentityApplicationManagementException { - - } - @Override public void postGetAuthorizedScopes(List authorizedScopesList, String appId, String tenantDomain) throws IdentityApplicationManagementException { @@ -141,12 +93,6 @@ public void postGetAuthorizedScopes(List authorizedScopesList, } } - @Override - public void preGetAuthorizedAPI(String appId, String apiId, String tenantDomain) - throws IdentityApplicationManagementException { - - } - @Override public AuthorizedAPI postGetAuthorizedAPI(AuthorizedAPI authorizedAPI, String appId, String apiId, String tenantDomain) throws IdentityApplicationManagementException { @@ -155,7 +101,7 @@ public AuthorizedAPI postGetAuthorizedAPI(AuthorizedAPI authorizedAPI, String ap try { APIResource apiResource = ApplicationManagementServiceComponentHolder.getInstance() .getAPIResourceManager().getAPIResourceById(apiId, tenantDomain); - AuthorizedAPI authorizedAPI1 = new AuthorizedAPI.AuthorizedAPIBuilder() + AuthorizedAPI authorizedAPI1 = new AuthorizedAPI.AuthorizedAPIBuilder() .appId(appId) .apiId(apiResource.getId()) .scopes(apiResource.getScopes())