Converts a Selenium cookie to a HTTP client one.

@param seleniumCookie the browser cookie to be converted

@return the converted HTTP client cookie
6248
public static BasicClientCookie convertToHttpClientCookie(final Cookie seleniumCookie) {
        BasicClientCookie httpClientCookie
                = new BasicClientCookie(seleniumCookie.getName(), seleniumCookie.getValue());
        httpClientCookie.setDomain(seleniumCookie.getDomain());
        httpClientCookie.setPath(seleniumCookie.getPath());
        httpClientCookie.setExpiryDate(seleniumCookie.getExpiry());
        httpClientCookie.setSecure(seleniumCookie.isSecure());

        if (seleniumCookie.isHttpOnly()) {
            httpClientCookie.setAttribute(HTTP_ONLY_ATTRIBUTE, StringUtils.EMPTY);
        }

        return httpClientCookie;
    }
360698
public HttpCookie getCookie(String name) {
        if (null == name || 0 == this.parsedList.size()) {
            return null;
        }
        for (HttpCookie cookie : this.parsedList) {
            if (cookie.getName().equals(name)) {
                return cookie;
            }
        }
        return null;
    }
1235292
@Then("^I save selenium dcos acs auth cookie in variable '(.+?)'$")
    public void getDcosAcsAuthCookie(String envVar) throws Exception {
        if (commonspec.getSeleniumCookies() != null && commonspec.getSeleniumCookies().size() != 0) {
            for (Cookie cookie: commonspec.getSeleniumCookies()) {
                if (cookie.getName().contains("dcos-acs-auth-cookie")) {
                    //It's this cookie where we have to extract the value
                    ThreadProperty.set(envVar, cookie.getValue());
                    break;
                }
            }
        } else {
            ThreadProperty.set(envVar, null);
        }
    }
246271
private static String convertV1Cookie(HttpCookie cookie) {
        StringBuilder buffer = new StringBuilder(40);

        // Append name=value
        buffer.append(cookie.getName());
        buffer.append('=');
        maybeQuote(buffer, cookie.getValue());

        // Always append the version
        buffer.append("; $Version=1");

        // check for optional path
        String value = cookie.getPath();
        if (null != value && 0 != value.length()) {
            buffer.append("; $Path=");
            if (!skipCookiePathQuotes) {
                maybeQuote(buffer, value);
            } else {
                buffer.append(value);
            }
        }

        // check for optional domain
        value = cookie.getDomain();
        if (null != value && 0 != value.length()) {
            buffer.append("; $Domain=");
            maybeQuote(buffer, value);
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "Created v1 Cookie: [" + buffer.toString() + "]");
        }
        return buffer.toString();
    }
1344226
public List<HttpCookie> get(URI uri) {
        // argument can't be null
        if (uri == null) {
            throw new NullPointerException("uri is null");
        }

        List<HttpCookie> cookies = new ArrayList<HttpCookie>();
        lock.lock();
        try {
            // check domainIndex first
            getInternal1(cookies, uriIndex, uri.getHost());
            // check uriIndex then
            getInternal2(cookies, uriIndex, getEffectiveURI(uri));
        } finally {
            lock.unlock();
        }

        return cookies;
    }
30635
protected Cookie getCookieFromRequest(String name, HttpServletRequest request) {
        final Cookie[] cookies = request.getCookies();
        if (cookies == null) { // getCookies() returns null if there aren't any
            return null;
        }

        for (final Cookie cookie : cookies) {
            if (name.equals(cookie.getName())) {
                return cookie;
            }
        }

        return null;
    }
457067
protected String encodeCookie(SerializableHttpCookie cookie) {
        if (cookie == null)
            return null;
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        try {
            ObjectOutputStream outputStream = new ObjectOutputStream(os);
            outputStream.writeObject(cookie);
        } catch (IOException e) {
            Util.log("IOException in encodeCookie", e);
            return null;
        }

        return byteArrayToHexString(os.toByteArray());
    }
1113002
public static Cookie encodeCookie(SessionInfo info) {
        // create a cookie using the configuration information
        HttpSession session = info.getSession();
        SessionConfig config = info.getSessionConfig();
        Cookie cookie = new Cookie(
                        config.getIDName(),
                        config.getSessionVersion() + session.getId());
        cookie.setSecure(config.isCookieSecure());
        cookie.setMaxAge(config.getCookieMaxAge());
        cookie.setPath(config.getCookiePath());
        cookie.setDomain(config.getCookieDomain());

        return cookie;
    }
