com.jfw.authentication
Class AuthenticationCookie

java.lang.Object
  extended by com.jfw.authentication.AuthenticationCookie

public final class AuthenticationCookie
extends java.lang.Object

Manage authentication cookie.


Field Summary
static int COOKIE_AGE_BROWSER
          Cookie is available until the closure of the browser.
static int COOKIE_DELETE
          Delete cookie now.
static java.lang.String COOKIE_NAME
          Default authentication cookie name.
static java.lang.String COOKIE_SEPARATOR
          Separator char for cookie values.
static int DEFAULT_COOKIE_AGE
          The default cookie age.
 
Constructor Summary
AuthenticationCookie()
           
 
Method Summary
static void delete(javax.servlet.http.HttpServletResponse response)
          Use method delete(javax.servlet.http.HttpServletResponse, java.lang.String).
static void delete(javax.servlet.http.HttpServletResponse response, java.lang.String cookieName)
          Delete authentication cookie.
static UserData read(javax.servlet.http.HttpServletRequest request)
          Use method read(javax.servlet.http.HttpServletRequest, java.lang.String).
static UserData read(javax.servlet.http.HttpServletRequest request, java.lang.String cookieName)
          Read authentication cookie.
static void write(javax.servlet.http.HttpServletResponse response, UserData userData)
          Use method write(javax.servlet.http.HttpServletResponse, com.jfw.authentication.UserData, java.lang.String, java.lang.String, java.lang.String, java.lang.String, int).
static void write(javax.servlet.http.HttpServletResponse response, UserData userData, java.lang.String cookieName, java.lang.String cookieDomain, java.lang.String cookiePath, java.lang.String cookieSecure, int cookieAge)
          Write authentication cookie.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COOKIE_NAME

public static final java.lang.String COOKIE_NAME
Default authentication cookie name.

See Also:
Constant Field Values

COOKIE_AGE_BROWSER

public static final int COOKIE_AGE_BROWSER
Cookie is available until the closure of the browser.

See Also:
Constant Field Values

DEFAULT_COOKIE_AGE

public static int DEFAULT_COOKIE_AGE
The default cookie age. The default value is COOKIE_AGE_BROWSER.


COOKIE_DELETE

public static final int COOKIE_DELETE
Delete cookie now.

See Also:
Constant Field Values

COOKIE_SEPARATOR

public static final java.lang.String COOKIE_SEPARATOR
Separator char for cookie values.

See Also:
Constant Field Values
Constructor Detail

AuthenticationCookie

public AuthenticationCookie()
Method Detail

read

public static UserData read(javax.servlet.http.HttpServletRequest request,
                            java.lang.String cookieName)
Read authentication cookie.

Parameters:
request - an HttpServletRequest object.
cookieName - cookie name. If null COOKIE_NAME is used.
Returns:
an UserData object or null if authetication cookie not found.

read

public static UserData read(javax.servlet.http.HttpServletRequest request)
Use method read(javax.servlet.http.HttpServletRequest, java.lang.String). The default value of parameter cookieName is COOKIE_NAME.


write

public static void write(javax.servlet.http.HttpServletResponse response,
                         UserData userData,
                         java.lang.String cookieName,
                         java.lang.String cookieDomain,
                         java.lang.String cookiePath,
                         java.lang.String cookieSecure,
                         int cookieAge)
Write authentication cookie.

Parameters:
response - an HttpServletResponse object.
userData - an UserData object.
cookieName - cookie name. If null COOKIE_NAME is used.
cookieDomain - cokie domain. If null is not used.
cookiePath - cokie path. If null is not used.
cookieSecure - cokie secure option. If null is not used.
cookieAge - cokie age. A integer value > 0 indicates the msecs before cookie expire. If value is COOKIE_AGE_BROWSER cookie is not stored and expire when browser is closed.

write

public static void write(javax.servlet.http.HttpServletResponse response,
                         UserData userData)
Use method write(javax.servlet.http.HttpServletResponse, com.jfw.authentication.UserData, java.lang.String, java.lang.String, java.lang.String, java.lang.String, int).
The default value of parameter cookieName is COOKIE_NAME.
The default value of parameter cookieDomain is null.
The default value of parameter cookiePath is null.
The default value of parameter cookieSecure is null.
The default value of parameter cookieAge is DEFAULT_COOKIE_AGE.


delete

public static void delete(javax.servlet.http.HttpServletResponse response,
                          java.lang.String cookieName)
Delete authentication cookie.

Parameters:
response - an HttpServletResponse object.
cookieName - cookie name. If null COOKIE_NAME is used.

delete

public static void delete(javax.servlet.http.HttpServletResponse response)
Use method delete(javax.servlet.http.HttpServletResponse, java.lang.String).
The default value of parameter cookieName is COOKIE_NAME.

Parameters:
response - an HttpServletResponse object.