From 05a5b9351e5ec57f5a53efdb6e638b047d12be63 Mon Sep 17 00:00:00 2001 From: Shan Chathusanda Jayathilaka Date: Tue, 12 Nov 2024 15:08:18 +0530 Subject: [PATCH] Resolve role sharing conflicts in app sharing --- .../pom.xml | 4 + .../handler/SharedRoleMgtHandler.java | 110 ++- .../listener/SharedRoleMgtListener.java | 10 +- .../tests/SharedRoleMgtHandlerTest.java | 215 ++++++ .../test/resources/repository.conf/carbon.xml | 684 ++++++++++++++++++ pom.xml | 5 + 6 files changed, 1016 insertions(+), 12 deletions(-) create mode 100644 components/org.wso2.carbon.identity.organization.management.handler/src/test/java/org/wso2/carbon/identity/organization/management/handler/tests/SharedRoleMgtHandlerTest.java create mode 100755 components/org.wso2.carbon.identity.organization.management.handler/src/test/resources/repository.conf/carbon.xml diff --git a/components/org.wso2.carbon.identity.organization.management.handler/pom.xml b/components/org.wso2.carbon.identity.organization.management.handler/pom.xml index 966bfaea7..ffeda1418 100644 --- a/components/org.wso2.carbon.identity.organization.management.handler/pom.xml +++ b/components/org.wso2.carbon.identity.organization.management.handler/pom.xml @@ -80,6 +80,10 @@ org.wso2.carbon.identity.framework org.wso2.carbon.identity.application.mgt + + org.wso2.carbon.identity.framework + org.wso2.carbon.identity.central.log.mgt + org.testng diff --git a/components/org.wso2.carbon.identity.organization.management.handler/src/main/java/org/wso2/carbon/identity/organization/management/handler/SharedRoleMgtHandler.java b/components/org.wso2.carbon.identity.organization.management.handler/src/main/java/org/wso2/carbon/identity/organization/management/handler/SharedRoleMgtHandler.java index 5bd4a6a9a..efb706c58 100644 --- a/components/org.wso2.carbon.identity.organization.management.handler/src/main/java/org/wso2/carbon/identity/organization/management/handler/SharedRoleMgtHandler.java +++ b/components/org.wso2.carbon.identity.organization.management.handler/src/main/java/org/wso2/carbon/identity/organization/management/handler/SharedRoleMgtHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * Copyright (c) 2023-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 @@ -26,6 +26,9 @@ import org.wso2.carbon.identity.application.common.model.ApplicationBasicInfo; import org.wso2.carbon.identity.application.common.model.RoleV2; import org.wso2.carbon.identity.application.mgt.ApplicationManagementService; +import org.wso2.carbon.identity.central.log.mgt.utils.LogConstants; +import org.wso2.carbon.identity.central.log.mgt.utils.LoggerUtils; +import org.wso2.carbon.identity.core.util.IdentityUtil; import org.wso2.carbon.identity.event.IdentityEventConstants; import org.wso2.carbon.identity.event.IdentityEventException; import org.wso2.carbon.identity.event.event.Event; @@ -42,9 +45,11 @@ 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.model.RoleBasicInfo; +import org.wso2.carbon.utils.AuditLog; import java.util.ArrayList; import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.CompletableFuture; @@ -72,6 +77,9 @@ public void handleEvent(Event event) throws IdentityEventException { case IdentityEventConstants.Event.POST_ADD_ROLE_V2_EVENT: createSharedRolesOnNewRoleCreation(eventProperties); break; + case OrgApplicationMgtConstants.EVENT_PRE_SHARE_APPLICATION: + checkSharingRoleConflicts(eventProperties); + break; default: if (LOG.isDebugEnabled()) { LOG.debug("Unsupported event: " + eventName); @@ -271,13 +279,31 @@ private void createSharedRolesOnNewRoleCreation(Map eventPropert for (BasicOrganization organization : applicationSharedOrganizations) { String shareAppTenantDomain = getOrganizationManager().resolveTenantDomain(organization.getId()); - RoleBasicInfo sharedRoleInfo = getRoleManagementServiceV2().addRole(mainRoleName, - Collections.emptyList(), - Collections.emptyList(), - Collections.emptyList(), RoleConstants.ORGANIZATION, organization.getId(), - shareAppTenantDomain); - getRoleManagementServiceV2().addMainRoleToSharedRoleRelationship(mainRoleUUID, - sharedRoleInfo.getId(), roleTenantDomain, shareAppTenantDomain); + if (!getRoleManagementServiceV2().isExistingRoleName(mainRoleName, RoleConstants.ORGANIZATION, + organization.getId(), shareAppTenantDomain)) { + RoleBasicInfo sharedRoleInfo = getRoleManagementServiceV2().addRole(mainRoleName, + Collections.emptyList(), + Collections.emptyList(), + Collections.emptyList(), RoleConstants.ORGANIZATION, organization.getId(), + shareAppTenantDomain); + getRoleManagementServiceV2().addMainRoleToSharedRoleRelationship(mainRoleUUID, + sharedRoleInfo.getId(), roleTenantDomain, shareAppTenantDomain); + } else { + if (LoggerUtils.isEnableV2AuditLogs()) { + String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext(). + getTenantDomain(); + AuditLog.AuditLogBuilder auditLogBuilder = new AuditLog.AuditLogBuilder( + IdentityUtil.getInitiatorId(username, tenantDomain), + LoggerUtils.Target.User.name(), mainRoleName, LoggerUtils.Target.Role.name(), + LogConstants.UserManagement.ADD_ROLE_ACTION) + .data(buildAuditData(roleOrgId, null, organization.getId(), mainRoleName, + mainRoleUUID, "Role conflict")); + LoggerUtils.triggerAuditLogEvent(auditLogBuilder, true); + } + LOG.warn(String.format("Organization %s has a non shared role with name %s, ", + organization.getId(), mainRoleName)); + } } break; default: @@ -289,6 +315,60 @@ private void createSharedRolesOnNewRoleCreation(Map eventPropert } } + private void checkSharingRoleConflicts(Map eventProperties) throws IdentityEventException { + + String parentOrganizationId = + (String) eventProperties.get(OrgApplicationMgtConstants.EVENT_PROP_PARENT_ORGANIZATION_ID); + String parentApplicationId = + (String) eventProperties.get(OrgApplicationMgtConstants.EVENT_PROP_PARENT_APPLICATION_ID); + String sharedOrganizationId = + (String) eventProperties.get(OrgApplicationMgtConstants.EVENT_PROP_SHARED_ORGANIZATION_ID); + String sharedApplicationId = + (String) eventProperties.get(OrgApplicationMgtConstants.EVENT_PROP_SHARED_APPLICATION_ID); + try { + String sharedAppTenantDomain = getOrganizationManager().resolveTenantDomain(sharedOrganizationId); + String mainAppTenantDomain = getOrganizationManager().resolveTenantDomain(parentOrganizationId); + String allowedAudienceForRoleAssociationInMainApp = getApplicationMgtService(). + getAllowedAudienceForRoleAssociation(parentApplicationId, mainAppTenantDomain); + if (RoleConstants.ORGANIZATION.equals(allowedAudienceForRoleAssociationInMainApp.toLowerCase())) { + List associatedRolesOfApplication = getApplicationMgtService(). + getAssociatedRolesOfApplication(parentApplicationId, mainAppTenantDomain); + for (RoleV2 roleV2 : associatedRolesOfApplication) { + boolean roleExistsInSharedOrg = getRoleManagementServiceV2().isExistingRoleName(roleV2.getName(), + RoleConstants.ORGANIZATION, sharedOrganizationId, sharedAppTenantDomain); + Map mainRoleToSharedRoleMappingInSharedOrg = + getRoleManagementServiceV2().getMainRoleToSharedRoleMappingsBySubOrg( + Collections.singletonList(roleV2.getId()), sharedAppTenantDomain); + boolean roleRelationshipExistsInSharedOrg = + MapUtils.isNotEmpty(mainRoleToSharedRoleMappingInSharedOrg); + if (roleExistsInSharedOrg && !roleRelationshipExistsInSharedOrg) { + // If the role exists in the shared org, but the relationship does not exist then this role is + // created directly in the sub organization level. So this is a conflict to share the role + // with same name and organization audience to the sub organization. + if (LoggerUtils.isEnableV2AuditLogs()) { + String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext(). + getTenantDomain(); + AuditLog.AuditLogBuilder auditLogBuilder = new AuditLog.AuditLogBuilder( + IdentityUtil.getInitiatorId(username, tenantDomain), + LoggerUtils.Target.User.name(), roleV2.getName(), LoggerUtils.Target.Role.name(), + LogConstants.ApplicationManagement.CREATE_APPLICATION_ACTION). + data(buildAuditData(parentOrganizationId, parentApplicationId, + sharedOrganizationId, roleV2.getName(), roleV2.getId(), "Role conflict")); + LoggerUtils.triggerAuditLogEvent(auditLogBuilder, true); + } + throw new IdentityEventException(String.format("Organization %s has a non shared role with " + + "name %s, ", sharedOrganizationId, roleV2.getName())); + } + } + } + } catch (OrganizationManagementException | IdentityRoleManagementException | + IdentityApplicationManagementException e) { + throw new IdentityEventException(String.format("Error while sharing roles related to application %s.", + sharedApplicationId), e); + } + } + private static RoleManagementService getRoleManagementServiceV2() { return OrganizationManagementHandlerDataHolder.getInstance().getRoleManagementServiceV2(); @@ -308,4 +388,18 @@ private static ApplicationManagementService getApplicationMgtService() { return OrganizationManagementHandlerDataHolder.getInstance().getApplicationManagementService(); } + + private Map buildAuditData(String parentOrganizationId, String parentApplicationId, + String sharedOrganizationId, String roleName, String roleId, + String failureReason) { + + Map auditData = new HashMap<>(); + auditData.put("parentOrganizationId", parentOrganizationId); + auditData.put("parentApplicationId", parentApplicationId); + auditData.put("sharedOrganizationId", sharedOrganizationId); + auditData.put("roleId", roleId); + auditData.put("roleName", roleName); + auditData.put("failureReason", failureReason); + return auditData; + } } diff --git a/components/org.wso2.carbon.identity.organization.management.handler/src/main/java/org/wso2/carbon/identity/organization/management/handler/listener/SharedRoleMgtListener.java b/components/org.wso2.carbon.identity.organization.management.handler/src/main/java/org/wso2/carbon/identity/organization/management/handler/listener/SharedRoleMgtListener.java index 5b852ef5d..459d6e4a0 100644 --- a/components/org.wso2.carbon.identity.organization.management.handler/src/main/java/org/wso2/carbon/identity/organization/management/handler/listener/SharedRoleMgtListener.java +++ b/components/org.wso2.carbon.identity.organization.management.handler/src/main/java/org/wso2/carbon/identity/organization/management/handler/listener/SharedRoleMgtListener.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * Copyright (c) 2023-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 @@ -608,11 +608,13 @@ public boolean doPostGetAssociatedRolesOfApplication(List associatedRole throws IdentityApplicationManagementException { try { - if (!OrganizationManagementUtil.isOrganization(tenantDomain)) { + String mainAppId = applicationManagementService.getMainAppId(applicationUUID); + // If the main application id is null, then this is the main application. We can skip this operation based + // on that. + if (StringUtils.isEmpty(mainAppId)) { return true; } // Resolve the associated roles of shared application from main application details. - String mainAppId = applicationManagementService.getMainAppId(applicationUUID); int mainAppTenantId = applicationManagementService.getTenantIdByApp(mainAppId); String mainAppTenantDomain = IdentityTenantUtil.getTenantDomain(mainAppTenantId); List resolvedAssociatedRolesFromMainApp = @@ -641,7 +643,7 @@ public boolean doPostGetAssociatedRolesOfApplication(List associatedRole .collect(Collectors.toList()); associatedRolesOfApplication.clear(); associatedRolesOfApplication.addAll(associatedRolesOfSharedApplication); - } catch (OrganizationManagementException | IdentityRoleManagementException e) { + } catch (IdentityRoleManagementException e) { throw new IdentityApplicationManagementException(String.format( "Error while fetching the allowed audience for role association of application with: %s.", applicationUUID), e); diff --git a/components/org.wso2.carbon.identity.organization.management.handler/src/test/java/org/wso2/carbon/identity/organization/management/handler/tests/SharedRoleMgtHandlerTest.java b/components/org.wso2.carbon.identity.organization.management.handler/src/test/java/org/wso2/carbon/identity/organization/management/handler/tests/SharedRoleMgtHandlerTest.java new file mode 100644 index 000000000..f60bf268b --- /dev/null +++ b/components/org.wso2.carbon.identity.organization.management.handler/src/test/java/org/wso2/carbon/identity/organization/management/handler/tests/SharedRoleMgtHandlerTest.java @@ -0,0 +1,215 @@ +/* + * 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.organization.management.handler.tests; + +import org.mockito.MockedStatic; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; +import org.wso2.carbon.base.CarbonBaseConstants; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.identity.application.common.model.RoleV2; +import org.wso2.carbon.identity.application.mgt.ApplicationManagementService; +import org.wso2.carbon.identity.central.log.mgt.utils.LoggerUtils; +import org.wso2.carbon.identity.core.util.IdentityUtil; +import org.wso2.carbon.identity.event.IdentityEventException; +import org.wso2.carbon.identity.event.event.Event; +import org.wso2.carbon.identity.organization.management.application.constant.OrgApplicationMgtConstants; +import org.wso2.carbon.identity.organization.management.handler.SharedRoleMgtHandler; +import org.wso2.carbon.identity.organization.management.handler.internal.OrganizationManagementHandlerDataHolder; +import org.wso2.carbon.identity.organization.management.service.OrganizationManager; +import org.wso2.carbon.identity.role.v2.mgt.core.RoleManagementService; + +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.mockito.Mockito.lenient; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.mockStatic; +import static org.wso2.carbon.identity.organization.management.application.constant.OrgApplicationMgtConstants.EVENT_PROP_PARENT_APPLICATION_ID; +import static org.wso2.carbon.identity.organization.management.application.constant.OrgApplicationMgtConstants.EVENT_PROP_PARENT_ORGANIZATION_ID; +import static org.wso2.carbon.identity.organization.management.application.constant.OrgApplicationMgtConstants.EVENT_PROP_SHARED_APPLICATION_ID; +import static org.wso2.carbon.identity.organization.management.application.constant.OrgApplicationMgtConstants.EVENT_PROP_SHARED_ORGANIZATION_ID; + +/** + * Unit tests for SharedRoleMgtHandler. + */ +public class SharedRoleMgtHandlerTest { + + private static final String PARENT_ORG_TENANT_DOMAIN = "parent-org-tenant-domain"; + private static final String PARENT_ORG_ID = "parent-org-id"; + private static final String PARENT_ORG_USER_NAME = "parent-org-user"; + private static final String PARENT_ORG_USER_ID = "parent-org-user-id"; + private static final String PARENT_ORG_APP_ID = "parent-application-id"; + private static final String SHARED_ORG_TENANT_DOMAIN = "shared-org-tenant-domain"; + private static final String SHARED_ORG_ID = "shared-org-id"; + private static final String SHARED_ORG_APP_ID = "shared-app-id"; + private static final String ORGANIZATION_AUD = "organization"; + + private static MockedStatic loggerUtils = null; + private static MockedStatic identityUtil = null; + + @BeforeClass + public void setUp() { + + initPrivilegedCarbonContext(); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(PARENT_ORG_TENANT_DOMAIN); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(PARENT_ORG_USER_NAME); + + loggerUtils = mockStatic(LoggerUtils.class); + identityUtil = mockStatic(IdentityUtil.class); + } + + @DataProvider(name = "v2AuditLogsEnabled") + public Object[][] v2AuditLogsEnabled() { + + return new Object[][]{ + {false}, + {true} + }; + } + + @Test(dataProvider = "v2AuditLogsEnabled", expectedExceptions = IdentityEventException.class, + expectedExceptionsMessageRegExp = ".*has a non shared role with.*") + public void testHandleEventForPreShareApplicationEventWithConflictingRoles(boolean isV2AuditLogsEnabled) + throws Exception { + + Event event = createPreShareApplicationEvent(); + + OrganizationManager mockedOrganizationManager = mock(OrganizationManager.class); + OrganizationManagementHandlerDataHolder.getInstance().setOrganizationManager(mockedOrganizationManager); + lenient().when(mockedOrganizationManager.resolveTenantDomain(SHARED_ORG_ID)). + thenReturn(SHARED_ORG_TENANT_DOMAIN); + lenient().when(mockedOrganizationManager.resolveTenantDomain(PARENT_ORG_ID)). + thenReturn(PARENT_ORG_TENANT_DOMAIN); + + List roles = new ArrayList<>(); + RoleV2 role = new RoleV2(); + role.setId("role-id"); + role.setName("role-name"); + roles.add(role); + + ApplicationManagementService mockedApplicationManagementService = mock(ApplicationManagementService.class); + OrganizationManagementHandlerDataHolder.getInstance() + .setApplicationManagementService(mockedApplicationManagementService); + lenient().when(mockedApplicationManagementService.getAllowedAudienceForRoleAssociation(PARENT_ORG_APP_ID, + PARENT_ORG_TENANT_DOMAIN)).thenReturn(ORGANIZATION_AUD); + lenient().when(mockedApplicationManagementService.getAssociatedRolesOfApplication(PARENT_ORG_APP_ID, + PARENT_ORG_TENANT_DOMAIN)).thenReturn(roles); + + RoleManagementService roleManagementService = mock(RoleManagementService.class); + OrganizationManagementHandlerDataHolder.getInstance().setRoleManagementServiceV2(roleManagementService); + lenient().when(roleManagementService.isExistingRoleName(roles.get(0).getName(), ORGANIZATION_AUD, + SHARED_ORG_ID, SHARED_ORG_TENANT_DOMAIN)).thenReturn(true); + lenient().when(roleManagementService.getMainRoleToSharedRoleMappingsBySubOrg( + Collections.singletonList(role.getId()), SHARED_ORG_TENANT_DOMAIN)).thenReturn(new HashMap<>()); + + loggerUtils.when(LoggerUtils::isEnableV2AuditLogs).thenReturn(isV2AuditLogsEnabled); + identityUtil.when(() -> IdentityUtil.getInitiatorId(PARENT_ORG_USER_NAME, PARENT_ORG_TENANT_DOMAIN)). + thenReturn(PARENT_ORG_USER_ID); + + SharedRoleMgtHandler sharedRoleMgtHandler = new SharedRoleMgtHandler(); + sharedRoleMgtHandler.handleEvent(event); + } + + @Test + public void testHandleEventForPreShareApplicationEventWithoutConflictingRoles() throws Exception { + + Event event = createPreShareApplicationEvent(); + + OrganizationManager mockedOrganizationManager = mock(OrganizationManager.class); + OrganizationManagementHandlerDataHolder.getInstance().setOrganizationManager(mockedOrganizationManager); + lenient().when(mockedOrganizationManager.resolveTenantDomain(SHARED_ORG_ID)). + thenReturn(SHARED_ORG_TENANT_DOMAIN); + lenient().when(mockedOrganizationManager.resolveTenantDomain(PARENT_ORG_ID)). + thenReturn(PARENT_ORG_TENANT_DOMAIN); + + List roles = new ArrayList<>(); + RoleV2 role = new RoleV2(); + role.setId("role-id"); + role.setName("role-name"); + roles.add(role); + + ApplicationManagementService mockedApplicationManagementService = mock(ApplicationManagementService.class); + OrganizationManagementHandlerDataHolder.getInstance() + .setApplicationManagementService(mockedApplicationManagementService); + lenient().when(mockedApplicationManagementService.getAllowedAudienceForRoleAssociation(PARENT_ORG_APP_ID, + PARENT_ORG_TENANT_DOMAIN)).thenReturn(ORGANIZATION_AUD); + lenient().when(mockedApplicationManagementService.getAssociatedRolesOfApplication(PARENT_ORG_APP_ID, + PARENT_ORG_TENANT_DOMAIN)).thenReturn(roles); + + RoleManagementService roleManagementService = mock(RoleManagementService.class); + OrganizationManagementHandlerDataHolder.getInstance().setRoleManagementServiceV2(roleManagementService); + lenient().when(roleManagementService.isExistingRoleName(roles.get(0).getName(), ORGANIZATION_AUD, + SHARED_ORG_ID, SHARED_ORG_TENANT_DOMAIN)).thenReturn(true); + Map mainRoleToSharedRoleMapping = new HashMap<>(); + mainRoleToSharedRoleMapping.put(roles.get(0).getId(), "mapped-shared-role-id"); + lenient().when(roleManagementService.getMainRoleToSharedRoleMappingsBySubOrg( + Collections.singletonList(role.getId()), SHARED_ORG_TENANT_DOMAIN)). + thenReturn(mainRoleToSharedRoleMapping); + + SharedRoleMgtHandler sharedRoleMgtHandler = new SharedRoleMgtHandler(); + sharedRoleMgtHandler.handleEvent(event); + } + + @Test + public void testHandleEventForPreShareApplicationEventWithApplicationAud() throws Exception { + + Event event = createPreShareApplicationEvent(); + + OrganizationManager mockedOrganizationManager = mock(OrganizationManager.class); + OrganizationManagementHandlerDataHolder.getInstance().setOrganizationManager(mockedOrganizationManager); + lenient().when(mockedOrganizationManager.resolveTenantDomain(SHARED_ORG_ID)). + thenReturn(SHARED_ORG_TENANT_DOMAIN); + lenient().when(mockedOrganizationManager.resolveTenantDomain(PARENT_ORG_ID)). + thenReturn(PARENT_ORG_TENANT_DOMAIN); + + ApplicationManagementService mockedApplicationManagementService = mock(ApplicationManagementService.class); + OrganizationManagementHandlerDataHolder.getInstance() + .setApplicationManagementService(mockedApplicationManagementService); + lenient().when(mockedApplicationManagementService.getAllowedAudienceForRoleAssociation(PARENT_ORG_APP_ID, + PARENT_ORG_TENANT_DOMAIN)).thenReturn("application"); + + SharedRoleMgtHandler sharedRoleMgtHandler = new SharedRoleMgtHandler(); + sharedRoleMgtHandler.handleEvent(event); + } + + private void initPrivilegedCarbonContext() { + + System.setProperty( + CarbonBaseConstants.CARBON_HOME, + Paths.get(System.getProperty("user.dir"), "src", "test", "resources").toString() + ); + PrivilegedCarbonContext.startTenantFlow(); + } + + private static Event createPreShareApplicationEvent() { + + Event event = new Event(OrgApplicationMgtConstants.EVENT_PRE_SHARE_APPLICATION); + event.addEventProperty(EVENT_PROP_PARENT_ORGANIZATION_ID, PARENT_ORG_ID); + event.addEventProperty(EVENT_PROP_PARENT_APPLICATION_ID, PARENT_ORG_APP_ID); + event.addEventProperty(EVENT_PROP_SHARED_ORGANIZATION_ID, SHARED_ORG_ID); + event.addEventProperty(EVENT_PROP_SHARED_APPLICATION_ID, SHARED_ORG_APP_ID); + return event; + } +} diff --git a/components/org.wso2.carbon.identity.organization.management.handler/src/test/resources/repository.conf/carbon.xml b/components/org.wso2.carbon.identity.organization.management.handler/src/test/resources/repository.conf/carbon.xml new file mode 100755 index 000000000..d348edbeb --- /dev/null +++ b/components/org.wso2.carbon.identity.organization.management.handler/src/test/resources/repository.conf/carbon.xml @@ -0,0 +1,684 @@ + + + + + + + + WSO2 Identity Server + + + IS + + + 5.3.0 + + + localhost + + + localhost + + + local:/${carbon.context}/services/ + + + + + + + IdentityServer + + + + + + + org.wso2.carbon + + + / + + + + + + + + + 15 + + + + + + + + + 0 + + + + + 9999 + + 11111 + + + + + + 10389 + + 8000 + + + + + + 10500 + + + + + + + + + org.wso2.carbon.tomcat.jndi.CarbonJavaURLContextFactory + + + + + + + + + java + + + + + + + + + + false + + + false + + + 600 + + + + false + + + + + + + + 30 + + + + + + + + + 15 + + + + + + ${carbon.home}/repository/deployment/server/ + + + 15 + + + ${carbon.home}/repository/conf/axis2/axis2.xml + + + 30000 + + + ${carbon.home}/repository/deployment/client/ + + ${carbon.home}/repository/conf/axis2/axis2_client.xml + + true + + + + + + + + + + admin + Default Administrator Role + + + user + Default User Role + + + + + + + + + + + + ${carbon.home}/repository/resources/security/wso2carbon.jks + + JKS + + wso2carbon + + wso2carbon + + wso2carbon + + + + + + ${carbon.home}/repository/resources/security/client-truststore.jks + + JKS + + wso2carbon + + + + + + + + + + + + + + + + + + + UserManager + + + false + + org.wso2.carbon.identity.provider.AttributeCallbackHandler + + + org.wso2.carbon.identity.sts.store.DBTokenStore + + + true + allow + + + + + + +claim_mgt_menu +identity_mgt_emailtemplate_menu +identity_security_questions_menu + + + + ${carbon.home}/tmp/work + + + + + + true + + + 10 + + + 30 + + + + + + 100 + + + + keystore + certificate + * + + org.wso2.carbon.ui.transports.fileupload.AnyFileUploadExecutor + + + + + jarZip + + org.wso2.carbon.ui.transports.fileupload.JarZipUploadExecutor + + + + dbs + + org.wso2.carbon.ui.transports.fileupload.DBSFileUploadExecutor + + + + tools + + org.wso2.carbon.ui.transports.fileupload.ToolsFileUploadExecutor + + + + toolsAny + + org.wso2.carbon.ui.transports.fileupload.ToolsAnyFileUploadExecutor + + + + + + + + + + info + org.wso2.carbon.core.transports.util.InfoProcessor + + + wsdl + org.wso2.carbon.core.transports.util.Wsdl11Processor + + + wsdl2 + org.wso2.carbon.core.transports.util.Wsdl20Processor + + + xsd + org.wso2.carbon.core.transports.util.XsdProcessor + + + + + + false + false + true + svn + http://svnrepo.example.com/repos/ + username + password + true + + + + + + + + + + + + + + + ${require.carbon.servlet} + + + + + true + + + + + + + default repository + http://product-dist.wso2.com/p2/carbon/releases/wilkes/ + + + + + + + + true + + + + + + true + + diff --git a/pom.xml b/pom.xml index 6cc4a4b27..be0c1cb59 100644 --- a/pom.xml +++ b/pom.xml @@ -268,6 +268,11 @@ commons-collections ${apache.common.collection.version} + + org.wso2.carbon.identity.framework + org.wso2.carbon.identity.central.log.mgt + ${carbon.identity.framework.version} +