1 22 package org.jboss.web.tomcat.security.authenticators; 23 24 import javax.servlet.http.HttpSession ; 25 26 import org.apache.catalina.deploy.LoginConfig; 27 import org.apache.catalina.connector.Request; 28 import org.apache.catalina.connector.Response; 29 import org.jboss.logging.Logger; 30 31 33 46 public class ExtendedJASPIFormAuthenticator extends JASPIFormAuthenticator 47 { 48 private static Logger log = Logger.getLogger(ExtendedJASPIFormAuthenticator.class); 49 private static boolean trace = log.isTraceEnabled(); 50 private boolean includePassword; 51 52 public boolean isIncludePassword() 53 { 54 return includePassword; 55 } 56 public void setIncludePassword(boolean includePassword) 57 { 58 this.includePassword = includePassword; 59 } 60 61 69 protected void forwardToErrorPage(Request request, Response response,LoginConfig config) 70 { 71 if( trace ) 72 log.trace("forwardToErrorPage"); 73 populateSession(request); 74 super.forwardToErrorPage(request, response,config); 75 SecurityAssociationActions.clearAuthException(); 76 } 77 78 86 protected void forwardToLoginPage(LoginConfig config, 87 Request request, Response response) 88 { 89 if( trace ) 90 log.trace("forwardToLoginPage"); 91 populateSession(request); 92 super.forwardToLoginPage(request, response,config); 93 } 94 95 protected void populateSession(Request request) 96 { 97 String username = request.getParameter("j_username"); 98 HttpSession session = request.getSession(false); 99 if( trace ) 100 log.trace("Enter, j_username="+username); 101 if( session != null ) 102 { 103 if( username != null ) 104 session.setAttribute("j_username", username); 105 if( includePassword ) 106 { 107 Object pass = request.getParameter("j_password"); 108 if( pass != null ) 109 session.setAttribute("j_password", pass); 110 } 111 } 112 113 username = request.getParameter("j_username"); 114 session = request.getSession(false); 115 if( session != null ) 116 { 117 if( trace ) 118 log.trace("SessionID: "+session.getId()); 119 if( username != null ) 120 session.setAttribute("j_username", username); 121 Throwable t = (Throwable ) SecurityAssociationActions.getAuthException(); 123 if( trace ) 124 log.trace("SecurityAssociation.exception: "+t); 125 if( t != null ) 126 session.setAttribute("j_exception", t); 127 } 128 if( trace ) 129 log.trace("Exit, username: "+username); 130 } 131 } 132 | Popular Tags |