Exemplo n.º 1
0
 private function fetchContentDivert($url, $method, $signer)
 {
     $authz = isset($_GET['authz']) ? $_GET['authz'] : (isset($_POST['authz']) ? $_POST['authz'] : '');
     $token = $this->context->extractAndValidateToken($signer);
     switch (strtoupper($authz)) {
         case 'SIGNED':
             $fetcher = $this->signingFetcher->getSigningFetcher(new BasicRemoteContentFetcher(), $token);
             return $fetcher->fetch($url, $method);
         case 'OAUTH':
             $params = new OAuthRequestParams();
             $fetcher = $this->signingFetcher->getSigningFetcher(new BasicRemoteContentFetcher(), $token);
             $oAuthFetcherFactory = new OAuthFetcherFactory($fetcher);
             $this->oauthFetcher = $oAuthFetcherFactory->getOAuthFetcher($fetcher, $token, $params);
             $request = new RemoteContentRequest($url);
             $request->createRemoteContentRequestWithUri($url);
             return $this->oauthFetcher->fetch($request);
         case 'NONE':
         default:
             return $this->fetchContent($url, $method);
     }
 }
 private function divertFetch(RemoteContentRequest $request)
 {
     switch ($request->getAuthType()) {
         case RemoteContentRequest::$AUTH_SIGNED:
             $fetcher = $this->signingFetcherFactory->getSigningFetcher($this->basicFetcher);
             return $fetcher->fetchRequest($request);
         case RemoteContentRequest::$AUTH_OAUTH:
             $params = $request->getOAuthRequestParams();
             $token = $request->getToken();
             $fetcher = $this->signingFetcherFactory->getSigningFetcher($this->basicFetcher);
             $oAuthFetcherFactory = new OAuthFetcherFactory($fetcher);
             $oauthFetcher = $oAuthFetcherFactory->getOAuthFetcher($fetcher, $token, $params);
             return $oauthFetcher->fetch($request);
         default:
             return $this->basicFetcher->fetchRequest($request);
     }
 }