* * 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:----mlBp3Ps5mtkYPZSraKOj0XQOAQryOEkGkkrhTSdZ8YvGFtUDO+dehzNfavGtu8IyTumJpVSnNew4Tg6o9hk52KWtpA0z0SxJ/4l1zr1ultetZHqWc5Dp0Gf1PtwYqIBJprQMxKzrQwWI0GaLrMcYLalfW2LEmODbHleDKHyIR77WzgG9GZ8xkWCnf45p0Ja5ozLeTKgJDVhS7qM4P+0zhhcKJoVufloMEqR0WUiczQAMbHhnL+ZVAI+1Odeh9Ep5/73+xvQyq1PCDgiA4DZfWA7udciw+ozd7vYVfWfa7Y1pkje9hfaZIcyrhpfrrctx5GY2M6EdvusJSUCMX1ArEoWbgj8V8IrmqzMMI/dE4cgB4W7OQzXLjq3vZtpxYcjinjTi+kdOrvy6DLPB25X7zVVZcCIcAIQOV52MYq34GVsaUe9RoMdlukZz1CMqGhdADGWRiGC+m00Bd3tHijS7bz35q6YnHzBI6WWRU9+uXpy6CvUVMHnHBgPcVdYRnHxOWddlfLSWQGqXShQw7ILNuNMuekFcAuLVnnJHmJB3p10SOAz1cUQDfs7G8gXdE51/gfwgwoIlpfoSi8H2FAY5EbrMDmZhJbgJOiJHxTlSozixOXdPgNujgDzCUgGa0m1LkOaEew8UgM2dd56qMxtTdWm+bVnGsaeIggpMI/AZQA0=----ATTACHMENT:----NzkxNzQ2NzI0NDEzODk1MyAyMTk4NzcyMDA1OTMwNzUwIDU0ODk4MjgxMjMwMTk3NA==