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

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

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

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

/**
 * 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: 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.servicemix.bundles/org.apache.servicemix.bundles.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

  /**
   * 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

  /**
   * 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.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.wso2.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

/**
 * 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/com.springsource.org.apache.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.servicemix.bundles/org.apache.servicemix.bundles.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

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

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

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.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));
  }
}

org.apache.commons.httpclient.cookieCookie2getPorts

Javadoc

Get the Port attribute. It restricts the ports to which a cookie may be returned in a Cookie request header.

Popular methods of Cookie2

  • <init>
    Creates a cookie with the given name, value, domain attribute, path attribute, expiration attribute,
  • getDomain
  • getExpiryDate
  • getName
  • getPath
  • getValue
  • getVersion
  • isDomainAttributeSpecified
  • isPathAttributeSpecified
  • isPortAttributeBlank
  • isPortAttributeSpecified
  • isVersionAttributeSpecified
  • isPortAttributeSpecified,
  • isVersionAttributeSpecified,
  • setCommentURL,
  • setDiscard,
  • setPortAttributeBlank,
  • setPortAttributeSpecified,
  • setPorts,
  • setVersion,
  • setVersionAttributeSpecified

Popular in Java

  • Reading from database using SQL prepared statement
  • addToBackStack (FragmentTransaction)
  • notifyDataSetChanged (ArrayAdapter)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • URLConnection (java.net)
    A connection to a URL for reading or writing. For HTTP connections, see HttpURLConnection for docume
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • Best plugins for Eclipse
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