OpMath

com.opmath.util.http
Class HttpLogOnServlet

java.lang.Object
  |
  +--javax.servlet.GenericServlet
        |
        +--javax.servlet.http.HttpServlet
              |
              +--com.opmath.util.http.HttpServlet
                    |
                    +--com.opmath.util.http.HttpLogOnServlet
All Implemented Interfaces:
ParamIndex, Serializable, Servlet, ServletConfig

public abstract class HttpLogOnServlet
extends HttpServlet
implements ParamIndex

Provides an abstract class for a servlet that can respond to a log on request.

Servlets of this class have to deal with three distinct outcomes of the log on request:

WARNING: It is up to the programmer to ensure that the use of the HttpSession instance variable (or any other instance variable) has thread safety.

Copyright: (c) 2002 The Open Math Company Limited

The Terms of Distribution of this software are stipulated in the javadoc Overview for this project.

Since:
J2SE 1.3.0
Version:
utilities-v011
Author:
Bruno Beloff bruno.beloff@opmath.com
See Also:
HttpServlet, HttpSessionServlet, HttpLogOffServlet, HttpProtectedServlet, Serialized Form

Field Summary
 
Fields inherited from class com.opmath.util.http.HttpServlet
EOL, LOGON_ID, LOGON_TARGET
 
Constructor Summary
HttpLogOnServlet()
           
 
Method Summary
 void doGet(HttpServletRequest req, HttpServletResponse rsp)
          Handles an HTTP GET request.
protected  String doGetDispatch(HttpServletRequest req)
          Services an HTTP GET request, as handled by the superclass.
 void doPost(HttpServletRequest req, HttpServletResponse rsp)
          Handles an HTTP POST request.
protected  String doPostDispatch(HttpServletRequest req)
          Services an HTTP POST request, as handled by doPost(HttpServletRequest, HttpServletResponse).
 String getServletInfo()
          Returns a String carrying some information about the servlet.
protected  String identifyUser(HttpServletRequest req)
          Attempts to authenticate the requester, and authorize the requester's access.
protected  String logOnRedirectURI()
          Returns the URI of the resource that is targetted where authentication and authorisation are successful, but no other URI is available.
 
Methods inherited from class com.opmath.util.http.HttpServlet
getIndex, getParamIndex, getValueCount, paramIndices, paramMappings, paramNames, paramValues, registerIndex, registerIndices, report, setConfig, setConfig
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletName, init, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.opmath.util.http.ParamIndex
getIndex, getParamIndex, getValueCount, paramIndices, paramMappings, paramNames, paramValues, registerIndex
 

Constructor Detail

HttpLogOnServlet

public HttpLogOnServlet()
Method Detail

logOnRedirectURI

protected String logOnRedirectURI()

Returns the URI of the resource that is targetted where authentication and authorisation are successful, but no other URI is available.

This method attempts to provide the home URI of the Web application - the actual URI String returned is "/".

Returns:
A String carrying the default redirection URI.
Since:
J2SE 1.3

doGet

public final void doGet(HttpServletRequest req,
                        HttpServletResponse rsp)
                 throws ServletException,
                        IOException

Handles an HTTP GET request. Specified as final to maintain security.

Overrides:
doGet in class HttpServlet
Throws:
ServletException - an exception thrown if the request could not be handled.
IOException - an exception thrown if an input or output error is detected when the servlet handles the GET request.
Since:
J2SE 1.3
See Also:
doGetDispatch(com.opmath.util.http.HttpServletRequest)

doGetDispatch

protected String doGetDispatch(HttpServletRequest req)
                        throws Exception

Services an HTTP GET request, as handled by the superclass. This method is normally invoked when a GET request is made directly to the implementing servlet.

Overrides:
doGetDispatch in class HttpServlet
Returns:
A String carrying the report.
Throws:
Exception - if a subclass's method encounters any error state.
Since:
J2SE 1.3
See Also:
HttpServlet.doGet(HttpServletRequest, HttpServletResponse)

doPost

public final void doPost(HttpServletRequest req,
                         HttpServletResponse rsp)
                  throws ServletException,
                         IOException

Handles an HTTP POST request. As with the doPost(HttpServletRequest, HttpServletResponse) method on its superclass, the idea here is to do any essential preparatory work, then hand over control to the doPostDispatch(HttpServletRequest, HttpServletResponse) method of the subclass. Once the subclass's doPostDispatch(HttpServletRequest, HttpServletResponse)method has completed, any essantial cleaning up is done.

Specifically in this case, an attempt is made to authenticate and authorize the user by invoking the identifyUser(com.opmath.util.http.HttpServletRequest) method on the actual class of the LogOn Servlet. If authentication and authoriztion are successful, a redirection takes place. Otherwise, doPostDispatch(com.opmath.util.http.HttpServletRequest) is executed.

Overrides:
doPost in class HttpServlet
Throws:
ServletException - if the method encounters any method-internal error.
IOException - if one of the method's resources could not be used.
Since:
J2SE 1.3
See Also:
doPostDispatch(com.opmath.util.http.HttpServletRequest)

doPostDispatch

protected String doPostDispatch(HttpServletRequest req)
                         throws Exception

Services an HTTP POST request, as handled by doPost(HttpServletRequest, HttpServletResponse).

In parctice, this method will only be invoked when a redirection could not take place - that is, when either authenication failed, or authorization was declined. This method should be overriden by any real-world application.

Overrides:
doPostDispatch in class HttpServlet
Returns:
A String carrying the report.
Throws:
Exception - if a subclass's method encounters any error state.
Since:
J2SE 1.3
See Also:
doPost(HttpServletRequest, HttpServletResponse)

identifyUser

protected String identifyUser(HttpServletRequest req)

Attempts to authenticate the requester, and authorize the requester's access. If authorized, this method should return a unique ID of the requester. If not authorized, this method should reurn null.

This method always returns null - in other words, access is always denied. The method should be overriden by any real-world application.

Returns:
A String uniquely identifying the requester, or null.
Since:
J2SE 1.3

getServletInfo

public String getServletInfo()
Returns a String carrying some information about the servlet. This method should be overridden by any subclass.

Specified by:
getServletInfo in interface Servlet
Overrides:
getServletInfo in class HttpServlet
Returns:
a String describing the class.
Since:
J2SE 1.3

OpMath

Submit a bug or feature to Open Math
Copyright © 2002 Open Math Company Limited, Brighton, UK