Skip to content

Commit

Permalink
New method to get tenant when tenant qualified url enabled.
Browse files Browse the repository at this point in the history
  • Loading branch information
Thisara-Welmilla committed Oct 10, 2023
1 parent eeec4d0 commit e70b7ea
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,26 @@ public static String getTenantDomainFromContext() {
return (String) IdentityUtil.threadLocalProperties.get().get(IdentityCoreConstants.TENANT_NAME_FROM_CONTEXT);
}

/**
* Get the tenant name from the thread local properties if available, otherwise get from the
* privileged carbon context.
*
* @return Tenant domain name.
*/
public static String resolveTenantDomain() {

String tenantDomain = IdentityTenantUtil.getTenantDomainFromContext();
if (StringUtils.isBlank(tenantDomain)) {
if (log.isDebugEnabled()) {
log.debug("The tenant domain is not set to the thread local. Hence using the tenant domain from the " +
"privileged carbon context.");
}
return PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
}

return tenantDomain;
}

/**
* Get the login tenant id.
* First it gets the tenant domain from the thread local properties. If empty, retrieve it from thread local
Expand Down

0 comments on commit e70b7ea

Please sign in to comment.