Handles anonymous authentication.

@param GetResponseEvent $event A GetResponseEvent instance
490047
public function handle(GetResponseEvent $event): void
    {
        if ($this->isEnabled()) {
            $hostRole = $this->getHostRole($event);

            if (null !== $hostRole) {
                $this->sidManager->addSpecialRole($hostRole);
            }
        }
    }
1161924
public function onRequest(GetResponseEvent $event)
    {
        if (!$event->isMasterRequest()) {
            return;
        }

        $request = $event->getRequest();
        $session = $request->getSession();

        $isProfilerRoute = strpos($request->getPathInfo(), $this->profilerMountPrefix) === 0;
        if (!$isProfilerRoute && ($this->debug || $request->hasPreviousSession()) && !$session->isStarted()) {
            $this->attachFlashBag($session);
        }
    }
197073
public function onKernelRequest(GetResponseEvent $event)
	{
		if (!$event->isMasterRequest()) {
			return;
		}
		
		$request = $event->getRequest();
		if ($this->reverseProxies) {
			$request->setTrustedProxies($this->reverseProxies);
		}
		if ($this->xForwardedFor) {
			$request->setTrustedHeaderName(Request::HEADER_CLIENT_IP, $this->xForwardedFor);
		}
		
		$ip = $request->getClientIp();
		$start = microtime(true);

		$this->key=$this->prefix.'_'.$ip;
		
		$this->memcache->add($this->key,0,false,$this->lockMaxWait);
		while (true) {
			$this->incremented = true;
			if ($this->memcache->increment($this->key)<=$this->concurrency) {
				break;
			}
			$this->incremented = false;
			$this->memcache->decrement($this->key);
			if (!$this->spinLockWait || microtime(true)-$start>$this->lockMaxWait) {
				throw new TooManyRequestsHttpException();
			}
			usleep($this->spinLockWait);
		}
	}
810688
public function handle(GetResponseEvent $event)
    {
        $request = $event->getRequest();
        $application = $event->getKernel()->getApplication();

        if (null !== $application && false === $request->hasSession()) {
            $container = $application->getContainer();
            $event->getRequest()->setSession($container->get('bb_session'));
        }

        parent::handle($event);
    }
886989
public function onKernelRequest(GetResponseEvent $event) {
		if (HttpKernel::MASTER_REQUEST != $event->getRequestType()) {
			return;
		}

		if ($event->getRequest()->headers->has('x-amz-sns-message-type')) {
			$result = $this->handleSnsNotifications($event);
			$event->setResponse(new Response($result, 200));
		}

		if ($event->getRequest()->headers->has('iron-message-id')) {
			$result = $this->handleIronMqNotifications($event);
			$event->setResponse(new Response($result, 200));
		}
	}
175466
public function onKernelRequest(GetResponseEvent $event): void
    {
        $request = $event->getRequest();
        if (!$attributes = RequestAttributesExtractor::extractAttributes($request)) {
            return;
        }

        $resourceMetadata = $this->resourceMetadataFactory->create($attributes['resource_class']);

        $isGranted = $resourceMetadata->getOperationAttribute($attributes, 'access_control', null, true);

        if (null === $isGranted) {
            return;
        }

        $extraVariables = $request->attributes->all();
        $extraVariables['object'] = $request->attributes->get('data');
        $extraVariables['request'] = $request;

        if (!$this->resourceAccessChecker->isGranted($attributes['resource_class'], $isGranted, $extraVariables)) {
            throw new AccessDeniedException($resourceMetadata->getOperationAttribute($attributes, 'access_control_message', 'Access Denied.', true));
        }
    }
330744
public function onCoreException(GetResponseForExceptionEvent $event)
	{
	    $exception = $event->getException();
	    $request = $event->getRequest();

    	if ($request->isXmlHttpRequest()) {
    		$msg = "";
    		if($exception instanceof AccessDeniedException ) {
    			$msg = "User Not Authenticated";
    		} elseif($exception instanceof AuthenticationCredentialsNotFoundException) {
    			$msg = "User Not Allowed";
    		} elseif($exception instanceof AuthenticationException) {
    			// Change this
    			$msg = "User Not Authenticated";
    		}

    		if($msg) {
    			$responseData = array('status' => 403, 'reason' => $msg);
    			$response = new JsonResponse();
    			$response->setData($responseData);
    			$response->setStatusCode($responseData['status']);
    			$event->setResponse($response);
    		}
	    }
	}
372494
public function handle(GetResponseEvent $event)
    {
        if (null !== $this->logger) {
            $this->logger->info('Checking for guard authentication credentials.', array('firewall_key' => $this->providerKey, 'authenticators' => count($this->guardAuthenticators)));
        }

        foreach ($this->guardAuthenticators as $key => $guardAuthenticator) {
            // get a key that's unique to *this* guard authenticator
            // this MUST be the same as GuardAuthenticationProvider
            $uniqueGuardKey = $this->providerKey.'_'.$key;

            $this->executeGuardAuthenticator($uniqueGuardKey, $guardAuthenticator, $event);
        }
    }
