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

Public Member Functions

 __construct (\Magento\Framework\Oauth\Helper\Oauth $oauthHelper, \Magento\Integration\Model\Oauth\NonceFactory $nonceFactory, \Magento\Framework\Stdlib\DateTime\DateTime $date, $nonceLength=\Magento\Framework\Oauth\Helper\Oauth::LENGTH_NONCE)
 
 generateNonce (ConsumerInterface $consumer=null)
 
 generateTimestamp ()
 
- Public Member Functions inherited from NonceGeneratorInterface
 validateNonce (ConsumerInterface $consumer, $nonce, $timestamp)
 

Data Fields

const TIME_DEVIATION = 600
 

Protected Attributes

 $_oauthHelper
 
 $_nonceFactory
 
 $_nonceLength
 
 $_date
 

Detailed Description

Definition at line 11 of file Generator.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Framework\Oauth\Helper\Oauth  $oauthHelper,
\Magento\Integration\Model\Oauth\NonceFactory  $nonceFactory,
\Magento\Framework\Stdlib\DateTime\DateTime  $date,
  $nonceLength = \Magento\Framework\Oauth\Helper\Oauth::LENGTH_NONCE 
)
Parameters
\Magento\Framework\Oauth\Helper\Oauth$oauthHelper
\Magento\Integration\Model\Oauth\NonceFactory$nonceFactory
\Magento\Framework\Stdlib\DateTime\DateTime$date
int$nonceLength- Length of the generated nonce

Definition at line 44 of file Generator.php.

49  {
50  $this->_oauthHelper = $oauthHelper;
51  $this->_nonceFactory = $nonceFactory;
52  $this->_date = $date;
53  $this->_nonceLength = $nonceLength;
54  }

Member Function Documentation

◆ generateNonce()

generateNonce ( ConsumerInterface  $consumer = null)

{Generate a new nonce for the consumer (if consumer is specified).

Parameters
ConsumerInterface$consumer
Returns
string The generated nonce value.
}

Implements NonceGeneratorInterface.

Definition at line 59 of file Generator.php.

60  {
61  return $this->_oauthHelper->generateRandomString($this->_nonceLength);
62  }

◆ generateTimestamp()

generateTimestamp ( )

{Generate a current timestamp.

Returns
int The time as an int
}

Implements NonceGeneratorInterface.

Definition at line 67 of file Generator.php.

68  {
69  return $this->_date->timestamp();
70  }

Field Documentation

◆ $_date

$_date
protected

Definition at line 31 of file Generator.php.

◆ $_nonceFactory

$_nonceFactory
protected

Definition at line 21 of file Generator.php.

◆ $_nonceLength

$_nonceLength
protected

Definition at line 26 of file Generator.php.

◆ $_oauthHelper

$_oauthHelper
protected

Definition at line 16 of file Generator.php.

◆ TIME_DEVIATION

const TIME_DEVIATION = 600

Possible time deviation for timestamp validation in seconds.

Definition at line 36 of file Generator.php.


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