|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.norther.tammi.core.base.Adaptee
org.norther.tammi.spray.filter.DefaultFilter
org.norther.tammi.spray.authenticator.AbstractAuthenticatorFilter
public abstract class AbstractAuthenticatorFilter
An abstract implementation of AuthenticatorFilter providing the base functionality for subclasses implementing specific authentication schemes.
This implementation requires that the principal has READ permission to the path info of the request in addition to authentication to allow filtering of the request to continue. Note that undefined permissions imply full access to everyone.
Based on AuthenticatorBase in the Apache Jakarta Tomcat
project.
| Field Summary | |
|---|---|
static String |
DEFAULT_USER_ACCOUNT_ID_ATTIBUTE
The default account id attribute. |
| Fields inherited from class org.norther.tammi.core.base.Adaptee |
|---|
ADAPTEE_NOTIF_DESCRIPTION, ADAPTEE_NOTIFICATIONS |
| Fields inherited from interface org.norther.tammi.core.base.MBeanDelegate |
|---|
ARRAY_TYPE, OBJECT_TYPE, PRIMITIVE_TYPE, STRING_TYPE |
| Constructor Summary | |
|---|---|
AbstractAuthenticatorFilter()
Constructs a new filter. |
|
| Method Summary | |
|---|---|
abstract Principal |
authenticate(HttpServletRequest request,
HttpServletResponse response,
FilterChain chain)
Authenticates a request within the realm of this filter. |
protected void |
decrementLoginAttempts(HttpServletRequest request)
Deccrements login attempts of the specified request by one. |
void |
doFilter(ServletRequest request,
ServletResponse response,
FilterChain chain)
|
protected String |
generateAuthenticate(HttpServletRequest request,
HttpServletResponse response,
FilterChain chain)
Generates the WWW-Authenticate header. |
protected StringBuilder |
getAuthenticationURL(String host,
boolean secure,
String service,
String pipe,
String flow,
String page,
HttpServletRequest request,
HttpServletResponse response,
HttpFilterChain chain)
Gets the authentication URL. |
abstract String |
getAuthType()
Gets the authentication scheme. |
protected String |
getCredentials(HttpServletRequest request)
Gets the credentials from the HTTP authorization header. |
String |
getDefaultDomain()
Gets the default domain. |
String |
getFaultyUser(HttpServletRequest request,
HttpServletResponse response,
FilterChain chain)
Gets the faulty user of the specified request. |
int |
getLoginAttempts()
Gets the number of allowed login attempts. |
int |
getLoginAttempts(HttpServletRequest request)
Gets the number of login attempts of the specified request. |
String |
getLogoutFlow()
Gets the logout flow. |
String |
getLogoutHost()
Gets the logout host. |
String |
getLogoutPipe()
Gets the logout pipe. |
String |
getLogoutService()
Gets the logout service. |
String |
getLogoutTemplate()
Gets the logout template. |
String |
getLogoutURI()
Gets the logout URI. |
StringBuilder |
getLogoutURL(HttpServletRequest request,
HttpServletResponse response,
FilterChain chain)
Gets the logout URL, with the scheme, host and port if required, for the specified request. |
String |
getPublicRealmName()
Gets the public name of the realm. |
protected Realm |
getRealm()
Gets the refernt of the realm MBean associated to this authenticator. |
ObjectName |
getRealmName()
Gets the user authentication realm. |
String |
getUnauthorizedTemplate()
Gets the unauthorized template. |
protected void |
incrementLoginAttempts(HttpServletRequest request)
Increments login attempts of the specified request by one. |
boolean |
isAuthenticationRequired()
Checks whether authentication is required for unidentified requests. |
boolean |
isAutoLoginEnabled(HttpServletRequest request,
HttpServletResponse response,
FilterChain chain)
Checks whether automatic login is enabled for the specified request. |
boolean |
isCachedPrincipalDiscarded()
Checks whether principals authenticated and cached by other authentication objects are discarded and re-authenticated. |
boolean |
isUserInRole(Principal principal,
String role)
Checks whether the specified principal is in the specified security role within the context of the realm of this filter. |
void |
postmanaged()
This method is called when the implementing adaptee has been managed either during post-registration of the corresponding adapter MBean or just after it is explicitly added to the adapter MBean during run-time. |
void |
setAuthenticationRequired(boolean flag)
Sets the authentication required flag. |
void |
setAutoLoginEnabled(HttpServletRequest request,
HttpServletResponse response,
FilterChain chain,
boolean flag)
Sets whether automatic login is enabled for the specified request. |
void |
setCachedPrincipalDiscarded(boolean flag)
Sets whether principals authenticated and cached by other authentication objects are discarded and re-authenticated. |
void |
setDefaultDomain(String domain)
Sets the the default domain. |
protected void |
setFaultyUser(HttpServletRequest request,
String username)
Sets the faulty user of the specified request. |
void |
setLoginAttempts(int count)
Sets the number of allowed login attempts. |
void |
setLogoutFlow(String flow)
Sets the logout flow. |
void |
setLogoutHost(String host)
Sets the logout host. |
void |
setLogoutPipe(String pipe)
Sets the logout pipe. |
void |
setLogoutService(String service)
Sets the logout service. |
void |
setLogoutTemplate(String template)
Sets the logout template. |
void |
setLogoutURI(String uri)
Sets the logout URI. |
void |
setPublicRealmName(String name)
Sets the public name of the realm. |
void |
setRealmName(ObjectName realm)
Sets the user authentication realm. |
void |
setUnauthorizedTemplate(String template)
Sets the unauthorized template. |
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. |
void |
unmanaged()
This method is called when the implementing adaptee is unmanaged either during pre-deregistration of the corresponding adapter MBean or just before it is explicitly removed from the adapter MBean during run-time. |
protected Principal |
verifyAuthentication(Principal principal)
Verifies whether authentication is required. |
| 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 javax.servlet.Filter |
|---|
destroy, init |
| Field Detail |
|---|
public static final String DEFAULT_USER_ACCOUNT_ID_ATTIBUTE
| Constructor Detail |
|---|
public AbstractAuthenticatorFilter()
| Method Detail |
|---|
public void postmanaged()
Manageable
postmanaged in interface Manageablepostmanaged in class Adaptee
public void unmanaged()
throws Exception
Manageable
unmanaged in interface Manageableunmanaged in class AdapteeException - if the adaptee refused to be unmanaged.public ObjectName getRealmName()
AuthenticatorFilter
getRealmName in interface AuthenticatorFilterpublic void setRealmName(ObjectName realm)
AuthenticatorFilter
setRealmName in interface AuthenticatorFilterrealm - the name of the realm or a query.public String getPublicRealmName()
AuthenticatorFilter
getPublicRealmName in interface AuthenticatorFilterpublic void setPublicRealmName(String name)
AuthenticatorFilter
setPublicRealmName in interface AuthenticatorFiltername - the public name of the realm.public String getDefaultDomain()
AuthenticatorFilter
getDefaultDomain in interface AuthenticatorFilterpublic void setDefaultDomain(String domain)
AuthenticatorFilter
setDefaultDomain in interface AuthenticatorFilterdomain - the default domain.public boolean isAuthenticationRequired()
AuthenticatorFilter
isAuthenticationRequired in interface AuthenticatorFilterpublic void setAuthenticationRequired(boolean flag)
AuthenticatorFilter
setAuthenticationRequired in interface AuthenticatorFilterflag - the authentication required flag.public boolean isCachedPrincipalDiscarded()
AuthenticatorFilter
isCachedPrincipalDiscarded in interface AuthenticatorFilterpublic void setCachedPrincipalDiscarded(boolean flag)
AuthenticatorFilter
setCachedPrincipalDiscarded in interface AuthenticatorFilterflag - the cached principals discarded flag.public String getUnauthorizedTemplate()
AuthenticatorFilter
getUnauthorizedTemplate in interface AuthenticatorFilterpublic void setUnauthorizedTemplate(String template)
AuthenticatorFilter
setUnauthorizedTemplate in interface AuthenticatorFiltertemplate - the unauthorized template.public int getLoginAttempts()
AuthenticatorFilter
getLoginAttempts in interface AuthenticatorFilterpublic void setLoginAttempts(int count)
AuthenticatorFilter
setLoginAttempts in interface AuthenticatorFiltercount - the number of login attempts, -1 = unlimited.public int getLoginAttempts(HttpServletRequest request)
AuthenticatorFilter
getLoginAttempts in interface AuthenticatorFilterrequest - the request.
public String getLogoutURI()
AuthenticatorFilter
getLogoutURI in interface AuthenticatorFilterpublic void setLogoutURI(String uri)
AuthenticatorFilter
setLogoutURI in interface AuthenticatorFilteruri - the logout URI.public String getLogoutHost()
AuthenticatorFilter
getLogoutHost in interface AuthenticatorFilterpublic void setLogoutHost(String host)
AuthenticatorFilter
setLogoutHost in interface AuthenticatorFilterhost - the logout host.public String getLogoutService()
AuthenticatorFilter
getLogoutService in interface AuthenticatorFilterpublic void setLogoutService(String service)
AuthenticatorFilter
setLogoutService in interface AuthenticatorFilterservice - the logout service.public String getLogoutPipe()
AuthenticatorFilter
getLogoutPipe in interface AuthenticatorFilterpublic void setLogoutPipe(String pipe)
AuthenticatorFilter
setLogoutPipe in interface AuthenticatorFilterpipe - the logout pipe.public String getLogoutFlow()
AuthenticatorFilter
getLogoutFlow in interface AuthenticatorFilterpublic void setLogoutFlow(String flow)
AuthenticatorFilter
setLogoutFlow in interface AuthenticatorFilterflow - the login flow.public String getLogoutTemplate()
AuthenticatorFilter
getLogoutTemplate in interface AuthenticatorFilterpublic void setLogoutTemplate(String template)
AuthenticatorFilter
setLogoutTemplate in interface AuthenticatorFiltertemplate - the logout template.
public StringBuilder getLogoutURL(HttpServletRequest request,
HttpServletResponse response,
FilterChain chain)
AuthenticatorFilter
getLogoutURL in interface AuthenticatorFilterrequest - the request.response - the response.chain - the filter chain.
public String getFaultyUser(HttpServletRequest request,
HttpServletResponse response,
FilterChain chain)
AuthenticatorFilter
getFaultyUser in interface AuthenticatorFilterrequest - the request.response - the response.chain - the filter chain.
public boolean isUserInRole(Principal principal,
String role)
AuthenticatorFilter
isUserInRole in interface AuthenticatorFilterprincipal - the principal for whom the role is to be checked.role - the security role to be checked.
public void doFilter(ServletRequest request,
ServletResponse response,
FilterChain chain)
throws ServletException,
IOException
doFilter in interface FilterdoFilter in class DefaultFilterServletException
IOExceptionpublic abstract String getAuthType()
AuthenticatorFilter
getAuthType in interface AuthenticatorFilter
public abstract Principal authenticate(HttpServletRequest request,
HttpServletResponse response,
FilterChain chain)
AuthenticatorFilter
authenticate in interface AuthenticatorFilterrequest - the request.response - the response.chain - the filter chain.
public void unauthenticated(HttpServletRequest request,
HttpServletResponse response,
FilterChain chain)
throws ServletException,
IOException
AuthenticatorFilter
unauthenticated in interface AuthenticatorFilterrequest - the request.response - the response.chain - the filter chain.
ServletException - for servlet errors.
IOException - for general errors.
public boolean isAutoLoginEnabled(HttpServletRequest request,
HttpServletResponse response,
FilterChain chain)
AuthenticatorFilter
isAutoLoginEnabled in interface AuthenticatorFilterrequest - the request.response - the response.chain - the filter chain.
public void setAutoLoginEnabled(HttpServletRequest request,
HttpServletResponse response,
FilterChain chain,
boolean flag)
AuthenticatorFilter
setAutoLoginEnabled in interface AuthenticatorFilterrequest - the request.response - the response.chain - the filter chain.flag - true if enabled, false otherwise.protected Realm getRealm()
protected StringBuilder getAuthenticationURL(String host,
boolean secure,
String service,
String pipe,
String flow,
String page,
HttpServletRequest request,
HttpServletResponse response,
HttpFilterChain chain)
host - the host.secure - true if secure.service - the service.pipe - the pipe.flow - the flow.page - the page.request - the request.response - the response.chain - the filter chain.
protected Principal verifyAuthentication(Principal principal)
principal - the authenticated principal.
protected String getCredentials(HttpServletRequest request)
request - the request.
IllegalArgumentException - for incorrect scheme.
protected String generateAuthenticate(HttpServletRequest request,
HttpServletResponse response,
FilterChain chain)
The header MUST follow this template:
WWW-Authenticate = "WWW-Authenticate" ":" "Basic"
basic-challenge
basic-challenge = 1#(realm)
realm = "realm" "=" realm-value
realm-value = quoted-string
request - the request.response - the response.chain - the filter chain.
protected void incrementLoginAttempts(HttpServletRequest request)
request - the request.protected void decrementLoginAttempts(HttpServletRequest request)
request - the request.
protected void setFaultyUser(HttpServletRequest request,
String username)
request - the request.username - the remote user.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||