org.eclipse.jetty.security
Class SecurityHandler
java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.server.handler.AbstractHandler
org.eclipse.jetty.server.handler.AbstractHandlerContainer
org.eclipse.jetty.server.handler.HandlerWrapper
org.eclipse.jetty.security.SecurityHandler
- All Implemented Interfaces:
- Authenticator.Configuration, Handler, HandlerContainer, LifeCycle
- Direct Known Subclasses:
- ConstraintSecurityHandler
public abstract class SecurityHandler
- extends HandlerWrapper
- implements Authenticator.Configuration
Abstract SecurityHandler.
Select and apply an Authenticator to a request.
The Authenticator may either be directly set on the handler
or will be create during AbstractLifeCycle.start() with a call to
either the default or set AuthenticatorFactory.
SecurityHandler has a set of initparameters that are used by the
Authentication.Configuration. At startup, any context init parameters
that start with "org.eclipse.jetty.security." that do not have
values in the SecurityHandler init parameters, are copied.
|
Field Summary |
static java.security.Principal |
__NO_USER
|
static java.security.Principal |
__NOBODY
Nobody user. |
|
Method Summary |
protected boolean |
checkSecurity(Request request)
|
protected abstract boolean |
checkUserDataPermissions(java.lang.String pathInContext,
Request request,
Response response,
java.lang.Object constraintInfo)
|
protected abstract boolean |
checkWebResourcePermissions(java.lang.String pathInContext,
Request request,
Response response,
java.lang.Object constraintInfo,
UserIdentity userIdentity)
|
protected void |
doStart()
|
protected void |
doStop()
|
protected IdentityService |
findIdentityService()
|
protected LoginService |
findLoginService()
|
Authenticator |
getAuthenticator()
|
Authenticator.Factory |
getAuthenticatorFactory()
|
java.lang.String |
getAuthMethod()
|
IdentityService |
getIdentityService()
Get the identityService. |
java.lang.String |
getInitParameter(java.lang.String key)
|
java.util.Set<java.lang.String> |
getInitParameterNames()
|
LoginService |
getLoginService()
Get the loginService. |
java.lang.String |
getRealmName()
|
void |
handle(java.lang.String pathInContext,
Request baseRequest,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
|
protected abstract boolean |
isAuthMandatory(Request baseRequest,
Response base_response,
java.lang.Object constraintInfo)
|
boolean |
isCheckWelcomeFiles()
|
protected abstract java.lang.Object |
prepareConstraintInfo(java.lang.String pathInContext,
Request request)
|
void |
setAuthenticator(Authenticator authenticator)
Set the authenticator. |
void |
setAuthenticatorFactory(Authenticator.Factory authenticatorFactory)
|
void |
setAuthMethod(java.lang.String authMethod)
|
void |
setCheckWelcomeFiles(boolean authenticateWelcomeFiles)
|
void |
setIdentityService(IdentityService identityService)
Set the identityService. |
java.lang.String |
setInitParameter(java.lang.String key,
java.lang.String value)
Set an initialization parameter. |
void |
setLoginService(LoginService loginService)
Set the loginService. |
void |
setRealmName(java.lang.String realmName)
|
| Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle |
addLifeCycleListener, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
__NO_USER
public static java.security.Principal __NO_USER
__NOBODY
public static java.security.Principal __NOBODY
- Nobody user. The Nobody UserPrincipal is used to indicate a partial state
of authentication. A request with a Nobody UserPrincipal will be allowed
past all authentication constraints - but will not be considered an
authenticated request. It can be used by Authenticators such as
FormAuthenticator to allow access to logon and error pages within an
authenticated URI tree.
SecurityHandler
protected SecurityHandler()
getIdentityService
public IdentityService getIdentityService()
- Get the identityService.
- Specified by:
getIdentityService in interface Authenticator.Configuration
- Returns:
- the identityService
setIdentityService
public void setIdentityService(IdentityService identityService)
- Set the identityService.
- Parameters:
identityService - the identityService to set
getLoginService
public LoginService getLoginService()
- Get the loginService.
- Specified by:
getLoginService in interface Authenticator.Configuration
- Returns:
- the loginService
setLoginService
public void setLoginService(LoginService loginService)
- Set the loginService.
- Parameters:
loginService - the loginService to set
getAuthenticator
public Authenticator getAuthenticator()
setAuthenticator
public void setAuthenticator(Authenticator authenticator)
- Set the authenticator.
- Parameters:
authenticator -
- Throws:
java.lang.IllegalStateException - if the SecurityHandler is running
getAuthenticatorFactory
public Authenticator.Factory getAuthenticatorFactory()
- Returns:
- the authenticatorFactory
setAuthenticatorFactory
public void setAuthenticatorFactory(Authenticator.Factory authenticatorFactory)
- Parameters:
authenticatorFactory - the authenticatorFactory to set
- Throws:
java.lang.IllegalStateException - if the SecurityHandler is running
getRealmName
public java.lang.String getRealmName()
- Specified by:
getRealmName in interface Authenticator.Configuration
- Returns:
- the realmName
setRealmName
public void setRealmName(java.lang.String realmName)
- Parameters:
realmName - the realmName to set
- Throws:
java.lang.IllegalStateException - if the SecurityHandler is running
getAuthMethod
public java.lang.String getAuthMethod()
- Specified by:
getAuthMethod in interface Authenticator.Configuration
- Returns:
- the authMethod
setAuthMethod
public void setAuthMethod(java.lang.String authMethod)
- Parameters:
authMethod - the authMethod to set
- Throws:
java.lang.IllegalStateException - if the SecurityHandler is running
isCheckWelcomeFiles
public boolean isCheckWelcomeFiles()
- Returns:
- True if forwards to welcome files are authenticated
setCheckWelcomeFiles
public void setCheckWelcomeFiles(boolean authenticateWelcomeFiles)
- Parameters:
authenticateWelcomeFiles - True if forwards to welcome files are
authenticated
- Throws:
java.lang.IllegalStateException - if the SecurityHandler is running
getInitParameter
public java.lang.String getInitParameter(java.lang.String key)
- Specified by:
getInitParameter in interface Authenticator.Configuration
getInitParameterNames
public java.util.Set<java.lang.String> getInitParameterNames()
- Specified by:
getInitParameterNames in interface Authenticator.Configuration
setInitParameter
public java.lang.String setInitParameter(java.lang.String key,
java.lang.String value)
- Set an initialization parameter.
- Parameters:
key - value -
- Returns:
- previous value
- Throws:
java.lang.IllegalStateException - if the SecurityHandler is running
findLoginService
protected LoginService findLoginService()
findIdentityService
protected IdentityService findIdentityService()
doStart
protected void doStart()
throws java.lang.Exception
- Overrides:
doStart in class HandlerWrapper
- Throws:
java.lang.Exception
doStop
protected void doStop()
throws java.lang.Exception
- Overrides:
doStop in class HandlerWrapper
- Throws:
java.lang.Exception- See Also:
HandlerWrapper.doStop()
checkSecurity
protected boolean checkSecurity(Request request)
handle
public void handle(java.lang.String pathInContext,
Request baseRequest,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws java.io.IOException,
javax.servlet.ServletException
- Specified by:
handle in interface Handler- Overrides:
handle in class HandlerWrapper
- Throws:
java.io.IOException
javax.servlet.ServletException
prepareConstraintInfo
protected abstract java.lang.Object prepareConstraintInfo(java.lang.String pathInContext,
Request request)
checkUserDataPermissions
protected abstract boolean checkUserDataPermissions(java.lang.String pathInContext,
Request request,
Response response,
java.lang.Object constraintInfo)
throws java.io.IOException
- Throws:
java.io.IOException
isAuthMandatory
protected abstract boolean isAuthMandatory(Request baseRequest,
Response base_response,
java.lang.Object constraintInfo)
checkWebResourcePermissions
protected abstract boolean checkWebResourcePermissions(java.lang.String pathInContext,
Request request,
Response response,
java.lang.Object constraintInfo,
UserIdentity userIdentity)
throws java.io.IOException
- Throws:
java.io.IOException
Copyright © 1995-2009 Mort Bay Consulting. All Rights Reserved.