File indexing completed on 2025-01-26 05:29:42

0001 <?php
0002 /**
0003  * Zend Framework
0004  *
0005  * LICENSE
0006  *
0007  * This source file is subject to the new BSD license that is bundled
0008  * with this package in the file LICENSE.txt.
0009  * It is also available through the world-wide-web at this URL:
0010  * http://framework.zend.com/license/new-bsd
0011  * If you did not receive a copy of the license and are unable to
0012  * obtain it through the world-wide-web, please send an email
0013  * to license@zend.com so we can send you a copy immediately.
0014  *
0015  * @category   Zend
0016  * @package    Zend_Oauth
0017  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0018  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0019  * @version    $Id$
0020  */
0021 
0022 /** Zend_Oauth_Token */
0023 // require_once 'Zend/Oauth/Token.php';
0024 
0025 /** Zend_Oauth_Http */
0026 // require_once 'Zend/Oauth/Http.php';
0027 
0028 /** Zend_Uri_Http */
0029 // require_once 'Zend/Uri/Http.php';
0030 
0031 /** Zend_Oauth_Client */
0032 // require_once 'Zend/Oauth/Client.php';
0033 
0034 /**
0035  * @category   Zend
0036  * @package    Zend_Oauth
0037  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0038  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0039  */
0040 class Zend_Oauth_Token_Access extends Zend_Oauth_Token
0041 {
0042     /**
0043      * Cast to HTTP header
0044      *
0045      * @param  string $url
0046      * @param  Zend_Oauth_Config_ConfigInterface $config
0047      * @param  null|array $customParams
0048      * @param  null|string $realm
0049      * @return string
0050      */
0051     public function toHeader(
0052         $url, Zend_Oauth_Config_ConfigInterface $config, array $customParams = null, $realm = null
0053     ) {
0054         if (!Zend_Uri::check($url)) {
0055             // require_once 'Zend/Oauth/Exception.php';
0056             throw new Zend_Oauth_Exception(
0057                 '\'' . $url . '\' is not a valid URI'
0058             );
0059         }
0060         $params = $this->_httpUtility->assembleParams($url, $config, $customParams);
0061         return $this->_httpUtility->toAuthorizationHeader($params, $realm);
0062     }
0063 
0064     /**
0065      * Cast to HTTP query string
0066      *
0067      * @param  mixed $url
0068      * @param  Zend_Oauth_Config_ConfigInterface $config
0069      * @param  null|array $params
0070      * @return string
0071      */
0072     public function toQueryString($url, Zend_Oauth_Config_ConfigInterface $config, array $params = null)
0073     {
0074         if (!Zend_Uri::check($url)) {
0075             // require_once 'Zend/Oauth/Exception.php';
0076             throw new Zend_Oauth_Exception(
0077                 '\'' . $url . '\' is not a valid URI'
0078             );
0079         }
0080         $params = $this->_httpUtility->assembleParams($url, $config, $params);
0081         return $this->_httpUtility->toEncodedQueryString($params);
0082     }
0083 
0084     /**
0085      * Get OAuth client
0086      *
0087      * @param  array $oauthOptions
0088      * @param  null|string $uri
0089      * @param  null|array|Zend_Config $config
0090      * @param  bool $excludeCustomParamsFromHeader
0091      * @return Zend_Oauth_Client
0092      */
0093     public function getHttpClient(array $oauthOptions, $uri = null, $config = null, $excludeCustomParamsFromHeader = true)
0094     {
0095         $client = new Zend_Oauth_Client($oauthOptions, $uri, $config, $excludeCustomParamsFromHeader);
0096         $client->setToken($this);
0097         return $client;
0098     }
0099 }