Expresso 5-5-0

com.jcorporate.expresso.core.servlet
Class CheckLogin

java.lang.Object
  extended bycom.jcorporate.expresso.core.servlet.CheckLogin

public final class CheckLogin
extends Object

CheckLogin accepts an HttpServletRequest and HttpServletResponse object pair, and attempts to check if the user is logged in. If not, CheckLogin tries to log the user in via a cookie from the client. If this is not possible, the user is logged in as "NONE". It has now been modified to be a Singleton Object rather than having a new object allocated with each request. Example Usage:
CheckLogin.getInstance().checkLogin(request,response);

Version:
$Revision: 1.20 $ $Date: 2003/08/03 10:26:26 $
Author:
Michael Nash, Singleton Modification by Michael Rimov

Constructor Summary
protected CheckLogin()
          Default Constructor....
 
Method Summary
 void checkLogin(HttpServletRequest request, HttpServletResponse response)
          Constructor.
 void checkLogin(HttpServletRequest request, HttpServletResponse response, ServletConfig c)
          Enhanced Constructor.
 void checkLogin(HttpServletRequest request, HttpServletResponse response, ServletConfig c, String forceDB)
          Enhanced Constructor.
static CheckLogin getInstance()
           
 void logInAsNone(HttpServletRequest request, String forceDB)
          For some reason a login session could not be established, so log the user in as the "unknown" user "NONE"
 boolean loginViaContainer(HttpServletRequest request, String forceDB)
          Try to log in with a user name obtained from the container.
 boolean loginViaCookie(HttpServletRequest request, String forceDB)
          Try to log in via the cookie from the client - if successful, return true.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CheckLogin

protected CheckLogin()
Default Constructor.... Simply sets up the Log It should not be called anymore directly. Use getInstance() instead.

Method Detail

getInstance

public static CheckLogin getInstance()

checkLogin

public void checkLogin(HttpServletRequest request,
                       HttpServletResponse response,
                       ServletConfig c,
                       String forceDB)
                throws ServletException,
                       NonHandleableException,
                       IOException
Enhanced Constructor. Same as older constructor, but includes option to specify a particular database

Parameters:
request - Standard request object
response - Standard response object
c - ServletConfig object of the calling servlet
forceDB - the db to force a login to
Throws:
ServletException - If an uncaught exception occurs
IOException - If an I/O error occurs while communicating with the client
NonHandleableException - upon fatal error

checkLogin

public void checkLogin(HttpServletRequest request,
                       HttpServletResponse response,
                       ServletConfig c)
                throws ServletException,
                       NonHandleableException,
                       IOException
Enhanced Constructor. Same as older constructor, but also checks if this application is initialized, and initializes if needed

Parameters:
request - Standard request object
response - Standard response object
c - ServletConfig object of the calling servlet
Throws:
ServletException - If an uncaught exception occurs
IOException - If an I/O error occurs while communicating with the client
NonHandleableException - upon fatal error

checkLogin

public void checkLogin(HttpServletRequest request,
                       HttpServletResponse response)
                throws ServletException,
                       NonHandleableException,
                       IOException
Constructor. Performs all the functions of the class immediately

Parameters:
request - Standard request object
response - Standard response object
Throws:
ServletException - If an uncaught exception occurs
IOException - If an I/O error occurs while communicating with the client
NonHandleableException - upon fatal error

logInAsNone

public void logInAsNone(HttpServletRequest request,
                        String forceDB)
                 throws ServletException
For some reason a login session could not be established, so log the user in as the "unknown" user "NONE"

Parameters:
request - the servlet request object
forceDB - the data context to log into
Throws:
ServletException

loginViaContainer

public boolean loginViaContainer(HttpServletRequest request,
                                 String forceDB)
                          throws Exception
Try to log in with a user name obtained from the container. This function assumes that the container has already authenticated the user's ID and password, thus no password checking is performed. This is intended to allow more fine-grained access control via Expresso's built-in mechanisms. If successful, return true. If not, return false.

Parameters:
request - The request object
forceDB - Name of default database to set
Returns:
true if successfull
Throws:
Exception - upon error

loginViaCookie

public boolean loginViaCookie(HttpServletRequest request,
                              String forceDB)
                       throws Exception
Try to log in via the cookie from the client - if successful, return true. If not, return false

Parameters:
request - the servlet request object
forceDB - the data context to login to
Returns:
true if successfull
Throws:
Exception - upon error

Expresso 5-5-0

Please see www.jcorporate.com for information about new Expresso releases.