|
PAJES 2.3.9 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.pajes.servlet.PajesContextListener
org.pajes.security.AccessPermission
The abstract AccessPermission is sub-classed by classes that determine whether a user has access to servlet resources, and how to process a login request.
The sub-class should be defined as a <listener> in the web application deployment descriptor.
| Field Summary | |
static java.lang.String |
J_PASSWORD
Name of text input field that contains the password |
static java.lang.String |
J_USERNAME
Name of text input field that contains the user name |
| Constructor Summary | |
AccessPermission()
|
|
| Method Summary | |
void |
contextDestroyed(javax.servlet.ServletContextEvent sce)
Notification that the servlet context is about to be shut down. |
void |
contextInitialized(javax.servlet.ServletContextEvent sce)
Notification that the web application is ready to process requests. |
void |
destroy()
Called to destroy this AccessPermission instance. |
java.sql.Connection |
getDBConnection()
Convenience method to return a free database connection from the default connection pool. |
java.sql.Connection |
getDBConnection(java.lang.String poolName)
Convenience method to return a free database connection from the named connection pool. |
ConnectionManager |
getDBConnectionPoolManager()
Convenience method to return the ConnectionManager that manages the defined connection pools available in this ServletContext. |
java.lang.Integer |
getLoginAttempts(javax.servlet.http.HttpSession session)
Returns the current number of times an attempt has been made to login without success. |
javax.servlet.RequestDispatcher |
getLoginAttemptsExceededPage()
Deprecated. Use #getLoginAttemptsExceededPage(HttpServletRequest) |
javax.servlet.RequestDispatcher |
getLoginAttemptsExceededPage(javax.servlet.http.HttpServletRequest request)
Returns the page to which the user will be forwarded when the maximum number of login attempts is exceeded. |
javax.servlet.RequestDispatcher |
getLoginFailedPage()
Deprecated. Use #getLoginFailedPage(HttpServletRequest) |
javax.servlet.RequestDispatcher |
getLoginFailedPage(javax.servlet.http.HttpServletRequest request)
Returns the page to which the user will be forwarded when authentication fails. |
javax.servlet.RequestDispatcher |
getLoginPage()
Deprecated. Use #getLoginPage(HttpServletRequest) |
javax.servlet.RequestDispatcher |
getLoginPage(javax.servlet.http.HttpServletRequest request)
Returns the login page to which the user will be forwarded if they have not yet been authenticated. |
javax.servlet.RequestDispatcher |
getLoginSuccessPage(javax.servlet.http.HttpServletRequest request)
Returns the page to which the user will be forwarded when authentication succeeds. |
int |
getMaximumLoginAttempts()
Returns the maximum number of times an attempt may be made to login without success. |
javax.servlet.ServletContext |
getServletContext()
Returns a reference to the ServletContext from which this
instance was initialised. |
abstract java.security.Principal |
getUserPrincipal(PajeServlet servlet,
javax.servlet.http.HttpServletRequest request)
Determines whether the specified request should be allowed to access the specified servlet. |
abstract PrincipalRoles |
getUserPrincipalRoles(java.security.Principal user)
Returns a list of valid roles for a specific user. |
void |
init()
AccessPermission sub-class initialisation. |
void |
init(javax.servlet.ServletContext context)
Main AccessPermission initialisation. |
boolean |
isInitialised()
Determines if |
boolean |
isInvalid(java.security.Principal principal,
javax.servlet.http.HttpServletRequest request)
Called to determine if the Principal requires revalidation. |
boolean |
isPermitted(AuthenticatedPajeServlet servlet,
java.security.Principal principal,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Called by the AuthenticatedPajeServlet.isPermitted(java.security.Principal, org.pajes.security.AccessPermission, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) method to
provide additional access checking before allowing the request to be
serviced. |
javax.servlet.RequestDispatcher |
loginFailed(javax.servlet.http.HttpServletRequest request,
java.lang.Integer attempts)
Called by AuthenticatedPajeServlet to handle a
failed login attempt, and determine the next page to be displayed to
the user. |
void |
loginSucceeded(javax.servlet.http.HttpSession session,
java.security.Principal principal)
Called by Login to handle a successful login attempt. |
javax.servlet.RequestDispatcher |
logout(javax.servlet.http.HttpServletRequest request)
Called by Logout to revoke authentication, and determine the
next page to be displayed to the user. |
protected void |
postLoginProcessing(javax.servlet.http.HttpSession session,
java.security.Principal principal)
Called immediately after successful login. |
protected void |
preLogoutProcessing(javax.servlet.http.HttpServletRequest request)
Called immediately before logout. |
protected void |
resetLoginAttempts(javax.servlet.http.HttpSession session)
Resets the login attempts count to null. |
java.lang.Integer |
setLoginAttempts(javax.servlet.http.HttpSession session)
Sets the number of logins that have been attempted. |
protected void |
setLoginAttemptsExceededPage(javax.servlet.RequestDispatcher dispatcher)
Sets the page to which the user will be forwarded when the maximum number of login attempts is exceeded. |
protected void |
setLoginFailedPage(javax.servlet.RequestDispatcher dispatcher)
Sets the page to which the user will be forwarded when authentication fails. |
protected void |
setLoginPage(javax.servlet.RequestDispatcher dispatcher)
Sets the login page to which the user will be forwarded if they have not yet been authenticated. |
protected void |
setLoginSuccessPage(javax.servlet.RequestDispatcher dispatcher)
Sets the page to which the user will be forwarded when authentication succeeds. |
protected void |
setMaximumLoginAttempts(int attempts)
Sets the maximum number of times an attempt may be made to login without success. |
| Methods inherited from class org.pajes.servlet.PajesContextListener |
getContext |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final java.lang.String J_PASSWORD
public static final java.lang.String J_USERNAME
| Constructor Detail |
public AccessPermission()
| Method Detail |
public final void contextDestroyed(javax.servlet.ServletContextEvent sce)
contextDestroyed in interface javax.servlet.ServletContextListenercontextDestroyed in class PajesContextListenersce - the event class for notifications about changes to the
servlet context of a web application.destroy()public final void contextInitialized(javax.servlet.ServletContextEvent sce)
contextInitialized in interface javax.servlet.ServletContextListenercontextInitialized in class PajesContextListenersce - the event class for notifications about changes to the
servlet context of a web application.
public java.sql.Connection getDBConnection()
throws java.sql.SQLException
java.sql.SQLException - if an error occurs accessing the database.
public java.sql.Connection getDBConnection(java.lang.String poolName)
throws java.sql.SQLException
poolName - the name of the connection pool to use.
java.sql.SQLException - if an error occurs accessing the database.public ConnectionManager getDBConnectionPoolManager()
public java.lang.Integer getLoginAttempts(javax.servlet.http.HttpSession session)
session - the session object.
null if no attempts have
been made.public javax.servlet.RequestDispatcher getLoginAttemptsExceededPage()
public javax.servlet.RequestDispatcher getLoginAttemptsExceededPage(javax.servlet.http.HttpServletRequest request)
maximum number of login attempts is exceeded.
The default implementation returns the RequestDispatcher
set by the setLoginAttemptsExceededPage(javax.servlet.RequestDispatcher) method. However,
sub-classes may over-ride this method to provide alternate destinations
depending upon the request object.
request - the request object.
maximum times.public javax.servlet.RequestDispatcher getLoginFailedPage()
public javax.servlet.RequestDispatcher getLoginFailedPage(javax.servlet.http.HttpServletRequest request)
The default implementation returns the RequestDispatcher
set by the setLoginFailedPage(javax.servlet.RequestDispatcher) method. However, sub-classes may
over-ride this method to provide alternate destinations depending upon
the request object.
request - the request object.
public javax.servlet.RequestDispatcher getLoginPage()
public javax.servlet.RequestDispatcher getLoginPage(javax.servlet.http.HttpServletRequest request)
The default implementation returns the RequestDispatcher
set by the setLoginPage(javax.servlet.RequestDispatcher) method. However, sub-classes may
over-ride this method to provide alternate destinations depending upon
the request object.
request - the request object.
public javax.servlet.RequestDispatcher getLoginSuccessPage(javax.servlet.http.HttpServletRequest request)
The default implementation returns the RequestDispatcher
set by the setLoginSuccessPage(javax.servlet.RequestDispatcher) method. However, sub-classes
may over-ride this method to provide alternate destinations depending
upon the request object.
request - the request object.
public int getMaximumLoginAttempts()
public javax.servlet.ServletContext getServletContext()
ServletContext from which this
instance was initialised.
ServletContext object passed to
this object by the init methodinit(ServletContext)
public abstract java.security.Principal getUserPrincipal(PajeServlet servlet,
javax.servlet.http.HttpServletRequest request)
servlet - the servlet to which access is requested.request - the request object.
public abstract PrincipalRoles getUserPrincipalRoles(java.security.Principal user)
user - Description of Parameter
public final boolean isInitialised()
init(ServletContext) method has been run.public void destroy()
AccessPermission instance.
The default implementation does nothing.
contextDestroyed(javax.servlet.ServletContextEvent),
Initialisation.destroy()
public final void init(javax.servlet.ServletContext context)
throws AccessPermissionException
Called the first time that authentication services are required.
context - the ServletContext object that contains
context information about this web application
AccessPermissionException - if a security related exception
occurs.
public boolean isInvalid(java.security.Principal principal,
javax.servlet.http.HttpServletRequest request)
Principal requires revalidation.
The default implementation always returns false.
principal - the authenticated user principal.request - the request object.
Principal requires revalidation, or
false if no revalidation is required.
public boolean isPermitted(AuthenticatedPajeServlet servlet,
java.security.Principal principal,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
AuthenticatedPajeServlet.isPermitted(java.security.Principal, org.pajes.security.AccessPermission, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) method to
provide additional access checking before allowing the request to be
serviced.
This method will only be called if the user has been succesfully
authenticated (i.e. the Principal has been established).
The default implementation simply returns true.
servlet - the servlet to which access is being requested.principal - the authenticated principal object.request - the object that contains the request the client made of
the servlet.response - the object that contains the response the servlet will
return to the client.
public void init()
throws AccessPermissionException
This method is called by init(ServletContext), and the default
implementation does nothing.
Sub-classes should over-ride this method and call the protected set methods to correctly configure access permissions.
AccessPermissionException - if a security related exception
occurs.setLoginAttemptsExceededPage(javax.servlet.RequestDispatcher),
setLoginFailedPage(javax.servlet.RequestDispatcher),
setLoginPage(javax.servlet.RequestDispatcher),
setLoginSuccessPage(javax.servlet.RequestDispatcher),
setMaximumLoginAttempts(int)
public final javax.servlet.RequestDispatcher loginFailed(javax.servlet.http.HttpServletRequest request,
java.lang.Integer attempts)
AuthenticatedPajeServlet to handle a
failed login attempt, and determine the next page to be displayed to
the user.
request - the request object.attempts - the number of logins attempted by this session.
public final void loginSucceeded(javax.servlet.http.HttpSession session,
java.security.Principal principal)
Login to handle a successful login attempt.
session - the session object.principal - the authenticated user principal.public final javax.servlet.RequestDispatcher logout(javax.servlet.http.HttpServletRequest request)
Logout to revoke authentication, and determine the
next page to be displayed to the user.
request - the request object.
public java.lang.Integer setLoginAttempts(javax.servlet.http.HttpSession session)
session - the session object.
zero if no attempts have
been made.
protected void setLoginAttemptsExceededPage(javax.servlet.RequestDispatcher dispatcher)
throws AccessPermissionException
maximum number of login attempts is exceeded.
dispatcher - the page to which the user will be forwarded when
authentication fails maximum
times.
AccessPermissionException - if a null dispatcher is passed.
protected void setLoginFailedPage(javax.servlet.RequestDispatcher dispatcher)
throws AccessPermissionException
dispatcher - the page to which the user will be forwarded when
authentication fails.
AccessPermissionException - if a null dispatcher is passed.
protected void setLoginPage(javax.servlet.RequestDispatcher dispatcher)
throws AccessPermissionException
dispatcher - the login page to which the user will be forwarded if
they have not yet been authenticated.
AccessPermissionException - if a null dispatcher is passed.
protected void setLoginSuccessPage(javax.servlet.RequestDispatcher dispatcher)
throws AccessPermissionException
NOTE: Some servlet containers do not correctly save the session
if a redirect is done after authentication. It is recommended that only
a realRequestDispatcher, rather than a PAJES
RequestRedirector be used on login success.
dispatcher - the page to which the user will be forwarded when
authentication succeeds.
AccessPermissionException - if a null dispatcher is passed.protected void setMaximumLoginAttempts(int attempts)
attempts - the maximum number of times an attempt may be made to
login without success.
protected void postLoginProcessing(javax.servlet.http.HttpSession session,
java.security.Principal principal)
Sub-classes may over-ride this method to perform any application specific login processing. The default implementation does nothing.
session - the session object.principal - the authenticated user principal.protected void preLogoutProcessing(javax.servlet.http.HttpServletRequest request)
Sub-classes may over-ride this method to perform any application specific logout processing. The default implementation does nothing.
request - the request object.protected void resetLoginAttempts(javax.servlet.http.HttpSession session)
null.
session - the session object.
|
PAJES 2.3.9 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||