/**
  * @group ZF-10182
  */
 public function testOauthClientPassingArrayInConstructor()
 {
     $options = array('requestMethod' => 'GET', 'siteUrl' => 'http://www.example.com');
     require_once 'Zend/Oauth/Client.php';
     $client = new Zend_Oauth_Client($options);
     $this->assertEquals('GET', $client->getRequestMethod());
     $this->assertEquals('http://www.example.com', $client->getSiteUrl());
 }
예제 #2
0
 /**
  * Constructor
  *
  * @param null|Zend_Http_Response $response
  * @param null|Zend_Oauth_Http_Utility $utility
  */
 public function __construct(Zend_Http_Response $response = null, Zend_Oauth_Http_Utility $utility = null)
 {
     parent::__construct($response, $utility);
     // detect if server supports OAuth 1.0a
     if (isset($this->_params[Zend_Oauth_Token::TOKEN_PARAM_CALLBACK_CONFIRMED])) {
         Zend_Oauth_Client::$supportsRevisionA = true;
     }
 }
 public static function createFromConfigs(Zend_Config $config, $userId)
 {
     $databaseFactory = new EngineBlock_Database_ConnectionFactory();
     $databaseAdapter = $databaseFactory->create(EngineBlock_Database_ConnectionFactory::MODE_READ);
     $accessTokenHelper = new EngineBlock_Group_Provider_OpenSocial_Oauth_Helper_AccessToken($config->id, $databaseAdapter, $userId);
     $authConfig = $config->auth->toArray();
     if (isset($authConfig['rsaPrivateKey'])) {
         if (empty($authConfig['rsaPrivateKey'])) {
             unset($authConfig['rsaPrivateKey']);
         } else {
             $authConfig['rsaPrivateKey'] = new Zend_Crypt_Rsa_Key_Private($authConfig['rsaPrivateKey']);
         }
     }
     if (isset($authConfig['rsaPublicKey'])) {
         if (empty($authConfig['rsaPublicKey'])) {
             unset($authConfig['rsaPublicKey']);
         } else {
             $authConfig['rsaPublicKey'] = new Zend_Crypt_Rsa_Key_Public($authConfig['rsaPublicKey']);
         }
     }
     $httpClient = new Zend_Oauth_Client($authConfig, $config->url, $config);
     $accessToken = $accessTokenHelper->loadAccessToken();
     if ($accessToken) {
         $httpClient->setToken($accessToken);
     }
     $openSocialRestClient = new OpenSocial_Rest_Client($httpClient);
     $provider = new self($config->id, $config->name, $openSocialRestClient);
     $provider->setUserId($userId);
     $provider->setAccessTokenHelper($accessTokenHelper);
     $provider->addPrecondition('EngineBlock_Group_Provider_Precondition_OpenSocial_Oauth_AccessTokenExists');
     $provider->configurePreconditions($config);
     $provider->configureGroupFilters($config);
     $provider->configureGroupMemberFilters($config);
     $decoratedProvider = $provider->configureDecoratorChain($config);
     return $decoratedProvider;
 }
예제 #4
0
    /**
     * @group ZF-10851
     */
    public function testOauthClientPreparationWithRealmConfigurationOption()
    {
        require_once "Zend/Oauth/Token/Access.php";
        
        $options = array(
            'requestMethod' => 'GET',
            'siteUrl'       => 'http://www.example.com',
            'realm'			=> 'someRealm'
        );
        $token = new Zend_Oauth_Token_Access();

        require_once 'Zend/Oauth/Client.php';
        $client = new Zend_Oauth_Client($options);
        $this->assertEquals(NULL,$client->getHeader('Authorization'));
        
        $client->setToken($token);
        $client->setUri('http://oauth.example.com');
        $client->prepareOauth();
        
        $this->assertNotContains('realm=""',$client->getHeader('Authorization'));
        $this->assertContains('realm="someRealm"',$client->getHeader('Authorization'));
    }
예제 #5
0
 /**
  * Get OAuth client
  * 
  * @param  array $oauthOptions 
  * @param  null|string $uri 
  * @param  null|array|Zend_Config $config 
  * @param  bool $excludeCustomParamsFromHeader 
  * @return Zend_Oauth_Client
  */
 public function getHttpClient(array $oauthOptions, $uri = null, $config = null, $excludeCustomParamsFromHeader = true)
 {
     $client = new Zend_Oauth_Client($oauthOptions, $uri, $config, $excludeCustomParamsFromHeader);
     $client->setToken($this);
     return $client;
 }
예제 #6
0
 /**
  * @group ZF-11663
  */
 public function testOauthClientAcceptsGetParametersThroughSetter()
 {
     require_once "Zend/Oauth/Token/Access.php";
     $token = new Zend_Oauth_Token_Access();
     $options = array('requestMethod' => 'GET', 'requestScheme' => Zend_Oauth::REQUEST_SCHEME_QUERYSTRING, 'realm' => 'someRealm');
     require_once 'Zend/Oauth/Client.php';
     $client = new Zend_Oauth_Client($options);
     $client->setToken($token);
     $client->setUri('http://www.example.com/?test=FooBar');
     $queryString = $client->getUri()->getQuery();
     // Check that query string was set properly
     $this->assertSame('test=FooBar', $queryString);
     // Change the GET parameters
     $client->setParameterGet('test', 'FooBaz');
     $client->setParameterGet('second', 'TestTest');
     // Prepare the OAuth request
     $client->prepareOauth();
     $queryString = $client->getUri()->getQuery();
     // Ensure that parameter 'test' is unchanged, as URI parameters
     // should take precedence over ones set with setParameterGet
     $this->assertContains('test=FooBar', $queryString);
     // Ensure that new parameter was added
     $this->assertContains('second=TestTest', $queryString);
 }
 /**
  * Set local HTTP client as distinct from the static HTTP client
  * as inherited from Zend_Rest_Client.
  *
  * @param Zend_Http_Client $client
  * @return ZendX_Service_Dropbox
  */
 public function setLocalHttpClient(Zend_Http_Client $client)
 {
     $this->_localHttpClient = $client;
     $this->_localHttpClient->setHeaders('Accept-Charset', 'ISO-8859-1,utf-8');
     return $this;
 }