* * 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\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Security\Http\Util\TargetPathTrait; use Symfony\Component\Security\Http\HttpUtils; use Symfony\Component\Security\Http\ParameterBagUtils; /** * Class with the default authentication success handling logic. * * @author Fabien Potencier * @author Johannes M. Schmitt * @author Alexander */ class DefaultAuthenticationSuccessHandler implements AuthenticationSuccessHandlerInterface { use TargetPathTrait; protected $httpUtils; protected $options; protected $providerKey; protected $defaultOptions = array( 'always_use_default_target_path' => false, 'default_target_path' => '/', 'login_path' => '/login', 'target_path_parameter' => '_target_path', 'use_referer' => false, ); /** * @param HttpUtils $httpUtils * @param array $options Options for processing a successful authentication attempt */ public function __construct(HttpUtils $httpUtils, array $options = array()) { $this->httpUtils = $httpUtils; $this->setOptions($options); } /** * {@inheritdoc} */ public function onAuthenticationSuccess(Request $request, TokenInterface $token) { return $this->httpUtils->createRedirectResponse($request, $this->determineTargetUrl($request)); } /** * Gets the options. * * @return array An array of options */ public function getOptions() { return $this->options; } public function setOptions(array $options) { $this->options = array_merge($this->defaultOptions, $options); } /** * Get the provider key. * * @return string */ public function getProviderKey() { return $this->providerKey; } /** * Set the provider key. * * @param string $providerKey */ public function setProviderKey($providerKey) { $this->providerKey = $providerKey; } /** * Builds the target URL according to the defined options. * * @return string */ protected function determineTargetUrl(Request $request) { if ($this->options['always_use_default_target_path']) { return $this->options['default_target_path']; } if ($targetUrl = ParameterBagUtils::getRequestParameterValue($request, $this->options['target_path_parameter'])) { return $targetUrl; } if (null !== $this->providerKey && $targetUrl = $this->getTargetPath($request->getSession(), $this->providerKey)) { $this->removeTargetPath($request->getSession(), $this->providerKey); return $targetUrl; } if ($this->options['use_referer'] && $targetUrl = $request->headers->get('Referer')) { if (false !== $pos = strpos($targetUrl, '?')) { $targetUrl = substr($targetUrl, 0, $pos); } if ($targetUrl && $targetUrl !== $this->httpUtils->generateUri($request, $this->options['login_path'])) { return $targetUrl; } } return $this->options['default_target_path']; } } __halt_compiler();----SIGNATURE:----EVrnagoDoljpTibsb2eBmvjjCp4QZb5KpK0o3T3SACU+Yu7WqaBYgkd390QcTZ7JiXc4PbBt24n0ctG1mqJL0zEXH+n/hBmeKcTruBwMrs9mwOOQVfsGIhYX7IyZ0NOV3Uf7d5BLU37/gnj0aLzTj8zaWy1sEO0KkD10vNfFgZlfKFY6yqXw2xvQyonMCGxtghCrL7RWmj4iqUuFnIh801R56hhcFukVw20LhtcR3pTGopzBnQTm04py7Ycz0KJSXUBfLZ0fJY2jD1a5JsQy9xnvFuNYoboaIhLA0U+zd6h9LwgYEZndsJ6BdCoX/l6cbEVIFmAmoZ4Bv5J/NCLyaCtkasjprlo1O/qGN583G4DKP7VWYLJFN9conjGFki8KEasYFKvKQt2BTSg40RFvyT3GkxrqRxOu/WhqXVT17KmlpubhLQ4gNAWVcXdUJftSXbLiJBAtMUZWci8nfF0JQZeQ9H9tchsgTrEfrBJMLhFgNdgCmFoot5tTOW1s2CxSG2XeBb2UDzv2dXiAVuOCsHJP9NQjINRlOv8tbAn4Q/qY9nyE/s3ee+BI0xXE0m7RcUrfd12xBXYWy7TDkRuhHFTPwJBWsroqt1Fubl6iuN9WpYt+t8sd1G13zzmdpRDISR7NjVMgc/ssjszgseG92RJigRz+l3uTJfsXIKsvqXI=----ATTACHMENT:----Njg1ODgxNDIxMzAxMDQ2NCA2MjQ1MjQ0NjA4NjA4MTE2IDE4MDg3NDA3OTU3NTgyNjE=