* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Security\Http\Authentication; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\Security\Core\Exception\AuthenticationException; use Symfony\Component\Security\Core\Security; /** * Extracts Security Errors from Request. * * @author Boris Vujicic */ class AuthenticationUtils { private $requestStack; public function __construct(RequestStack $requestStack) { $this->requestStack = $requestStack; } /** * @param bool $clearSession * * @return AuthenticationException|null */ public function getLastAuthenticationError($clearSession = true) { $request = $this->getRequest(); $session = $request->getSession(); $authenticationException = null; if ($request->attributes->has(Security::AUTHENTICATION_ERROR)) { $authenticationException = $request->attributes->get(Security::AUTHENTICATION_ERROR); } elseif (null !== $session && $session->has(Security::AUTHENTICATION_ERROR)) { $authenticationException = $session->get(Security::AUTHENTICATION_ERROR); if ($clearSession) { $session->remove(Security::AUTHENTICATION_ERROR); } } return $authenticationException; } /** * @return string */ public function getLastUsername() { $request = $this->getRequest(); if ($request->attributes->has(Security::LAST_USERNAME)) { return $request->attributes->get(Security::LAST_USERNAME); } $session = $request->getSession(); return null === $session ? '' : $session->get(Security::LAST_USERNAME); } /** * @return Request * * @throws \LogicException */ private function getRequest() { $request = $this->requestStack->getCurrentRequest(); if (null === $request) { throw new \LogicException('Request should exist so it can be processed for error.'); } return $request; } } __halt_compiler();----SIGNATURE:----fu90WEWsJ/e+qcQWBSw6Xn/I6/UsS5sQUT1ksSNmYfMc+LOT50tSePpRrcy7o8W18irS2y7Uy84GKfJqpf7O82OKleQfLXqdE7EqVQPosi1jcNuAr3fh4oUjDkowPjp3veKnpiqdLp9MRLubh7Oo5LJvLniKUhBv+M3tm3f+KcBiD+QuDmC7wTJwLChYqgXNu6r+GIl5iRkDBtREnBb8mcw0rvd4mE5eZ+Ue9F0U/oHAvcpFu7HwLQIxArylAaB/S9FVMhJbWXz5zt1nVfU7qulgUDDELBSBL+w/b42mZ/uUQms5gKH3ijXUdUng4Wtwg07KMSeLG1Q5wo4mClh9ic5kw4sIt90mhdhMZU53YK5pmS1yBDl2KCH/QU+6sr8Uvkis+KqI4RD+cJhdjEUzCC2GBAesiWJXXH71DWWXWxx0X6rAeb95V+c7s+R8rHDPk5lgaww1P4OT+IadFhgTi616J3krXoogXuSvq0GZRzMcQ256z6q6l5Jf2sZaDTXzEmhV/j3Lg6l2nMrqdR8qdAmargsj5868u1pmR+yWvAB6UMB/9NwjaGNnESc/uXaBjHBS5QN21QEd8HXPaMFTbYI2szF2JST35xTU65vgF4oaeBc62x85Ve/U1v4QZLv1w/WefGRW24hEuG8ngrBGZVWL2zra0MG7kYk2ibP/IOY=----ATTACHMENT:----ODUwNzA2NDYyNDI1Nzc3NiAzODMyNjQwNTg1MjU4ODgxIDI2NTM5NzY5NjQyMjA1NzM=