<?php
namespace Claromentis\OAuth2\Repository;

$GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"] ?: array()) + array("_9bc1e8c6088" . "8a0c746682a5" . "10e002b63" => base64_decode("aW50OmV4cGlyZV90aW" . "1l"), "_bbdd0ef9c7e" . "6ae51b02222a" . "58037206f" => base64_decode("c3RyOmNsaWVudF9yZWRpcmVjdF91cm" . "k="), "_ee9641936c78d02ceb0b51fbe5eda" . "d1a" => base64_decode("c3RyO" . "mF1dG" . "hfY29" . "kZQ=="), "_7ac5707040e22dfd0" . "d207576493c48fe" => base64_decode("U0VMRUNUIGF1dGhfY29kZSBGUk9NIG9hdXRoX2F1dGhfY29kZXMgV0hFUkUgZXhwaXJlX3" . "RpbWUgPCBpbnQ6dGltZXN0YW1w"), "_e5e7fcd8cfd5a3314b61eb4" . "115d31b30" => base64_decode("REVMRVRFIEZST00gb2F1dGhfYXV0a" . "F9jb2RlcyBXSEVSRSBhdXRoX2NvZG" . "UgZXE6c3RyOmF1dGhfY29kZQ=="), "_4740575658dcbfe8a4fd4cf8d4c30" . "2c6" => base64_decode("U0VMRUNUIDEgRlJPTSBvYXV0" . "aF9hdXRoX2NvZGVzIFdIRVJF" . "IGF1dGhfY29kZSBlcTpzdHI6" . "YXV0aF9jb2Rl"), "_8e059b73a665dda4deae17328426606" . "b" => base64_decode("YXV" . "0aF" . "9jb" . "2Rl"), "_6fd46564" . "567a93b5b" . "51dc954ac" . "166e4c" => base64_decode("b2F1dGhfYX" . "V0aF9jb2Rl" . "cw=="));
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["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_ee9641936c78d02ce" . "b0b51fbe5edad1a"] => $_8b2541273059c5aa9b0192abce1296ab->getIdentifier(), $GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_bbdd0ef9c7e" . "6ae51b02222a" . "58037206f"] => $_8b2541273059c5aa9b0192abce1296ab->getRedirectUri(), $GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_9bc1e8c60888a0c746682a51" . "0e002b63"] => $_49ee1e842dca787e7c39f02341effb25->getDate(DATE_FORMAT_UNIXTIME)];
        $this->db->unsafe_query = true;
        $this->db->query(new DAL\QueryInsert($GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_6fd46564567a93" . "b5b51dc954ac166" . "e4c"], $data));
    }
    
    
    
    
    
    
    public function revokeAuthCode($_5f5a1ae5974e540c70aa205543c7e148)
    {
        $this->db->unsafe_query = true;
        $this->db->query($GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_e5e7fcd" . "8cfd5a33" . "14b61eb4" . "115d31b3" . "0"], $_5f5a1ae5974e540c70aa205543c7e148);
    }
    
    
    
    
    public function removeOldAuthCodes()
    {
        $_c8b38c7133c2e8460c1cca42230ac6c2 = new \Date();
        $_97ea09a7faf27c52c6eff69773df1d8a = $_c8b38c7133c2e8460c1cca42230ac6c2->getDate(DATE_FORMAT_UNIXTIME);
        $_189840d11056515e52402d1412a0b6e4 = $this->db->query($GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_7ac5707040e22dfd0d2075764" . "93c48fe"], $_97ea09a7faf27c52c6eff69773df1d8a);
        while ($_343a395319323dd7609bcbc465b4d034 = $_189840d11056515e52402d1412a0b6e4->fetchArray()) {
            $this->revokeAuthCode($_343a395319323dd7609bcbc465b4d034[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_8e059b73a665dda4d" . "eae17328426606b"]]);
        }
    }
    
    
    
    
    
    
    
    
    public function isAuthCodeRevoked($_5f5a1ae5974e540c70aa205543c7e148)
    {
        $this->removeOldAuthCodes();
        $_189840d11056515e52402d1412a0b6e4 = $this->db->query($GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_47405756" . "58dcbfe8a" . "4fd4cf8d4" . "c302c6"], $_5f5a1ae5974e540c70aa205543c7e148);
        return $_189840d11056515e52402d1412a0b6e4->numRows() === 0;
    }
}