|  | @@ -37,40 +37,40 @@ public class DefaultLoginPageGeneratingFilter extends SpringSecurityFilter {
 | 
	
		
			
				|  |  |      private String openIDauthenticationUrl;
 | 
	
		
			
				|  |  |      private String openIDusernameParameter;
 | 
	
		
			
				|  |  |      private String openIDrememberMeParameter;
 | 
	
		
			
				|  |  | -    
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      public DefaultLoginPageGeneratingFilter(AbstractProcessingFilter filter) {
 | 
	
		
			
				|  |  | -    	if (filter instanceof AuthenticationProcessingFilter) {
 | 
	
		
			
				|  |  | -    		init((AuthenticationProcessingFilter)filter, null);
 | 
	
		
			
				|  |  | -    	} else {
 | 
	
		
			
				|  |  | -    		init(null, filter);
 | 
	
		
			
				|  |  | -    	}
 | 
	
		
			
				|  |  | +        if (filter instanceof AuthenticationProcessingFilter) {
 | 
	
		
			
				|  |  | +            init((AuthenticationProcessingFilter)filter, null);
 | 
	
		
			
				|  |  | +        } else {
 | 
	
		
			
				|  |  | +            init(null, filter);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | -    
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      public DefaultLoginPageGeneratingFilter(AuthenticationProcessingFilter authFilter, AbstractProcessingFilter openIDFilter) {
 | 
	
		
			
				|  |  | -    	init(authFilter, openIDFilter);
 | 
	
		
			
				|  |  | +        init(authFilter, openIDFilter);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | -    
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      private void init(AuthenticationProcessingFilter authFilter, AbstractProcessingFilter openIDFilter) {
 | 
	
		
			
				|  |  | -    	if (authFilter != null) {
 | 
	
		
			
				|  |  | -    		formLoginEnabled = true;
 | 
	
		
			
				|  |  | -	        authenticationUrl = authFilter.getDefaultFilterProcessesUrl();
 | 
	
		
			
				|  |  | -	        usernameParameter = authFilter.getUsernameParameter();
 | 
	
		
			
				|  |  | -	        passwordParameter = authFilter.getPasswordParameter();
 | 
	
		
			
				|  |  | -	
 | 
	
		
			
				|  |  | -	        if (authFilter.getRememberMeServices() instanceof AbstractRememberMeServices) {
 | 
	
		
			
				|  |  | -	            rememberMeParameter = ((AbstractRememberMeServices)authFilter.getRememberMeServices()).getParameter();
 | 
	
		
			
				|  |  | -	        }
 | 
	
		
			
				|  |  | -    	}
 | 
	
		
			
				|  |  | -    	
 | 
	
		
			
				|  |  | -    	if (openIDFilter != null) {
 | 
	
		
			
				|  |  | -    		openIdEnabled = true;
 | 
	
		
			
				|  |  | -    		openIDauthenticationUrl = openIDFilter.getDefaultFilterProcessesUrl();
 | 
	
		
			
				|  |  | -    		openIDusernameParameter = (String) (new BeanWrapperImpl(openIDFilter)).getPropertyValue("claimedIdentityFieldName");
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -	        if (openIDFilter.getRememberMeServices() instanceof AbstractRememberMeServices) {
 | 
	
		
			
				|  |  | -	        	openIDrememberMeParameter = ((AbstractRememberMeServices)openIDFilter.getRememberMeServices()).getParameter();
 | 
	
		
			
				|  |  | -	        }
 | 
	
		
			
				|  |  | -    	}    	
 | 
	
		
			
				|  |  | +        if (authFilter != null) {
 | 
	
		
			
				|  |  | +            formLoginEnabled = true;
 | 
	
		
			
				|  |  | +            authenticationUrl = authFilter.getFilterProcessesUrl();
 | 
	
		
			
				|  |  | +            usernameParameter = authFilter.getUsernameParameter();
 | 
	
		
			
				|  |  | +            passwordParameter = authFilter.getPasswordParameter();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            if (authFilter.getRememberMeServices() instanceof AbstractRememberMeServices) {
 | 
	
		
			
				|  |  | +                rememberMeParameter = ((AbstractRememberMeServices)authFilter.getRememberMeServices()).getParameter();
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if (openIDFilter != null) {
 | 
	
		
			
				|  |  | +            openIdEnabled = true;
 | 
	
		
			
				|  |  | +            openIDauthenticationUrl = openIDFilter.getFilterProcessesUrl();
 | 
	
		
			
				|  |  | +            openIDusernameParameter = (String) (new BeanWrapperImpl(openIDFilter)).getPropertyValue("claimedIdentityFieldName");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            if (openIDFilter.getRememberMeServices() instanceof AbstractRememberMeServices) {
 | 
	
		
			
				|  |  | +                openIDrememberMeParameter = ((AbstractRememberMeServices)openIDFilter.getRememberMeServices()).getParameter();
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      protected void doFilterHttp(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException {
 | 
	
	
		
			
				|  | @@ -78,7 +78,7 @@ public class DefaultLoginPageGeneratingFilter extends SpringSecurityFilter {
 | 
	
		
			
				|  |  |              String loginPageHtml = generateLoginPageHtml(request);
 | 
	
		
			
				|  |  |              response.setContentType("text/html;charset=UTF-8");
 | 
	
		
			
				|  |  |              response.setContentLength(loginPageHtml.length());
 | 
	
		
			
				|  |  | -            response.getOutputStream().print(loginPageHtml);            
 | 
	
		
			
				|  |  | +            response.getOutputStream().print(loginPageHtml);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              return;
 | 
	
		
			
				|  |  |          }
 | 
	
	
		
			
				|  | @@ -95,66 +95,66 @@ public class DefaultLoginPageGeneratingFilter extends SpringSecurityFilter {
 | 
	
		
			
				|  |  |              HttpSession session = request.getSession(false);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              if(session != null) {
 | 
	
		
			
				|  |  | -            	lastUser = (String) session.getAttribute(AuthenticationProcessingFilter.SPRING_SECURITY_LAST_USERNAME_KEY);
 | 
	
		
			
				|  |  | -            	AuthenticationException ex = (AuthenticationException) session.getAttribute(AbstractProcessingFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY);
 | 
	
		
			
				|  |  | +                lastUser = (String) session.getAttribute(AuthenticationProcessingFilter.SPRING_SECURITY_LAST_USERNAME_KEY);
 | 
	
		
			
				|  |  | +                AuthenticationException ex = (AuthenticationException) session.getAttribute(AbstractProcessingFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY);
 | 
	
		
			
				|  |  |                  errorMsg = ex != null ? ex.getMessage() : "none";
 | 
	
		
			
				|  |  |                  if (lastUser == null) {
 | 
	
		
			
				|  |  | -                	lastUser = "";
 | 
	
		
			
				|  |  | +                    lastUser = "";
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          StringBuffer sb = new StringBuffer();
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          sb.append("<html><head><title>Login Page</title></head>");
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          if (formLoginEnabled) {
 | 
	
		
			
				|  |  | -        	sb.append("<body onload='document.f.").append(usernameParameter).append(".focus();'>\n");
 | 
	
		
			
				|  |  | +            sb.append("<body onload='document.f.").append(usernameParameter).append(".focus();'>\n");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          if (loginError) {
 | 
	
		
			
				|  |  | -        	sb.append("<p><font color='red'>Your login attempt was not successful, try again.<br/><br/>Reason: ");
 | 
	
		
			
				|  |  | +            sb.append("<p><font color='red'>Your login attempt was not successful, try again.<br/><br/>Reason: ");
 | 
	
		
			
				|  |  |              sb.append(errorMsg);
 | 
	
		
			
				|  |  |              sb.append("</font></p>");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          if (formLoginEnabled) {
 | 
	
		
			
				|  |  | -        	sb.append("<h3>Login with Username and Password</h3>");
 | 
	
		
			
				|  |  | -	        sb.append("<form name='f' action='").append(request.getContextPath()).append(authenticationUrl).append("' method='POST'>\n");
 | 
	
		
			
				|  |  | -	        sb.append(" <table>\n");
 | 
	
		
			
				|  |  | -	        sb.append("    <tr><td>User:</td><td><input type='text' name='");
 | 
	
		
			
				|  |  | -	        sb.append(usernameParameter).append("' value='").append(lastUser).append("'></td></tr>\n");
 | 
	
		
			
				|  |  | -	        sb.append("    <tr><td>Password:</td><td><input type='password' name='").append(passwordParameter).append("'/></td></tr>\n");
 | 
	
		
			
				|  |  | -	
 | 
	
		
			
				|  |  | -	        if (rememberMeParameter != null) {
 | 
	
		
			
				|  |  | -	        	sb.append("    <tr><td><input type='checkbox' name='").append(rememberMeParameter).append("'/></td><td>Remember me on this computer.</td></tr>\n");
 | 
	
		
			
				|  |  | -	        }
 | 
	
		
			
				|  |  | -	
 | 
	
		
			
				|  |  | -	        sb.append("    <tr><td colspan='2'><input name=\"submit\" type=\"submit\"/></td></tr>\n");
 | 
	
		
			
				|  |  | -	        sb.append("    <tr><td colspan='2'><input name=\"reset\" type=\"reset\"/></td></tr>\n");
 | 
	
		
			
				|  |  | -	        sb.append("  </table>\n");
 | 
	
		
			
				|  |  | -	        sb.append("</form>");
 | 
	
		
			
				|  |  | +            sb.append("<h3>Login with Username and Password</h3>");
 | 
	
		
			
				|  |  | +            sb.append("<form name='f' action='").append(request.getContextPath()).append(authenticationUrl).append("' method='POST'>\n");
 | 
	
		
			
				|  |  | +            sb.append(" <table>\n");
 | 
	
		
			
				|  |  | +            sb.append("    <tr><td>User:</td><td><input type='text' name='");
 | 
	
		
			
				|  |  | +            sb.append(usernameParameter).append("' value='").append(lastUser).append("'></td></tr>\n");
 | 
	
		
			
				|  |  | +            sb.append("    <tr><td>Password:</td><td><input type='password' name='").append(passwordParameter).append("'/></td></tr>\n");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            if (rememberMeParameter != null) {
 | 
	
		
			
				|  |  | +                sb.append("    <tr><td><input type='checkbox' name='").append(rememberMeParameter).append("'/></td><td>Remember me on this computer.</td></tr>\n");
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            sb.append("    <tr><td colspan='2'><input name=\"submit\" type=\"submit\"/></td></tr>\n");
 | 
	
		
			
				|  |  | +            sb.append("    <tr><td colspan='2'><input name=\"reset\" type=\"reset\"/></td></tr>\n");
 | 
	
		
			
				|  |  | +            sb.append("  </table>\n");
 | 
	
		
			
				|  |  | +            sb.append("</form>");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          if(openIdEnabled) {
 | 
	
		
			
				|  |  | -        	sb.append("<h3>Login with OpenID Identity</h3>");
 | 
	
		
			
				|  |  | -	        sb.append("<form name='oidf' action='").append(request.getContextPath()).append(openIDauthenticationUrl).append("' method='POST'>\n");
 | 
	
		
			
				|  |  | -	        sb.append(" <table>\n");
 | 
	
		
			
				|  |  | -	        sb.append("    <tr><td>Identity:</td><td><input type='text' name='");
 | 
	
		
			
				|  |  | -	        sb.append(openIDusernameParameter).append("'/></td></tr>\n");
 | 
	
		
			
				|  |  | -	
 | 
	
		
			
				|  |  | -	        if (rememberMeParameter != null) {
 | 
	
		
			
				|  |  | -	        	sb.append("    <tr><td><input type='checkbox' name='").append(openIDrememberMeParameter).append("'></td><td>Remember me on this computer.</td></tr>\n");
 | 
	
		
			
				|  |  | -	        }
 | 
	
		
			
				|  |  | -	
 | 
	
		
			
				|  |  | -	        sb.append("    <tr><td colspan='2'><input name=\"submit\" type=\"submit\"/></td></tr>\n");
 | 
	
		
			
				|  |  | -	        sb.append("    <tr><td colspan='2'><input name=\"reset\" type=\"reset\"/></td></tr>\n");
 | 
	
		
			
				|  |  | -	        sb.append("  </table>\n");
 | 
	
		
			
				|  |  | -	        sb.append("</form>");        	
 | 
	
		
			
				|  |  | +            sb.append("<h3>Login with OpenID Identity</h3>");
 | 
	
		
			
				|  |  | +            sb.append("<form name='oidf' action='").append(request.getContextPath()).append(openIDauthenticationUrl).append("' method='POST'>\n");
 | 
	
		
			
				|  |  | +            sb.append(" <table>\n");
 | 
	
		
			
				|  |  | +            sb.append("    <tr><td>Identity:</td><td><input type='text' name='");
 | 
	
		
			
				|  |  | +            sb.append(openIDusernameParameter).append("'/></td></tr>\n");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            if (rememberMeParameter != null) {
 | 
	
		
			
				|  |  | +                sb.append("    <tr><td><input type='checkbox' name='").append(openIDrememberMeParameter).append("'></td><td>Remember me on this computer.</td></tr>\n");
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            sb.append("    <tr><td colspan='2'><input name=\"submit\" type=\"submit\"/></td></tr>\n");
 | 
	
		
			
				|  |  | +            sb.append("    <tr><td colspan='2'><input name=\"reset\" type=\"reset\"/></td></tr>\n");
 | 
	
		
			
				|  |  | +            sb.append("  </table>\n");
 | 
	
		
			
				|  |  | +            sb.append("</form>");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          sb.append("</body></html>");
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          return sb.toString();
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -162,19 +162,19 @@ public class DefaultLoginPageGeneratingFilter extends SpringSecurityFilter {
 | 
	
		
			
				|  |  |          return FilterChainOrder.LOGIN_PAGE_FILTER;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	private boolean isLoginUrlRequest(HttpServletRequest request) {
 | 
	
		
			
				|  |  | -		String uri = request.getRequestURI();
 | 
	
		
			
				|  |  | -		int pathParamIndex = uri.indexOf(';');
 | 
	
		
			
				|  |  | +    private boolean isLoginUrlRequest(HttpServletRequest request) {
 | 
	
		
			
				|  |  | +        String uri = request.getRequestURI();
 | 
	
		
			
				|  |  | +        int pathParamIndex = uri.indexOf(';');
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		if (pathParamIndex > 0) {
 | 
	
		
			
				|  |  | -			// strip everything after the first semi-colon
 | 
	
		
			
				|  |  | -			uri = uri.substring(0, pathParamIndex);
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | +        if (pathParamIndex > 0) {
 | 
	
		
			
				|  |  | +            // strip everything after the first semi-colon
 | 
	
		
			
				|  |  | +            uri = uri.substring(0, pathParamIndex);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		if ("".equals(request.getContextPath())) {
 | 
	
		
			
				|  |  | -			return uri.endsWith(DEFAULT_LOGIN_PAGE_URL);
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | +        if ("".equals(request.getContextPath())) {
 | 
	
		
			
				|  |  | +            return uri.endsWith(DEFAULT_LOGIN_PAGE_URL);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		return uri.endsWith(request.getContextPath() + DEFAULT_LOGIN_PAGE_URL);
 | 
	
		
			
				|  |  | -	}
 | 
	
		
			
				|  |  | +        return uri.endsWith(request.getContextPath() + DEFAULT_LOGIN_PAGE_URL);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  }
 |