org.apache.shiro.web.servlet
Class SimpleCookie

java.lang.Object
  extended by org.apache.shiro.web.servlet.SimpleCookie
All Implemented Interfaces:
Cookie

public class SimpleCookie
extends Object
implements Cookie

Default Cookie implementation. 'HttpOnly' is supported out of the box, even on Servlet 2.4 and 2.5 container implementations, using raw header writing logic and not javax.servlet.http.Cookie objects (which only has 'HttpOnly' support in Servlet 2.6 specifications and above).

Since:
1.0

Field Summary
protected static String ATTRIBUTE_DELIMITER
           
protected static String COMMENT_ATTRIBUTE_NAME
           
protected static String COOKIE_DATE_FORMAT_STRING
           
protected static String COOKIE_HEADER_NAME
           
protected static long DAY_MILLIS
           
static int DEFAULT_MAX_AGE
          -1, indicating the cookie should expire when the browser closes.
static int DEFAULT_VERSION
          -1 indicating that no version property should be set on the cookie.
protected static String DOMAIN_ATTRIBUTE_NAME
           
protected static String EXPIRES_ATTRIBUTE_NAME
           
protected static String GMT_TIME_ZONE_ID
           
protected static String HTTP_ONLY_ATTRIBUTE_NAME
           
protected static String MAXAGE_ATTRIBUTE_NAME
           
protected static String NAME_VALUE_DELIMITER
           
protected static String PATH_ATTRIBUTE_NAME
           
protected static String SECURE_ATTRIBUTE_NAME
           
protected static String VERSION_ATTRIBUTE_NAME
           
 
Fields inherited from interface org.apache.shiro.web.servlet.Cookie
DELETED_COOKIE_VALUE, ONE_YEAR, ROOT_PATH
 
Constructor Summary
SimpleCookie()
           
SimpleCookie(Cookie cookie)
           
SimpleCookie(String name)
           
 
Method Summary
protected  String buildHeaderValue(String name, String value, String comment, String domain, String path, int maxAge, int version, boolean secure, boolean httpOnly)
           
 String getComment()
           
 String getDomain()
           
 int getMaxAge()
           
 String getName()
           
 String getPath()
           
 String getValue()
           
 int getVersion()
           
 boolean isHttpOnly()
           
 boolean isSecure()
           
 String readValue(HttpServletRequest request, HttpServletResponse ignored)
           
 void removeFrom(HttpServletRequest request, HttpServletResponse response)
           
 void saveTo(HttpServletRequest request, HttpServletResponse response)
           
 void setComment(String comment)
           
 void setDomain(String domain)
           
 void setHttpOnly(boolean httpOnly)
           
 void setMaxAge(int maxAge)
           
 void setName(String name)
           
 void setPath(String path)
           
 void setSecure(boolean secure)
           
 void setValue(String value)
           
 void setVersion(int version)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MAX_AGE

public static final int DEFAULT_MAX_AGE
-1, indicating the cookie should expire when the browser closes.

See Also:
Constant Field Values

DEFAULT_VERSION

public static final int DEFAULT_VERSION
-1 indicating that no version property should be set on the cookie.

See Also:
Constant Field Values

NAME_VALUE_DELIMITER

protected static final String NAME_VALUE_DELIMITER
See Also:
Constant Field Values

ATTRIBUTE_DELIMITER

protected static final String ATTRIBUTE_DELIMITER
See Also:
Constant Field Values

DAY_MILLIS

protected static final long DAY_MILLIS
See Also:
Constant Field Values

GMT_TIME_ZONE_ID

protected static final String GMT_TIME_ZONE_ID
See Also:
Constant Field Values

COOKIE_DATE_FORMAT_STRING

protected static final String COOKIE_DATE_FORMAT_STRING
See Also:
Constant Field Values

COOKIE_HEADER_NAME

protected static final String COOKIE_HEADER_NAME
See Also:
Constant Field Values

PATH_ATTRIBUTE_NAME

protected static final String PATH_ATTRIBUTE_NAME
See Also:
Constant Field Values

EXPIRES_ATTRIBUTE_NAME

protected static final String EXPIRES_ATTRIBUTE_NAME
See Also:
Constant Field Values

MAXAGE_ATTRIBUTE_NAME

protected static final String MAXAGE_ATTRIBUTE_NAME
See Also:
Constant Field Values

DOMAIN_ATTRIBUTE_NAME

protected static final String DOMAIN_ATTRIBUTE_NAME
See Also:
Constant Field Values

VERSION_ATTRIBUTE_NAME

protected static final String VERSION_ATTRIBUTE_NAME
See Also:
Constant Field Values

COMMENT_ATTRIBUTE_NAME

protected static final String COMMENT_ATTRIBUTE_NAME
See Also:
Constant Field Values

SECURE_ATTRIBUTE_NAME

protected static final String SECURE_ATTRIBUTE_NAME
See Also:
Constant Field Values

HTTP_ONLY_ATTRIBUTE_NAME

protected static final String HTTP_ONLY_ATTRIBUTE_NAME
See Also:
Constant Field Values
Constructor Detail

SimpleCookie

public SimpleCookie()

SimpleCookie

public SimpleCookie(String name)

SimpleCookie

public SimpleCookie(Cookie cookie)
Method Detail

getName

public String getName()
Specified by:
getName in interface Cookie

setName

public void setName(String name)
Specified by:
setName in interface Cookie

getValue

public String getValue()
Specified by:
getValue in interface Cookie

setValue

public void setValue(String value)
Specified by:
setValue in interface Cookie

getComment

public String getComment()
Specified by:
getComment in interface Cookie

setComment

public void setComment(String comment)
Specified by:
setComment in interface Cookie

getDomain

public String getDomain()
Specified by:
getDomain in interface Cookie

setDomain

public void setDomain(String domain)
Specified by:
setDomain in interface Cookie

getPath

public String getPath()
Specified by:
getPath in interface Cookie

setPath

public void setPath(String path)
Specified by:
setPath in interface Cookie

getMaxAge

public int getMaxAge()
Specified by:
getMaxAge in interface Cookie

setMaxAge

public void setMaxAge(int maxAge)
Specified by:
setMaxAge in interface Cookie

getVersion

public int getVersion()
Specified by:
getVersion in interface Cookie

setVersion

public void setVersion(int version)
Specified by:
setVersion in interface Cookie

isSecure

public boolean isSecure()
Specified by:
isSecure in interface Cookie

setSecure

public void setSecure(boolean secure)
Specified by:
setSecure in interface Cookie

isHttpOnly

public boolean isHttpOnly()
Specified by:
isHttpOnly in interface Cookie

setHttpOnly

public void setHttpOnly(boolean httpOnly)
Specified by:
setHttpOnly in interface Cookie

saveTo

public void saveTo(HttpServletRequest request,
                   HttpServletResponse response)
Specified by:
saveTo in interface Cookie

buildHeaderValue

protected String buildHeaderValue(String name,
                                  String value,
                                  String comment,
                                  String domain,
                                  String path,
                                  int maxAge,
                                  int version,
                                  boolean secure,
                                  boolean httpOnly)

removeFrom

public void removeFrom(HttpServletRequest request,
                       HttpServletResponse response)
Specified by:
removeFrom in interface Cookie

readValue

public String readValue(HttpServletRequest request,
                        HttpServletResponse ignored)
Specified by:
readValue in interface Cookie


Copyright © 2004-2014 The Apache Software Foundation. All Rights Reserved.