Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
Zend_Oauth_Token Class Reference
Inheritance diagram for Zend_Oauth_Token:
Zend_Oauth_Token_Access Zend_Oauth_Token_AuthorizedRequest Zend_Oauth_Token_Request

Public Member Functions

 __construct (Zend_Http_Response $response=null, Zend_Oauth_Http_Utility $utility=null)
 
 isValid ()
 
 getResponse ()
 
 setTokenSecret ($secret)
 
 getTokenSecret ()
 
 setParam ($key, $value)
 
 setParams (array $params)
 
 getParam ($key)
 
 setToken ($token)
 
 getToken ()
 
 __get ($key)
 
 __set ($key, $value)
 
 toString ()
 
 __toString ()
 
 __sleep ()
 
 __wakeup ()
 

Data Fields

const TOKEN_PARAM_KEY = 'oauth_token'
 
const TOKEN_SECRET_PARAM_KEY = 'oauth_token_secret'
 
const TOKEN_PARAM_CALLBACK_CONFIRMED = 'oauth_callback_confirmed'
 

Protected Member Functions

 _parseParameters (Zend_Http_Response $response)
 

Protected Attributes

 $_params = array()
 
 $_response = null
 
 $_httpUtility = null
 

Detailed Description

Definition at line 31 of file Token.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( Zend_Http_Response  $response = null,
Zend_Oauth_Http_Utility  $utility = null 
)

Constructor; basic setup for any Token subclass.

Parameters
null | Zend_Http_Response$response
null | Zend_Oauth_Http_Utility$utility
Returns
void

Definition at line 67 of file Token.php.

70  {
71  if ($response !== null) {
72  $this->_response = $response;
73  $params = $this->_parseParameters($response);
74  if (count($params) > 0) {
75  $this->setParams($params);
76  }
77  }
78  if ($utility !== null) {
79  $this->_httpUtility = $utility;
80  } else {
81  $this->_httpUtility = new Zend_Oauth_Http_Utility;
82  }
83  }
$response
Definition: 404.php:11
setParams(array $params)
Definition: Token.php:157
_parseParameters(Zend_Http_Response $response)
Definition: Token.php:251
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18

Member Function Documentation

◆ __get()

__get (   $key)

Generic accessor to enable access as public properties.

Returns
string

Definition at line 206 of file Token.php.

207  {
208  return $this->getParam($key);
209  }
getParam($key)
Definition: Token.php:171

◆ __set()

__set (   $key,
  $value 
)

Generic mutator to enable access as public properties.

Parameters
string$key
string$value
Returns
void

Definition at line 218 of file Token.php.

219  {
220  $this->setParam($key, $value);
221  }
setParam($key, $value)
Definition: Token.php:144
$value
Definition: gender.phtml:16

◆ __sleep()

__sleep ( )

Limit serialisation stored data to the parameters

Definition at line 271 of file Token.php.

272  {
273  return array('_params');
274  }

◆ __toString()

__toString ( )

Convert Token to a string, specifically a raw encoded query string. Aliases to self::toString()

Returns
string

Definition at line 239 of file Token.php.

240  {
241  return $this->toString();
242  }

◆ __wakeup()

__wakeup ( )

After serialisation, re-instantiate a HTTP utility class for use

Definition at line 279 of file Token.php.

280  {
281  if ($this->_httpUtility === null) {
282  $this->_httpUtility = new Zend_Oauth_Http_Utility;
283  }
284  }

◆ _parseParameters()

_parseParameters ( Zend_Http_Response  $response)
protected

Parse a HTTP response body and collect returned parameters as raw url decoded key-value pairs in an associative array.

Parameters
Zend_Http_Response$response
Returns
array

Definition at line 251 of file Token.php.

252  {
253  $params = array();
254  $body = $response->getBody();
255  if (empty($body)) {
256  return;
257  }
258 
259  // validate body based on acceptable characters...todo
260  $parts = explode('&', $body);
261  foreach ($parts as $kvpair) {
262  $pair = explode('=', $kvpair);
263  $params[rawurldecode($pair[0])] = rawurldecode($pair[1]);
264  }
265  return $params;
266  }
$response
Definition: 404.php:11
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18

◆ getParam()

getParam (   $key)

Get the value for a parameter (e.g. token secret or other).

