Skip to content

Commit

Permalink
INTGW-584 - code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
SkNuwanTissera authored and jaadds committed Jun 28, 2019
1 parent 7feb13e commit a6f8a40
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ public boolean doPostUpdateCredential(String userName, Object credential, UserSt
log.debug("Username : "+ userName);
}

String threadLocalUsername = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
String threadTenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
final int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();

try {
startTenantFlow(userName);

Expand All @@ -91,7 +95,7 @@ public boolean doPostUpdateCredential(String userName, Object credential, UserSt
} catch (IdentityOAuthAdminException e) {
log.error("Error while Fetching application details ", e);
} finally {
endTenantFlow();
endTenantFlow(threadLocalUsername, threadTenantDomain,tenantId);
}

return true;
Expand Down Expand Up @@ -146,11 +150,7 @@ private OAuthClientAuthnContext getOAuthClientAuthnContext(OAuthConsumerAppDTO o
return oAuthClientAuthnContext;
}

private void endTenantFlow() {
String threadLocalUsername = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
String threadTenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
final int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();

private void endTenantFlow(String threadLocalUsername, String threadTenantDomain, int tenantId) {
PrivilegedCarbonContext.endTenantFlow();
PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(threadLocalUsername);
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(threadTenantDomain);
Expand Down

0 comments on commit a6f8a40

Please sign in to comment.