* * 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\Response; use Psr\Log\LoggerInterface; use Symfony\Component\Security\Core\Exception\AuthenticationException; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface; /** * Class to proxy authentication success/failure handlers. * * Events are sent to the SimpleAuthenticatorInterface if it implements * the right interface, otherwise (or if it fails to return a Response) * the default handlers are triggered. * * @author Jordi Boggiano */ class SimpleAuthenticationHandler implements AuthenticationFailureHandlerInterface, AuthenticationSuccessHandlerInterface { protected $successHandler; protected $failureHandler; protected $simpleAuthenticator; protected $logger; /** * @param SimpleAuthenticatorInterface $authenticator SimpleAuthenticatorInterface instance * @param AuthenticationSuccessHandlerInterface $successHandler Default success handler * @param AuthenticationFailureHandlerInterface $failureHandler Default failure handler * @param LoggerInterface $logger Optional logger */ public function __construct(SimpleAuthenticatorInterface $authenticator, AuthenticationSuccessHandlerInterface $successHandler, AuthenticationFailureHandlerInterface $failureHandler, LoggerInterface $logger = null) { $this->simpleAuthenticator = $authenticator; $this->successHandler = $successHandler; $this->failureHandler = $failureHandler; $this->logger = $logger; } /** * {@inheritdoc} */ public function onAuthenticationSuccess(Request $request, TokenInterface $token) { if ($this->simpleAuthenticator instanceof AuthenticationSuccessHandlerInterface) { if ($this->logger) { $this->logger->debug('Selected an authentication success handler.', array('handler' => get_class($this->simpleAuthenticator))); } $response = $this->simpleAuthenticator->onAuthenticationSuccess($request, $token); if ($response instanceof Response) { return $response; } if (null !== $response) { throw new \UnexpectedValueException(sprintf('The %s::onAuthenticationSuccess method must return null to use the default success handler, or a Response object', get_class($this->simpleAuthenticator))); } } if ($this->logger) { $this->logger->debug('Fallback to the default authentication success handler.'); } return $this->successHandler->onAuthenticationSuccess($request, $token); } /** * {@inheritdoc} */ public function onAuthenticationFailure(Request $request, AuthenticationException $exception) { if ($this->simpleAuthenticator instanceof AuthenticationFailureHandlerInterface) { if ($this->logger) { $this->logger->debug('Selected an authentication failure handler.', array('handler' => get_class($this->simpleAuthenticator))); } $response = $this->simpleAuthenticator->onAuthenticationFailure($request, $exception); if ($response instanceof Response) { return $response; } if (null !== $response) { throw new \UnexpectedValueException(sprintf('The %s::onAuthenticationFailure method must return null to use the default failure handler, or a Response object', get_class($this->simpleAuthenticator))); } } if ($this->logger) { $this->logger->debug('Fallback to the default authentication failure handler.'); } return $this->failureHandler->onAuthenticationFailure($request, $exception); } } __halt_compiler();----SIGNATURE:----bhKiSHOPtV+Aobb2WmtjXa8XJubLjwbCg7g8tljilNzz/BhzdHyAhetnFv1buK2XutM4fQKfvp62aJg5SFcJ0NFD6NRtFCGpcb1ihzrJ94k0zQsqyJVuuTFPJr3iNH2mNlMtX6V2C7v0WmY3xeP0+N3XDOPjOp8AZwh/vGAlTugHqAv8ryFjUOie3UPYd9Pdkh2txFiNMZknUvS9h6dNGGpTgU2DCOuD0v9ueZ35OslAWm6VmQ2/dKL5mKNpL+0zTkiSD0bbfuARKDzj6bLABzS8jmpfqQmmj4KruLoFr5ExHPwuNYudnB7v8/OxZiwuwL4iJ39riGQ7xPeNqfIvDqkhrEJRDGxRwgx5pvPK1DSboH0S/+xjyA29/tmERdsNSmNbVN0/VoUrIANGS54evjGGm4miMX4yQyRjE3L8k8sJ3681YRPZFbSl76CAOzrtyYs9yRqz6yk2sSDpXJUG+5aSIKVPndD02+2lH0ea0vKFLZh+83VB6R3nyE3ss5A5qhR4v1iC9JzCqGID8RQQ5OYL9dqeRlCJ139uhV28LmpO1lOItmKvn57vuasFoAdUwYqhrYraGjGclJc2Kc4WZ0RTtFSmOH7OyuCiJ5FpnK8fJHBWFpr8aLTBp9JQHOd1rEfYCnLm63Hnou97Lf5tiOK0NGPdgaddp5Wk0KBRIMg=----ATTACHMENT:----NjA2NjIzMzgyMjM4MzMxNiA2MTE2NDU4MjY2NTE2NzYyIDUyMDg1OTg0NDUzNTg1MDU=