web/lib/Zend/Oauth/Config.php
changeset 807 877f952ae2bd
parent 207 621fa6caec0c
child 1230 68c69c656a2c
equal deleted inserted replaced
805:5e7a0fedabdf 807:877f952ae2bd
    12  * obtain it through the world-wide-web, please send an email
    12  * obtain it through the world-wide-web, please send an email
    13  * to license@zend.com so we can send you a copy immediately.
    13  * to license@zend.com so we can send you a copy immediately.
    14  *
    14  *
    15  * @category   Zend
    15  * @category   Zend
    16  * @package    Zend_Oauth
    16  * @package    Zend_Oauth
    17  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    17  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    18  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    18  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    19  * @version    $Id: Config.php 22662 2010-07-24 17:37:36Z mabe $
    19  * @version    $Id: Config.php 25167 2012-12-19 16:28:01Z matthew $
    20  */
    20  */
    21 
    21 
    22 /** Zend_Oauth */
    22 /** Zend_Oauth */
    23 require_once 'Zend/Oauth.php';
    23 require_once 'Zend/Oauth.php';
    24 
    24 
    29 require_once 'Zend/Oauth/Config/ConfigInterface.php';
    29 require_once 'Zend/Oauth/Config/ConfigInterface.php';
    30 
    30 
    31 /**
    31 /**
    32  * @category   Zend
    32  * @category   Zend
    33  * @package    Zend_Oauth
    33  * @package    Zend_Oauth
    34  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    34  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    35  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    35  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    36  */
    36  */
    37 class Zend_Oauth_Config implements Zend_Oauth_Config_ConfigInterface
    37 class Zend_Oauth_Config implements Zend_Oauth_Config_ConfigInterface
    38 {
    38 {
    39     /**
    39     /**
   144      * Zend_Oauth_Token_Access object.
   144      * Zend_Oauth_Token_Access object.
   145      *
   145      *
   146      * @var Zend_Oauth_Token
   146      * @var Zend_Oauth_Token
   147      */
   147      */
   148     protected $_token = null;
   148     protected $_token = null;
       
   149     
       
   150     /**
       
   151      * Define the OAuth realm
       
   152      * 
       
   153      * @var string
       
   154      */
       
   155     protected $_realm = null;
   149 
   156 
   150     /**
   157     /**
   151      * Constructor; create a new object with an optional array|Zend_Config
   158      * Constructor; create a new object with an optional array|Zend_Config
   152      * instance containing initialising options.
   159      * instance containing initialising options.
   153      *
   160      *
   212                     $this->setRsaPrivateKey($value);
   219                     $this->setRsaPrivateKey($value);
   213                     break;
   220                     break;
   214                 case 'rsaPublicKey':
   221                 case 'rsaPublicKey':
   215                     $this->setRsaPublicKey($value);
   222                     $this->setRsaPublicKey($value);
   216                     break;
   223                     break;
       
   224                 case 'realm':
       
   225                     $this->setRealm($value);
       
   226                     break;
   217             }
   227             }
   218         }
   228         }
   219         if (isset($options['requestScheme'])) {
   229         if (isset($options['requestScheme'])) {
   220             $this->setRequestScheme($options['requestScheme']);
   230             $this->setRequestScheme($options['requestScheme']);
   221         }
   231         }
   258     }
   268     }
   259 
   269 
   260     /**
   270     /**
   261      * Get consumer secret
   271      * Get consumer secret
   262      *
   272      *
   263      * Returns RSA private key if set; otherwise, returns any previously set 
   273      * Returns RSA private key if set; otherwise, returns any previously set
   264      * consumer secret.
   274      * consumer secret.
   265      *
   275      *
   266      * @return string
   276      * @return string
   267      */
   277      */
   268     public function getConsumerSecret()
   278     public function getConsumerSecret()
   378      * @return Zend_Oauth_Config
   388      * @return Zend_Oauth_Config
   379      * @throws Zend_Oauth_Exception for invalid URLs
   389      * @throws Zend_Oauth_Exception for invalid URLs
   380      */
   390      */
   381     public function setCallbackUrl($url)
   391     public function setCallbackUrl($url)
   382     {
   392     {
   383         if (!Zend_Uri::check($url)) {
   393         if (!Zend_Uri::check($url) && $url !== 'oob') {
   384             require_once 'Zend/Oauth/Exception.php';
   394             require_once 'Zend/Oauth/Exception.php';
   385             throw new Zend_Oauth_Exception(
   395             throw new Zend_Oauth_Exception(
   386                 '\'' . $url . '\' is not a valid URI'
   396                 '\'' . $url . '\' is not a valid URI'
   387             );
   397             );
   388         }
   398         }
   449     }
   459     }
   450 
   460 
   451     /**
   461     /**
   452      * Get request token URL
   462      * Get request token URL
   453      *
   463      *
   454      * If no request token URL has been set, but a site URL has, returns the 
   464      * If no request token URL has been set, but a site URL has, returns the
   455      * site URL with the string "/request_token" appended.
   465      * site URL with the string "/request_token" appended.
   456      *
   466      *
   457      * @return string
   467      * @return string
   458      */
   468      */
   459     public function getRequestTokenUrl()
   469     public function getRequestTokenUrl()
   484     }
   494     }
   485 
   495 
   486     /**
   496     /**
   487      * Get access token URL
   497      * Get access token URL
   488      *
   498      *
   489      * If no access token URL has been set, but a site URL has, returns the 
   499      * If no access token URL has been set, but a site URL has, returns the
   490      * site URL with the string "/access_token" appended.
   500      * site URL with the string "/access_token" appended.
   491      *
   501      *
   492      * @return string
   502      * @return string
   493      */
   503      */
   494     public function getAccessTokenUrl()
   504     public function getAccessTokenUrl()
   541     }
   551     }
   542 
   552 
   543     /**
   553     /**
   544      * Get authorization URL
   554      * Get authorization URL
   545      *
   555      *
   546      * If no authorization URL has been set, but a site URL has, returns the 
   556      * If no authorization URL has been set, but a site URL has, returns the
   547      * site URL with the string "/authorize" appended.
   557      * site URL with the string "/authorize" appended.
   548      *
   558      *
   549      * @return string
   559      * @return string
   550      */
   560      */
   551     public function getAuthorizeUrl()
   561     public function getAuthorizeUrl()
   565      */
   575      */
   566     public function setRequestMethod($method)
   576     public function setRequestMethod($method)
   567     {
   577     {
   568         $method = strtoupper($method);
   578         $method = strtoupper($method);
   569         if (!in_array($method, array(
   579         if (!in_array($method, array(
   570                 Zend_Oauth::GET, 
   580                 Zend_Oauth::GET,
   571                 Zend_Oauth::POST, 
   581                 Zend_Oauth::POST,
   572                 Zend_Oauth::PUT, 
   582                 Zend_Oauth::PUT,
   573                 Zend_Oauth::DELETE,
   583                 Zend_Oauth::DELETE,
       
   584                 Zend_Oauth::OPTIONS,
   574             ))
   585             ))
   575         ) {
   586         ) {
   576             require_once 'Zend/Oauth/Exception.php';
   587             require_once 'Zend/Oauth/Exception.php';
   577             throw new Zend_Oauth_Exception('Invalid method: ' . $method);
   588             throw new Zend_Oauth_Exception('Invalid method: ' . $method);
   578         }
   589         }
   653      */
   664      */
   654     public function getToken()
   665     public function getToken()
   655     {
   666     {
   656         return $this->_token;
   667         return $this->_token;
   657     }
   668     }
       
   669 
       
   670     /**
       
   671      * Set OAuth realm
       
   672      *
       
   673      * @param  string $realm
       
   674      * @return Zend_Oauth_Config
       
   675      */
       
   676     public function setRealm($realm)
       
   677     {
       
   678         $this->_realm = $realm;
       
   679         return $this;
       
   680     }
       
   681 
       
   682     /**
       
   683      * Get OAuth realm
       
   684      *
       
   685      * @return string
       
   686      */
       
   687     public function getRealm()
       
   688     {
       
   689         return $this->_realm;
       
   690     }
   658 }
   691 }