Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.RuntimeCollective.webapps.bean
Class LoginCookie  view LoginCookie download LoginCookie.java

java.lang.Object
  extended byjavax.servlet.http.Cookie
      extended bycom.RuntimeCollective.webapps.bean.LoginCookie
All Implemented Interfaces:
java.lang.Cloneable

public class LoginCookie
extends javax.servlet.http.Cookie

LoginCookie.java Keeps track of users who want to stay logged in

Version:
$Id: LoginCookie.java,v 1.7 2003/09/30 15:13:09 joe Exp $ Portions derived from Marty Hall's Servlet Tutorial: http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/Servlet-Tutorial-Cookies.html (c) 1999 Marty Hall. All source code freely available for unrestricted use.

Field Summary
static java.lang.String COOKIE_NAME
          The cookie name, to use when storing the cookie on the request.
static int KEY_SIZE
          How large the random key should be (must match up with the data model)
static java.lang.String RETURN_URL_NAME
          When a user tries to access a page that requires them to be logged on, this page's URL will be stored in the session under RETURN_URL_NAME
static int SECONDS_PER_YEAR
          The cookie persists for a year.
 
Fields inherited from class javax.servlet.http.Cookie
 
Constructor Summary
LoginCookie(java.lang.String name, java.lang.String value)
          Make a new login cookie.
 
Method Summary
static java.lang.String getCookieValue(javax.servlet.http.Cookie[] cookies, java.lang.String cookieName, java.lang.String defaultValue)
          Gets a specific value from a bunch of cookies
static User getUser(javax.servlet.http.Cookie[] cookies)
          Return the User stored in the COOKIE_NAME cookie
static void removeCookie(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Removes the LoginCookie from the given request
static void setCookie(User cookieUser, javax.servlet.http.HttpServletResponse response)
          Sets a login cookie for a user who wants to be permenantly logged on.
 
Methods inherited from class javax.servlet.http.Cookie
clone, getComment, getDomain, getMaxAge, getName, getPath, getSecure, getValue, getVersion, setComment, setDomain, setMaxAge, setPath, setSecure, setValue, setVersion
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SECONDS_PER_YEAR

public static final int SECONDS_PER_YEAR
The cookie persists for a year.

See Also:
Constant Field Values

COOKIE_NAME

public static final java.lang.String COOKIE_NAME
The cookie name, to use when storing the cookie on the request.

See Also:
Constant Field Values

RETURN_URL_NAME

public static java.lang.String RETURN_URL_NAME
When a user tries to access a page that requires them to be logged on, this page's URL will be stored in the session under RETURN_URL_NAME


KEY_SIZE

public static final int KEY_SIZE
How large the random key should be (must match up with the data model)

See Also:
Constant Field Values
Constructor Detail

LoginCookie

public LoginCookie(java.lang.String name,
                   java.lang.String value)
Make a new login cookie. It persists for a year, and is sent to every page on the server.

Method Detail

setCookie

public static void setCookie(User cookieUser,
                             javax.servlet.http.HttpServletResponse response)
Sets a login cookie for a user who wants to be permenantly logged on.


removeCookie

public static void removeCookie(javax.servlet.http.HttpServletRequest request,
                                javax.servlet.http.HttpServletResponse response)
Removes the LoginCookie from the given request


getCookieValue

public static java.lang.String getCookieValue(javax.servlet.http.Cookie[] cookies,
                                              java.lang.String cookieName,
                                              java.lang.String defaultValue)
Gets a specific value from a bunch of cookies


getUser

public static User getUser(javax.servlet.http.Cookie[] cookies)
Return the User stored in the COOKIE_NAME cookie