Gets security token from request.

@param request the request
@return the security token from request
771295
protected SecurityToken getSecurityTokenFromRequest(final HttpServletRequest request) {
        val cookieValue = wsFederationRequestConfigurationContext.getTicketGrantingTicketCookieGenerator().retrieveCookieValue(request);
        if (StringUtils.isNotBlank(cookieValue)) {
            val tgt = wsFederationRequestConfigurationContext.getTicketRegistry().getTicket(cookieValue, TicketGrantingTicket.class);
            if (tgt != null) {
                val sts = tgt.getDescendantTickets().stream()
                    .filter(t -> t.startsWith(SecurityTokenTicket.PREFIX))
                    .findFirst()
                    .orElse(null);
                if (StringUtils.isNotBlank(sts)) {
                    val stt = wsFederationRequestConfigurationContext.getTicketRegistry().getTicket(sts, SecurityTokenTicket.class);
                    if (stt == null || stt.isExpired()) {
                        LOGGER.warn("Security token ticket [{}] is not found or has expired", sts);
                        return null;
                    }
                    if (stt.getSecurityToken().isExpired()) {
                        LOGGER.warn("Security token linked to ticket [{}] has expired", sts);
                        return null;
                    }
                    return stt.getSecurityToken();
                }
            }
        }
        return null;
    }
264153
public static String getToken(final HttpServletRequest request, final String key) {
		return (String) request.getSession(true).getAttribute(key);
	}
1232719
def _get_token(request):
    
    token = request.headers.get('Authorization')
    if not token:
        message = 'Token not in Authorization header'
        logging.warning(message)
        raise HTTPError(401, message)
    return token
190607
public static function getScriptToken($request)
    {
        // Check for script authorizing token in request parameters.
        $token = $request->query('script_token');
        if (empty($token)) {
            // Check for script token in request HEADER.
            $token = $request->header('X_DREAMFACTORY_SCRIPT_TOKEN');
        }
        if (empty($token)) {
            // Check for script token in request payload.
            $token = $request->input('script_token');
        }

        return $token;
    }
24996
public static String getToken(HttpServletRequest request, ActionMapping mapping)
    {
        if (mapping instanceof PageFlowActionMapping && ((PageFlowActionMapping) mapping).isPreventDoubleSubmit()) {
            HttpSession session = request.getSession();
            String token = (String) session.getAttribute(Globals.TRANSACTION_TOKEN_KEY);
            if (token != null) return token;
            token = TokenProcessor.getInstance().generateToken(request);
            request.getSession().setAttribute(Globals.TRANSACTION_TOKEN_KEY, token);
            return token;
        }

        return null;
    }
274581
public function getToken($request = null)
    {
        $config = $this->_config;

        if ($request === null) {
            return $this->_token;
        }

        $header = $request->getHeaderLine($config['header']);
        if ($header && stripos($header, $config['prefix']) === 0) {
            return $this->_token = str_ireplace($config['prefix'] . ' ', '', $header);
        }

        if (!empty($this->_config['cookie'])) {
            $token = $request->getCookie($this->_config['cookie']);
            if ($token !== null) {
                $token = (string)$token;
            }

            return $this->_token = $token;
        }

        if (!empty($this->_config['parameter'])) {
            $token = $request->getQuery($this->_config['parameter']);
            if ($token !== null) {
                $token = (string)$token;
            }

            return $this->_token = $token;
        }

        return $this->_token;
    }
433933
public static HttpServletRequest getHttpServletRequest(final Request request)
	{
		final WebRequest webRequest = (WebRequest)request;
		final HttpServletRequest httpServletRequest = (HttpServletRequest)webRequest
			.getContainerRequest();
		return httpServletRequest;
	}
1131030
public CsrfToken loadToken(HttpServletRequest request) {
		CsrfToken token = null;
		String ident = getIdentifierFromCookie(request);
		if (ident != null) {
			String key = ident.concat(parameterName);
			if (Config.isCacheEnabled()) {
				token = cache.get(Config.getRootAppIdentifier(), key);
			} else {
				Object[] arr = localCache.get(key);
				if (arr != null && arr.length == 2) {
					boolean expired = (((Long) arr[1]) + Config.SESSION_TIMEOUT_SEC * 1000) < System.currentTimeMillis();
					if (expired) {
						localCache.remove(key);
					} else {
						token = (CsrfToken) arr[0];
					}
				}
			}
		}
		return token;
	}
