66 \
Magento\Framework\Data\Collection\AbstractDb $resourceCollection =
null,
69 $this->keyLengthValidator = $keyLength;
93 private function getDateHelper()
95 if ($this->_dateHelper ===
null) {
97 ->get(\
Magento\Framework\Stdlib\DateTime\DateTime::class);
99 return $this->_dateHelper;
110 parent::beforeSave();
121 $this->setRejectedCallbackUrl(trim($this->getRejectedCallbackUrl()));
123 if ($this->
getCallbackUrl() && !$this->urlValidator->isValid($this->getCallbackUrl())) {
124 throw new \Magento\Framework\Exception\LocalizedException(
__(
'Invalid Callback URL'));
126 if ($this->getRejectedCallbackUrl() && !$this->urlValidator->isValid($this->getRejectedCallbackUrl())) {
127 throw new \Magento\Framework\Exception\LocalizedException(
__(
'Invalid Rejected Callback URL'));
131 $this->keyLengthValidator
132 ->setLength(\
Magento\Framework\Oauth\Helper\Oauth::LENGTH_CONSUMER_KEY)
133 ->setName(
'Consumer Key');
134 if (!$this->keyLengthValidator->isValid($this->getKey())) {
135 $messages = $this->keyLengthValidator->getMessages();
136 throw new \Magento\Framework\Exception\LocalizedException(
__(array_shift($messages)));
139 $this->keyLengthValidator
140 ->setLength(\
Magento\Framework\Oauth\Helper\Oauth::LENGTH_CONSUMER_SECRET)
141 ->setName(
'Consumer Secret');
142 if (!$this->keyLengthValidator->isValid($this->getSecret())) {
143 $messages = $this->keyLengthValidator->getMessages();
144 throw new \Magento\Framework\Exception\LocalizedException(
__(array_shift($messages)));
157 return $this->
load($key,
'key');
173 return $this->
getData(
'secret');
181 return $this->
getData(
'callback_url');
189 return $this->
getData(
'created_at');
197 $expiry = $this->dataHelper->getConsumerExpirationPeriod();
198 $currentTimestamp = $this->getDateHelper()->gmtTimestamp();
199 $updatedTimestamp = $this->getDateHelper()->gmtTimestamp($this->getUpdatedAt());
200 return $expiry > ($currentTimestamp - $updatedTimestamp);
getData($key='', $index=null)
load($modelId, $field=null)
__construct(\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Integration\Model\Oauth\Consumer\Validator\KeyLength $keyLength, \Magento\Framework\Url\Validator $urlValidator, \Magento\Integration\Helper\Oauth\Data $dataHelper, \Magento\Framework\Model\ResourceModel\AbstractResource $resource=null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[])
isValidForTokenExchange()