Polls until a challenge has been validated.

@api

@param string $location URI of the challenge

@return Promise resolves to null
@throws AcmeException
186380
public function pollForChallenge(string $location): Promise {
        return call(function () use ($location) {
            do {
                /** @var Response $response */
                $response = yield $this->acmeClient->get($location);
                $body = yield $response->getBody();
                $data = json_decode($body);

                if ($data->status === 'pending') {
                    if (!$response->hasHeader('retry-after')) {
                        // throw new AcmeException("Protocol Violation: No Retry-After Header!");

                        yield new Delayed(1000);
                        continue;
                    }

                    $waitTime = $this->parseRetryAfter($response->getHeader('retry-after'));
                    $waitTime = max($waitTime, 1);

                    yield new Delayed($waitTime * 1000);

                    continue;
                }

                if ($data->status === 'invalid') {
                    $errors = [];

                    foreach ($data->errors ?? [] as $error) {
                        $message = $error->title ?? '???';

                        if ($error->detail ?? '') {
                            $message .= ' (' . $error->detail . ')';
                        }

                        $errors[] = $message;
                    }

                    throw new AcmeException('Challenge marked as invalid: ' . ($errors ? \implode(', ', $errors) : ('Unknown error: ' . $body)));
                }

                if ($data->status === 'valid') {
                    break;
                }

                throw new AcmeException("Invalid challenge status: {$data->status}.");
            } while (1);
        });
    }
289230
protected function getForwardRequest(Location $location, Content $content, SiteAccess $previewSiteAccess, Request $request, $language)
    {
        $request = parent::getForwardRequest($location, $content, $previewSiteAccess, $request, $language);

        $overrideViewAction = $this->configResolver->getParameter(
            'override_url_alias_view_action',
            'netgen_ez_platform_site_api'
        );

        // If the preview siteaccess is configured in legacy_mode
        // we forward to the LegacyKernelController.
        // For compatibility with eZ Publish Legacy
        if ($this->isLegacyModeSiteAccess($previewSiteAccess->name)) {
            $request->attributes->set('_controller', 'ezpublish_legacy.controller:indexAction');
        } elseif ($overrideViewAction) {
            $request->attributes->set('_controller', UrlAliasRouter::OVERRIDE_VIEW_ACTION);

            $this->injectSiteApiValueObjects($request, $language);
        }

        return $request;
    }
1314623
public function setLocation( Location $location )
    {
        foreach ( $this->handlers as $handler )
        {
            if ( $handler instanceof LocationAwareHandlerInterface )
            {
                $handler->setLocation( $location );
            }
        }
    }
154375
public function tagHttpCacheForLocation(Location $location)
    {
        $this->responseTagger->tag($location);
        $this->responseTagger->tag($location->getContentInfo());
    }
166485
public function transform($location, array $options = [])
    {
        $regexp = '/((https?\:|\/\/).*)/i';
        if (preg_match($regexp, $location)) {
            return new CustomUri($location);
        }
        return null;
    }
30705
protected function doesDirectoryExist($location)
    {
        // Maybe this isn't an actual key, but a prefix.
        // Do a prefix listing of objects to determine.
        $command = $this->s3Client->getCommand(
            'listObjects',
            [
                'Bucket'  => $this->bucket,
                'Prefix'  => rtrim($location, '/') . '/',
                'MaxKeys' => 1,
            ]
        );

        try {
            $result = $this->s3Client->execute($command);

            return $result['Contents'] || $result['CommonPrefixes'];
        } catch (S3Exception $e) {
            if ($e->getStatusCode() === 403) {
                return false;
            }

            throw $e;
        }
    }
456490
public function created($location = null)
    {
        $this->respondWith(201);

        if (!empty($location)) {
            $this->setResponseHeader('Location', $location);
        }
    }
316513
public function setLocation($location)
    {
        Validate::isString($location, 'location');
        Validate::notNullOrEmpty($location, 'location');

        $this->_location = $location;
    }
1189150
private function createRestLocation(Location $location): RestLocation
    {
        return new RestLocation(
            $location,
            $this->locationService->getLocationChildCount($location)
        );
    }