1245872
private String getCertFromHeader(final HttpServletRequest request) {
        val certHeaderValue = request.getHeader(sslClientCertHeader);
        if (StringUtils.isBlank(certHeaderValue)) {
            return null;
        }

        if ("(null)".equalsIgnoreCase(certHeaderValue)) {
            return null;
        }
        return StringUtils.trim(certHeaderValue);
    }
235199
public function token(Request $request)
    {
        $user = $this->getUser($request);
        
        $client = $user->clients->first();
        if (null !== $client && $client instanceof Client) {

            $serverRequest = $this->createRequest(
                $client,
                $user->id,
                $request, $scope = []
            );
            $reponse = parent::issueToken($serverRequest);
            $responseArray = json_decode($reponse->content(), true);
            unset($responseArray['refresh_token']);
            return response()->json($responseArray)
                ->setStatusCode($reponse->getStatusCode());
        }
        return response(['error' => 'Please create a client first'], 401);
    }
23052
protected function getToken(ServerRequestInterface $request)
    {
        $token = $this->getTokenFromHeader($request, $this->getConfig('header'));
        if ($token === null) {
            $token = $this->getTokenFromQuery($request, $this->getConfig('queryParam'));
        }

        $prefix = $this->getConfig('tokenPrefix');
        if ($prefix !== null && is_string($token)) {
            return $this->stripTokenPrefix($token, $prefix);
        }

        return $token;
    }
826866
protected function getTokenFromRequest($request)
    {
        $token = $request->input('_token') ?: $request->header('X-CSRF-TOKEN');

        if (! $token && $header = $request->header('X-XSRF-TOKEN')) {
            $token = $this->encrypter->decrypt($header, static::serialized());
        }

        return $token;
    }
129916
public static AuthenticationResult authenticationResultFromRequest(final HttpServletRequest request)
  {
    final AuthenticationResult authenticationResult = (AuthenticationResult) request.getAttribute(
        AuthConfig.DRUID_AUTHENTICATION_RESULT
    );

    if (authenticationResult == null) {
      throw new ISE("Null authentication result");
    }

    return authenticationResult;
  }
840672
async def _get_security_token(self) -> None:
        """"""
        _LOGGER.debug('Requesting security token.')
        if self._credentials is None:
            return

        # Make sure only 1 request can be sent at a time.
        async with self._security_token_lock:
            # Confirm there is still no security token.
            if self._security_token is None:
                login_resp = await self._request(
                    'post',
                    LOGIN_ENDPOINT,
                    json=self._credentials,
                    login_request=True,
                )

                return_code = int(login_resp.get('ReturnCode', 1))
                if return_code != 0:
                    if return_code == 203:
                        # Invalid username or password.
                        _LOGGER.debug('Invalid username or password')
                        self._credentials = None
                    raise MyQError(login_resp['ErrorMessage'])

                self._security_token = login_resp['SecurityToken']
271192
public CreateSecurityGroupResponse createSecurityGroup(CreateSecurityGroupRequest request) {
        checkNotNull(request, "request should not be null.");
        if (Strings.isNullOrEmpty(request.getClientToken())) {
            request.setClientToken(this.generateClientToken());
        }
        checkStringNotEmpty(request.getName(), "request name should not be empty.");
        if (null == request.getRules() || request.getRules().isEmpty()) {
            throw new IllegalArgumentException("request rules should not be empty");
        }
        InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, SECURITYGROUP_PREFIX);
        internalRequest.addParameter("clientToken", request.getClientToken());
        fillPayload(internalRequest, request);
        return invokeHttpClient(internalRequest, CreateSecurityGroupResponse.class);
    }
343322
public String getEndUserAuthorizationRequestUri(final HttpServletRequest request) {

		OAuthClientRequest oauthClientRequest;

		try {

			oauthClientRequest = OAuthClientRequest
				.authorizationLocation(authorizationLocation)
				.setClientId(clientId)
				.setRedirectURI(getAbsoluteUrl(request, redirectUri))
				.setScope(getScope())
				.setResponseType(getResponseType())
				.setState(getState())
				.buildQueryMessage();

			logger.info("Authorization request location URI: {}", oauthClientRequest.getLocationUri());

			return oauthClientRequest.getLocationUri();

		} catch (OAuthSystemException ex) {
			logger.error("", ex);
		}

		return null;

	}
624777
private function getTokenFromRequestBody(ServerRequestInterface $request): ?string
    {
        try {
            $parameters = RequestBodyParser::parseFormUrlEncoded($request);

            return $this->getAccessTokenFromParameters($parameters);
        } catch (\Exception $e) {
            return null;
        }
    }