Build cookie generation context cookie.

@param cookie the cookie
@return the cookie generation context
163477
public static CookieGenerationContext buildCookieGenerationContext(final TicketGrantingCookieProperties cookie) {
        val rememberMeMaxAge = (int) Beans.newDuration(cookie.getRememberMeMaxAge()).getSeconds();
        val builder = buildCookieGenerationContextBuilder(cookie);
        return builder.rememberMeMaxAge(rememberMeMaxAge).build();
    }
850154
public function cookie($cookie = null) {
        if ($cookie === null) {
            $this->cookies = [];
        } else {
            $this->cookies[] = $cookie;
        }

        return $this;
    }
750094
private Cookie convertHttpCookie(HttpCookie cookie)
  {
    Cookie rc = new Cookie(cookie.getName(), cookie.getValue());
    rc.setVersion(cookie.getVersion());
    if (null != cookie.getPath())
    {
      rc.setPath(cookie.getPath());
    }
    if (null != cookie.getDomain())
    {
      rc.setDomain(cookie.getDomain());
    }
    rc.setMaxAge(cookie.getMaxAge());
    rc.setSecure(cookie.isSecure());
    return rc;
  }
371617
public void sendCookie(String name, String value) {
        context.addCookie(Cookie.builder(name, value).build());
    }
728349
public static Cookie cookie(String name){
        javax.servlet.http.Cookie[] servletCookies = RequestContext.getHttpRequest().getCookies();
        if (servletCookies != null) {
            for (javax.servlet.http.Cookie servletCookie : servletCookies) {
                if (servletCookie.getName().equals(name)) {
                    return Cookie.fromServletCookie(servletCookie);
                }
            }
        }
        return null;
    }
696600
@Override
    public Cookie toCookie() {
        Cookie cookie = new Cookie(name, value);
        cookie.setComment(comment);
        if (domain != null) {
            cookie.setDomain(domain);
        }
        cookie.setMaxAge(getMaxAge());
        cookie.setPath(path);
        cookie.setSecure(secure);
        cookie.setVersion(version);
        return cookie;
    }
1055884
public Cookie cookie(String expectedCookieName) {
        try {
            return driver.manage().getCookieNamed(expectedCookieName);
        } catch (Exception e) {
            log.warn(e);
            return null;
        }
    }
133421
public static Cookie getCookie(final WebContext context, final String name) {
        return getCookie(context.getRequestCookies(), name);
    }
533069
public void setCookies(List<HttpCookie> cookies) {
		Map<String, HttpCookie> map = new HashMap<String, HttpCookie>();
		for (HttpCookie cookie : cookies) {
			map.put(cookie.getName(), cookie);
		}
		this.cookies = map;
	}
1269024
public void setCookie(Cookie cookie) {
        String domain = cookie.getDomain();
        Date expiry = cookie.getExpiry();
        String name = cookie.getName();
        String path = cookie.getPath();
        String value = cookie.getValue();

        String action = "Setting up cookie with attributes:<div><table><tbody><tr><td>Domain</td><td>" + domain +
                "</tr><tr><td>Expiration</td><td>" + expiry.toString() + "</tr><tr><td>Name</td><td>" + name +
                "</tr><tr><td>Path</td><td>" + path + "</tr><tr><td>Value</td><td>" + value +
                "</tr></tbody></table></div><br/>";
        String expected = "Cookie is added";
        try {
            driver.manage().addCookie(cookie);
        } catch (Exception e) {
            reporter.fail(action, expected, "Unable to add cookie. " + e.getMessage());
            log.warn(e);
            return;
        }
        reporter.pass(action, expected, expected);
    }
1330189
private static String getHttpOnlyCookieHeader(Cookie cookie) {
    NewCookie newCookie = new NewCookie(cookie.getName(), cookie.getValue(),
      cookie.getPath(), cookie.getDomain(), cookie.getVersion(),
      cookie.getComment(), cookie.getMaxAge(), cookie.getSecure());
    return newCookie + "; HttpOnly";
  }
885075
public void setCookies(final Cookie[] cookies) {
        this.cookies.clear();
        if (cookies != null) {
            for (final Cookie cookie : cookies) {
                cookie(cookie);
            }
        }
    }
539262
public Response cookie(String name, String value, int maxAge) {
        Cookie cookie = new Cookie(name, value);
        cookie.setSecure(true);
        cookie.setMaxAge(maxAge);
        addCookie(cookie);

        return this;
    }
1289859
public String encode(Cookie cookie) {
        StringBuilder buf = stringBuilder();
        encode(buf, checkNotNull(cookie, "cookie"));
        return stripTrailingSeparator(buf);
    }
1284969
public static Cookie convertNettyCookieToWisdomCookie(DefaultCookie cookie) {
        Preconditions.checkNotNull(cookie);
        String value = cookie.value();
//        // Netty append some data at the end f the cookie:
//        // -createdBy=wisdom&at=3+nov.+2013+11%3A52%3A15&___TS=1383475935779, path=/, maxAge=3600s, secure, HTTPOnly
//        // We have to remove them
//        // TODO Do we really need this ? It was probably related to the cookie encoding issue.
//        if (value.contains(PATH)) {
//            value = value.substring(0, value.indexOf(PATH));
//        }

        Cookie.Builder builder
                = Cookie.builder(cookie.name(), value);

        builder.setMaxAge(cookie.maxAge());

        if (cookie.domain() != null) {
            builder.setDomain(cookie.domain());
        }

        builder.setSecure(cookie.isSecure());

        if (cookie.path() != null) {
            builder.setPath(cookie.path());
        }

        builder.setHttpOnly(cookie.isHttpOnly());

        return builder.build();
    }
262947
@Deprecated
    public static String encode(Cookie cookie) {
        return io.netty.handler.codec.http.cookie.ServerCookieEncoder.LAX.encode(cookie);
    }
852733
public static Cookie getCookie(String name, Cookie[] cookies) {
        if (Checker.isNotEmpty(cookies)) {
            for (Cookie cookie : cookies) {
                if (name.equals(cookie.getName())) {
                    return cookie;
                }
            }
        }
        return null;
    }