237769
public function onKernelRequest(GetResponseEvent $event)
    {
        if (!$event->isMasterRequest()) {
            // don't do anything if it's not the master request
            return;
        }

        $request = $event->getRequest();

        $referer = $request->headers->get('referer');

        if ($referer && false === mb_strpos($referer, $request->getHost())) {
            $session = $this->getContainer()->get('session');

            $session->set('referer', $referer);
        }
    }
1041144
public function handle(GetResponseEvent $event)
    {
        $request = $event->getRequest();

        if ($request->getMethod() !== 'POST') {
            throw new MethodNotAllowedHttpException(['POST']);
        }

        $data = json_decode($request->getContent(), true);

        if (null === $token = $this->createToken($data)) {
            throw new AuthenticationServiceException('Invalid JSON!');
        }

        if (null !== $this->logger) {
            $this->logger->info(
                sprintf('Post Authentication body found using passwordCredentials for user "%s"', $token->getUsername())
            );
        }

        try {
            $token = $this->authenticationManager->authenticate($token);
            $this->tokenStorage->setToken($token);
        } catch (AuthenticationException $failed) {
            $this->tokenStorage->setToken(null);

            if (null !== $this->logger) {
                $this->logger->info(
                    sprintf(
                        'Authentication request failed for user "%s" using POST and data: %s',
                        json_encode($data),
                        $failed->getMessage()
                    )
                );
            }

            throw $failed;
        }
    }
448804
public function onKernelRequest(GetResponseEvent $event): void
    {
        if (!$event->isMasterRequest()) {
            return;
        }

        $request = $event->getRequest();
        $route = $request->attributes->get('_route');

        if ($route !== null && !$request->attributes->get('requires_license')) {
            return;
        }

        if ($request->get('lic') === 'active' || $this->kernel->getEnvironment() !== 'prod') {
            return;
        }

        // Checking for whitelisted users
        try {
            /** @noinspection NullPointerExceptionInspection */
            $user = $this->tokenStorage->getToken()->getUser();
            if ($user instanceof TenantInterface) {
                if ($user->isWhiteListed()) {
                    return;
                }

                $today = \date('Y-m-d');
                $whitelist = $this->kernel->getContainer()->getParameter('license_whitelist');
                /** @noinspection ForeachSourceInspection */
                foreach ($whitelist as $allowed) {
                    if ($today <= $allowed['valid_till'] && $allowed['client_key'] === $user->getClientKey()) {
                        return;
                    }
                }
            }
        } catch (\Throwable $e) {
            // Do nothing
        }

        $url = $this->router->generate('atlassian_connect_unlicensed', $request->query->all());
        $response = new RedirectResponse($url);
        $event->setResponse($response);
    }
786399
public function onEarlyKernelRequest(GetResponseEvent $event)
    {
        $request = $event->getRequest();
        foreach ($this->customFormats as $name => $mimeTypes) {
            $request->setFormat($name, $mimeTypes);
        }
    }
1107323
public function onKernelRequest(GetResponseEvent $event)
    {
        $request = $event->getRequest();

        // This call is required in all cases, because the default router needs our webspace information
        // Would be nice to also only call this if the _requestAnalyzer attribute is set, but it's set on the next line
        $this->requestAnalyzer->analyze($request);
        $this->baseRouteListener->onKernelRequest($event);
        if (false !== $request->attributes->get(static::REQUEST_ANALYZER, true)) {
            $this->requestAnalyzer->validate($request);
        }
    }
917897
public function onKernelRequest(GetResponseEvent $event): void
    {
        foreach ($this->extensions as $extension) {
            if (!class_exists($extension) || !is_a($extension, ExtensionInterface::class, true)) {
                continue;
            }

            if ($this->twig->hasExtension($extension)) {
                continue;
            }

            $this->twig->addExtension(new $extension());
        }
    }
161034
public function onKernelRequest(GetResponseEvent $event)
    {
        $request = $event->getRequest();

        foreach ($this->requestMatchers as $requestMatcher) {
            if ($requestMatcher->matches($request)) {
                $request->attributes->set(FOSRestBundle::ZONE_ATTRIBUTE, true);

                return;
            }
        }

        $request->attributes->set(FOSRestBundle::ZONE_ATTRIBUTE, false);
    }
1228863
public function onKernelRequest(GetResponseEvent $event)
    {
        $request = $event->getRequest();
        if (!$strMockedDate = $request->query->get($this->mockParamName)) {
            return;
        }

        $this->mock($strMockedDate);
    }
510678
public function onRequest(GetResponseEvent $event)
    {
        if (!$event->isMasterRequest()) {
            return;
        }

        $this->manager->initialize($event->getRequest());
    }