45 \
Magento\Framework\Oauth\Helper\Oauth $oauthHelper,
47 \
Magento\Framework\Stdlib\DateTime\DateTime $date,
48 $nonceLength = \
Magento\Framework\Oauth\Helper\Oauth::LENGTH_NONCE
50 $this->_oauthHelper = $oauthHelper;
51 $this->_nonceFactory = $nonceFactory;
53 $this->_nonceLength = $nonceLength;
61 return $this->_oauthHelper->generateRandomString($this->_nonceLength);
69 return $this->_date->timestamp();
78 $timestamp = (int)$timestamp;
80 throw new \Magento\Framework\Oauth\OauthInputException(
81 __(
'Incorrect timestamp value in the oauth_timestamp parameter')
86 $nonceObj = $this->_nonceFactory->create()->loadByCompositeKey($nonce, $consumer->
getId());
88 if ($nonceObj->getNonce()) {
89 throw new \Magento\Framework\Oauth\Exception(
91 'The nonce is already being used by the consumer with ID %1',
97 $nonceObj->setNonce($nonce)->setConsumerId($consumer->
getId())->setTimestamp($timestamp)->save();
98 }
catch (\
Magento\Framework\Oauth\Exception $exception) {
100 }
catch (\Exception $exception) {
101 throw new \Magento\Framework\Oauth\Exception(
__(
'An error occurred validating the nonce'));
validateNonce(ConsumerInterface $consumer, $nonce, $timestamp)
generateNonce(ConsumerInterface $consumer=null)
__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)