JSecurity

org.jsecurity.web.filter.authc
Class AuthenticatingFilter

java.lang.Object
  extended by org.jsecurity.web.servlet.ServletContextSupport
      extended by org.jsecurity.web.servlet.OncePerRequestFilter
          extended by org.jsecurity.web.servlet.AdviceFilter
              extended by org.jsecurity.web.filter.PathMatchingFilter
                  extended by org.jsecurity.web.filter.AccessControlFilter
                      extended by org.jsecurity.web.filter.authc.AuthenticationFilter
                          extended by org.jsecurity.web.filter.authc.AuthenticatingFilter
All Implemented Interfaces:
Filter, Nameable, PathConfigProcessor
Direct Known Subclasses:
BasicHttpAuthenticationFilter, FormAuthenticationFilter

public abstract class AuthenticatingFilter
extends AuthenticationFilter

An AuthenticationFilter that is capable of automatically performing an authentication attempt based on the incoming request.

Since:
0.9
Author:
Les Hazlewood

Field Summary
 
Fields inherited from class org.jsecurity.web.filter.authc.AuthenticationFilter
DEFAULT_SUCCESS_URL
 
Fields inherited from class org.jsecurity.web.filter.AccessControlFilter
DEFAULT_LOGIN_URL, GET_METHOD, POST_METHOD
 
Fields inherited from class org.jsecurity.web.filter.PathMatchingFilter
appliedPaths, pathMatcher
 
Fields inherited from class org.jsecurity.web.servlet.OncePerRequestFilter
ALREADY_FILTERED_SUFFIX, filterConfig
 
Fields inherited from class org.jsecurity.web.servlet.ServletContextSupport
HTTP_SESSION_MODE, JSECURITY_SESSION_MODE, SESSION_MODE_CONTEXT_PARAM_NAME
 
Constructor Summary
AuthenticatingFilter()
           
 
Method Summary
protected abstract  AuthenticationToken createToken(ServletRequest request, ServletResponse response)
           
protected  AuthenticationToken createToken(String username, String password, boolean rememberMe, InetAddress inet)
           
protected  AuthenticationToken createToken(String username, String password, ServletRequest request, ServletResponse response)
           
protected  boolean executeLogin(ServletRequest request, ServletResponse response)
           
protected  InetAddress getInetAddress(ServletRequest request)
          Returns the InetAddress associated with the current subject.
protected  boolean isRememberMe(ServletRequest request)
          Returns true if "rememberMe" should be enabled for the login attempt associated with the current request, false otherwise.
protected  boolean onLoginFailure(AuthenticationToken token, AuthenticationException e, ServletRequest request, ServletResponse response)
           
protected  boolean onLoginSuccess(AuthenticationToken token, Subject subject, ServletRequest request, ServletResponse response)
           
 
Methods inherited from class org.jsecurity.web.filter.authc.AuthenticationFilter
getSuccessUrl, isAccessAllowed, issueSuccessRedirect, setSuccessUrl
 
Methods inherited from class org.jsecurity.web.filter.AccessControlFilter
getLoginUrl, getSubject, isLoginRequest, onAccessDenied, onPreHandle, redirectToLogin, saveRequest, saveRequestAndRedirectToLogin, setLoginUrl
 
Methods inherited from class org.jsecurity.web.filter.PathMatchingFilter
getPathWithinApplication, pathsMatch, pathsMatch, preHandle, processPathConfig
 
Methods inherited from class org.jsecurity.web.servlet.AdviceFilter
afterCompletion, cleanup, doFilterInternal, executeChain, postHandle
 
Methods inherited from class org.jsecurity.web.servlet.OncePerRequestFilter
destroy, doFilter, getAlreadyFilteredAttributeName, getFilterConfig, getName, init, onFilterConfigSet, setFilterConfig, setName, shouldNotFilter
 
Methods inherited from class org.jsecurity.web.servlet.ServletContextSupport
bind, getAttribute, getContextInitParam, getServletContext, removeAttribute, setAttribute, setServletContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AuthenticatingFilter

public AuthenticatingFilter()
Method Detail

executeLogin

protected boolean executeLogin(ServletRequest request,
                               ServletResponse response)
                        throws Exception
Throws:
Exception

createToken

protected abstract AuthenticationToken createToken(ServletRequest request,
                                                   ServletResponse response)
                                            throws Exception
Throws:
Exception

createToken

protected AuthenticationToken createToken(String username,
                                          String password,
                                          ServletRequest request,
                                          ServletResponse response)

createToken

protected AuthenticationToken createToken(String username,
                                          String password,
                                          boolean rememberMe,
                                          InetAddress inet)

onLoginSuccess

protected boolean onLoginSuccess(AuthenticationToken token,
                                 Subject subject,
                                 ServletRequest request,
                                 ServletResponse response)
                          throws Exception
Throws:
Exception

onLoginFailure

protected boolean onLoginFailure(AuthenticationToken token,
                                 AuthenticationException e,
                                 ServletRequest request,
                                 ServletResponse response)

getInetAddress

protected InetAddress getInetAddress(ServletRequest request)
Returns the InetAddress associated with the current subject. This method is primarily provided for use during construction of an AuthenticationToken.

The default implementation merely returns WebUtils.getInetAddress(request).

Parameters:
request - the incoming ServletRequest
Returns:
the InetAddress to associate with the login attempt.

isRememberMe

protected boolean isRememberMe(ServletRequest request)
Returns true if "rememberMe" should be enabled for the login attempt associated with the current request, false otherwise.

This implementation always returns false and is provided as a template hook to subclasses that support rememberMe logins and wish to determine rememberMe in a custom mannner based on the current request.

Parameters:
request - the incoming ServletRequest
Returns:
true if "rememberMe" should be enabled for the login attempt associated with the current request, false otherwise.

JSecurity

Copyright © 2004-2008 JSecurity.