Skip to content

Commit

Permalink
Add instance type check to avoid ClassCastException
Browse files Browse the repository at this point in the history
  • Loading branch information
ZiyamSanthosh committed Nov 28, 2023
1 parent 5544b7e commit e673a7c
Showing 1 changed file with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,17 +163,21 @@ public void invoke(Request request, Response response) throws IOException, Servl
try {
AuthorizationResult authorizationResult = authorizationManager.authorize(authorizationContext);
if (authorizationResult.getAuthorizationStatus().equals(AuthorizationStatus.GRANT)) {
String authorizedOrganization = ((AuthenticatedUser)authorizationContext.getUser())
.getAccessingOrganization();
// Start tenant flow corresponds to the accessed organization.
if (StringUtils.isNotEmpty(authorizedOrganization)) {
try {
startOrganizationBoundTenantFlow(authorizedOrganization);
if (authorizationContext.getUser() instanceof AuthenticatedUser) {
String authorizedOrganization = ((AuthenticatedUser)authorizationContext.getUser())
.getAccessingOrganization();
// Start tenant flow corresponds to the accessed organization.
if (StringUtils.isNotEmpty(authorizedOrganization)) {
try {
startOrganizationBoundTenantFlow(authorizedOrganization);
getNext().invoke(request, response);
} finally {
PrivilegedCarbonContext.endTenantFlow();
IdentityUtil.threadLocalProperties.get()
.remove(OrganizationManagementConstants.ROOT_TENANT_DOMAIN);
}
} else {
getNext().invoke(request, response);
} finally {
PrivilegedCarbonContext.endTenantFlow();
IdentityUtil.threadLocalProperties.get()
.remove(OrganizationManagementConstants.ROOT_TENANT_DOMAIN);
}
} else {
getNext().invoke(request, response);
Expand Down

0 comments on commit e673a7c

Please sign in to comment.