832383
protected function checkCategoryRedirect(Location $location): ?RedirectResponse
    {
        $content = $location->content;

        $internalRedirectContent = null;
        if (!$content->getField('internal_redirect')->isEmpty()) {
            $internalRedirectContent = $content->getFieldRelation('internal_redirect');
        }

        $externalRedirectValue = $content->getField('external_redirect')->value;

        if ($internalRedirectContent instanceof Content) {
            if ($internalRedirectContent->contentInfo->mainLocationId !== $location->id) {
                return new RedirectResponse(
                    $this->router->generate($internalRedirectContent),
                    RedirectResponse::HTTP_MOVED_PERMANENTLY
                );
            }
        } elseif ($externalRedirectValue instanceof UrlValue && !$content->getField('external_redirect')->isEmpty()) {
            if (mb_stripos($externalRedirectValue->link, 'http') === 0) {
                return new RedirectResponse($externalRedirectValue->link, RedirectResponse::HTTP_MOVED_PERMANENTLY);
            }

            return new RedirectResponse(
                $this->router->generate($this->getRootLocation()) . trim($externalRedirectValue->link, '/'),
                RedirectResponse::HTTP_MOVED_PERMANENTLY
            );
        }

        return null;
    }
1068446
@Override
    public AuthenticationStatus redirect(String location) {
        try {
            response.sendRedirect(response.encodeURL(location));
            response.setStatus(HttpServletResponse.SC_FOUND);
        } catch (IOException e) {
            // TODO: Determine if this needs a serviceability message
        }
        return AuthenticationStatus.SEND_CONTINUE;
    }
717427
public function setLocation($location): self
    {
        if ($location instanceof LocationResponse) {
            $this->setLocationResponse($location);

            return $this;
        }

        if ($location instanceof StopLocationResponse) {
            $this->setStopResponse($location);

            return $this;
        }

        if (\is_int($location) || \is_string($location)) {
            $this->setLocationId($location);

            return $this;
        }

        throw new \InvalidArgumentException(
            'The location must be either a LocationResponse object, StopLocationResponse object, string or integer'
        );
    }
601419
public function removeLocation(Location $location): void
    {
        if (!$this->locations->contains($location)) {
            throw new \InvalidArgumentException(
                    'The location to remove does not exist');
        }
        $location->setWarehouse(null);
        $this->locations->removeElement($location);
    }
538014
public function validate($location, Constraint $constraint)
    {
        if (null === $location) {
            $this->context->addViolation($constraint->message);

            return;
        }

        $haveUniqueRelation = new ContentHaveUniqueRelation($this->contentService);
        try {
            if (!$haveUniqueRelation->isSatisfiedBy($location->getContent())) {
                $this->context->addViolation($constraint->message);
            }
        } catch (InvalidArgumentException $e) {
            $this->context->addViolation($e->getMessage());
        } catch (UnauthorizedException $e) {
            $this->context->addViolation($e->getMessage());
        }
    }
683323
public function setLocation(\CampaignChain\CoreBundle\Entity\Location $location = null)
    {
        $this->location = $location;

        return $this;
    }
505819
public function redirectTo($location) {
        $app = $GLOBALS['app'];
        $host = $_SERVER['HTTP_HOST'];
        if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
            $host = $_SERVER['HTTP_X_FORWARDED_HOST'];
        }
        $protocol = isset($_SERVER['HTTPS'])?'https://':'http://'; 
        $redirectLocation = $protocol.$host.'/'.$app->getConfiguration()->getApplicationContext().'/'.$location;
        if ($app->getSubject()->isAuthenticated()) {
            $separator = '?';
            if(strpos($redirectLocation, '?'))
                $separator = '&';
            $redirectLocation .= $separator."rand_token=".urlencode($app->getSessionManager()->getActiveSession()->getAttribute('nonce'));
        }
        if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && 
            strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
                $this->addHeader("Content-type: application/json");
                $response = array();
                $response['redirect'] = $redirectLocation;
                echo json_encode($response);
                exit;
        } else {
            $this->addHeader('Location: '.$redirectLocation);
        }
    }
163045
public function seek($position)
    {
        reset($this->_storage);
        while (($key = key($this->_storage)) !== null && $key !== $position)
        {
            next($this->_storage);
        }
    }