Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions | Protected Attributes
Zend_Oauth_Signature_SignatureAbstract Class Reference
Inheritance diagram for Zend_Oauth_Signature_SignatureAbstract:
Zend_Oauth_Signature_Hmac Zend_Oauth_Signature_Plaintext Zend_Oauth_Signature_Rsa

Public Member Functions

 __construct ($consumerSecret, $tokenSecret=null, $hashAlgo=null)
 
 sign (array $params, $method=null, $url=null)
 
 normaliseBaseSignatureUrl ($url)
 

Protected Member Functions

 _assembleKey ()
 
 _getBaseSignatureString (array $params, $method=null, $url=null)
 
 _toByteValueOrderedQueryString (array $params)
 

Protected Attributes

 $_hashAlgorithm = null
 
 $_key = null
 
 $_consumerSecret = null
 
 $_tokenSecret = ''
 

Detailed Description

Definition at line 34 of file SignatureAbstract.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $consumerSecret,
  $tokenSecret = null,
  $hashAlgo = null 
)

Constructor

Parameters
string$consumerSecret
null | string$tokenSecret
null | string$hashAlgo
Returns
void

Definition at line 68 of file SignatureAbstract.php.

69  {
70  $this->_consumerSecret = $consumerSecret;
71  if (isset($tokenSecret)) {
72  $this->_tokenSecret = $tokenSecret;
73  }
74  $this->_key = $this->_assembleKey();
75  if (isset($hashAlgo)) {
76  $this->_hashAlgorithm = $hashAlgo;
77  }
78  }

Member Function Documentation

◆ _assembleKey()

_assembleKey ( )
protected

Assemble key from consumer and token secrets

Returns
string

Definition at line 115 of file SignatureAbstract.php.

116  {
117  $parts = array($this->_consumerSecret);
118  if ($this->_tokenSecret !== null) {
119  $parts[] = $this->_tokenSecret;
120  }
121  foreach ($parts as $key => $secret) {
122  $parts[$key] = Zend_Oauth_Http_Utility::urlEncode($secret);
123  }
124  return implode('&', $parts);
125  }
static urlEncode($value)
Definition: Utility.php:211

◆ _getBaseSignatureString()

_getBaseSignatureString ( array  $params,
  $method = null,
  $url = null 
)
protected

Get base signature string

Parameters
array$params
null | string$method
null | string$url
Returns
string

Definition at line 135 of file SignatureAbstract.php.

136  {
137  $encodedParams = array();
138  foreach ($params as $key => $value) {
139  $encodedParams[Zend_Oauth_Http_Utility::urlEncode($key)] =
141  }
142  $baseStrings = array();
143  if (isset($method)) {
144  $baseStrings[] = strtoupper($method);
145  }
146  if (isset($url)) {
147  // should normalise later
148  $baseStrings[] = Zend_Oauth_Http_Utility::urlEncode(
150  );
151  }
152  if (isset($encodedParams['oauth_signature'])) {
153  unset($encodedParams['oauth_signature']);
154  }
155  $baseStrings[] = Zend_Oauth_Http_Utility::urlEncode(
156  $this->_toByteValueOrderedQueryString($encodedParams)
157  );
158  return implode('&', $baseStrings);
159  }
static urlEncode($value)
Definition: Utility.php:211
$value
Definition: gender.phtml:16
$method
Definition: info.phtml:13
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18

◆ _toByteValueOrderedQueryString()

_toByteValueOrderedQueryString ( array  $params)
protected

Transform an array to a byte value ordered query string

Parameters
array$params
Returns
string

Definition at line 167 of file SignatureAbstract.php.

168  {
169  $return = array();
170  uksort($params, 'strnatcmp');
171  foreach ($params as $key => $value) {
172  if (is_array($value)) {
173  natsort($value);
174  foreach ($value as $keyduplicate) {
175  $return[] = $key . '=' . $keyduplicate;
176  }
177  } else {
178  $return[] = $key . '=' . $value;
179  }
180  }
181  return implode('&', $return);
182  }
$value
Definition: gender.phtml:16
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18

◆ normaliseBaseSignatureUrl()

normaliseBaseSignatureUrl (   $url)

Normalize the base signature URL

Parameters
string$url
Returns
string

Definition at line 96 of file SignatureAbstract.php.

97  {
98  $uri = Zend_Uri_Http::fromString($url);
99  if ($uri->getScheme() == 'http' && $uri->getPort() == '80') {
100  $uri->setPort('');
101  } elseif ($uri->getScheme() == 'https' && $uri->getPort() == '443') {
102  $uri->setPort('');
103  }
104  $uri->setQuery('');
105  $uri->setFragment('');
106  $uri->setHost(strtolower($uri->getHost()));
107  return $uri->getUri(true);
108  }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17

◆ sign()

sign ( array  $params,
  $method = null,
  $url = null 
)
abstract

Sign a request

Parameters
array$params
null | string$method
null | string$url
Returns
string

Field Documentation

◆ $_consumerSecret

$_consumerSecret = null
protected

Definition at line 52 of file SignatureAbstract.php.

◆ $_hashAlgorithm

$_hashAlgorithm = null
protected

Definition at line 40 of file SignatureAbstract.php.

◆ $_key

$_key = null
protected

Definition at line 46 of file SignatureAbstract.php.

◆ $_tokenSecret

$_tokenSecret = ''
protected

Definition at line 58 of file SignatureAbstract.php.


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