edu.ucsb.adl.middleware
Class LoginServlet

java.lang.Object
  |
  +--javax.servlet.GenericServlet
        |
        +--javax.servlet.http.HttpServlet
              |
              +--edu.ucsb.adl.middleware.LoginServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public final class LoginServlet
extends javax.servlet.http.HttpServlet

Sample servlet that triggers a web browser to ask the user for a username and password. The servlet accepts simple HTTP GET requests. If the request lacks an HTTP "basic" authorization header, or if the request includes a "basic" authorization header but the authorization is rejected by a specified gatekeeper, an HTTP 401 (unauthorized) status code is returned. Otherwise, an HTTP 200 (OK) status code is returned.

Gatekeeper exceptions are caught and returned as HTTP errors. In particular, BadRequestException is mapped to 400 (bad request) and InternalErrorException is mapped to 500 (internal server error).

Version:
$Header: /export/home/gjanee/middleware/edu/ucsb/adl/middleware/RCS/LoginServlet.java,v 1.7 2006/06/21 18:07:58 gjanee Exp $

$Log: LoginServlet.java,v $ Revision 1.7 2006/06/21 18:07:58 gjanee
To make web browsers a little happier, servlets that formerly returned HTTP status code 204 (no content) now return status code 200 (OK) and return the plain text "DONE\n".

Revision 1.6 2004/09/21 22:47:53 gjanee
Rewrite to use class ExtendedProperties.

Revision 1.5 2004/03/02 22:01:48 gjanee
If the middleware_configuration_file servlet initialization parameter is not available, we now look for it as a context-wide initialization parameter.

Revision 1.4 2001/10/08 18:23:27 gjanee
Added the middleware_configuration_file property.

Revision 1.3 2001/10/04 18:41:12 gjanee
To support the middleware being a web application, we now allow the location of the middleware configuration file to be specified relative to the web application directory.

Revision 1.2 2001/02/15 18:36:46 gjanee
Minor upgrade to servlet API 2.2.

Revision 1.1 2000/05/20 22:00:20 gjanee
Initial revision

Author:
Greg Janée
Alexandria Digital Library
See Also:
Serialized Form

Constructor Summary
LoginServlet()
          Creates a LoginServlet.
 
Method Summary
 void destroy()
          Frees all resources held by the servlet.
 void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Performs the HTTP GET service described above.
 void init(javax.servlet.ServletConfig config)
          Initializes the servlet.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoginServlet

public LoginServlet()
Creates a LoginServlet.

Method Detail

init

public void init(javax.servlet.ServletConfig config)
          throws javax.servlet.ServletException
Initializes the servlet.

Specified by:
init in interface javax.servlet.Servlet
Overrides:
init in class javax.servlet.GenericServlet
Parameters:
config - Must contain the following initialization parameters:
middleware_configuration_file
The filename of an ADL middleware configuration file. If the filename is not absolute, it is interpreted relative to the middleware web application directory.
class_property
The name of a property in the above configuration file whose value is the fully-qualified name of a gatekeeper class. The gatekeeper must implement interface GenericGatekeeper.
argument_property
The name of a property in the above configuration file whose value is the gatekeeper's startup parameter.
Throws:
javax.servlet.UnavailableException - If the initialization fails.
javax.servlet.ServletException

doGet

public void doGet(javax.servlet.http.HttpServletRequest request,
                  javax.servlet.http.HttpServletResponse response)
           throws java.io.IOException
Performs the HTTP GET service described above.

Overrides:
doGet in class javax.servlet.http.HttpServlet
Parameters:
request - The HTTP request.
response - The HTTP response.
Throws:
java.io.IOException - On any I/O error.

destroy

public void destroy()
Frees all resources held by the servlet.

Specified by:
destroy in interface javax.servlet.Servlet
Overrides:
destroy in class javax.servlet.GenericServlet