<?php
namespace Claromentis\Core\Security\Authentication;

$GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"] = (@$GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"] ?: array()) + array("_e92ad742fc" . "12ec1dd5c30" . "557fafca331" => base64_decode("Ig=" . "="), "_01f117db67aa749d3ec8da7eb478" . "730c" => base64_decode("LC" . "A="), "_658d27d8ec5b8004d6924bb93aae5f0" . "5" => base64_decode("SFRUUCBCYXNpYzogbm8gYXV0aGVu" . "dGljYXRpb24gaW5mb3JtYXRpb24="), "_4d707fab93bebb00bbe69e8159697" . "c90" => base64_decode(""), "_fdd4c4053422aa845b0fb5767ec680e" . "a" => base64_decode("SFRUUCBBdXRoZW50aWNhdGlvbjogKA=" . "="), "_4201abdd2a20b7" . "5e8516bbd67a910" . "e53" => base64_decode("UEhQX0FVVEhfU" . "Fc="), "_fcc49f3559d280c84d996" . "535b8ee1d94" => base64_decode("V1dXLUF1dGhlbnRpY2F0Z" . "Q=="), "_3c203632a406849" . "cd10b4d854641747" . "8" => base64_decode("QmFzaWMgcm" . "VhbG09Ig=="), "_0284d38f97f9e8b9c7b03bb8928afae" . "1" => base64_decode("KQ" . "=="), "_a5424137aa81510d931225" . "26c2964925" => base64_decode("UEhQX0" . "FVVEhf" . "VVNFUg" . "=="), "_7050b4c" . "97738656" . "47992224" . "4ab112ef" . "7" => base64_decode("SFRUUCBCYXNpYzogaW5pdGlhdGVkIGF1dGhlbnR" . "pY2F0aW9u"));
use Claromentis\Core\Security\AuthenticatorInterface;
use Claromentis\Core\Security\Authorization\UsernamePasswordChecker;
use Claromentis\Core\Security\Exception\AuthenticationException;
use Claromentis\Core\Security\SessionSecurityContext;
use DateClaTimeZone;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\RequestEvent;




class HttpBasicAuthenticator implements AuthenticatorInterface
{
    const LOGOUT_USERNAME = 'logout';
    protected $logger;
    protected $realm = 'Claromentis';
    protected $password_checker;
    public function __construct(UsernamePasswordChecker $_899425cf8f6a732f838a55aa5f03ec1f, LoggerInterface $logger = null)
    {
        $this->logger = $logger;
        $this->password_checker = $_899425cf8f6a732f838a55aa5f03ec1f;
    }
    
    
    
    
    
    
    
    public function Handle(RequestEvent $event, SessionSecurityContext $context)
    {
        $request = $event->getRequest();
        if (($_28c85ce81fee6532980262893b6f2425 = $request->headers->get($GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_a5424137aa81510" . "d93122526c296492" . "5"], $GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_4d707fab93bebb0" . "0bbe69e8159697c9" . "0"])) === $GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_4d707fab93bebb00b" . "be69e8159697c90"] || ($_e0637eee905ebe3938c5da50e3db10d7 = $request->headers->get($GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_4201abdd2a20b75e8516bbd67a910" . "e53"], $GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_4d707fab93be" . "bb00bbe69e815" . "9697c90"])) === $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_4d707fab93bebb00bb" . "e69e8159697c90"]) {
            if (null !== $this->logger) {
                $this->logger->debug($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_658d27d8ec5b8004d6924bb93aae5f0" . "5"]);
            }
            return;
        }
        if (null !== $this->logger) {
            $this->logger->debug($GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_fdd4c4053422aa845b0fb5767e" . "c680ea"] . $_28c85ce81fee6532980262893b6f2425 . $GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_01f117db67aa749d3ec8da7eb478" . "730c"] . $_e0637eee905ebe3938c5da50e3db10d7 . $GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_0284d38f97f9e8b9c7b03bb89" . "28afae1"]);
        }
        if ($_28c85ce81fee6532980262893b6f2425 == self::LOGOUT_USERNAME) {
            return;
        }
        $user_id = $this->password_checker->Check($_28c85ce81fee6532980262893b6f2425, $_e0637eee905ebe3938c5da50e3db10d7);
        
        
        $context->SetUserId($user_id);
        DateClaTimeZone::InitUserTZ($context);
    }
    public function StartHttpAuth()
    {
        $_fd5a3a643834299cbdadfc3540ba0bcb = new Response();
        $_fd5a3a643834299cbdadfc3540ba0bcb->headers->set($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_fcc49f3559d280c84d99653" . "5b8ee1d94"], $GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_3c203632a406849cd10b4d85464" . "17478"] . $this->realm . $GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_e92ad742fc12ec1dd5c30557fafca" . "331"]);
        $_fd5a3a643834299cbdadfc3540ba0bcb->setStatusCode(401);
        if (null !== $this->logger) {
            $this->logger->debug($GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_7050b4c97738656479922244ab" . "112ef7"]);
        }
        
        
        return $_fd5a3a643834299cbdadfc3540ba0bcb;
    }
    public function SetRealm($_209feb15212c9c696cb91611744bf98c)
    {
        $this->realm = $_209feb15212c9c696cb91611744bf98c;
    }
}