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

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

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

origin: commons-httpclient/commons-httpclient

Cookie2 cookie = null;
try {
  cookie = new Cookie2(host,
            headerelement.getName(),
            headerelement.getValue(),
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

/**
 * Returns <tt>false</tt> if the cookie should be discarded at the end
 * of the "session"; <tt>true</tt> otherwise.
 *
 * @return <tt>false</tt> if the cookie should be discarded at the end
 *         of the "session"; <tt>true</tt> otherwise
 */
public boolean isPersistent() {
  return (null != getExpiryDate()) && !discard;
}
origin: commons-httpclient/commons-httpclient

  /**
   * Match cookie port attribute. If the Port attribute is not specified
   * in header, the cookie can be sent to any port. Otherwise, the request port
   * must be in the cookie's port list.
   */
  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");
    }
    if (cookie instanceof Cookie2) {
      Cookie2 cookie2 = (Cookie2) cookie;
      int port = origin.getPort();
      if (cookie2.isPortAttributeSpecified()) {
        if (cookie2.getPorts() == null) {
          LOG.warn("Invalid cookie state: port not specified");
          return false;
        }
        if (!portMatch(port, cookie2.getPorts())) {
          return false;
        }
      }
      return true;
    } else {
      return false;
    }
  }
}
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

/**
 * Validate cookie port attribute. If the Port attribute was specified
 * in header, the request port must be in cookie's port list.
 */
public void validate(final Cookie cookie, final CookieOrigin origin)
    throws MalformedCookieException {
  if (cookie == null) {
    throw new IllegalArgumentException("Cookie may not be null");
  }
  if (origin == null) {
    throw new IllegalArgumentException("Cookie origin may not be null");
  }
  if (cookie instanceof Cookie2) {
    Cookie2 cookie2 = (Cookie2) cookie;
    int port = origin.getPort();
    if (cookie2.isPortAttributeSpecified()) {
      if (!portMatch(port, cookie2.getPorts())) {
        throw new MalformedCookieException(
            "Port attribute violates RFC 2965: "
            + "Request port not found in cookie's port list.");
      }
    }
  }
}
origin: org.apache.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: org.wso2.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: org.apache.commons/com.springsource.org.apache.commons.httpclient

  /**
   * Match cookie port attribute. If the Port attribute is not specified
   * in header, the cookie can be sent to any port. Otherwise, the request port
   * must be in the cookie's port list.
   */
  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");
    }
    if (cookie instanceof Cookie2) {
      Cookie2 cookie2 = (Cookie2) cookie;
      int port = origin.getPort();
      if (cookie2.isPortAttributeSpecified()) {
        if (cookie2.getPorts() == null) {
          LOG.warn("Invalid cookie state: port not specified");
          return false;
        }
        if (!portMatch(port, cookie2.getPorts())) {
          return false;
        }
      }
      return true;
    } else {
      return false;
    }
  }
}
origin: org.apache.commons/httpclient

/**
 * Returns <tt>false</tt> if the cookie should be discarded at the end
 * of the "session"; <tt>true</tt> otherwise.
 *
 * @return <tt>false</tt> if the cookie should be discarded at the end
 *         of the "session"; <tt>true</tt> otherwise
 */
public boolean isPersistent() {
  return (null != getExpiryDate()) && !discard;
}
origin: org.apache.commons/com.springsource.org.apache.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: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-httpclient

Cookie2 cookie = null;
try {
  cookie = new Cookie2(host,
            headerelement.getName(),
            headerelement.getValue(),
origin: org.apache.commons/com.springsource.org.apache.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: org.apache.commons/httpclient

  /**
   * Match cookie port attribute. If the Port attribute is not specified
   * in header, the cookie can be sent to any port. Otherwise, the request port
   * must be in the cookie's port list.
   */
  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");
    }
    if (cookie instanceof Cookie2) {
      Cookie2 cookie2 = (Cookie2) cookie;
      int port = origin.getPort();
      if (cookie2.isPortAttributeSpecified()) {
        if (cookie2.getPorts() == null) {
          LOG.warn("Invalid cookie state: port not specified");
          return false;
        }
        if (!portMatch(port, cookie2.getPorts())) {
          return false;
        }
      }
      return true;
    } else {
      return false;
    }
  }
}
origin: org.apache.commons/com.springsource.org.apache.commons.httpclient

/**
 * Returns <tt>false</tt> if the cookie should be discarded at the end
 * of the "session"; <tt>true</tt> otherwise.
 *
 * @return <tt>false</tt> if the cookie should be discarded at the end
 *         of the "session"; <tt>true</tt> otherwise
 */
public boolean isPersistent() {
  return (null != getExpiryDate()) && !discard;
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.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: org.apache.commons/httpclient

Cookie2 cookie = null;
try {
  cookie = new Cookie2(host,
            headerelement.getName(),
            headerelement.getValue(),
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.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: org.wso2.commons-httpclient/commons-httpclient

  /**
   * Match cookie port attribute. If the Port attribute is not specified
   * in header, the cookie can be sent to any port. Otherwise, the request port
   * must be in the cookie's port list.
   */
  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");
    }
    if (cookie instanceof Cookie2) {
      Cookie2 cookie2 = (Cookie2) cookie;
      int port = origin.getPort();
      if (cookie2.isPortAttributeSpecified()) {
        if (cookie2.getPorts() == null) {
          LOG.warn("Invalid cookie state: port not specified");
          return false;
        }
        if (!portMatch(port, cookie2.getPorts())) {
          return false;
        }
      }
      return true;
    } else {
      return false;
    }
  }
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-httpclient

/**
 * Returns <tt>false</tt> if the cookie should be discarded at the end
 * of the "session"; <tt>true</tt> otherwise.
 *
 * @return <tt>false</tt> if the cookie should be discarded at the end
 *         of the "session"; <tt>true</tt> otherwise
 */
public boolean isPersistent() {
  return (null != getExpiryDate()) && !discard;
}
org.apache.commons.httpclient.cookieCookie2

Javadoc

Cookie class for org.apache.commons.httpclient.cookie.RFC2965Speccookie specification. It extends Cookie class and adds newer cookie attributes and functions required for this specification.

Most used methods

  • <init>
    Creates a cookie with the given name, value, domain attribute, path attribute, expiration attribute,
  • getDomain
  • getExpiryDate
  • getName
  • getPath
  • getPorts
    Get the Port attribute. It restricts the ports to which a cookie may be returned in a Cookie request
  • getValue
  • getVersion
  • isDomainAttributeSpecified
  • isPathAttributeSpecified
  • isPortAttributeBlank
  • isPortAttributeSpecified
  • isPortAttributeBlank,
  • isPortAttributeSpecified,
  • isVersionAttributeSpecified,
  • setCommentURL,
  • setDiscard,
  • setPortAttributeBlank,
  • setPortAttributeSpecified,
  • setPorts,
  • setVersion,
  • setVersionAttributeSpecified

Popular in Java

  • Creating JSON documents from java classes using gson
  • onRequestPermissionsResult (Fragment)
  • setScale (BigDecimal)
  • runOnUiThread (Activity)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • MalformedURLException (java.net)
    This exception is thrown when a program attempts to create an URL from an incorrect specification.
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • Queue (java.util)
    A collection designed for holding elements prior to processing. Besides basic java.util.Collection o
  • 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