From 46c5f2534f2d0b76fdd827c007dbe79e8d2ec832 Mon Sep 17 00:00:00 2001 From: prabathabey Date: Thu, 3 Sep 2015 00:18:39 +0530 Subject: [PATCH] Fixing NoSuchElement exception thrown when standard context is accessed --- .../framework/WebappAuthenticationHandler.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/WebappAuthenticationHandler.java b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/WebappAuthenticationHandler.java index 698c1579b05..97683448320 100644 --- a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/WebappAuthenticationHandler.java +++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/WebappAuthenticationHandler.java @@ -64,14 +64,18 @@ public class WebappAuthenticationHandler extends CarbonTomcatValve { if (ctx == null || "".equals(ctx)) { ctx = request.getContextPath(); if (ctx == null || "".equals(ctx)) { + String requestUri = request.getRequestURI(); + if ("/".equals(requestUri)) { + return true; + } StringTokenizer tokenizer = new StringTokenizer(request.getRequestURI(), "/"); - ctx = tokenizer.nextToken(); - if (ctx == null || "".equals(ctx)) { - return false; + if (!tokenizer.hasMoreTokens()) { + return false; } + ctx = tokenizer.nextToken(); } } - return ctx.equalsIgnoreCase("carbon") || ctx.equalsIgnoreCase("services"); + return (ctx.equalsIgnoreCase("carbon") || ctx.equalsIgnoreCase("services")); } private void processResponse(Request request, Response response, CompositeValve compositeValve,