Package org.apache.http.cookie

Examples of org.apache.http.cookie.CookieRestrictionViolationException


    throws MalformedCookieException
  {
    if (paramCookie == null)
      throw new IllegalArgumentException("Cookie may not be null");
    if (paramCookie.getVersion() < 0)
      throw new CookieRestrictionViolationException("Cookie version may not be negative");
  }
View Full Code Here


    {
      int i = new StringTokenizer(str2, ".").countTokens();
      if (isSpecialDomain(str2))
      {
        if (i < 2)
          throw new CookieRestrictionViolationException("Domain attribute \"" + str2 + "\" violates the Netscape cookie specification for " + "special domains");
      }
      else if (i < 3)
        throw new CookieRestrictionViolationException("Domain attribute \"" + str2 + "\" violates the Netscape cookie specification");
    }
  }
View Full Code Here

  {
    if (paramCookie == null)
      throw new IllegalArgumentException("Cookie may not be null");
    String str = paramCookie.getName();
    if (str.indexOf(' ') != -1)
      throw new CookieRestrictionViolationException("Cookie name may not contain blanks");
    if (str.startsWith("$"))
      throw new CookieRestrictionViolationException("Cookie name may not start with $");
    super.validate(paramCookie, paramCookieOrigin);
  }
View Full Code Here

    throws MalformedCookieException
  {
    if (paramCookie == null)
      throw new IllegalArgumentException("Cookie may not be null");
    if (((paramCookie instanceof SetCookie2)) && ((paramCookie instanceof ClientCookie)) && (!((ClientCookie)paramCookie).containsAttribute("version")))
      throw new CookieRestrictionViolationException("Violates RFC 2965. Version attribute is required.");
  }
View Full Code Here

  public void validate(Cookie paramCookie, CookieOrigin paramCookieOrigin)
    throws MalformedCookieException
  {
    if (!match(paramCookie, paramCookieOrigin))
      throw new CookieRestrictionViolationException("Illegal path attribute \"" + paramCookie.getPath() + "\". Path of origin: \"" + paramCookieOrigin.getPath() + "\"");
  }
View Full Code Here

    if (paramCookieOrigin == null)
      throw new IllegalArgumentException("Cookie origin may not be null");
    String str1 = paramCookieOrigin.getHost();
    String str2 = paramCookie.getDomain();
    if (str2 == null)
      throw new CookieRestrictionViolationException("Cookie domain may not be null");
    if (!str2.equals(str1))
    {
      int i = str2.indexOf('.');
      if (i == -1)
        throw new CookieRestrictionViolationException("Domain attribute \"" + str2 + "\" does not match the host \"" + str1 + "\"");
      if (!str2.startsWith("."))
        throw new CookieRestrictionViolationException("Domain attribute \"" + str2 + "\" violates RFC 2109: domain must start with a dot");
      i = str2.indexOf('.', 1);
      if ((i < 0) || (i == str2.length() - 1))
        throw new CookieRestrictionViolationException("Domain attribute \"" + str2 + "\" violates RFC 2109: domain must contain an embedded dot");
      str1 = str1.toLowerCase(Locale.ENGLISH);
      if (!str1.endsWith(str2))
        throw new CookieRestrictionViolationException("Illegal domain attribute \"" + str2 + "\". Domain of origin: \"" + str1 + "\"");
      String str3 = str1.substring(0, str1.length() - str2.length());
      if (str3.indexOf('.') != -1)
        throw new CookieRestrictionViolationException("Domain attribute \"" + str2 + "\" violates RFC 2109: host minus domain may not contain any dots");
    }
  }
View Full Code Here

      throw new IllegalArgumentException("Cookie may not be null");
    if (paramCookieOrigin == null)
      throw new IllegalArgumentException("Cookie origin may not be null");
    String str1 = paramCookieOrigin.getHost().toLowerCase(Locale.ENGLISH);
    if (paramCookie.getDomain() == null)
      throw new CookieRestrictionViolationException("Invalid cookie state: domain not specified");
    String str2 = paramCookie.getDomain().toLowerCase(Locale.ENGLISH);
    if (((paramCookie instanceof ClientCookie)) && (((ClientCookie)paramCookie).containsAttribute("domain")))
    {
      if (!str2.startsWith("."))
        throw new CookieRestrictionViolationException("Domain attribute \"" + paramCookie.getDomain() + "\" violates RFC 2109: domain must start with a dot");
      int i = str2.indexOf('.', 1);
      if (((i < 0) || (i == str2.length() - 1)) && (!str2.equals(".local")))
        throw new CookieRestrictionViolationException("Domain attribute \"" + paramCookie.getDomain() + "\" violates RFC 2965: the value contains no embedded dots " + "and the value is not .local");
      if (!domainMatch(str1, str2))
        throw new CookieRestrictionViolationException("Domain attribute \"" + paramCookie.getDomain() + "\" violates RFC 2965: effective host name does not " + "domain-match domain attribute.");
      String str3 = str1.substring(0, str1.length() - str2.length());
      if (str3.indexOf('.') != -1)
        throw new CookieRestrictionViolationException("Domain attribute \"" + paramCookie.getDomain() + "\" violates RFC 2965: " + "effective host minus domain may not contain any dots");
    }
    else if (!paramCookie.getDomain().equals(str1))
    {
      throw new CookieRestrictionViolationException("Illegal domain attribute: \"" + paramCookie.getDomain() + "\"." + "Domain of origin: \"" + str1 + "\"");
    }
  }
View Full Code Here

    public void validate(final Cookie cookie, final CookieOrigin origin)
            throws MalformedCookieException {
        Args.notNull(cookie, "Cookie");
        final String name = cookie.getName();
        if (name.indexOf(' ') != -1) {
            throw new CookieRestrictionViolationException("Cookie name may not contain blanks");
        }
        if (name.startsWith("$")) {
            throw new CookieRestrictionViolationException("Cookie name may not start with $");
        }
        super.validate(cookie, origin);
    }
View Full Code Here

TOP

Related Classes of org.apache.http.cookie.CookieRestrictionViolationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.