org.norther.tammi.spray.authenticator
Class DefaultHttpFormAuthFilter

java.lang.Object
  extended by org.norther.tammi.core.base.Adaptee
      extended by org.norther.tammi.spray.filter.DefaultFilter
          extended by org.norther.tammi.spray.authenticator.AbstractAuthenticatorFilter
              extended by org.norther.tammi.spray.authenticator.DefaultHttpServiceAuthFilter
                  extended by org.norther.tammi.spray.authenticator.DefaultHttpFormAuthFilter
All Implemented Interfaces:
Serializable, NotificationBroadcaster, NotificationEmitter, Filter, Manageable, MBeanDelegate, AuthenticatorFilter, HttpFormAuthFilter, HttpServiceAuthFilter

public class DefaultHttpFormAuthFilter
extends DefaultHttpServiceAuthFilter
implements HttpFormAuthFilter

An default implementation of HttpFormAuthFilter.

Based on FormAuthenticator in the Apache Jakarta Tomcat project.

Version:
$Id: DefaultHttpFormAuthFilter.java,v 1.25 2009/09/28 15:08:28 cvsimp Exp $
Author:
Craig R. McClanahan, Ilkka Priha
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.norther.tammi.spray.authenticator.DefaultHttpServiceAuthFilter
DefaultHttpServiceAuthFilter.LoginStatus
 
Field Summary
 
Fields inherited from class org.norther.tammi.spray.authenticator.DefaultHttpServiceAuthFilter
LOGIN_STATUS
 
Fields inherited from class org.norther.tammi.spray.authenticator.AbstractAuthenticatorFilter
DEFAULT_USER_ACCOUNT_ID_ATTIBUTE
 
Fields inherited from class org.norther.tammi.core.base.Adaptee
ADAPTEE_NOTIF_DESCRIPTION, ADAPTEE_NOTIFICATIONS
 
Fields inherited from interface org.norther.tammi.spray.authenticator.HttpServiceAuthFilter
FORM_AUTH
 
Constructor Summary
DefaultHttpFormAuthFilter()
          Constructs a new filter.
 
