Tabnine Logo
RFC2965Spec
Code IndexAdd Tabnine to your IDE (free)

How to use
RFC2965Spec
in
org.apache.commons.httpclient.cookie

Best Java code snippets using org.apache.commons.httpclient.cookie.RFC2965Spec (Showing top 20 results out of 315)

origin: commons-httpclient/commons-httpclient

/**
 * @param policy cookie policy to get the CookieSpec for
 * @return cookie specification interface for the given policy
 * 
 * @deprecated Use {@link CookiePolicy#getCookieSpec(String)} 
 */
public static CookieSpec getSpecByPolicy(int policy) {
  switch(policy) {
    case COMPATIBILITY: 
      return new CookieSpecBase(); 
    case NETSCAPE_DRAFT: 
      return new NetscapeDraftSpec(); 
    case RFC2109:
      return new RFC2109Spec();
    case RFC2965:
      return new RFC2965Spec();
    default:
      return getDefaultSpec(); 
  }
}
origin: commons-httpclient/commons-httpclient

private void doFormatCookie2(final Cookie2 cookie, final StringBuffer buffer) {
  String name = cookie.getName();
  String value = cookie.getValue();
  if (value == null) {
    value = "";
  }
  this.formatter.format(buffer, new NameValuePair(name, value));
  // format domain attribute
  if (cookie.getDomain() != null && cookie.isDomainAttributeSpecified()) {
    buffer.append("; ");
    this.formatter.format(buffer, new NameValuePair("$Domain", cookie.getDomain()));
  }
  // format path attribute
  if ((cookie.getPath() != null) && (cookie.isPathAttributeSpecified())) {
    buffer.append("; ");
    this.formatter.format(buffer, new NameValuePair("$Path", cookie.getPath()));
  }
  // format port attribute
  if (cookie.isPortAttributeSpecified()) {
    String portValue = "";
    if (!cookie.isPortAttributeBlank()) {
      portValue = createPortAttribute(cookie.getPorts());
    }
    buffer.append("; ");
    this.formatter.format(buffer, new NameValuePair("$Port", portValue));
  }
}

origin: commons-httpclient/commons-httpclient

/**
 * Return a string suitable for sending in a <tt>"Cookie"</tt> header as
 * defined in RFC 2965
 * @param cookie a {@link org.apache.commons.httpclient.Cookie} to be formatted as string
 * @return a string suitable for sending in a <tt>"Cookie"</tt> header.
 */
public String formatCookie(final Cookie cookie) {
  LOG.trace("enter RFC2965Spec.formatCookie(Cookie)");
  if (cookie == null) {
    throw new IllegalArgumentException("Cookie may not be null");
  }
  if (cookie instanceof Cookie2) {
    Cookie2 cookie2 = (Cookie2) cookie;
    int version = cookie2.getVersion();
    final StringBuffer buffer = new StringBuffer();
    this.formatter.format(buffer, new NameValuePair("$Version", Integer.toString(version)));
    buffer.append("; ");
    doFormatCookie2(cookie2, buffer);
    return buffer.toString();
  } else {
    // old-style cookies are formatted according to the old rules
    return this.rfc2109.formatCookie(cookie);
  }
}
origin: commons-httpclient/commons-httpclient

  return false;
