/**
  * Create a new cookie with domain, name, value, path and expires.
  *
  * @param domain the domain
  * @param name the name
  * @param value the value
  * @param path the path
  * @param expires the expires
  * @return a new cookie
  */
 protected Cookie createCookie(
     String domain, String name, String value, String path, long expires) {
   Cookie cookie = new Cookie();
   cookie.setDomain(domain);
   cookie.setName(name);
   cookie.setValue(value);
   cookie.setPath(path);
   cookie.setExpiryDate(new Date(System.currentTimeMillis() + expires));
   return cookie;
 }
 /** Parse cookie domain attribute. */
 public void parse(final Cookie cookie, String domain) throws MalformedCookieException {
   if (cookie == null) {
     throw new IllegalArgumentException("Cookie may not be null");
   }
   if (domain == null) {
     throw new MalformedCookieException("Missing value for domain attribute");
   }
   if (domain.trim().equals("")) {
     throw new MalformedCookieException("Blank value for domain attribute");
   }
   domain = domain.toLowerCase();
   if (!domain.startsWith(".")) {
     // Per RFC 2965 section 3.2.2
     // "... If an explicitly specified value does not start with
     // a dot, the user agent supplies a leading dot ..."
     // That effectively implies that the domain attribute
     // MAY NOT be an IP address of a host name
     domain = "." + domain;
   }
   cookie.setDomain(domain);
   cookie.setDomainAttributeSpecified(true);
 }