Skip to content

Commit

Permalink
Improve sub org application creation when accessing through tenant pe…
Browse files Browse the repository at this point in the history
…rspective
  • Loading branch information
ShanChathusanda93 committed Nov 30, 2024
1 parent 3833c81 commit c16a54c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,23 +131,26 @@ public boolean isEnable() {
public boolean doPreCreateApplication(ServiceProvider serviceProvider, String tenantDomain, String userName)
throws IdentityApplicationManagementException {

try {
String organizationId = getOrganizationManager().resolveOrganizationId(tenantDomain);
int organizationDepthInHierarchy =
getOrganizationManager().getOrganizationDepthInHierarchy(organizationId);
if (isSubOrganization(organizationDepthInHierarchy) &&
!isSharedAppFromInternalProcess(serviceProvider, tenantDomain)) {
throw new IdentityApplicationManagementClientException(
ERROR_CODE_SUB_ORG_CANNOT_CREATE_APP.getCode(),
ERROR_CODE_SUB_ORG_CANNOT_CREATE_APP.getMessage());
}
} catch (OrganizationManagementClientException e) {
if (LOG.isDebugEnabled()) {
LOG.debug("Organization not found for the tenant: " + tenantDomain);
if (StringUtils.isEmpty(PrivilegedCarbonContext.getThreadLocalCarbonContext()
.getApplicationResidentOrganizationId())) {
try {
String organizationId = getOrganizationManager().resolveOrganizationId(tenantDomain);
int organizationDepthInHierarchy =
getOrganizationManager().getOrganizationDepthInHierarchy(organizationId);
if (isSubOrganization(organizationDepthInHierarchy) &&
!isSharedAppFromInternalProcess(serviceProvider, tenantDomain)) {
throw new IdentityApplicationManagementClientException(
ERROR_CODE_SUB_ORG_CANNOT_CREATE_APP.getCode(),
ERROR_CODE_SUB_ORG_CANNOT_CREATE_APP.getMessage());
}
} catch (OrganizationManagementClientException e) {
if (LOG.isDebugEnabled()) {
LOG.debug("Organization not found for the tenant: " + tenantDomain);
}
} catch (OrganizationManagementException e) {
throw new IdentityApplicationManagementException(
"An error occurred while getting depth of the organization", e);
}
} catch (OrganizationManagementException e) {
throw new IdentityApplicationManagementException(
"An error occurred while getting depth of the organization", e);
}
return true;
}
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -502,9 +502,9 @@
<properties>

<!-- Carbon kernel version -->
<carbon.kernel.version>4.9.17</carbon.kernel.version>
<carbon.kernel.package.import.version.range>[4.7.0, 5.0.0)</carbon.kernel.package.import.version.range>
<carbon.kernel.feature.version>4.6.0</carbon.kernel.feature.version>
<carbon.kernel.version>4.10.25</carbon.kernel.version>
<carbon.kernel.package.import.version.range>[4.10.0, 5.0.0)</carbon.kernel.package.import.version.range>
<carbon.kernel.feature.version>4.10.0</carbon.kernel.feature.version>

<carbon.commons.imp.pkg.version.range>[4.7.0, 5.0.0)</carbon.commons.imp.pkg.version.range>

Expand Down

0 comments on commit c16a54c

Please sign in to comment.