Method Summary
protected  Cookie addLoginCookie(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
          Adds a login cookie, if required.
 Principal authenticate(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
          Authenticates a request within the realm of this filter.
 String getLoginFlow()
          Gets the login flow.
 String getLoginHost()
          Gets the login host.
protected  String getLoginPath(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
          Gets the login path for the specified request.
 String getLoginPipe()
          Gets the login pipe.
 String getLoginService()
          Gets the login service.
 String getLoginTemplate()
          Gets the login template.
 String getLoginURI()
          Gets the login URI.
 StringBuilder getLoginURL(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
          Gets the login URL, with the scheme, host and port if required, for the specified request.
protected  boolean isLoginRequest(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
          Checks whether the specified request is a login request.
 void setLoginFlow(String flow)
          Sets the login flow.
 void setLoginHost(String host)
          Sets the login host.
 void setLoginPipe(String pipe)
          Sets the login pipe.
 void setLoginService(String service)
          Sets the login service.
 void setLoginTemplate(String template)
          Sets the login template.
 void setLoginURI(String uri)
          Sets the login URI.
 void unauthenticated(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
          A handler for unauthenticated requests that should provide an opportunity for the user to re-authenticate himself.
protected  Principal verifyAuthentication(Principal identity, HttpServletRequest request, HttpServletResponse response, FilterChain chain)
          Verifies whether authentication is required.
 
Methods inherited from class org.norther.tammi.spray.authenticator.DefaultHttpServiceAuthFilter
cacheAuthentication, getAuthType, getCookieAuthenticationAge, getLoginCheck, getLoginCookie, isAutoLoginEnabled, isQueryStringCredentialsAllowed, isSecure, isURLAuthenticationEnabled, setAutoLoginEnabled, setCookieAuthenticationAge, setQueryStringCredentialsAllowed, setSecure, setURLAuthenticationEnabled
 
Methods inherited from class org.norther.tammi.spray.authenticator.AbstractAuthenticatorFilter
authenticate, authenticate, decrementLoginAttempts, doFilter, getAuthDomain, getAuthenticationURL, getCredentials, getFaultyUser, getLoginAttempts, getLoginAttempts, getLogoutFlow, getLogoutHost, getLogoutPipe, getLogoutService, getLogoutTemplate, getLogoutURI, getLogoutURL, getPublicRealmName, getRealm, getRealmDomain, getRealmName, getUnauthorizedTemplate, getUserURL, incrementLoginAttempts, isAnonymousPrincipalAccepted, isAuthenticationRequired, isCachedPrincipalDiscarded, isUserInRole, postmanaged, setAnonymousPrincipalAccepted, setAuthDomain, setAuthenticationRequired, setCachedPrincipalDiscarded, setFaultyUser, setLoginAttempts, setLogoutFlow, setLogoutHost, setLogoutPipe, setLogoutService, setLogoutTemplate, setLogoutURI, setPublicRealmName, setRealmName, setUnauthorizedTemplate, unmanaged
 
Methods inherited from class org.norther.tammi.spray.filter.DefaultFilter
destroy, getFilterConfig, getRequestMap, getSessionMap, init
 
Methods inherited from class org.norther.tammi.core.base.Adaptee
addAdaptee, addNotificationListener, getAttributeSupport, getBroker, getCanonicalName, getDomain, getFactory, getLoader, getLog, getLog, getMBean, getMBeanServer, getNotificationInfo, getObjectName, getRegistrationTime, getSequenceNumber, hasListeners, isRegistered, premanaged, removeNotificationListener, removeNotificationListener, sendNotification, sendNotification, sendNotification, sendNotification, unregister
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.norther.tammi.spray.authenticator.HttpServiceAuthFilter
getCookieAuthenticationAge, isQueryStringCredentialsAllowed, isSecure, isURLAuthenticationEnabled, setCookieAuthenticationAge, setQueryStringCredentialsAllowed, setSecure, setURLAuthenticationEnabled
 
Methods inherited from interface org.norther.tammi.spray.authenticator.AuthenticatorFilter
authenticate, authenticate, getAuthDomain, getAuthType, getFaultyUser, getLoginAttempts, getLoginAttempts, getLogoutFlow, getLogoutHost, getLogoutPipe, getLogoutService, getLogoutTemplate, getLogoutURI, getLogoutURL, getPublicRealmName, getRealmDomain, getRealmName, getUnauthorizedTemplate, getUserURL, isAnonymousPrincipalAccepted, isAuthenticationRequired, isAutoLoginEnabled, isCachedPrincipalDiscarded, isUserInRole, setAnonymousPrincipalAccepted, setAuthDomain, setAuthenticationRequired, setAutoLoginEnabled, setCachedPrincipalDiscarded, setLoginAttempts, setLogoutFlow, setLogoutHost, setLogoutPipe, setLogoutService, setLogoutTemplate, setLogoutURI, setPublicRealmName, setRealmName, setUnauthorizedTemplate
 
Methods inherited from interface javax.servlet.Filter
destroy, doFilter, init
 

Constructor Detail

DefaultHttpFormAuthFilter

public DefaultHttpFormAuthFilter()
Constructs a new filter.

Method Detail

getLoginURI

public String getLoginURI()
Description copied from interface: HttpFormAuthFilter
Gets the login URI.

Specified by:
getLoginURI in interface HttpFormAuthFilter
Returns:
the login URI.

setLoginURI

public void setLoginURI(String uri)
Description copied from interface: HttpFormAuthFilter
Sets the login URI. An explicit URI overrides the login host, service, pipe, template and flow.

Specified by:
setLoginURI in interface HttpFormAuthFilter
Parameters:
uri - the login URI.

getLoginHost

public String getLoginHost()
Description copied from interface: HttpFormAuthFilter
Gets the login host.

Specified by:
getLoginHost in interface HttpFormAuthFilter
Returns:
the login host.

setLoginHost

public void setLoginHost(String host)
Description copied from interface: HttpFormAuthFilter
Sets the login host.

Specified by:
setLoginHost in interface HttpFormAuthFilter
Parameters:
host - the login host.

getLoginService

public String getLoginService()
Description copied from interface: HttpFormAuthFilter
Gets the login service.

Specified by:
getLoginService in interface HttpFormAuthFilter
Returns:
the login service.

setLoginService

public void setLoginService(String service)
Description copied from interface: HttpFormAuthFilter
Sets the login service. The service is applied to the login URI if an explicit one is not specified.

Specified by:
setLoginService in interface HttpFormAuthFilter
Parameters:
service - the login service.

getLoginPipe

public String getLoginPipe()
Description copied from interface: HttpFormAuthFilter
Gets the login pipe.

Specified by:
getLoginPipe in interface HttpFormAuthFilter
Returns:
the login pipe.

setLoginPipe

public void setLoginPipe(String pipe)
Description copied from interface: HttpFormAuthFilter
Sets the login pipe. The pipe is applied to the login URI if an explicit one is not specified.

Specified by:
setLoginPipe in interface HttpFormAuthFilter
Parameters:
pipe - the login pipe.

getLoginFlow

public String getLoginFlow()
Description copied from interface: HttpFormAuthFilter
Gets the login flow.

Specified by:
getLoginFlow in interface HttpFormAuthFilter
Returns:
the login flow.

setLoginFlow

public void setLoginFlow(String flow)
Description copied from interface: HttpFormAuthFilter
Sets the login flow. The flow is applied to the login URI if an explicit one is not specified.

Specified by:
setLoginFlow in interface HttpFormAuthFilter
Parameters:
flow - the login flow.

getLoginTemplate

public String getLoginTemplate()
Description copied from interface: HttpFormAuthFilter
Gets the login template.

Specified by:
getLoginTemplate in interface HttpFormAuthFilter
Returns:
the login template.

setLoginTemplate

public void setLoginTemplate(String template)
Description copied from interface: HttpFormAuthFilter
Sets the login template. The template is applied to the login URI if an explicit one is not specified.

Specified by:
setLoginTemplate in interface HttpFormAuthFilter
Parameters:
template - the login template.

getLoginURL

public StringBuilder getLoginURL(HttpServletRequest request,
                                 HttpServletResponse response,
                                 FilterChain chain)
Description copied from interface: HttpFormAuthFilter
Gets the login URL, with the scheme, host and port if required, for the specified request.

Specified by:
getLoginURL in interface HttpFormAuthFilter
Parameters:
request - the request.
response - the response.
chain - the filter chain.
Returns:
the login URL or null if not defined.

authenticate

public Principal authenticate(HttpServletRequest request,
                              HttpServletResponse response,
                              FilterChain chain)
Description copied from interface: AuthenticatorFilter
Authenticates a request within the realm of this filter.

Specified by:
authenticate in interface AuthenticatorFilter
Overrides:
authenticate in class DefaultHttpServiceAuthFilter
Parameters:
request - the request.
response - the response.
chain - the filter chain.
Returns:
the authenticated user principal or null.

unauthenticated

public void unauthenticated(HttpServletRequest request,
                            HttpServletResponse response,
                            FilterChain chain)
                     throws ServletException,
                            IOException
Description copied from interface: AuthenticatorFilter
A handler for unauthenticated requests that should provide an opportunity for the user to re-authenticate himself. Must either produce a valid response or throw an exception.

Specified by:
unauthenticated in interface AuthenticatorFilter
Overrides:
unauthenticated in class DefaultHttpServiceAuthFilter
Parameters:
request - the request.
response - the response.
chain - the filter chain.
Throws:
ServletException - for servlet errors.
IOException - for general errors.

isLoginRequest

protected boolean isLoginRequest(HttpServletRequest request,
                                 HttpServletResponse response,
                                 FilterChain chain)
Description copied from class: DefaultHttpServiceAuthFilter
Checks whether the specified request is a login request.

Overrides:
isLoginRequest in class DefaultHttpServiceAuthFilter
Parameters:
request - the request.
response - the response.
chain - the filter chain.
Returns:
true for a login request, false otherwise.

getLoginPath

protected String getLoginPath(HttpServletRequest request,
                              HttpServletResponse response,
                              FilterChain chain)
Description copied from class: DefaultHttpServiceAuthFilter
Gets the login path for the specified request.

Overrides:
getLoginPath in class DefaultHttpServiceAuthFilter
Parameters:
request - the request.
response - the response.
chain - the filter chain.
Returns:
the login path.

addLoginCookie

protected Cookie addLoginCookie(HttpServletRequest request,
                                HttpServletResponse response,
                                FilterChain chain)
Description copied from class: DefaultHttpServiceAuthFilter
Adds a login cookie, if required.

Overrides:
addLoginCookie in class DefaultHttpServiceAuthFilter
Parameters:
request - the request.
response - the response.
chain - the filter chain.
Returns:
the cookie or null.

verifyAuthentication

protected Principal verifyAuthentication(Principal identity,
                                         HttpServletRequest request,
                                         HttpServletResponse response,
                                         FilterChain chain)
Description copied from class: AbstractAuthenticatorFilter
Verifies whether authentication is required.

Overrides:
verifyAuthentication in class AbstractAuthenticatorFilter
Parameters:
identity - the authenticated principal.
request - the request.
response - the response.
chain - the filter chain.
Returns:
the verified principal.


Copyright © 2004 The Norther Organization. All rights reserved.