CookieOrigin origin = new CookieOrigin(getEffectiveHost(host), port, path, secure); 
for (Iterator i = getAttribHandlerIterator(); i.hasNext(); ) {
  CookieAttributeHandler handler = (CookieAttributeHandler) i.next();
  if (!handler.match(cookie, origin)) {
origin: commons-httpclient/commons-httpclient

  path = PATH_DELIM;
host = getEffectiveHost(host);
      parseAttribute((NameValuePair) entry.getValue(), cookie);
origin: commons-httpclient/commons-httpclient

/**
 * Gets attribute handler {@link CookieAttributeHandler} for the
 * given attribute.
 *
 * @param name attribute name. e.g. Domain, Path, etc.
 * @throws IllegalStateException if handler not found for the
 *          specified attribute.
 */
protected CookieAttributeHandler getAttribHandler(final String name) {
  CookieAttributeHandler handler = findAttribHandler(name);
  if (handler == null) {
    throw new IllegalStateException("Handler not registered for " +
                    name + " attribute.");
  } else {
    return handler;
  }
}
origin: commons-httpclient/commons-httpclient

/**
 * Match cookie domain attribute.
 */
public boolean match(final Cookie cookie, final CookieOrigin origin) {
  if (cookie == null) {
    throw new IllegalArgumentException("Cookie may not be null");
  }
  if (origin == null) {
    throw new IllegalArgumentException("Cookie origin may not be null");
  }
  String host = origin.getHost().toLowerCase();
  String cookieDomain = cookie.getDomain();
  // The effective host name MUST domain-match the Domain
  // attribute of the cookie.
  if (!domainMatch(host, cookieDomain)) {
    return false;
  }
  // effective host name minus domain must not contain any dots
  String effectiveHostWithoutDomain = host.substring(
      0, host.length() - cookieDomain.length());
  if (effectiveHostWithoutDomain.indexOf('.') != -1) {
    return false;
  }
  return true;
}
origin: commons-httpclient/commons-httpclient

public Header getVersionHeader() {
  ParameterFormatter formatter = new ParameterFormatter();
  StringBuffer buffer = new StringBuffer();
  formatter.format(buffer, new NameValuePair("$Version",
      Integer.toString(getVersion())));
  return new Header("Cookie2", buffer.toString(), true);
}

origin: commons-httpclient/commons-httpclient

  return parse(host, port, path, secure, header.getValue());
} else if (header.getName().equalsIgnoreCase(RFC2109Spec.SET_COOKIE_KEY)) {
origin: commons-httpclient/commons-httpclient

  throw new MalformedCookieException("Cookie name may not start with $");
CookieOrigin origin = new CookieOrigin(getEffectiveHost(host), port, path, secure); 
for (Iterator i = getAttribHandlerIterator(); i.hasNext(); ) {
 CookieAttributeHandler handler = (CookieAttributeHandler) i.next();
 handler.validate(cookie, origin);
origin: org.apache.commons/httpclient

  path = PATH_DELIM;
host = getEffectiveHost(host);
      parseAttribute((NameValuePair) entry.getValue(), cookie);
origin: commons-httpclient/commons-httpclient

final String paramValue = attribute.getValue();
CookieAttributeHandler handler = findAttribHandler(paramName);
if (handler == null) {
origin: commons-httpclient/commons-httpclient

if (!domainMatch(host, cookieDomain)) {
  throw new MalformedCookieException(
      "Domain attribute \"" + cookie.getDomain()
origin: org.apache.commons/httpclient

public Header getVersionHeader() {
  ParameterFormatter formatter = new ParameterFormatter();
  StringBuffer buffer = new StringBuffer();
  formatter.format(buffer, new NameValuePair("$Version",
      Integer.toString(getVersion())));
  return new Header("Cookie2", buffer.toString(), true);
}

origin: org.apache.commons/httpclient

  return parse(host, port, path, secure, header.getValue());
} else if (header.getName().equalsIgnoreCase(RFC2109Spec.SET_COOKIE_KEY)) {
origin: org.apache.commons/httpclient

  return false;
CookieOrigin origin = new CookieOrigin(getEffectiveHost(host), port, path, secure); 
for (Iterator i = getAttribHandlerIterator(); i.hasNext(); ) {
  CookieAttributeHandler handler = (CookieAttributeHandler) i.next();
  if (!handler.match(cookie, origin)) {
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-httpclient

  path = PATH_DELIM;
host = getEffectiveHost(host);
      parseAttribute((NameValuePair) entry.getValue(), cookie);
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-httpclient

/**
 * Gets attribute handler {@link CookieAttributeHandler} for the
 * given attribute.
 *
 * @param name attribute name. e.g. Domain, Path, etc.
 * @throws IllegalStateException if handler not found for the
 *          specified attribute.
 */
protected CookieAttributeHandler getAttribHandler(final String name) {
  CookieAttributeHandler handler = findAttribHandler(name);
  if (handler == null) {
    throw new IllegalStateException("Handler not registered for " +
                    name + " attribute.");
  } else {
    return handler;
  }
}
origin: commons-httpclient/commons-httpclient

Cookie2 cookie = (Cookie2) cookies[i];
doFormatCookie2(cookie, buffer);
origin: org.apache.commons/httpclient

/**
 * Match cookie domain attribute.
 */
public boolean match(final Cookie cookie, final CookieOrigin origin) {
  if (cookie == null) {
    throw new IllegalArgumentException("Cookie may not be null");
  }
  if (origin == null) {
    throw new IllegalArgumentException("Cookie origin may not be null");
  }
  String host = origin.getHost().toLowerCase();
  String cookieDomain = cookie.getDomain();
  // The effective host name MUST domain-match the Domain
  // attribute of the cookie.
  if (!domainMatch(host, cookieDomain)) {
    return false;
  }
  // effective host name minus domain must not contain any dots
  String effectiveHostWithoutDomain = host.substring(
      0, host.length() - cookieDomain.length());
  if (effectiveHostWithoutDomain.indexOf('.') != -1) {
    return false;
  }
  return true;
}
org.apache.commons.httpclient.cookieRFC2965Spec

Javadoc

RFC 2965 specific cookie management functions.

Most used methods

  • <init>
    Default constructor
  • createPortAttribute
    Retrieves valid Port attribute value for the given ports array. e.g. "8000,8001,8002"
  • doFormatCookie2
  • domainMatch
    Performs domain-match as defined by the RFC2965. Host A's name domain-matches host B's if 1. their h
  • findAttribHandler
    Finds an attribute handler CookieAttributeHandler for the given attribute. Returns null if no attrib
  • getAttribHandlerIterator
  • getEffectiveHost
    Gets 'effective host name' as defined in RFC 2965. If a host name contains no dots, the effective ho
  • getVersion
  • parse
    Parses the Set-Cookie2 value into an array of Cookies.The syntax for the Set-Cookie2 response header
  • parseAttribute
    Parse RFC 2965 specific cookie attribute and update the corresponsing org.apache.commons.httpclient.
  • pathMatch
  • registerAttribHandler
  • pathMatch,
  • registerAttribHandler

Popular in Java

  • Reactive rest calls using spring rest template
  • notifyDataSetChanged (ArrayAdapter)
  • findViewById (Activity)
  • getSystemService (Context)
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • Pattern (java.util.regex)
    Patterns are compiled regular expressions. In many cases, convenience methods such as String#matches
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • IsNull (org.hamcrest.core)
    Is the value null?
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now