forked from zendframework/zendframework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NS4] Converted Zend_Oauth to namespaces
- Various fixes to URI and Validator\Hostname components based on issues found during testing OAuth component.
- Loading branch information
1 parent
8cc0310
commit 65f0f44
Showing
39 changed files
with
975 additions
and
658 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,24 +13,29 @@ | |
* to [email protected] so we can send you a copy immediately. | ||
* | ||
* @category Zend | ||
* @package Zend_Oauth | ||
* @package Zend_OAuth | ||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
* @version $Id$ | ||
*/ | ||
|
||
/** | ||
* @uses Zend_Http_Client | ||
* @uses Zend_Oauth | ||
* @uses Zend_Oauth_Config | ||
* @uses Zend_Oauth_Exception | ||
* @uses Zend_Oauth_Http_Utility | ||
* @namespace | ||
*/ | ||
namespace Zend\OAuth; | ||
|
||
/** | ||
* @uses Zend\HTTP\Client | ||
* @uses Zend\OAuth\OAuth | ||
* @uses Zend\OAuth\Config\StandardConfig | ||
* @uses Zend\OAuth\Exception | ||
* @uses Zend\OAuth\HTTP\Utility | ||
* @category Zend | ||
* @package Zend_Oauth | ||
* @package Zend_OAuth | ||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
*/ | ||
class Zend_Oauth_Client extends Zend_Http_Client | ||
class Client extends \Zend\HTTP\Client | ||
{ | ||
/** | ||
* Flag to indicate that the client has detected the server as supporting | ||
|
@@ -40,44 +45,44 @@ class Zend_Oauth_Client extends Zend_Http_Client | |
|
||
/** | ||
* Holds the current OAuth Configuration set encapsulated in an instance | ||
* of Zend_Oauth_Config; it's not a Zend_Config instance since that level | ||
* of Zend_OAuth_Config; it's not a Zend_Config instance since that level | ||
* of abstraction is unnecessary and doesn't let me escape the accessors | ||
* and mutators anyway! | ||
* | ||
* @var Zend_Oauth_Config | ||
* @var Zend\OAuth\Config | ||
*/ | ||
protected $_config = null; | ||
|
||
/** | ||
* Constructor; creates a new HTTP Client instance which itself is | ||
* just a typical Zend_Http_Client subclass with some OAuth icing to | ||
* just a typical Zend_HTTP_Client subclass with some OAuth icing to | ||
* assist in automating OAuth parameter generation, addition and | ||
* cryptographioc signing of requests. | ||
* | ||
* @param array $oauthOptions | ||
* @param string $uri | ||
* @param array|Zend_Config $config | ||
* @param array|\Zend\Config\Config $config | ||
* @return void | ||
*/ | ||
public function __construct(array $oauthOptions, $uri = null, $config = null) | ||
{ | ||
parent::__construct($uri, $config); | ||
$this->_config = new Zend_Oauth_Config; | ||
$this->_config = new Config\StandardConfig; | ||
if (!is_null($oauthOptions)) { | ||
if ($oauthOptions instanceof Zend_Config) { | ||
if ($oauthOptions instanceof \Zend\Config\Config) { | ||
$oauthOptions = $oauthOptions->toArray(); | ||
} | ||
$this->_config->setOptions($oauthOptions); | ||
} | ||
} | ||
|
||
/** | ||
* Same as Zend_Http_Client::setMethod() except it also creates an | ||
* Oauth specific reference to the method type. | ||
* Same as Zend_HTTP_Client::setMethod() except it also creates an | ||
* OAuth specific reference to the method type. | ||
* Might be defunct and removed in a later iteration. | ||
* | ||
* @param string $method | ||
* @return Zend_Http_Client | ||
* @return Zend\HTTP\Client | ||
*/ | ||
public function setMethod($method = self::GET) | ||
{ | ||
|
@@ -96,19 +101,19 @@ public function setMethod($method = self::GET) | |
} | ||
|
||
/** | ||
* Same as Zend_Http_Client::request() except just before the request is | ||
* Same as Zend_HTTP_Client::request() except just before the request is | ||
* executed, we automatically append any necessary OAuth parameters and | ||
* sign the request using the relevant signature method. | ||
* | ||
* @param string $method | ||
* @return Zend_Http_Response | ||
* @return Zend\HTTP\Response\Response | ||
*/ | ||
public function request($method = null) | ||
{ | ||
if (!is_null($method)) { | ||
$this->setMethod($method); | ||
} | ||
$this->prepareOauth(); | ||
$this->prepareOAuth(); | ||
return parent::request(); | ||
} | ||
|
||
|
@@ -120,14 +125,14 @@ public function request($method = null) | |
* being used. | ||
* | ||
* @return void | ||
* @throws Zend_Oauth_Exception If POSTBODY scheme requested, but GET request method used; or if invalid request scheme provided | ||
* @throws Zend\OAuth\Exception If POSTBODY scheme requested, but GET request method used; or if invalid request scheme provided | ||
*/ | ||
public function prepareOauth() | ||
public function prepareOAuth() | ||
{ | ||
$requestScheme = $this->getRequestScheme(); | ||
$requestMethod = $this->getRequestMethod(); | ||
$query = null; | ||
if ($requestScheme == Zend_Oauth::REQUEST_SCHEME_HEADER) { | ||
if ($requestScheme == OAuth::REQUEST_SCHEME_HEADER) { | ||
$params = array(); | ||
if (!empty($this->paramsGet)) { | ||
$params = array_merge($params, $this->paramsGet); | ||
|
@@ -145,9 +150,9 @@ public function prepareOauth() | |
$this->getUri(true), $this->_config, $params | ||
); | ||
$this->setHeaders('Authorization', $oauthHeaderValue); | ||
} elseif ($requestScheme == Zend_Oauth::REQUEST_SCHEME_POSTBODY) { | ||
} elseif ($requestScheme == OAuth::REQUEST_SCHEME_POSTBODY) { | ||
if ($requestMethod == self::GET) { | ||
throw new Zend_Oauth_Exception( | ||
throw new Exception( | ||
'The client is configured to' | ||
. ' pass OAuth parameters through a POST body but request method' | ||
. ' is set to GET' | ||
|
@@ -158,7 +163,7 @@ public function prepareOauth() | |
); | ||
$this->setRawData($raw); | ||
$this->paramsPost = array(); | ||
} elseif ($requestScheme == Zend_Oauth::REQUEST_SCHEME_QUERYSTRING) { | ||
} elseif ($requestScheme == OAuth::REQUEST_SCHEME_QUERYSTRING) { | ||
$params = array(); | ||
$query = $this->getUri()->getQuery(); | ||
if ($query) { | ||
|
@@ -176,24 +181,24 @@ public function prepareOauth() | |
$this->getUri()->setQuery($query); | ||
$this->paramsGet = array(); | ||
} else { | ||
throw new Zend_Oauth_Exception('Invalid request scheme: ' . $requestScheme); | ||
throw new Exception('Invalid request scheme: ' . $requestScheme); | ||
} | ||
} | ||
|
||
/** | ||
* Simple Proxy to the current Zend_Oauth_Config method. It's that instance | ||
* Simple Proxy to the current Zend_OAuth_Config method. It's that instance | ||
* which holds all configuration methods and values this object also presents | ||
* as it's API. | ||
* | ||
* @param string $method | ||
* @param array $args | ||
* @return mixed | ||
* @throws Zend_Oauth_Exception if method does not exist in config object | ||
* @throws Zend\OAuth\Exception if method does not exist in config object | ||
*/ | ||
public function __call($method, array $args) | ||
{ | ||
if (!method_exists($this->_config, $method)) { | ||
throw new Zend_Oauth_Exception('Method does not exist: ' . $method); | ||
throw new Exception('Method does not exist: ' . $method); | ||
} | ||
return call_user_func_array(array($this->_config,$method), $args); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,19 +13,24 @@ | |
* to [email protected] so we can send you a copy immediately. | ||
* | ||
* @category Zend | ||
* @package Zend_Oauth | ||
* @package Zend_OAuth | ||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
* @version $Id$ | ||
*/ | ||
|
||
/** | ||
* @namespace | ||
*/ | ||
namespace Zend\OAuth; | ||
|
||
/** | ||
* @category Zend | ||
* @package Zend_Oauth | ||
* @package Zend_OAuth | ||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
*/ | ||
interface Zend_Oauth_Config_ConfigInterface | ||
interface Config | ||
{ | ||
public function setOptions(array $options); | ||
|
||
|
@@ -69,7 +74,7 @@ public function setUserAuthorizationUrl($url); | |
|
||
public function getUserAuthorizationUrl(); | ||
|
||
public function setToken(Zend_Oauth_Token $token); | ||
public function setToken(Token $token); | ||
|
||
public function getToken(); | ||
} |
Oops, something went wrong.