* * 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:----VSBndZaEclafSuiPwVbXIuu0kfuBOuPiJKF++BH7hOb8+2oa3v+az7SV/weSAgnYpfaHy/rVwJdLAvfqyA5c8eNxg3JjaGdT5ckoeRL7Q2kh1I+gERDbXjE3O9BxxbUXWz3pVrRH79yNEdIavaDvIBZQQMGdGjXMiulHB6oeVtZklVvmYp19IYycey1ty2xJuYZ72MhQ98IRZtdFgS+brHje+rFxfk7eLb6GqD31gVNDH8aPZfhb9gpQo5bumBodgwfLY14B6nMishIn1tTiGj11PkphRszyL8N33/FFEre8xvCtUWAnIAntXHnEsmnc7C1/L1fNRysAT9gUmrVFsFXo3WE0sAvAkI7s5RX8b4iHoeQl24bvMUGrOQY1iX+78xfBtzMt/A4nELMvRpH21fZnU9+SGNd0LqyFf4/A6QzkPEwn6l4j+fnCbifICtqYyLTR9fFIK7lFl1hgaWlQFLBThcvL9OGaxdDSd/thgIMKRnwgJN0OM8R/GF+TaKV88Zz2HTgFRgdzSFtXPn8vptXGpA7u2VmxfddYL2K2zUgN97MzPyT1q9n/GwIX1YyzPspgPR2gKFysuGu642V/FH0RGfUIQ6rhXlzqTKAAbWjK50rVHOrRjT9PoRWJt9gM2tOK8xOFmFYgooXc6Tki4j6sBQPdEfxkrMvZX8Z2f9k=----ATTACHMENT:----MTM0MDQ4MTQ5NzEwODg3NSAxNDQzMzEyNDM4OTU0MjgyIDE5MjgyNjI5NzA2NzUwNjA=