<?php
namespace Claromentis\OAuth2\Repository;

$GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"] = (@$GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"] ?: array()) + array("_7ac5707040" . "e22dfd0d207" . "576493c48fe" => base64_decode("U0VMRUNUIGF1dGhfY29kZSBGUk9NIG9hdXRoX2F1dGhfY29kZX" . "MgV0hFUkUgZXhwaXJlX3RpbWUgPCBpbnQ6dGltZXN0YW1w"), "_6fd46564567a93b5b51" . "dc954ac166e4c" => base64_decode("b2F1dGhfYXV0aF9jb2Rl" . "cw=="), "_e5e7fcd8c" . "fd5a3314b6" . "1eb4115d31" . "b30" => base64_decode("REVMRVRFIEZST00gb2F1dGhfYXV0aF9jb2RlcyBXSEVSRSBhdXRoX2NvZGUgZXE6c3RyOmF1dGhf" . "Y29kZQ=="), "_ee9641936c78d02ceb0b5" . "1fbe5edad1a" => base64_decode("c3RyOmF1" . "dGhfY29k" . "ZQ=="), "_8e059b73a6" . "65dda4deae1" . "7328426606b" => base64_decode("YXV0aF9" . "jb2Rl"), "_bbdd0ef" . "9c7e6ae5" . "1b02222a" . "58037206" . "f" => base64_decode("c3RyOmNsaWVudF9yZWR" . "pcmVjdF91cmk="), "_9bc1e8c60888a0c746682a510e" . "002b63" => base64_decode("aW50Om" . "V4cGly" . "ZV90aW" . "1l"), "_4740575" . "658dcbfe" . "8a4fd4cf" . "8d4c302c" . "6" => base64_decode("U0VMRUNUIDEgRlJPTSBvYXV0a" . "F9hdXRoX2NvZGVzIFdIRVJFIG" . "F1dGhfY29kZSBlcTpzdHI6YXV" . "0aF9jb2Rl"));
use Claromentis\Core\DAL;
use Claromentis\OAuth2\Entity\AuthCodeEntity;
use League\OAuth2\Server\Entities\AuthCodeEntityInterface;
use League\OAuth2\Server\Exception\UniqueTokenIdentifierConstraintViolationException;
use League\OAuth2\Server\Repositories\AuthCodeRepositoryInterface;
class AuthCodeRepository implements AuthCodeRepositoryInterface
{
    
    
    protected $db;
    public function __construct(DAL\Db $db)
    {
        $this->db = $db;
    }
    
    
    
    
    
    
    public function getNewAuthCode()
    {
        return new AuthCodeEntity();
    }
    
    
    
    
    
    
    
    
    public function persistNewAuthCode(AuthCodeEntityInterface $_8b2541273059c5aa9b0192abce1296ab)
    {
        $_49ee1e842dca787e7c39f02341effb25 = new \Date($_8b2541273059c5aa9b0192abce1296ab->getExpiryDateTime());
        $data = [$GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_ee9641936c78d02" . "ceb0b51fbe5edad1" . "a"] => $_8b2541273059c5aa9b0192abce1296ab->getIdentifier(), $GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_bbdd0ef9c7e6ae51b02" . "222a58037206f"] => $_8b2541273059c5aa9b0192abce1296ab->getRedirectUri(), $GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_9bc1e8c60888" . "a0c746682a510" . "e002b63"] => $_49ee1e842dca787e7c39f02341effb25->getDate(DATE_FORMAT_UNIXTIME)];
        $this->db->unsafe_query = true;
        $this->db->query(new DAL\QueryInsert($GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_6fd46564567a93b5b5" . "1dc954ac166e4c"], $data));
    }
    
    
    
    
    
    
    public function revokeAuthCode($_5f5a1ae5974e540c70aa205543c7e148)
    {
        $this->db->unsafe_query = true;
        $this->db->query($GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_e5e7fcd8" . "cfd5a3314" . "b61eb4115" . "d31b30"], $_5f5a1ae5974e540c70aa205543c7e148);
    }
    
    
    
    
    public function removeOldAuthCodes()
    {
        $_c8b38c7133c2e8460c1cca42230ac6c2 = new \Date();
        $_97ea09a7faf27c52c6eff69773df1d8a = $_c8b38c7133c2e8460c1cca42230ac6c2->getDate(DATE_FORMAT_UNIXTIME);
        $_189840d11056515e52402d1412a0b6e4 = $this->db->query($GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_7ac5707" . "040e22df" . "d0d20757" . "6493c48f" . "e"], $_97ea09a7faf27c52c6eff69773df1d8a);
        while ($_343a395319323dd7609bcbc465b4d034 = $_189840d11056515e52402d1412a0b6e4->fetchArray()) {
            $this->revokeAuthCode($_343a395319323dd7609bcbc465b4d034[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_8e059b7" . "3a665dda" . "4deae173" . "28426606" . "b"]]);
        }
    }
    
    
    
    
    
    
    
    
    public function isAuthCodeRevoked($_5f5a1ae5974e540c70aa205543c7e148)
    {
        $this->removeOldAuthCodes();
        $_189840d11056515e52402d1412a0b6e4 = $this->db->query($GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_4740575658dcb" . "fe8a4fd4cf8d4c" . "302c6"], $_5f5a1ae5974e540c70aa205543c7e148);
        return $_189840d11056515e52402d1412a0b6e4->numRows() === 0;
    }
}