From 3c5a3adc2fc874bae51215f2b60284a58e9bd4a2 Mon Sep 17 00:00:00 2001 From: prabathabey Date: Tue, 26 May 2015 17:08:38 +0530 Subject: [PATCH] Fixing failures prompted while invoking APIs that are OAuth protected --- .../framework/AuthenticationFrameworkUtil.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/AuthenticationFrameworkUtil.java b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/AuthenticationFrameworkUtil.java index c0728d5c9a..d4a61e570a 100644 --- a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/AuthenticationFrameworkUtil.java +++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/AuthenticationFrameworkUtil.java @@ -64,21 +64,21 @@ public class AuthenticationFrameworkUtil { APIKeyValidationInfoDTO apiKeyValidationDTO = tokenValidator.validateKey(context, version, accessToken, requiredAuthenticationLevel, clientDomain); if (apiKeyValidationDTO.isAuthorized()) { - String userName = apiKeyValidationDTO.getEndUserName(); - PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(userName); + String username = apiKeyValidationDTO.getEndUserName(); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(username); try { PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId( - IdentityUtil.getTenantIdOFUser(userName)); + IdentityUtil.getTenantIdOFUser(username)); } catch (IdentityException e) { throw new AuthenticationException("Error occurred while retrieving the tenant ID of user '" + - userName + "'", e); + username + "'", e); } + return true; } else { throw new AuthenticationException(apiKeyValidationDTO.getValidationStatus(), "Access failure for API: " + context + ", version: " + version + " with key: " + accessToken); } - return false; } public static void handleResponse(Request request, Response response, int statusCode, String payload) {