|
Tynamo™-TINI v1.0.4 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavax.servlet.GenericServlet
javax.servlet.http.HttpServlet
com.qindesign.servlet.AuthenticatedHttpServlet
public abstract class AuthenticatedHttpServlet
This class is provided to enable servlets to perform authentication. It
can be extended and used as-is by overriding the
getRealm(HttpServletRequest) and
getPassword(String, String) methods. If one wishes, the various
doUnauthorizedXXX can be overridden to gather or send
additional information after it is known that a request is unauthorized.
The design of this class is such that a developer needs only replace the
HttpServlet superclass with AuthenticatedHttpServlet.
All else is unchanged unless
HttpServlet.service(HttpServletRequest, HttpServletResponse)
needs to be overridden, in which case please see the
authorizedService(HttpServletRequest, HttpServletResponse)
and authorizedService(HttpServletRequest, HttpServletResponse)
methods.
Subclassers may also wish to determine how their document is cached via the appropriate HTTP headers.
Authenticator.Authorizer,
Serialized Form| Constructor Summary | |
|---|---|
AuthenticatedHttpServlet()
|
|
| Method Summary | |
|---|---|
protected void |
authorizedService(HttpServletRequest req,
HttpServletResponse resp)
This method is the authorized equivalent of the HttpServlet.service(HttpServletRequest, HttpServletResponse)
method. |
protected void |
doUnauthorizedDelete(HttpServletRequest req,
HttpServletResponse resp)
This method is called if the DELETE request was not authenticated. |
protected void |
doUnauthorizedGet(HttpServletRequest req,
HttpServletResponse resp)
This method is called if the GET request was not authenticated. |
protected void |
doUnauthorizedOptions(HttpServletRequest req,
HttpServletResponse resp)
This method is called if the OPTIONS request was not authenticated. |
protected void |
doUnauthorizedPost(HttpServletRequest req,
HttpServletResponse resp)
This method is called if the POST request was not authenticated. |
protected void |
doUnauthorizedPut(HttpServletRequest req,
HttpServletResponse resp)
This method is called if the PUT request was not authenticated. |
protected void |
doUnauthorizedTrace(HttpServletRequest req,
HttpServletResponse resp)
This method is called if the TRACE request was not authenticated. |
String |
getDefaultScheme(HttpServletRequest req)
Gets the default authentication scheme. |
abstract String |
getPassword(String realm,
String user)
This method must be implemented. |
String |
getProperty(String name,
HttpServletRequest req)
Gets a property of the authentication scheme. |
abstract String |
getRealm(HttpServletRequest req)
Users must implement this to find the "realm" of a specific request. |
boolean |
isAuthExpired(long age,
HttpServletRequest req)
Checks if the authorization is expired for the given request. |
boolean |
isSchemeAcceptable(String scheme,
HttpServletRequest req)
Determines if the specified scheme is acceptable for the given request. |
protected void |
service(HttpServletRequest req,
HttpServletResponse resp)
Receives standard HTTP requests from the public service
method and dispatches them to the doXXX methods
defined in this class. |
void |
service(ServletRequest req,
ServletResponse resp)
This method is implemented so that it can be prevented from being overridden. |
protected void |
unauthorizedService(HttpServletRequest req,
HttpServletResponse resp)
This method is the unauthorized equivalent of the HttpServlet.service(HttpServletRequest, HttpServletResponse)
method. |
| Methods inherited from class javax.servlet.http.HttpServlet |
|---|
doDelete, doGet, doOptions, doPost, doPut, doTrace, getLastModified |
| Methods inherited from class javax.servlet.GenericServlet |
|---|
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public AuthenticatedHttpServlet()
| Method Detail |
|---|
public abstract String getRealm(HttpServletRequest req)
getRealm in interface com.qindesign.tini.http.Authenticator.Authorizerreq - the requestAuthenticator.Authorizer
public abstract String getPassword(String realm,
String user)
getPassword in interface com.qindesign.tini.http.Authenticator.Authorizerrealm - the protection space, a case-insensitive valueuser - the user
public String getProperty(String name,
HttpServletRequest req)
This returns null as the default.
getProperty in interface com.qindesign.tini.http.Authenticator.Authorizername - the name of the property whose value is requestedreq - the request
null if
the property has no value.public String getDefaultScheme(HttpServletRequest req)
This returns "Digest" as the default.
getDefaultScheme in interface com.qindesign.tini.http.Authenticator.Authorizerreq - the request
public boolean isSchemeAcceptable(String scheme,
HttpServletRequest req)
As the default, this returns
isSchemeAcceptable in interface com.qindesign.tini.http.Authenticator.Authorizer
scheme - the scheme currently being authorized, a case-insensitive
valuereq - the request
public boolean isAuthExpired(long age,
HttpServletRequest req)
This is used by Digest authentication.
This returns false as the default.
isAuthExpired in interface com.qindesign.tini.http.Authenticator.Authorizerage - the age, in ms, of the authorizationreq - the request
public final void service(ServletRequest req,
ServletResponse resp)
throws ServletException,
IOException
service in interface Servletservice in class HttpServletServletException
IOException
protected void unauthorizedService(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException,
IOException
HttpServlet.service(HttpServletRequest, HttpServletResponse)
method. This is called when it is known that the request was not
authorized. It dispatches the request to the appropriate
doUnauthorizedXXX method.
One would want to override this method for the same reasons as
overriding HttpServlet.service(HttpServletRequest, HttpServletResponse),
except only for unauthorized requests.
req - the HTTP request objectresp - the HTTP response object
ServletException - if the request cannot be handled.
IOException - if an I/O error occurs while handling the request.
protected void authorizedService(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException,
IOException
HttpServlet.service(HttpServletRequest, HttpServletResponse)
method. This is called when it is known that the request is
authenticated. It dispatches the request to the appropriate
doXXX method.
One would want to override this method for the same reasons as
overriding HttpServlet.service(HttpServletRequest, HttpServletResponse),
except only for authenticated requests.
req - the HTTP request objectresp - the HTTP response object
ServletException - if the request cannot be handled.
IOException - if an I/O error occurs while handling the request.unauthorizedService(HttpServletRequest, HttpServletResponse)
protected final void service(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException,
IOException
service
method and dispatches them to the doXXX methods
defined in this class.
This method cannot be overridden because it performs the
authentication. To implement similar behaviour, please override
authorizedService(HttpServletRequest, HttpServletResponse).
The unauthorized equivalent is
unauthorizedService(HttpServletRequest, HttpServletResponse).
service in class HttpServletreq - the HTTP request objectresp - the HTTP response object
ServletException - if the request cannot be handled.
IOException - if an I/O error occurs while handling the request.authorizedService(HttpServletRequest, HttpServletResponse),
unauthorizedService(HttpServletRequest, HttpServletResponse)
protected void doUnauthorizedGet(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException,
IOException
doGet. The response status code
is already set appropriately.
This method provides the opportunity to gather or send additional information after it is known that the request was unauthorized.
This method also supports unauthorized HEAD requests.
ServletException
IOException
protected void doUnauthorizedPost(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException,
IOException
doPost. The response status code
is already set appropriately.
This method provides the opportunity to gather or send additional information after it is known that the request was unauthorized.
ServletException
IOException
protected void doUnauthorizedPut(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException,
IOException
doPut. The response status code
is already set appropriately.
This method provides the opportunity to gather or send additional information after it is known that the request was unauthorized.
ServletException
IOException
protected void doUnauthorizedDelete(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException,
IOException
doDelete. The response status
code is already set appropriately.
This method provides the opportunity to gather or send additional information after it is known that the request was unauthorized.
ServletException
IOException
protected void doUnauthorizedOptions(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException,
IOException
doOptions. The response status
code is already set appropriately.
This method provides the opportunity to gather or send additional information after it is known that the request was unauthorized.
ServletException
IOException
protected void doUnauthorizedTrace(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException,
IOException
doTrace. The response status
code is already set appropriately.
This method provides the opportunity to gather or send additional information after it is known that the request was unauthorized.
ServletException
IOException
|
Tynamo™-TINI v1.0.4 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||