|
DJDoc v.1.0.0b-1 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.djdoc.app.UserStrategy
public abstract class UserStrategy
An abstract class implementing the Strategy design pattern. Its main purpose is authenticating the user for the DJDoc web application. The name of the concrete implementation of this class is specified in the DJDoc configuration.
Constructor Summary | |
---|---|
UserStrategy()
|
Method Summary | |
---|---|
abstract User |
authenticate(javax.servlet.http.HttpServletRequest httpServletRequest,
javax.servlet.http.HttpServletResponse httpServletResponse)
This method authenticates the user. |
protected static User |
findUserInDatabase(java.lang.String userName)
This method attempts to look up a user in the database by his/her name. |
static UserStrategy |
getStrategy()
This method returns the single instance of the UserStrategy
class. |
protected static java.lang.String |
retrieveUserNameFromCookie(javax.servlet.http.HttpServletRequest req)
This utility method is used in the SimpleUserStrategy class; it
extracts a username string from a browser cookie sent in the request. |
static void |
setup(java.lang.String strategyClassName)
This static method initializes the (single) instance of the UserStrategy via reflection. |
protected static void |
storeUserNameInCookie(java.lang.String userName,
javax.servlet.http.HttpServletResponse res)
This method is used to store a (newly created) user name in a browser cookie. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public UserStrategy()
Method Detail |
---|
public static void setup(java.lang.String strategyClassName) throws ConfigurationException
UserStrategy
via reflection.
strategyClassName
- The name of the concrete class implementing the
UserStrategy
ConfigurationException
- A ConfigurationException
is
thrown if an invalid class name is specified or if the construction of
an instance of the specified class fails.public static UserStrategy getStrategy()
UserStrategy
class.
UserStrategy
class.public abstract User authenticate(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse)
UserStrategy
class. The method is
not responsible for authorization.
httpServletRequest
- The current HTTP request objecthttpServletResponse
- The current HTTP response object
User
objectprotected static java.lang.String retrieveUserNameFromCookie(javax.servlet.http.HttpServletRequest req)
SimpleUserStrategy
class; it
extracts a username string from a browser cookie sent in the request.
req
- The current HTTP request object
DJDOC_USER
); null
if no such cookie is set.protected static void storeUserNameInCookie(java.lang.String userName, javax.servlet.http.HttpServletResponse res)
retrieveUserNameFromCookie(HttpServletRequest)
,
it is used by the SimpleUserStrategy
. It is identified by the key
DJDOC_USER
and has a duration of one week.
userName
- The user name to be stored in the cookieres
- The HTTP response object to which the cookie is writtenprotected static User findUserInDatabase(java.lang.String userName)
userName
- The name of the user to be looked up
User
with the specified name
|
DJDoc v.1.0.0b-1 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |