Sets expectations that will check:
<ol>
<li>The provided WebClient contains a cookie with the default JWT SSO cookie name, its value is a JWT, is NOT marked secure, and is marked HttpOnly
</ol>
966011
public static Expectations jwtCookieExists(String testAction, WebClient webClient, String jwtCookieName, boolean isSecure, boolean isHttpOnly) {
        Expectations expectations = new Expectations();
        expectations.addExpectation(new CookieExpectation(testAction, webClient, jwtCookieName, JwtFatConstants.JWT_REGEX, isSecure, isHttpOnly));
        return expectations;
    }
813730
public final HttpClient cookie(String name, Consumer<? super Cookie> cookieBuilder) {
		return new HttpClientCookie(this, name, cookieBuilder);
	}
1308226
public void assertCookiePresentByName(final String cookieName) {
		Set<Cookie> cookies = driver.manage().getCookies();

		for (Cookie cookie : cookies) {
			if (cookie.getName().equals(cookieName)) {
				LOG.info("Cookie: " + cookieName + " was found with value: "
						+ cookie.getValue());
				Assert.assertEquals(cookieName, cookie.getName());
				return;
			}
		}
		Assert.fail("The given cookie name: " + cookieName
				+ " is not present within the current session!");
	}
1055884
public Cookie cookie(String expectedCookieName) {
        try {
            return driver.manage().getCookieNamed(expectedCookieName);
        } catch (Exception e) {
            log.warn(e);
            return null;
        }
    }
823016
function _decode (cookieName, cookieDomain, publicUrl) {
  return (req, res, next) => {
    // JWT in a cookie = already active session
    const cookies = new Cookies(req, res)
    const token = _getCookieToken(cookies, req, cookieName, cookieDomain, publicUrl)
    if (token) {
      req.user = jwt.decode(token)
      _setOrganization(cookies, cookieName, req, req.user)
    }
    next()
  }
}
1046200
public static boolean getWarningCookie(final RequestContext context) {
        val val = ObjectUtils.defaultIfNull(context.getFlowScope().get("warnCookieValue"), Boolean.FALSE.toString()).toString();
        return Boolean.parseBoolean(val);
    }
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;
        }
    }
1338197
@Override
    protected int authenticated(final Request request, final Response response)
    {
        try
        {
            final CookieSetting credentialsCookie = this.getCredentialsCookie(request, response);
            credentialsCookie.setValue(this.formatCredentials(request.getChallengeResponse()));
            credentialsCookie.setMaxAge(this.getMaxCookieAge());
        }
        catch(final GeneralSecurityException e)
        {
            this.log.error("Could not format credentials cookie", e);
        }
        
        // log.info("calling super.authenticated");
        // return super.authenticated(request, response);
        
        // Modified copy of Authenticator.authenticated
        if(this.log.isDebugEnabled())
        {
            this.log.debug("The authentication succeeded for the identifer \"{}\" using the {} scheme.", request
                    .getChallengeResponse().getIdentifier(), request.getChallengeResponse().getScheme());
        }
        
        // Update the client info accordingly
        if(request.getClientInfo() != null)
        {
            request.getClientInfo().setAuthenticated(true);
        }
        
        // Clear previous challenge requests
        response.getChallengeRequests().clear();
        
        // Add the roles for the authenticated subject
        if(this.getEnroler() != null)
        {
            this.getEnroler().enrole(request.getClientInfo());
        }
        
        // Return STOP here works for login but not for subsequent requests that expect a response
        // return STOP;
        return Filter.CONTINUE;
    }
104268
@Override
    public boolean set(HttpCookie cookie, byte[] attribValue) {
        try {
            if (null != cookie && null != attribValue && 0 < attribValue.length) {
                cookie.setVersion(GenericUtils.asIntValue(attribValue));
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "Cookie version set to " + cookie.getVersion());
                }
                return true;
            }
        } catch (Exception e) {
            FFDCFilter.processException(e, getClass().getName(), "set", this);
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Exception setting version; " + e);
            }
        }
        return false;
    }
168871
@Override
    public void addSSOCookiesToResponse(Subject subject, HttpServletRequest req, HttpServletResponse resp) {
        if (!allowToAddCookieToResponse(req))
            return;

        addJwtSsoCookiesToResponse(subject, req, resp);

        if (!JwtSSOTokenHelper.shouldAlsoIncludeLtpaCookie()) {
            return;
        }

        SingleSignonToken ssoToken = getDefaultSSOTokenFromSubject(subject);
        if (ssoToken == null) {
            return;
        }

        byte[] ssoTokenBytes = ssoToken.getBytes();
        if (ssoTokenBytes == null) {
            return;
        }

        ByteArray cookieBytes = new ByteArray(ssoTokenBytes);
        String cookieByteString = cookieByteStringCache.get(cookieBytes);
        if (cookieByteString == null) {
            cookieByteString = StringUtil.toString(Base64Coder.base64Encode(ssoTokenBytes));
            updateCookieCache(cookieBytes, cookieByteString);
        }

        Cookie ssoCookie = createCookie(req, cookieByteString);
        resp.addCookie(ssoCookie);
    }
487147
@Override
    @SuppressWarnings("unused")
    public boolean set(HttpCookie cookie, byte[] attribValue) {

        // The mere presence of the SECURE attribute means that
        // this attrib is set
        cookie.setSecure(true);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "Cookie secure set to " + cookie.isSecure());
        }
        return true;
    }
