Novell exteNd
Director 5.2 API

com.sssw.fw.util
Class EboCookieUtil

java.lang.Object
 |
 +--com.sssw.fw.util.EboCookieUtil

public class EboCookieUtil
extends Object

This class provides methods for working with Cookies from the Browser response specified in the context object.


Constructor Summary
EboCookieUtil()
           
 
Method Summary
static void addCookieToResponse(EbiContext context, Cookie cookie)
          Adds a cookie to the underlying response
static Cookie getCookie(EbiContext context, String cookieName)
          Retrieves a cookie from the underlying request with the specified name
static Cookie getCookieFromBrowser(String cookieName, int maxAge, EbiContext context, boolean create)
          Get the cookie identified by cookieName from the context's request.
static String getCookieHeader(Cookie cookie)
          Construction the Set-cookie header value based on the past in cookie
static Enumeration getCookieNames(EbiContext context)
          Return the names of all cookies found in the request object of the context
static Cookie[] getCookies(EbiContext context)
          Retrieves the cookies that are part of the contexts request object
static Cookie[] getCookies(String cookieHeader)
          Takes a string in the form of the http header and returns an array of cookies
static String getCookieValue(EbiContext context, String cookieName)
          Get the cookie value of the cookie specified by the cookieName.
static Object getCookieValue(String cookieName, EbiContext context)
          Get the cookie value.
static int getMaxAge(int days)
          Return the max age specified by this cookie.
static void setCookieInBrowser(Cookie cookie, EbiContext context)
          Set the cookie into the response provided by the context
static void setCookieValue(String cookieName, String cookieValue, int maxAge, EbiContext context)
          Set the cookie into the response provided by the context using specified value and max age.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EboCookieUtil

public EboCookieUtil()
Method Detail

getCookies

public static Cookie[] getCookies(String cookieHeader)
Takes a string in the form of the http header and returns an array of cookies

Example cookie header: Cookie: Name1=Value1; Name2=Value2; Name3=Value3; Name4=Value4

Parameters:
-  
Returns:
The cookie array created from teh header
Since:
v5.0

addCookieToResponse

public static void addCookieToResponse(EbiContext context,
                                       Cookie cookie)
Adds a cookie to the underlying response

This method will determine the response type of the response contained by the context. It will then add the cookie to the response object

Parameters:
context - the originating context
cookie - the cookie to be added to the response
Since:
v5.0

getCookieHeader

public static String getCookieHeader(Cookie cookie)
Construction the Set-cookie header value based on the past in cookie
Parameters:
cookie - the original cookie
Returns:
the header value based on the cookie
Since:
v5.0

setCookieInBrowser

public static void setCookieInBrowser(Cookie cookie,
                                      EbiContext context)
Set the cookie into the response provided by the context
Parameters:
cookie - The cookie to place in the browser.
context - The context that provides the response object for the cookie.

getMaxAge

public static int getMaxAge(int days)
Return the max age specified by this cookie.
Returns:
int Number of days for which Cookie is valid

setCookieValue

public static void setCookieValue(String cookieName,
                                  String cookieValue,
                                  int maxAge,
                                  EbiContext context)
Set the cookie into the response provided by the context using specified value and max age.
Parameters:
cookieName - Name of the Cookie
cookieValue - Set the Cookie to the value specified by this parameter
maxAge - Number of days before Browser expires the Cookie
context - com.sssw.fw.api.EbiContext that provides the response object for the cookie.

getCookieValue

public static Object getCookieValue(String cookieName,
                                    EbiContext context)
Get the cookie value.
Parameters:
cookieName - Name of the Cookie
context - com.sssw.fw.api.EbiContext that provides the request object for the cookie.
Returns:
Object the cookie value

getCookieValue

public static String getCookieValue(EbiContext context,
                                    String cookieName)
Get the cookie value of the cookie specified by the cookieName.
Parameters:
cookieName - Name of the Cookie
context - com.sssw.fw.api.EbiContext that provides the request object for the cookie.
Returns:
String the cookie value
Since:
v5.0

getCookieFromBrowser

public static Cookie getCookieFromBrowser(String cookieName,
                                          int maxAge,
                                          EbiContext context,
                                          boolean create)
Get the cookie identified by cookieName from the context's request. If the cookie is not found then create it if create = true. Also set the maxAge and domain of the cookie.
Parameters:
cookieName - the identifier for the cookie.
maxAge - the maxAge of the cookie in the browser.
context - the context that provides the request to retrieve the cookie from
create - true = create cookie if it does not exist false = do not create cookie if it does not exist
Returns:
Cookie

getCookies

public static Cookie[] getCookies(EbiContext context)
Retrieves the cookies that are part of the contexts request object
Parameters:
context -  
Returns:
 
Since:
v5.0

getCookie

public static Cookie getCookie(EbiContext context,
                               String cookieName)
Retrieves a cookie from the underlying request with the specified name
Parameters:
context -  
cookieName -  
Returns:
 
Since:
v5.0

getCookieNames

public static Enumeration getCookieNames(EbiContext context)
Return the names of all cookies found in the request object of the context
Parameters:
context - the com.sssw.fw.api.EbiContext object that provides the request
Returns:
Enumeration An Enumeration of cookie names

Novell exteNd
Director 5.2 API