From 30ee88854181d25a8e702979db42cbaab70a173c Mon Sep 17 00:00:00 2001 From: Thisara-Welmilla Date: Mon, 16 Oct 2023 11:07:38 +0530 Subject: [PATCH] Fix resolving tenant domain issue. --- .../application/v1/core/ApplicationService.java | 5 +++-- .../association/v1/impl/MeApiServiceImpl.java | 4 ++-- .../association/v1/impl/UserIdApiServiceImpl.java | 4 ++-- .../apps/v1/impl/UserIdApiServiceImpl.java | 4 ++-- .../apps/v2/core/AuthorizedAppsService.java | 2 +- .../apps/v2/impl/UserIdApiServiceImpl.java | 4 ++-- .../challenge/v1/core/UserChallengeService.java | 4 ++-- .../challenge/v1/impl/UserIdApiServiceImpl.java | 4 ++-- .../identity/api/user/common/ContextLoader.java | 15 +++++++++++---- .../idv/v1/core/IdentityVerificationService.java | 2 +- .../rest/api/user/mfa/v1/core/MFAService.java | 2 +- .../session/v1/impl/SessionsApiServiceImpl.java | 4 ++-- .../session/v1/impl/UserIdApiServiceImpl.java | 9 +++++---- 13 files changed, 36 insertions(+), 27 deletions(-) diff --git a/components/org.wso2.carbon.identity.api.user.application/org.wso2.carbon.identity.rest.api.user.application.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/application/v1/core/ApplicationService.java b/components/org.wso2.carbon.identity.api.user.application/org.wso2.carbon.identity.rest.api.user.application.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/application/v1/core/ApplicationService.java index ad31aa0ad..056e8f30d 100644 --- a/components/org.wso2.carbon.identity.api.user.application/org.wso2.carbon.identity.rest.api.user.application.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/application/v1/core/ApplicationService.java +++ b/components/org.wso2.carbon.identity.api.user.application/org.wso2.carbon.identity.rest.api.user.application.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/application/v1/core/ApplicationService.java @@ -33,6 +33,7 @@ import org.wso2.carbon.identity.core.model.ExpressionNode; import org.wso2.carbon.identity.core.model.FilterTreeBuilder; import org.wso2.carbon.identity.core.model.Node; +import org.wso2.carbon.identity.core.util.IdentityTenantUtil; import org.wso2.carbon.identity.rest.api.user.application.v1.core.function.ApplicationBasicInfoToApiModel; import org.wso2.carbon.identity.rest.api.user.application.v1.model.ApplicationListResponse; import org.wso2.carbon.identity.rest.api.user.application.v1.model.ApplicationResponse; @@ -71,7 +72,7 @@ public ApplicationResponse getApplication(String applicationId) { try { - String tenantDomain = ContextLoader.getTenantDomainFromContext(); + String tenantDomain = IdentityTenantUtil.resolveTenantDomain(); ApplicationBasicInfo applicationBasicInfo = ApplicationServiceHolder.getDiscoverableApplicationManager() .getDiscoverableApplicationBasicInfoByResourceId(applicationId, tenantDomain); if (applicationBasicInfo == null) { @@ -104,7 +105,7 @@ public ApplicationListResponse getApplications(String attributes, Integer limit, handleNotImplementedCapabilities(attributes, sortOrder, sortBy); - String tenantDomain = ContextLoader.getTenantDomainFromContext(); + String tenantDomain = IdentityTenantUtil.resolveTenantDomain(); String filterFormatted = buildFilter(filter); try { List applicationBasicInfos = ApplicationServiceHolder diff --git a/components/org.wso2.carbon.identity.api.user.association/org.wso2.carbon.identity.api.user.association.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/association/v1/impl/MeApiServiceImpl.java b/components/org.wso2.carbon.identity.api.user.association/org.wso2.carbon.identity.api.user.association.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/association/v1/impl/MeApiServiceImpl.java index 1493c5e1c..3c9aae993 100644 --- a/components/org.wso2.carbon.identity.api.user.association/org.wso2.carbon.identity.api.user.association.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/association/v1/impl/MeApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.user.association/org.wso2.carbon.identity.api.user.association.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/association/v1/impl/MeApiServiceImpl.java @@ -2,9 +2,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.identity.api.user.common.ContextLoader; import org.wso2.carbon.identity.api.user.common.function.UniqueIdToUser; import org.wso2.carbon.identity.application.common.model.User; +import org.wso2.carbon.identity.core.util.IdentityTenantUtil; import org.wso2.carbon.identity.rest.api.user.association.v1.MeApiService; import org.wso2.carbon.identity.rest.api.user.association.v1.core.UserAssociationService; import org.wso2.carbon.identity.rest.api.user.association.v1.dto.AssociationUserRequestDTO; @@ -86,7 +86,7 @@ private String getFullyQualifiedUsernameFromContext() { private String getFullyQualifiedUserName(String userId) { User user = new UniqueIdToUser().apply(UserAssociationServiceHolder.getRealmService(), userId, - ContextLoader.getTenantDomainFromContext()); + IdentityTenantUtil.resolveTenantDomain()); return user.toFullQualifiedUsername(); } diff --git a/components/org.wso2.carbon.identity.api.user.association/org.wso2.carbon.identity.api.user.association.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/association/v1/impl/UserIdApiServiceImpl.java b/components/org.wso2.carbon.identity.api.user.association/org.wso2.carbon.identity.api.user.association.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/association/v1/impl/UserIdApiServiceImpl.java index f6f848546..e24bcb400 100644 --- a/components/org.wso2.carbon.identity.api.user.association/org.wso2.carbon.identity.api.user.association.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/association/v1/impl/UserIdApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.user.association/org.wso2.carbon.identity.api.user.association.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/association/v1/impl/UserIdApiServiceImpl.java @@ -1,9 +1,9 @@ package org.wso2.carbon.identity.rest.api.user.association.v1.impl; import org.springframework.beans.factory.annotation.Autowired; -import org.wso2.carbon.identity.api.user.common.ContextLoader; import org.wso2.carbon.identity.api.user.common.function.UniqueIdToUser; import org.wso2.carbon.identity.application.common.model.User; +import org.wso2.carbon.identity.core.util.IdentityTenantUtil; import org.wso2.carbon.identity.rest.api.user.association.v1.UserIdApiService; import org.wso2.carbon.identity.rest.api.user.association.v1.core.UserAssociationService; import org.wso2.carbon.identity.rest.api.user.association.v1.util.UserAssociationServiceHolder; @@ -34,7 +34,7 @@ public Response userIdAssociationsGet(String userId) { private String getUser(String userId) { User user = new UniqueIdToUser().apply(UserAssociationServiceHolder.getRealmService(), userId, - ContextLoader.getTenantDomainFromContext()); + IdentityTenantUtil.resolveTenantDomain()); return user.toFullQualifiedUsername(); } diff --git a/components/org.wso2.carbon.identity.api.user.authorized.apps/org.wso2.carbon.identity.rest.api.user.authorized.apps.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/authorized/apps/v1/impl/UserIdApiServiceImpl.java b/components/org.wso2.carbon.identity.api.user.authorized.apps/org.wso2.carbon.identity.rest.api.user.authorized.apps.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/authorized/apps/v1/impl/UserIdApiServiceImpl.java index 7fd380298..17a1230a7 100644 --- a/components/org.wso2.carbon.identity.api.user.authorized.apps/org.wso2.carbon.identity.rest.api.user.authorized.apps.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/authorized/apps/v1/impl/UserIdApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.user.authorized.apps/org.wso2.carbon.identity.rest.api.user.authorized.apps.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/authorized/apps/v1/impl/UserIdApiServiceImpl.java @@ -18,9 +18,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.identity.api.user.common.ContextLoader; import org.wso2.carbon.identity.api.user.common.function.UniqueIdToUser; import org.wso2.carbon.identity.application.common.model.User; +import org.wso2.carbon.identity.core.util.IdentityTenantUtil; import org.wso2.carbon.identity.rest.api.user.authorized.apps.v1.UserIdApiService; import org.wso2.carbon.identity.rest.api.user.authorized.apps.v1.core.AuthorizedAppsService; import org.wso2.carbon.identity.rest.api.user.authorized.apps.v1.dto.AuthorizedAppDTO; @@ -74,6 +74,6 @@ public Response listUserAuthorizedAppsByAppId(String userId, String applicationI private User getUser(String userId) { - return new UniqueIdToUser().apply(realmService, userId, ContextLoader.getTenantDomainFromContext()); + return new UniqueIdToUser().apply(realmService, userId, IdentityTenantUtil.resolveTenantDomain()); } } diff --git a/components/org.wso2.carbon.identity.api.user.authorized.apps/org.wso2.carbon.identity.rest.api.user.authorized.apps.v2/src/main/java/org/wso2/carbon/identity/rest/api/user/authorized/apps/v2/core/AuthorizedAppsService.java b/components/org.wso2.carbon.identity.api.user.authorized.apps/org.wso2.carbon.identity.rest.api.user.authorized.apps.v2/src/main/java/org/wso2/carbon/identity/rest/api/user/authorized/apps/v2/core/AuthorizedAppsService.java index 85d87ae26..e89dc942f 100644 --- a/components/org.wso2.carbon.identity.api.user.authorized.apps/org.wso2.carbon.identity.rest.api.user.authorized.apps.v2/src/main/java/org/wso2/carbon/identity/rest/api/user/authorized/apps/v2/core/AuthorizedAppsService.java +++ b/components/org.wso2.carbon.identity.api.user.authorized.apps/org.wso2.carbon.identity.rest.api.user.authorized.apps.v2/src/main/java/org/wso2/carbon/identity/rest/api/user/authorized/apps/v2/core/AuthorizedAppsService.java @@ -234,7 +234,7 @@ public List listUserAuthorizedApps(User user) { */ public void deleteIssuedTokensByAppId(String applicationId) { - String tenantDomain = ContextLoader.getTenantDomainFromContext(); + String tenantDomain = IdentityTenantUtil.resolveTenantDomain(); ServiceProvider application = getServiceProvider(applicationId, tenantDomain); // Extract the inbound authentication request config for the given inbound type. diff --git a/components/org.wso2.carbon.identity.api.user.authorized.apps/org.wso2.carbon.identity.rest.api.user.authorized.apps.v2/src/main/java/org/wso2/carbon/identity/rest/api/user/authorized/apps/v2/impl/UserIdApiServiceImpl.java b/components/org.wso2.carbon.identity.api.user.authorized.apps/org.wso2.carbon.identity.rest.api.user.authorized.apps.v2/src/main/java/org/wso2/carbon/identity/rest/api/user/authorized/apps/v2/impl/UserIdApiServiceImpl.java index abaefee18..23974d1da 100644 --- a/components/org.wso2.carbon.identity.api.user.authorized.apps/org.wso2.carbon.identity.rest.api.user.authorized.apps.v2/src/main/java/org/wso2/carbon/identity/rest/api/user/authorized/apps/v2/impl/UserIdApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.user.authorized.apps/org.wso2.carbon.identity.rest.api.user.authorized.apps.v2/src/main/java/org/wso2/carbon/identity/rest/api/user/authorized/apps/v2/impl/UserIdApiServiceImpl.java @@ -18,9 +18,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.identity.api.user.common.ContextLoader; import org.wso2.carbon.identity.api.user.common.function.UniqueIdToUser; import org.wso2.carbon.identity.application.common.model.User; +import org.wso2.carbon.identity.core.util.IdentityTenantUtil; import org.wso2.carbon.identity.rest.api.user.authorized.apps.v2.UserIdApiService; import org.wso2.carbon.identity.rest.api.user.authorized.apps.v2.core.AuthorizedAppsService; import org.wso2.carbon.identity.rest.api.user.authorized.apps.v2.dto.AuthorizedAppDTO; @@ -75,6 +75,6 @@ public Response listUserAuthorizedAppsByAppId(String userId, String applicationI private User getUser(String userId) { - return new UniqueIdToUser().apply(realmService, userId, ContextLoader.getTenantDomainFromContext()); + return new UniqueIdToUser().apply(realmService, userId, IdentityTenantUtil.resolveTenantDomain()); } } diff --git a/components/org.wso2.carbon.identity.api.user.challenge/org.wso2.carbon.identity.rest.api.user.challenge.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/challenge/v1/core/UserChallengeService.java b/components/org.wso2.carbon.identity.api.user.challenge/org.wso2.carbon.identity.rest.api.user.challenge.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/challenge/v1/core/UserChallengeService.java index cfd92ff93..003936bcc 100644 --- a/components/org.wso2.carbon.identity.api.user.challenge/org.wso2.carbon.identity.rest.api.user.challenge.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/challenge/v1/core/UserChallengeService.java +++ b/components/org.wso2.carbon.identity.api.user.challenge/org.wso2.carbon.identity.rest.api.user.challenge.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/challenge/v1/core/UserChallengeService.java @@ -21,10 +21,10 @@ import org.wso2.carbon.identity.api.user.challenge.common.ChallengeQuestionServiceHolder; import org.wso2.carbon.identity.api.user.challenge.common.Constant; import org.wso2.carbon.identity.api.user.common.Constants; -import org.wso2.carbon.identity.api.user.common.ContextLoader; import org.wso2.carbon.identity.api.user.common.error.APIError; import org.wso2.carbon.identity.api.user.common.error.ErrorResponse; import org.wso2.carbon.identity.application.common.model.User; +import org.wso2.carbon.identity.core.util.IdentityTenantUtil; import org.wso2.carbon.identity.recovery.IdentityRecoveryClientException; import org.wso2.carbon.identity.recovery.IdentityRecoveryException; import org.wso2.carbon.identity.recovery.model.ChallengeQuestion; @@ -65,7 +65,7 @@ public List getChallengesForUser(User user, Integer offset, Int try { return buildChallengesDTO(ChallengeQuestionServiceHolder.getChallengeQuestionManager() - .getAllChallengeQuestionsForUser(ContextLoader.getTenantDomainFromContext(), user), offset, limit); + .getAllChallengeQuestionsForUser(IdentityTenantUtil.resolveTenantDomain(), user), offset, limit); } catch (IdentityRecoveryException e) { throw handleIdentityRecoveryException(e, Constant.ErrorMessage.ERROR_CODE_ERROR_RETRIEVING_CHALLENGES_FOR_USER); diff --git a/components/org.wso2.carbon.identity.api.user.challenge/org.wso2.carbon.identity.rest.api.user.challenge.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/challenge/v1/impl/UserIdApiServiceImpl.java b/components/org.wso2.carbon.identity.api.user.challenge/org.wso2.carbon.identity.rest.api.user.challenge.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/challenge/v1/impl/UserIdApiServiceImpl.java index fb5fa5814..82bdc7cfa 100644 --- a/components/org.wso2.carbon.identity.api.user.challenge/org.wso2.carbon.identity.rest.api.user.challenge.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/challenge/v1/impl/UserIdApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.user.challenge/org.wso2.carbon.identity.rest.api.user.challenge.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/challenge/v1/impl/UserIdApiServiceImpl.java @@ -20,9 +20,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.wso2.carbon.identity.api.user.challenge.common.ChallengeQuestionServiceHolder; -import org.wso2.carbon.identity.api.user.common.ContextLoader; import org.wso2.carbon.identity.api.user.common.function.UniqueIdToUser; import org.wso2.carbon.identity.application.common.model.User; +import org.wso2.carbon.identity.core.util.IdentityTenantUtil; import org.wso2.carbon.identity.rest.api.user.challenge.v1.UserIdApiService; import org.wso2.carbon.identity.rest.api.user.challenge.v1.core.UserChallengeService; import org.wso2.carbon.identity.rest.api.user.challenge.v1.dto.ChallengeAnswerDTO; @@ -108,6 +108,6 @@ private URI getUserChallengeAnswersLocation(String userId) { private User getUser(String userId) { return new UniqueIdToUser().apply(ChallengeQuestionServiceHolder.getRealmService(), userId, - ContextLoader.getTenantDomainFromContext()); + IdentityTenantUtil.resolveTenantDomain()); } } diff --git a/components/org.wso2.carbon.identity.api.user.common/src/main/java/org/wso2/carbon/identity/api/user/common/ContextLoader.java b/components/org.wso2.carbon.identity.api.user.common/src/main/java/org/wso2/carbon/identity/api/user/common/ContextLoader.java index e5d2d86df..95f4b81d9 100644 --- a/components/org.wso2.carbon.identity.api.user.common/src/main/java/org/wso2/carbon/identity/api/user/common/ContextLoader.java +++ b/components/org.wso2.carbon.identity.api.user.common/src/main/java/org/wso2/carbon/identity/api/user/common/ContextLoader.java @@ -19,6 +19,7 @@ import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.identity.api.user.common.error.APIError; @@ -27,6 +28,7 @@ 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.user.api.UserRealm; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.core.UserStoreConfigConstants; @@ -38,6 +40,7 @@ import static org.wso2.carbon.identity.api.user.common.Constants.ErrorMessage.ERROR_CODE_INVALID_USERNAME; import static org.wso2.carbon.identity.api.user.common.Constants.ErrorMessage.ERROR_CODE_SERVER_ERROR; import static org.wso2.carbon.identity.api.user.common.Constants.TENANT_CONTEXT_PATH_COMPONENT; +import static org.wso2.carbon.identity.api.user.common.Constants.TENANT_NAME_FROM_CONTEXT; import static org.wso2.carbon.identity.api.user.common.Constants.USER_API_PATH_COMPONENT; import static org.wso2.carbon.identity.application.common.util.IdentityApplicationConstants.Error.UNEXPECTED_SERVER_ERROR; @@ -54,7 +57,11 @@ public class ContextLoader { */ public static String getTenantDomainFromContext() { - return IdentityTenantUtil.resolveTenantDomain(); + String tenantDomain = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME; + if (IdentityUtil.threadLocalProperties.get().get(TENANT_NAME_FROM_CONTEXT) != null) { + tenantDomain = (String) IdentityUtil.threadLocalProperties.get().get(TENANT_NAME_FROM_CONTEXT); + } + return tenantDomain; } /** @@ -72,7 +79,7 @@ public static String getUsernameFromContext() { */ public static User getUserFromContext() { - return getUser(getTenantDomainFromContext(), getUsernameFromContext()); + return getUser(IdentityTenantUtil.resolveTenantDomain(), getUsernameFromContext()); } @@ -159,7 +166,7 @@ public static org.wso2.carbon.identity.application.common.model.User getUser(org public static URI buildURI(String endpoint) { String tenantQualifiedRelativePath = - String.format(TENANT_CONTEXT_PATH_COMPONENT, getTenantDomainFromContext()) + USER_API_PATH_COMPONENT; + String.format(TENANT_CONTEXT_PATH_COMPONENT, IdentityTenantUtil.resolveTenantDomain()) + USER_API_PATH_COMPONENT; String url = tenantQualifiedRelativePath + endpoint; return URI.create(url); } @@ -221,7 +228,7 @@ private static String getContext(String endpoint) { if (IdentityTenantUtil.isTenantQualifiedUrlsEnabled()) { context = USER_API_PATH_COMPONENT + endpoint; } else { - context = String.format(TENANT_CONTEXT_PATH_COMPONENT, getTenantDomainFromContext()) + + context = String.format(TENANT_CONTEXT_PATH_COMPONENT, IdentityTenantUtil.resolveTenantDomain()) + USER_API_PATH_COMPONENT + endpoint; } return context; diff --git a/components/org.wso2.carbon.identity.api.user.idv/org.wso2.carbon.identity.api.user.idv.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/idv/v1/core/IdentityVerificationService.java b/components/org.wso2.carbon.identity.api.user.idv/org.wso2.carbon.identity.api.user.idv.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/idv/v1/core/IdentityVerificationService.java index 3cc972937..b5c35cc9d 100644 --- a/components/org.wso2.carbon.identity.api.user.idv/org.wso2.carbon.identity.api.user.idv.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/idv/v1/core/IdentityVerificationService.java +++ b/components/org.wso2.carbon.identity.api.user.idv/org.wso2.carbon.identity.api.user.idv.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/idv/v1/core/IdentityVerificationService.java @@ -415,7 +415,7 @@ private String includeData(Constants.ErrorMessage error, String data) { private int getTenantId() { - String tenantDomain = ContextLoader.getTenantDomainFromContext(); + String tenantDomain = IdentityTenantUtil.resolveTenantDomain(); if (StringUtils.isBlank(tenantDomain)) { throw handleException( Response.Status.INTERNAL_SERVER_ERROR, diff --git a/components/org.wso2.carbon.identity.api.user.mfa/org.wso2.carbon.identity.api.user.mfa.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/mfa/v1/core/MFAService.java b/components/org.wso2.carbon.identity.api.user.mfa/org.wso2.carbon.identity.api.user.mfa.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/mfa/v1/core/MFAService.java index 1f6bb2ebc..897c11d1f 100644 --- a/components/org.wso2.carbon.identity.api.user.mfa/org.wso2.carbon.identity.api.user.mfa.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/mfa/v1/core/MFAService.java +++ b/components/org.wso2.carbon.identity.api.user.mfa/org.wso2.carbon.identity.api.user.mfa.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/mfa/v1/core/MFAService.java @@ -148,7 +148,7 @@ private String getUserName() { private String getTenantDomain() { - return ContextLoader.getTenantDomainFromContext(); + return IdentityTenantUtil.resolveTenantDomain(); } /** diff --git a/components/org.wso2.carbon.identity.api.user.session/org.wso2.carbon.identity.api.user.session.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/session/v1/impl/SessionsApiServiceImpl.java b/components/org.wso2.carbon.identity.api.user.session/org.wso2.carbon.identity.api.user.session.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/session/v1/impl/SessionsApiServiceImpl.java index 287727a74..2d59ca517 100644 --- a/components/org.wso2.carbon.identity.api.user.session/org.wso2.carbon.identity.api.user.session.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/session/v1/impl/SessionsApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.user.session/org.wso2.carbon.identity.api.user.session.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/session/v1/impl/SessionsApiServiceImpl.java @@ -17,7 +17,7 @@ package org.wso2.carbon.identity.rest.api.user.session.v1.impl; import org.springframework.beans.factory.annotation.Autowired; -import org.wso2.carbon.identity.api.user.common.ContextLoader; +import org.wso2.carbon.identity.core.util.IdentityTenantUtil; import org.wso2.carbon.identity.rest.api.user.session.v1.SessionsApiService; import org.wso2.carbon.identity.rest.api.user.session.v1.core.SessionManagementService; import org.wso2.carbon.identity.rest.api.user.session.v1.dto.SearchResponseDTO; @@ -35,7 +35,7 @@ public class SessionsApiServiceImpl extends SessionsApiService { @Override public Response getSessions(String filter, Integer limit, Long since, Long until) { - SearchResponseDTO responseDTO = sessionManagementService.getSessions(ContextLoader.getTenantDomainFromContext(), + SearchResponseDTO responseDTO = sessionManagementService.getSessions(IdentityTenantUtil.resolveTenantDomain(), filter, limit, since, until); return Response.ok().entity(responseDTO).build(); diff --git a/components/org.wso2.carbon.identity.api.user.session/org.wso2.carbon.identity.api.user.session.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/session/v1/impl/UserIdApiServiceImpl.java b/components/org.wso2.carbon.identity.api.user.session/org.wso2.carbon.identity.api.user.session.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/session/v1/impl/UserIdApiServiceImpl.java index 2f78c03fd..a97065d9a 100644 --- a/components/org.wso2.carbon.identity.api.user.session/org.wso2.carbon.identity.api.user.session.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/session/v1/impl/UserIdApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.user.session/org.wso2.carbon.identity.api.user.session.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/session/v1/impl/UserIdApiServiceImpl.java @@ -26,6 +26,7 @@ import org.wso2.carbon.identity.api.user.common.ContextLoader; import org.wso2.carbon.identity.api.user.common.Util; import org.wso2.carbon.identity.api.user.session.common.util.SessionManagementServiceHolder; +import org.wso2.carbon.identity.core.util.IdentityTenantUtil; import org.wso2.carbon.identity.rest.api.user.session.v1.UserIdApiService; import org.wso2.carbon.identity.rest.api.user.session.v1.core.SessionManagementService; import org.wso2.carbon.identity.rest.api.user.session.v1.dto.SessionDTO; @@ -52,7 +53,7 @@ public class UserIdApiServiceImpl extends UserIdApiService { public Response getSessionBySessionId(String userId, String sessionId) { Util.validateUserId(SessionManagementServiceHolder.getRealmService(), userId, - ContextLoader.getTenantDomainFromContext()); + IdentityTenantUtil.resolveTenantDomain()); Optional session = sessionManagementService.getSessionBySessionId(userId, sessionId); if (session.isPresent()) { @@ -66,7 +67,7 @@ public Response getSessionBySessionId(String userId, String sessionId) { public Response getSessionsByUserId(String userId, Integer limit, Integer offset, String filter, String sort) { Util.validateUserId(SessionManagementServiceHolder.getRealmService(), userId, - ContextLoader.getTenantDomainFromContext()); + IdentityTenantUtil.resolveTenantDomain()); SessionsDTO sessionsOfUser = sessionManagementService.getSessionsByUserId(userId, limit, offset, filter, sort); if (sessionsOfUser == null || sessionsOfUser.getSessions().isEmpty()) { @@ -80,7 +81,7 @@ public Response getSessionsByUserId(String userId, Integer limit, Integer offset public Response terminateSessionBySessionId(String userId, String sessionId) { Util.validateUserId(SessionManagementServiceHolder.getRealmService(), userId, - ContextLoader.getTenantDomainFromContext()); + IdentityTenantUtil.resolveTenantDomain()); sessionManagementService.terminateSessionBySessionId(userId, sessionId); return Response.noContent().build(); } @@ -112,7 +113,7 @@ public Response terminateSessionsByUserId(String userId) { } Util.validateUserId(SessionManagementServiceHolder.getRealmService(), userId, - ContextLoader.getTenantDomainFromContext()); + IdentityTenantUtil.resolveTenantDomain()); sessionManagementService.terminateSessionsByUserId(userId); return Response.noContent().build(); } catch (UserStoreException e) {