wjhk.jupload2.upload.helper
Class CookieJar

java.lang.Object
  extended by wjhk.jupload2.upload.helper.CookieJar

public class CookieJar
extends java.lang.Object

This class implements a container for multiple cookies in a single domain.

Author:
felfert

Nested Class Summary
private static class CookieJar.Cookie
           
 
Field Summary
private  java.lang.String domain
           
private  java.util.HashMap<java.lang.String,CookieJar.Cookie> jar
           
(package private) static java.util.regex.Pattern pNvPair
           
private  UploadPolicy uploadPolicy
          The current upload policy, always useful.
 
Constructor Summary
CookieJar(UploadPolicy uploadPolicy)
          The creator for this class.
 
Method Summary
 java.lang.String buildCookieHeader(java.net.URL url)
          Builds a RFC 2109 compliant client cookie header for the specified URL.
private  boolean domainMatch(java.lang.String cd)
           
 void parseCookieHeader(java.lang.String s)
          Parses a "Set-Cookie" header and creates/updates/deletes cookies according to the parsed values.
 void setDomain(java.lang.String domain)
          Sets the domain for this cookie jar.
private  java.lang.String stripQuotes(java.lang.String s)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pNvPair

static final java.util.regex.Pattern pNvPair

uploadPolicy

private UploadPolicy uploadPolicy
The current upload policy, always useful.


jar

private java.util.HashMap<java.lang.String,CookieJar.Cookie> jar

domain

private java.lang.String domain
Constructor Detail

CookieJar

public CookieJar(UploadPolicy uploadPolicy)
The creator for this class.

Parameters:
uploadPolicy - The current upload policy
Method Detail

stripQuotes

private java.lang.String stripQuotes(java.lang.String s)

domainMatch

private boolean domainMatch(java.lang.String cd)

setDomain

public void setDomain(java.lang.String domain)
Sets the domain for this cookie jar. If set, only cookies matching the specified domain are handled.

Parameters:
domain - The domain of this instance

buildCookieHeader

public java.lang.String buildCookieHeader(java.net.URL url)
Builds a RFC 2109 compliant client cookie header for the specified URL.

Parameters:
url - The URL for which the cookie header is to be used.
Returns:
A client cookie header (including the "Cookie: " prefix) or null if no cookies are to be set.

parseCookieHeader

public void parseCookieHeader(java.lang.String s)
Parses a "Set-Cookie" header and creates/updates/deletes cookies according to the parsed values. Parsing is done according to the specification in RFC 2109

Parameters:
s - The plain value of the "Set-Cookie" HTTP header. e.g.: without the "Set-Cookie: " prefix.