1044230
def set_cookie(self, cookie):
		'''
		
		'''

		# Function path: Network.setCookie
		# Domain: Network
		# Method name: setCookie
		# WARNING: This function is marked 'Experimental'!
		# Parameters:
		#         Required arguments:
		#                 'url' (type: string) -> The request-URI to associate with the setting of the cookie. This value can affect the default domain and path values of the created cookie.
		#                 'name' (type: string) -> The name of the cookie.
		#                 'value' (type: string) -> The value of the cookie.
		#         Optional arguments:
		#                 'domain' (type: string) -> If omitted, the cookie becomes a host-only cookie.
		#                 'path' (type: string) -> Defaults to the path portion of the url parameter.
		#                 'secure' (type: boolean) -> Defaults ot false.
		#                 'httpOnly' (type: boolean) -> Defaults to false.
		#                 'sameSite' (type: CookieSameSite) -> Defaults to browser default behavior.
		#                 'expirationDate' (type: Timestamp) -> If omitted, the cookie becomes a session cookie.
		# Returns:
		#         'success' (type: boolean) -> True if successfully set cookie.

		# Description: Sets a cookie with the given cookie data; may overwrite equivalent cookies if they exist.

		assert isinstance(cookie, http.cookiejar.Cookie), 'The value passed to `set_cookie` must be an instance of http.cookiejar.Cookie().' + \
			' Passed: %s ("%s").' % (type(cookie), cookie)

		# Yeah, the cookielib stores this attribute as a string, despite it containing a
		# boolean value. No idea why.
		is_http_only = str(cookie.get_nonstandard_attr('httponly', 'False')).lower() == "true"


		# I'm unclear what the "url" field is actually for. A cookie only needs the domain and
		# path component to be fully defined. Considering the API apparently allows the domain and
		# path parameters to be unset, I think it forms a partially redundant, with some
		# strange interactions with mode-changing between host-only and more general
		# cookies depending on what's set where.
		# Anyways, given we need a URL for the API to work properly, we produce a fake
		# host url by building it out of the relevant cookie properties.
		fake_url = urllib.parse.urlunsplit((
				"http" if is_http_only else "https",  # Scheme
				cookie.domain,                        # netloc
				cookie.path,                          # path
				'',                                   # query
				'',                                   # fragment
			))

		params = {
				'url'      : fake_url,

				'name'     : cookie.name,
				'value'    : cookie.value if cookie.value else "",
				'domain'   : cookie.domain,
				'path'     : cookie.path,
				'secure'   : cookie.secure,
				'expires'  : float(cookie.expires) if cookie.expires else float(2**32),

				'httpOnly' : is_http_only,

				# The "sameSite" flag appears to be a chromium-only extension for controlling
				# cookie sending in non-first-party contexts. See:
				# https://bugs.chromium.org/p/chromium/issues/detail?id=459154
				# Anyways, we just use the default here, whatever that is.
				# sameSite       = cookie.xxx
			}

		ret = self.Network_setCookie(**params)

		return ret
512864
public void setTokenValue(String tokenName, Cookie value) {
		if (value == null) {
			tokenValues.remove(tokenName);
		} else {
			tokenValues.put(tokenName, value);
		}
	}
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;
    }
1097595
@Override
    public boolean allowToAddCookieToResponse(HttpServletRequest req) {
        if (!config.isSingleSignonEnabled()) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "SSO is not enabled. Not setting the SSO Cookie");
            }
            return false;
        }
        boolean secureRequest = req.isSecure();
        if (config.getSSORequiresSSL() && !secureRequest) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "SSO requires SSL. The cookie will not be sent back because the request is not over https.");
            }
            return false;
        }
        return true;
    }
309544
protected void setCookies(HttpServletRequest request, HttpServletResponse response, String requestToken, String stateValue) {
        ReferrerURLCookieHandler referrerURLCookieHandler = WebAppSecurityCollaboratorImpl.getGlobalWebAppSecurityConfig().createReferrerURLCookieHandler();

        // Create cookie for request token
        Cookie requestTokenCookie = referrerURLCookieHandler.createCookie(TwitterConstants.COOKIE_NAME_REQUEST_TOKEN, requestToken, request);
        response.addCookie(requestTokenCookie);

        // Set original request URL in cookie
        String cookieName = ClientConstants.COOKIE_NAME_REQ_URL_PREFIX + stateValue.hashCode();
        Cookie c = referrerURLCookieHandler.createCookie(cookieName, webUtils.getRequestUrlWithEncodedQueryString(request), request);
        response.addCookie(c);

    }
1245232
private static HttpCookie parseInternal(String header,
                                            boolean retainHeader)
    {
        HttpCookie cookie = null;
        String namevaluePair = null;

        StringTokenizer tokenizer = new StringTokenizer(header, ";");

        // there should always have at least on name-value pair;
        // it's cookie's name
        try {
            namevaluePair = tokenizer.nextToken();
            int index = namevaluePair.indexOf('=');
            if (index != -1) {
                String name = namevaluePair.substring(0, index).trim();
                String value = namevaluePair.substring(index + 1).trim();
                if (retainHeader)
                    cookie = new HttpCookie(name,
                                            stripOffSurroundingQuote(value),
                                            header);
                else
                    cookie = new HttpCookie(name,
                                            stripOffSurroundingQuote(value));
            } else {
                // no "=" in name-value pair; it's an error
                throw new IllegalArgumentException("Invalid cookie name-value pair");
            }
        } catch (NoSuchElementException ignored) {
            throw new IllegalArgumentException("Empty cookie header string");
        }

        // remaining name-value pairs are cookie's attributes
        while (tokenizer.hasMoreTokens()) {
            namevaluePair = tokenizer.nextToken();
            int index = namevaluePair.indexOf('=');
            String name, value;
            if (index != -1) {
                name = namevaluePair.substring(0, index).trim();
                value = namevaluePair.substring(index + 1).trim();
            } else {
                name = namevaluePair.trim();
                value = null;
            }

            // assign attribute to cookie
            assignAttribute(cookie, name, value);
        }

        return cookie;
    }