Public Member Functions | Protected Member Functions | Private Attributes

CAS_CookieJar Class Reference

List of all members.

Public Member Functions

 __construct (array &$storageArray)
 storeCookies ($request_url, $response_headers)
 getCookies ($request_url)

Protected Member Functions

 parseCookieHeaders ($header, $defaultDomain)
 parseCookieHeader ($line, $defaultDomain)
 storeCookie ($cookie)
 discardCookie ($cookie)
 expireCookies ()
 cookieMatchesTarget ($cookie, $target)

Private Attributes

 $_cookies

Detailed Description

This class provides access to service cookies and handles parsing of response headers to pull out cookie values.

Definition at line 38 of file CookieJar.php.


Constructor & Destructor Documentation

CAS_CookieJar::__construct ( array &$  storageArray  ) 

Create a new cookie jar by passing it a reference to an array in which it should store cookies.

Parameters:
ref array $storageArray
Returns:
void

Definition at line 49 of file CookieJar.php.


Member Function Documentation

CAS_CookieJar::cookieMatchesTarget ( cookie,
target 
) [protected]

Answer true if cookie is applicable to a target.

Parameters:
array $cookie An array of cookie attributes.
array $target An array of URL attributes as generated by parse_url().
Returns:
boolean

private

Definition at line 288 of file CookieJar.php.

Referenced by getCookies(), and storeCookies().

CAS_CookieJar::discardCookie ( cookie  )  [protected]

Discard an existing cookie

Parameters:
stdClass $cookie
Returns:
void

private

Definition at line 249 of file CookieJar.php.

Referenced by storeCookie().

CAS_CookieJar::expireCookies (  )  [protected]

Go through our stored cookies and remove any that are expired.

Returns:
void

private

Definition at line 270 of file CookieJar.php.

Referenced by getCookies().

CAS_CookieJar::getCookies ( request_url  ) 

Retrieve cookies applicable for a web service request. Cookie applicability is based on RFC 2965: http://www.ietf.org/rfc/rfc2965.txt

Parameters:
string $request_url The url that the cookies will be for.
Returns:
array An array containing cookies. E.g. array('name' => 'val');

private

Definition at line 94 of file CookieJar.php.

References cookieMatchesTarget(), and expireCookies().

CAS_CookieJar::parseCookieHeader ( line,
defaultDomain 
) [protected]

Parse a single cookie header line.

Based on RFC2965 http://www.ietf.org/rfc/rfc2965.txt

Parameters:
string $line The header line.
string $defaultDomain The domain to use if none is specified in the cookie.
Returns:
array

Definition at line 144 of file CookieJar.php.

References phpCAS::trace().

Referenced by parseCookieHeaders().

CAS_CookieJar::parseCookieHeaders ( header,
defaultDomain 
) [protected]

Parse Cookies without PECL From the comments in http://php.net/manual/en/function.http-parse-cookie.php

Parameters:
array $header An array of header lines.
string $defaultDomain The domain to use if none is specified in the cookie.
Returns:
array of cookies

Definition at line 122 of file CookieJar.php.

References parseCookieHeader(), phpCAS::traceBegin(), and phpCAS::traceEnd().

Referenced by storeCookies().

CAS_CookieJar::storeCookie ( cookie  )  [protected]

Add, update, or remove a cookie.

Parameters:
array $cookie A cookie array as created by parseCookieHeaders()
Returns:
void

private

Definition at line 233 of file CookieJar.php.

References discardCookie().

Referenced by storeCookies().

CAS_CookieJar::storeCookies ( request_url,
response_headers 
)

Store cookies for a web service request. Cookie storage is based on RFC 2965: http://www.ietf.org/rfc/rfc2965.txt

Parameters:
string $request_url The URL that generated the response headers.
array $response_headers An array of the HTTP response header strings.
Returns:
void

private

Definition at line 64 of file CookieJar.php.

References cookieMatchesTarget(), parseCookieHeaders(), storeCookie(), and phpCAS::trace().


Member Data Documentation

CAS_CookieJar::$_cookies [private]

Definition at line 40 of file CookieJar.php.