1124693
public HttpMessage cookie(final Cookie cookie) {
        this.cookies.put(cookie.getName(), cookie);

        setHeader(
                HttpMessageHeaders.HTTP_COOKIE_PREFIX + cookie.getName(),
                cookieConverter.getCookieString(cookie));

        return this;
    }
208714
@SuppressWarnings("deprecation")
    private CookieSpec getCookieSpec(final HttpState state) {
    	if (this.cookiespec == null) {
    		int i = state.getCookiePolicy();
    		if (i == -1) {
        		this.cookiespec = CookiePolicy.getCookieSpec(this.params.getCookiePolicy());
    		} else {
        		this.cookiespec = CookiePolicy.getSpecByPolicy(i);
    		}
    		this.cookiespec.setValidDateFormats(
            		(Collection)this.params.getParameter(HttpMethodParams.DATE_PATTERNS));
    	}
    	return this.cookiespec;
    }
1252782
public String getCookie(String name) {
		Cookie c = requestCookies.get().get(name);
		return c == null ? null : c.getValue();
	}
271521
protected static Cookie getCookie(HttpServletRequest request, String name) {

        Cookie[] cookies = request.getCookies();
        for (int i = 0; (cookies != null) && (i < cookies.length); i++) {
            if (name.equalsIgnoreCase(cookies[i].getName())) {
                return cookies[i];
            }
        }
        return new Cookie(name, "");
    }
1044410
protected String getSuccessMessageFromCookie(final HttpServletRequest request) {
    final Cookie cookie = getCookieByName(request, AZKABAN_SUCCESS_MESSAGE);

    if (cookie == null) {
      return null;
    }
    return cookie.getValue();
  }
688829
private static String convertV0Cookie(HttpCookie cookie) {
        StringBuilder buffer = new StringBuilder(40);

        // Append name=value
        buffer.append(cookie.getName());
        String value = cookie.getValue();
        if (null != value && 0 != value.length()) {
            buffer.append('=');
            buffer.append(value);
        } else {
            // PK48196 - send an empty value string
            buffer.append("=\"\"");
        }

        // check for optional path
        value = cookie.getPath();
        if (null != value && 0 != value.length()) {
            buffer.append("; $Path=");
            buffer.append(value);
        }
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "Created v0 Cookie: [" + buffer.toString() + "]");
        }
        return buffer.toString();
    }
884749
private Cookie convertCookieString(String cookieString) {
        Cookie cookie = new Cookie(getCookieParam(NAME, cookieString), getCookieParam(VALUE, cookieString));

        if (cookieString.contains(COMMENT)) {
            cookie.setComment(getCookieParam(COMMENT, cookieString));
        }

        if (cookieString.contains(PATH)) {
            cookie.setPath(getCookieParam(PATH, cookieString));
        }

        if (cookieString.contains(DOMAIN)) {
            cookie.setDomain(getCookieParam(DOMAIN, cookieString));
        }

        if (cookieString.contains(MAX_AGE)) {
            cookie.setMaxAge(Integer.valueOf(getCookieParam(MAX_AGE, cookieString)));
        }

        if (cookieString.contains(SECURE)) {
            cookie.setSecure(Boolean.valueOf(getCookieParam(SECURE, cookieString)));
        }

        if (cookieString.contains(VERSION)) {
            cookie.setVersion(Integer.valueOf(getCookieParam(VERSION, cookieString)));
        }

        if (cookieString.contains(HTTP_ONLY)) {
            cookie.setHttpOnly(Boolean.valueOf(getCookieParam(HTTP_ONLY, cookieString)));
        }

        return cookie;
    }
535607
public final HttpServer cookieCodec(ServerCookieEncoder encoder) {
		ServerCookieDecoder decoder = encoder == ServerCookieEncoder.LAX ?
				ServerCookieDecoder.LAX : ServerCookieDecoder.STRICT;
		return tcpConfiguration(tcp -> tcp.bootstrap(
				b -> HttpServerConfiguration.cookieCodec(b, encoder, decoder)));
	}
204475
public boolean cookiePresent(String expectedCookieName) {
        boolean isCookiePresent = false;
        try {
            if (driver.manage().getCookieNamed(expectedCookieName) != null) {
                isCookiePresent = true;
            }
            return isCookiePresent;
        } catch (Exception e) {
            log.error(e);
            return false;
        }
    }