Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.cactus.internal.util
Class CookieUtil

    java.lang.Object
      org.apache.cactus.internal.util.CookieUtil

public class CookieUtil
extends java.lang.Object

Utility methods to manipulate cookies and transform Cactus cookie objects to HttpClient cookie objects.

Since:
  1.5
Version:
  $Id: CookieUtil.java 238991 2004-05-22 11:34:50Z vmassol $

Constructor Summary
`CookieUtil()`

Method Summary
`static org.apache.commons.httpclient.Header` | `createCookieHeader(java.lang.String theDomain, java.lang.String thePath, org.apache.commons.httpclient.Cookie[] theCookies)` Create a HttpClient `Header` for cookies that matches the domain and path.
`static org.apache.commons.httpclient.Cookie` | `createHttpClientCookie(WebRequest theRequest, java.net.URL theUrl, Cookie theCactusCookie)` Create a Commons-HttpClient cookie from a Cactus cookie, with information from the web request and the URL.
`static org.apache.commons.httpclient.Cookie[]` | `createHttpClientCookies(WebRequest theRequest, java.net.URL theUrl)` Transforms an array of Cactus cookies into an array of Commons-HttpClient cookies, using information from the request and URL.
`static java.lang.String` | `getCookieDomain(WebRequest theRequest, java.lang.String theRealHost)` Returns the domain that will be used to send the cookies.
`static java.lang.String` | `getCookiePath(WebRequest theRequest, java.lang.String theRealPath)` Returns the path that will be used to validate if a cookie will be sent or not.
`static int` | `getCookiePort(WebRequest theRequest, int theRealPort)` Returns the port that will be used to send the cookies.
`static java.lang.String` | `getCookieString(WebRequest theRequest, java.net.URL theUrl)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### CookieUtil

    public CookieUtil()

Method Detail

### getCookieDomain

    public static java.lang.String getCookieDomain(WebRequest theRequest,
                                                   java.lang.String theRealHost)

  Returns the domain that will be used to send the cookies. If a host was specified using `setURL()` then the domain will be this host. Otherwise it will be the real redirector host.

  Parameters:
    `theRequest` - the request containing all data to pass to the server redirector.
    `theRealHost` - the real host to which we are connecting to. We will use it if no simulation host has been specified.
  Returns:
    the cookie domain to use

### getCookiePort

    public static int getCookiePort(WebRequest theRequest,
                                    int theRealPort)

  Returns the port that will be used to send the cookies. If a port was specified using `setURL()` then the port sent will be this port. Otherwise it will be the real redirector port.

  Parameters:
    `theRequest` - the request containing all data to pass to the server redirector.
    `theRealPort` - the real port to which we are connecting to. We will use it if no simulation port has been specified.
  Returns:
    the cookie domain to use

### getCookiePath

    public static java.lang.String getCookiePath(WebRequest theRequest,
                                                 java.lang.String theRealPath)

  Returns the path that will be used to validate if a cookie will be sent or not. The algorithm is as follows : if the cookie path is not set (i.e. null) then the cookie is always sent (provided the domain is right). If the cookie path is set, the cookie is sent only if the request path starts with the same string as the cookie path. If `setURL()` has been called, return the path it has been set to (context + servletPath + pathInfo). Otherwise return the real redirector path.

  Parameters:
    `theRequest` - the request containing all data to pass to the server redirector.
    `theRealPath` - the real path to which we are connecting to. We will use it if no simulation path has been specified.
  Returns:
    the path to use to decide if a cookie will get sent

### createHttpClientCookie

    public static org.apache.commons.httpclient.Cookie createHttpClientCookie(WebRequest theRequest,
                                                                              java.net.URL theUrl,
                                                                              Cookie theCactusCookie)

  Create a Commons-HttpClient cookie from a Cactus cookie, with information from the web request and the URL.

  Parameters:
    `theRequest` - The request
    `theUrl` - The URL
    `theCactusCookie` - The Cactus Cookie object
  Returns:
    The HttpClient cookie

### createHttpClientCookies

    public static org.apache.commons.httpclient.Cookie[] createHttpClientCookies(WebRequest theRequest,
                                                                                 java.net.URL theUrl)

  Transforms an array of Cactus cookies into an array of Commons-HttpClient cookies, using information from the request and URL.

  Parameters:
    `theRequest` - The request
    `theUrl` - The URL
  Returns:
    The array of HttpClient cookies

### createCookieHeader

    public static org.apache.commons.httpclient.Header createCookieHeader(java.lang.String theDomain,
                                                                          java.lang.String thePath,
                                                                          org.apache.commons.httpclient.Cookie[] theCookies)
                                                                   throws ClientException

  Create a HttpClient `Header` for cookies that matches the domain and path.

  Parameters:
    `theDomain` - the cookie domain to match
    `thePath` - the cookie path to match
    `theCookies` - the list of potential cookies
  Returns:
    the HttpClient `Header` containing the matching cookies
  Throws:
    `ClientException` - if no cookie was matching the domain and path

### getCookieString

    public static java.lang.String getCookieString(WebRequest theRequest,
                                                   java.net.URL theUrl)
                                            throws ClientException

  Parameters:
    `theRequest` - the request containing all data to pass to the server redirector.
    `theUrl` - the URL to connect to
  Returns:
    the cookie string which will be added as a HTTP "Cookie" header or null if no cookie has been set
  Throws:
    `ClientException` - if an error occurred when creating the cookie string

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2004 Apache Software Foundation. All Rights Reserved.