From 7b544f354513a597074f23b4589081300bf79ee1 Mon Sep 17 00:00:00 2001 From: Kamidu Sachith Date: Fri, 18 Dec 2015 15:26:26 +0530 Subject: [PATCH] Fix the disable failier of the authenticator --- .../backend/oauth/OauthAuthenticator.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/components/identity-extensions/backend-oauth-authenticator/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/OauthAuthenticator.java b/components/identity-extensions/backend-oauth-authenticator/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/OauthAuthenticator.java index 3696cd6cce..e468275232 100755 --- a/components/identity-extensions/backend-oauth-authenticator/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/OauthAuthenticator.java +++ b/components/identity-extensions/backend-oauth-authenticator/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/OauthAuthenticator.java @@ -59,14 +59,16 @@ public class OauthAuthenticator implements CarbonServerAuthenticator { */ public boolean isHandle(MessageContext messageContext) { HttpServletRequest httpServletRequest = getHttpRequest(messageContext); - String headerValue = httpServletRequest.getHeader(HTTPConstants.HEADER_AUTHORIZATION); - if (headerValue != null && !headerValue.trim().isEmpty()) { - String[] headerPart = headerValue.trim().split(OauthAuthenticatorConstants.SPLITING_CHARACTOR); - if (OauthAuthenticatorConstants.AUTHORIZATION_HEADER_PREFIX_BEARER.equals(headerPart[0])) { + if(httpServletRequest != null) { + String headerValue = httpServletRequest.getHeader(HTTPConstants.HEADER_AUTHORIZATION); + if (headerValue != null && !headerValue.trim().isEmpty()) { + String[] headerPart = headerValue.trim().split(OauthAuthenticatorConstants.SPLITING_CHARACTOR); + if (OauthAuthenticatorConstants.AUTHORIZATION_HEADER_PREFIX_BEARER.equals(headerPart[0])) { + return true; + } + } else if (httpServletRequest.getParameter(OauthAuthenticatorConstants.BEARER_TOKEN_IDENTIFIER) != null) { return true; } - } else if (httpServletRequest.getParameter(OauthAuthenticatorConstants.BEARER_TOKEN_IDENTIFIER) != null) { - return true; } return false; } @@ -134,7 +136,10 @@ public class OauthAuthenticator implements CarbonServerAuthenticator { * @return boolean true for enable or otherwise for disable status. */ public boolean isDisabled() { - return false; + AuthenticatorsConfiguration authenticatorsConfiguration = AuthenticatorsConfiguration.getInstance(); + AuthenticatorsConfiguration.AuthenticatorConfig authenticatorConfig = authenticatorsConfiguration. + getAuthenticatorConfig(OauthAuthenticatorConstants.AUTHENTICATOR_NAME); + return authenticatorConfig.isDisabled(); } /**