Author: markt Date: Fri Jul 3 19:15:06 2015 New Revision: 1689067 URL: http://svn.apache.org/r1689067 Log: Added realm and login-config fields to FormAuthModule Patch by fjodorver
Modified: tomcat/trunk/java/org/apache/catalina/authenticator/jaspic/provider/modules/FormAuthModule.java Modified: tomcat/trunk/java/org/apache/catalina/authenticator/jaspic/provider/modules/FormAuthModule.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/authenticator/jaspic/provider/modules/FormAuthModule.java?rev=1689067&r1=1689066&r2=1689067&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/authenticator/jaspic/provider/modules/FormAuthModule.java (original) +++ tomcat/trunk/java/org/apache/catalina/authenticator/jaspic/provider/modules/FormAuthModule.java Fri Jul 3 19:15:06 2015 @@ -69,9 +69,14 @@ public class FormAuthModule extends Tomc private String landingPage; + private Realm realm; + private LoginConfig loginConfig; + public FormAuthModule(Context context) { super(context); + this.realm = context.getRealm(); + this.loginConfig = context.getLoginConfig(); } @@ -121,7 +126,7 @@ public class FormAuthModule extends Tomc handler.handle(new Callback[] { passwordCallback }); if (!passwordCallback.getResult()) { - forwardToErrorPage(request, response, context.getLoginConfig()); + forwardToErrorPage(request, response); } principal = getPrincipal(passwordCallback); if (principal != null) { @@ -153,7 +158,7 @@ public class FormAuthModule extends Tomc CallerPrincipalCallback principalCallback = new CallerPrincipalCallback(clientSubject, principal); GroupPrincipalCallback groupCallback = new GroupPrincipalCallback(clientSubject, - context.getRealm().getRoles(principal)); + realm.getRoles(principal)); handler.handle(new Callback[] { principalCallback, groupCallback }); // If we're caching principals we no longer needgetPrincipal the @@ -185,7 +190,6 @@ public class FormAuthModule extends Tomc boolean loginAction = requestURI.startsWith(contextPath) && requestURI.endsWith(Constants.FORM_ACTION); - LoginConfig config = context.getLoginConfig(); // No -- Save this request and redirect to the form login page if (!loginAction) { @@ -201,7 +205,7 @@ public class FormAuthModule extends Tomc sm.getString("authenticator.requestBodyTooBig")); return AuthStatus.FAILURE; } - forwardToLoginPage(request, response, config); + forwardToLoginPage(request, response); return AuthStatus.SEND_CONTINUE; } @@ -221,7 +225,7 @@ public class FormAuthModule extends Tomc } principal = realm.authenticate(username, password); if (principal == null) { - forwardToErrorPage(request, response, config); + forwardToErrorPage(request, response); return AuthStatus.FAILURE; } @@ -335,21 +339,18 @@ public class FormAuthModule extends Tomc * * @param request Request we are processing * @param response Response we are populating - * @param config Login configuration describing how authentication should be - * performed * @throws IOException If the forward to the login page fails and the call * to {@link HttpServletResponse#sendError(int, String)} throws * an {@link IOException} */ - protected void forwardToLoginPage(Request request, HttpServletResponse response, - LoginConfig config) throws IOException { + protected void forwardToLoginPage(Request request, HttpServletResponse response) throws IOException { if (log.isDebugEnabled()) { log.debug(sm.getString("formAuthenticator.forwardLogin", request.getRequestURI(), - request.getMethod(), config.getLoginPage(), context.getName())); + request.getMethod(), loginConfig.getLoginPage(), context.getName())); } - String loginPage = config.getLoginPage(); + String loginPage = loginConfig.getLoginPage(); if (loginPage == null || loginPage.length() == 0) { String msg = sm.getString("formAuthenticator.noLoginPage", context.getName()); log.warn(msg); @@ -398,17 +399,15 @@ public class FormAuthModule extends Tomc * Called to forward to the error page * * @param request Request we are processing - * @param response Response we are populating - * @param config Login configuration describing how authentication should be - * performed - * @throws IOException If the forward to the error page fails and the call - * to {@link HttpServletResponse#sendError(int, String)} throws - * an {@link IOException} + * @param response Response we are populating @throws IOException If the + * forward to the error page fails and the call to + * {@link HttpServletResponse#sendError(int, String)} throws an + * {@link IOException} */ - protected void forwardToErrorPage(Request request, HttpServletResponse response, - LoginConfig config) throws IOException { + protected void forwardToErrorPage(Request request, HttpServletResponse response) + throws IOException { - String errorPage = config.getErrorPage(); + String errorPage = loginConfig.getErrorPage(); if (errorPage == null || errorPage.length() == 0) { String msg = sm.getString("formAuthenticator.noErrorPage", context.getName()); log.warn(msg); @@ -417,7 +416,7 @@ public class FormAuthModule extends Tomc } RequestDispatcher disp = context.getServletContext().getRequestDispatcher( - config.getErrorPage()); + loginConfig.getErrorPage()); try { if (context.fireRequestInitEvent(request)) { disp.forward(request.getRequest(), response); --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org