Parameters
string$key
Returns
mixed

Definition at line 171 of file Token.php.

172  {
173  if (isset($this->_params[$key])) {
174  return $this->_params[$key];
175  }
176  return null;
177  }

◆ getResponse()

getResponse ( )

Return the HTTP response object used to initialise this instance.

Returns
Zend_Http_Response

Definition at line 107 of file Token.php.

108  {
109  return $this->_response;
110  }

◆ getToken()

getToken ( )

Gets the value for a Token.

Returns
string

Definition at line 196 of file Token.php.

197  {
198  return $this->getParam(self::TOKEN_PARAM_KEY);
199  }
getParam($key)
Definition: Token.php:171

◆ getTokenSecret()

getTokenSecret ( )

Retrieve this Token's secret which may be used when signing requests with this Token.

Returns
string

Definition at line 131 of file Token.php.

132  {
133  return $this->getParam(self::TOKEN_SECRET_PARAM_KEY);
134  }
getParam($key)
Definition: Token.php:171

◆ isValid()

isValid ( )

Attempts to validate the Token parsed from the HTTP response - really it's just very basic existence checks which are minimal.

Returns
bool

Definition at line 91 of file Token.php.

92  {
93  if (isset($this->_params[self::TOKEN_PARAM_KEY])
94  && !empty($this->_params[self::TOKEN_PARAM_KEY])
95  && isset($this->_params[self::TOKEN_SECRET_PARAM_KEY])
96  ) {
97  return true;
98  }
99  return false;
100  }

◆ setParam()

setParam (   $key,
  $value 
)

Sets the value for a parameter (e.g. token secret or other) and run a simple filter to remove any trailing newlines.

Parameters
string$key
string$value
Returns
Zend_Oauth_Token

Definition at line 144 of file Token.php.

145  {
146  $this->_params[$key] = trim($value, "\n");
147  return $this;
148  }
$value
Definition: gender.phtml:16

◆ setParams()

setParams ( array  $params)

Sets the value for some parameters (e.g. token secret or other) and run a simple filter to remove any trailing newlines.

Parameters
array$params
Returns
Zend_Oauth_Token

Definition at line 157 of file Token.php.

158  {
159  foreach ($params as $key=>$value) {
160  $this->setParam($key, $value);
161  }
162  return $this;
163  }
setParam($key, $value)
Definition: Token.php:144
$value
Definition: gender.phtml:16
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18

◆ setToken()

setToken (   $token)

Sets the value for a Token.

Parameters
string$token
Returns
Zend_Oauth_Token

Definition at line 185 of file Token.php.

186  {
187  $this->setParam(self::TOKEN_PARAM_KEY, $token);
188  return $this;
189  }
setParam($key, $value)
Definition: Token.php:144

◆ setTokenSecret()

setTokenSecret (   $secret)

Sets the value for the this Token's secret which may be used when signing requests with this Token.

Parameters
string$secret
Returns
Zend_Oauth_Token

Definition at line 119 of file Token.php.

120  {
121  $this->setParam(self::TOKEN_SECRET_PARAM_KEY, $secret);
122  return $this;
123  }
setParam($key, $value)
Definition: Token.php:144

◆ toString()

toString ( )

Convert Token to a string, specifically a raw encoded query string.

Returns
string

Definition at line 228 of file Token.php.

229  {
230  return $this->_httpUtility->toEncodedQueryString($this->_params);
231  }

Field Documentation

◆ $_httpUtility

$_httpUtility = null
protected

Definition at line 58 of file Token.php.

◆ $_params

$_params = array()
protected

Definition at line 46 of file Token.php.

◆ $_response

$_response = null
protected

Definition at line 53 of file Token.php.

◆ TOKEN_PARAM_CALLBACK_CONFIRMED

const TOKEN_PARAM_CALLBACK_CONFIRMED = 'oauth_callback_confirmed'

Definition at line 38 of file Token.php.

◆ TOKEN_PARAM_KEY

const TOKEN_PARAM_KEY = 'oauth_token'

+ Token constants

Definition at line 36 of file Token.php.

◆ TOKEN_SECRET_PARAM_KEY

const TOKEN_SECRET_PARAM_KEY = 'oauth_token_secret'

Definition at line 37 of file Token.php.


The documentation for this class was generated from the following file: