Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ThaminduDilshan committed Jun 17, 2023
1 parent 71bc091 commit 8c3f719
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
import static org.apache.commons.lang.StringUtils.isNotBlank;
import static org.wso2.carbon.identity.oauth.endpoint.util.EndpointUtil.parseJsonTokenRequest;
import static org.wso2.carbon.identity.oauth.endpoint.util.EndpointUtil.startSuperTenantFlow;
import static org.wso2.carbon.identity.oauth.endpoint.util.EndpointUtil.startTenantFlow;
import static org.wso2.carbon.identity.oauth.endpoint.util.EndpointUtil.triggerOnTokenExceptionListeners;
import static org.wso2.carbon.identity.oauth.endpoint.util.EndpointUtil.validateOauthApplication;
import static org.wso2.carbon.identity.oauth.endpoint.util.EndpointUtil.validateParams;
Expand All @@ -91,9 +90,8 @@ public Response issueAccessToken(@Context HttpServletRequest request, String pay

Map<String, List<String>> paramMap;
try {
if (IdentityTenantUtil.isTenantQualifiedUrlsEnabled()) {
startTenantFlow();
} else {
// Start super tenant flow only if tenant qualified URLs are disabled.
if (!IdentityTenantUtil.isTenantQualifiedUrlsEnabled()) {
startSuperTenantFlow();
}
paramMap = parseJsonTokenRequest(payload);
Expand All @@ -110,7 +108,9 @@ public Response issueAccessToken(@Context HttpServletRequest request, String pay
triggerOnTokenExceptionListeners(e, request, null);
throw e;
} finally {
PrivilegedCarbonContext.endTenantFlow();
if (!IdentityTenantUtil.isTenantQualifiedUrlsEnabled()) {
PrivilegedCarbonContext.endTenantFlow();
}
}
return issueAccessToken(request, paramMap);
}
Expand Down Expand Up @@ -139,9 +139,8 @@ protected Response issueAccessToken(HttpServletRequest request, Map<String, List
OAuthSystemException, InvalidRequestParentException {

try {
if (IdentityTenantUtil.isTenantQualifiedUrlsEnabled()) {
startTenantFlow();
} else {
// Start super tenant flow only if tenant qualified URLs are disabled.
if (!IdentityTenantUtil.isTenantQualifiedUrlsEnabled()) {
startSuperTenantFlow();
}
validateRepeatedParams(request, paramMap);
Expand All @@ -167,7 +166,9 @@ protected Response issueAccessToken(HttpServletRequest request, Map<String, List
throw e;

} finally {
PrivilegedCarbonContext.endTenantFlow();
if (!IdentityTenantUtil.isTenantQualifiedUrlsEnabled()) {
PrivilegedCarbonContext.endTenantFlow();
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1420,19 +1420,6 @@ public static void startSuperTenantFlow() {
carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
}

/**
* This method will start a tenant flow.
*/
public static void startTenantFlow() {

int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
PrivilegedCarbonContext.startTenantFlow();
PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
carbonContext.setTenantId(tenantId);
carbonContext.setTenantDomain(tenantDomain);
}

/**
* This API validate the oauth application. Check whether an application exits for given cosumerKey and check
* it's status
Expand Down

0 comments on commit 8c3f719

Please sign in to comment.