* * 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:----el0uf6hh/LVx5VMbhIH0q1gRrZtNDKYi1rDOFocAUTJeVqJtj+BEzqJiDaLAqZeMpiNg44//kJ0S1Ry5jpwaM1GAkAIRSqfZPdThq4Bk0g1YXfdHS4egC12GDT+rksalil3lh5yjACzyQELQSp0kZIzcpdpLo9+P4QpTCYKHEegsOq9r5iB/YRTDNjYccta52u5C/e6xsJrRK2hBPZ7O+wU9jys7iRcGyZe+fa0IRy3ItKnaewFeENK1PjIgHWTQMTT8q2Fx4h05b0qdllgnMJeXpVqNR72OfFOwiviHNajPIKmihg8/LD51jt4HkhbqZe7Ow+Azf24UpPXCvxAA3rpqbNmMhdOUoLcPUwJ9F8rW6d725GoFGGUvMOn9e56bzXly+pu6bZeIAcwREyhX4sYE29Yp9D0Er8xCHlZB61WcagvN3XezCjd9551imgYAqSlz5VPBiw1a5Rna5A5jUL8tD1Y/d/+K64wOYFCTrONKl1W3Lxi84jTArJURlW3gOJ5UkEaWt7z1ESQh30+ZJXGr/iGQ9Sz+FLf8/thEag23WA1lzVaXqEiad4xHkKzRija8EtCfb4Yvf5qm4X8Eu7A6lvkGn3AwkozdVmovikcBmR3+cNP+/xGoEVPnTtCPXE9jcx1thpwZXW5vVptzrq6MDgjLQiqygV16N3eM3IA=----ATTACHMENT:----MzE2ODY3MTg4NjQ4NzE2MSA5ODU4MTM1MTg0NTY5NzI1IDIyNDc1MDg0MDA4Mjk0MQ==