소스 검색

[HttpKernel\Security]Fixed use statement and updated parameters constructor

Dominique Bongiraud 14 년 전
부모
커밋
6885f90f17

+ 6 - 4
src/Symfony/Component/HttpKernel/Security/Firewall/AccessListener.php

@@ -2,13 +2,15 @@
 
 namespace Symfony\Component\HttpKernel\Security\Firewall;
 
+use Symfony\Component\Security\SecurityContext;
+use Symfony\Component\Security\Authorization\AccessDecisionManagerInterface;
+use Symfony\Component\HttpKernel\Security\AccessMap;
+use Symfony\Component\Security\Authentication\AuthenticationManagerInterface;
 use Symfony\Component\HttpKernel\Log\LoggerInterface;
 use Symfony\Component\EventDispatcher\EventDispatcher;
 use Symfony\Component\EventDispatcher\Event;
 use Symfony\Component\Security\Exception\AuthenticationCredentialsNotFoundException;
 use Symfony\Component\Security\Exception\AccessDeniedException;
-use Symfony\Component\HttpFoundation\RequestMatcherInterface;
-use Symfony\Component\HttpKernel\Security\AccessMap;
 
 /*
  * This file is part of the Symfony framework.
@@ -29,10 +31,10 @@ class AccessListener
     protected $context;
     protected $accessDecisionManager;
     protected $map;
-    protected $logger;
     protected $authManager;
+    protected $logger;
 
-    public function __construct($context, $accessDecisionManager, AccessMap $map, $authManager, LoggerInterface $logger = null)
+    public function __construct(SecurityContext $context, AccessDecisionManagerInterface $accessDecisionManager, AccessMap $map, AuthenticationManagerInterface $authManager, LoggerInterface $logger = null)
     {
         $this->context = $context;
         $this->accessDecisionManager = $accessDecisionManager;

+ 5 - 6
src/Symfony/Component/HttpKernel/Security/Firewall/AnonymousAuthenticationListener.php

@@ -3,10 +3,9 @@
 namespace Symfony\Component\HttpKernel\Security\Firewall;
 
 use Symfony\Component\Security\SecurityContext;
+use Symfony\Component\HttpKernel\Log\LoggerInterface;
 use Symfony\Component\EventDispatcher\EventDispatcher;
 use Symfony\Component\EventDispatcher\Event;
-use Symfony\Component\HttpFoundation\Request;
-use Symfony\Component\HttpKernel\LoggerInterface;
 use Symfony\Component\Security\Authentication\Token\AnonymousToken;
 
 /*
@@ -26,15 +25,15 @@ use Symfony\Component\Security\Authentication\Token\AnonymousToken;
  */
 class AnonymousAuthenticationListener
 {
-    protected $key;
     protected $context;
+    protected $key;
     protected $logger;
 
-    public function __construct(SecurityContext $context, $key, $logger = null)
+    public function __construct(SecurityContext $context, $key, LoggerInterface $logger = null)
     {
         $this->context = $context;
-        $this->key = $key;
-        $this->logger = $logger;
+        $this->key     = $key;
+        $this->logger  = $logger;
     }
 
     /**

+ 7 - 10
src/Symfony/Component/HttpKernel/Security/Firewall/BasicAuthenticationListener.php

@@ -2,17 +2,14 @@
 
 namespace Symfony\Component\HttpKernel\Security\Firewall;
 
-use Symfony\Component\EventDispatcher\EventDispatcher;
-use Symfony\Component\EventDispatcher\Event;
-use Symfony\Component\HttpFoundation\Request;
-use Symfony\Component\HttpKernel\Log\LoggerInterface;
-use Symfony\Component\HttpKernel\HttpKernelInterface;
-use Symfony\Component\Security\Exception\AuthenticationException;
 use Symfony\Component\Security\SecurityContext;
 use Symfony\Component\Security\Authentication\AuthenticationManagerInterface;
-use Symfony\Component\Security\Authentication\Token\UsernamePasswordToken;
 use Symfony\Component\Security\Authentication\EntryPoint\AuthenticationEntryPointInterface;
-use Symfony\Component\Security\Authentication\Token\AnonymousToken;
+use Symfony\Component\HttpKernel\Log\LoggerInterface;
+use Symfony\Component\EventDispatcher\EventDispatcher;
+use Symfony\Component\EventDispatcher\Event;
+use Symfony\Component\Security\Authentication\Token\UsernamePasswordToken;
+use Symfony\Component\Security\Exception\AuthenticationException;
 
 /*
  * This file is part of the Symfony framework.
@@ -31,10 +28,10 @@ use Symfony\Component\Security\Authentication\Token\AnonymousToken;
 class BasicAuthenticationListener
 {
     protected $securityContext;
-    protected $authenticationEntryPoint;
     protected $authenticationManager;
-    protected $ignoreFailure;
+    protected $authenticationEntryPoint;
     protected $logger;
+    protected $ignoreFailure;
 
     public function __construct(SecurityContext $securityContext, AuthenticationManagerInterface $authenticationManager, AuthenticationEntryPointInterface $authenticationEntryPoint, LoggerInterface $logger = null)
     {

+ 5 - 5
src/Symfony/Component/HttpKernel/Security/Firewall/ChannelListener.php

@@ -2,11 +2,11 @@
 
 namespace Symfony\Component\HttpKernel\Security\Firewall;
 
+use Symfony\Component\HttpKernel\Security\AccessMap;
+use Symfony\Component\Security\Authentication\EntryPoint\AuthenticationEntryPointInterface;
+use Symfony\Component\HttpKernel\Log\LoggerInterface;
 use Symfony\Component\EventDispatcher\EventDispatcher;
 use Symfony\Component\EventDispatcher\Event;
-use Symfony\Component\Security\Authentication\EntryPoint\AuthenticationEntryPointInterface;
-use Symfony\Component\HttpKernel\Security\AccessMap;
-use Symfony\Component\HttpFoundation\Request;
 
 /*
  * This file is part of the Symfony framework.
@@ -25,11 +25,11 @@ use Symfony\Component\HttpFoundation\Request;
  */
 class ChannelListener
 {
-    protected $authenticationEntryPoint;
     protected $map;
+    protected $authenticationEntryPoint;
     protected $logger;
 
-    public function __construct(AccessMap $map, AuthenticationEntryPointInterface $authenticationEntryPoint, $logger = null)
+    public function __construct(AccessMap $map, AuthenticationEntryPointInterface $authenticationEntryPoint, LoggerInterface $logger = null)
     {
         $this->map = $map;
         $this->authenticationEntryPoint = $authenticationEntryPoint;

+ 4 - 5
src/Symfony/Component/HttpKernel/Security/Firewall/ContextListener.php

@@ -2,14 +2,13 @@
 
 namespace Symfony\Component\HttpKernel\Security\Firewall;
 
-use Symfony\Component\HttpKernel\LoggerInterface;
-use Symfony\Component\HttpKernel\HttpKernelInterface;
+use Symfony\Component\Security\SecurityContext;
+use Symfony\Component\HttpKernel\Log\LoggerInterface;
 use Symfony\Component\EventDispatcher\EventDispatcher;
 use Symfony\Component\EventDispatcher\Event;
-use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpFoundation\Response;
+use Symfony\Component\HttpKernel\HttpKernelInterface;
 use Symfony\Component\Security\Authentication\Token\AnonymousToken;
-use Symfony\Component\Security\SecurityContext;
 
 /*
  * This file is part of the Symfony framework.
@@ -30,7 +29,7 @@ class ContextListener
     protected $context;
     protected $logger;
 
-    public function __construct(SecurityContext $context, $logger = null)
+    public function __construct(SecurityContext $context, LoggerInterface $logger = null)
     {
         $this->context = $context;
         $this->logger = $logger;

+ 11 - 9
src/Symfony/Component/HttpKernel/Security/Firewall/DigestAuthenticationListener.php

@@ -2,17 +2,19 @@
 
 namespace Symfony\Component\HttpKernel\Security\Firewall;
 
+use Symfony\Component\Security\SecurityContext;
+use Symfony\Component\Security\User\UserProviderInterface;
+use Symfony\Component\HttpKernel\Security\EntryPoint\DigestAuthenticationEntryPoint;
+use Symfony\Component\HttpKernel\Log\LoggerInterface;
 use Symfony\Component\EventDispatcher\EventDispatcher;
 use Symfony\Component\EventDispatcher\Event;
-use Symfony\Component\HttpFoundation\Request;
-use Symfony\Component\HttpKernel\Log\LoggerInterface;
-use Symfony\Component\HttpKernel\Security\EntryPoint\DigestAuthenticationEntryPoint;
-use Symfony\Component\Security\Exception\AuthenticationException;
+use Symfony\Component\Security\Authentication\Token\UsernamePasswordToken;
 use Symfony\Component\Security\Exception\BadCredentialsException;
 use Symfony\Component\Security\Exception\AuthenticationServiceException;
-use Symfony\Component\Security\SecurityContext;
-use Symfony\Component\Security\User\UserProviderInterface;
-use Symfony\Component\Security\Authentication\Token\UsernamePasswordToken;
+use Symfony\Component\Security\Exception\UsernameNotFoundException;
+use Symfony\Component\HttpKernel\Security\EntryPoint\NonceExpiredException;
+use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\Security\Exception\AuthenticationException;
 
 /*
  * This file is part of the Symfony framework.
@@ -31,11 +33,11 @@ use Symfony\Component\Security\Authentication\Token\UsernamePasswordToken;
 class DigestAuthenticationListener
 {
     protected $securityContext;
+    protected $provider;
     protected $authenticationEntryPoint;
     protected $logger;
-    protected $provider;
 
-    public function __construct(SecurityContext $securityContext, UserProviderInterface $provider, DigestAuthenticationEntryPoint $authenticationEntryPoint, $logger = null)
+    public function __construct(SecurityContext $securityContext, UserProviderInterface $provider, DigestAuthenticationEntryPoint $authenticationEntryPoint, LoggerInterface $logger = null)
     {
         $this->securityContext = $securityContext;
         $this->provider = $provider;

+ 8 - 9
src/Symfony/Component/HttpKernel/Security/Firewall/ExceptionListener.php

@@ -2,18 +2,17 @@
 
 namespace Symfony\Component\HttpKernel\Security\Firewall;
 
+use Symfony\Component\Security\SecurityContext;
+use Symfony\Component\Security\Authentication\EntryPoint\AuthenticationEntryPointInterface;
+use Symfony\Component\HttpKernel\Log\LoggerInterface;
 use Symfony\Component\EventDispatcher\EventDispatcher;
 use Symfony\Component\EventDispatcher\Event;
-use Symfony\Component\HttpFoundation\Request;
-use Symfony\Component\HttpFoundation\Response;
-use Symfony\Component\HttpKernel\Log\LoggerInterface;
-use Symfony\Component\HttpKernel\HttpKernelInterface;
-use Symfony\Component\Security\Exception\AccessDeniedException;
 use Symfony\Component\Security\Exception\AuthenticationException;
-use Symfony\Component\Security\Exception\InsufficientAuthenticationException;
-use Symfony\Component\Security\SecurityContext;
+use Symfony\Component\Security\Exception\AccessDeniedException;
 use Symfony\Component\Security\Authentication\Token\AnonymousToken;
-use Symfony\Component\Security\Authentication\EntryPoint\AuthenticationEntryPointInterface;
+use Symfony\Component\Security\Exception\InsufficientAuthenticationException;
+use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpKernel\HttpKernelInterface;
 
 /*
  * This file is part of the Symfony framework.
@@ -33,9 +32,9 @@ use Symfony\Component\Security\Authentication\EntryPoint\AuthenticationEntryPoin
 class ExceptionListener
 {
     protected $context;
-    protected $logger;
     protected $authenticationEntryPoint;
     protected $errorPage;
+    protected $logger;
 
     public function __construct(SecurityContext $context, AuthenticationEntryPointInterface $authenticationEntryPoint = null, $errorPage = null, LoggerInterface $logger = null)
     {

+ 17 - 18
src/Symfony/Component/HttpKernel/Security/Firewall/FormAuthenticationListener.php

@@ -2,15 +2,15 @@
 
 namespace Symfony\Component\HttpKernel\Security\Firewall;
 
+use Symfony\Component\Security\SecurityContext;
+use Symfony\Component\Security\Authentication\AuthenticationManagerInterface;
+use Symfony\Component\HttpKernel\Log\LoggerInterface;
 use Symfony\Component\EventDispatcher\EventDispatcher;
 use Symfony\Component\EventDispatcher\Event;
-use Symfony\Component\HttpKernel\HttpKernelInterface;
-use Symfony\Component\HttpKernel\Log\LoggerInterface;
+use Symfony\Component\Security\Exception\AuthenticationException;
 use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpKernel\HttpKernelInterface;
 use Symfony\Component\HttpFoundation\Response;
-use Symfony\Component\Security\SecurityContext;
-use Symfony\Component\Security\Authentication\AuthenticationManagerInterface;
-use Symfony\Component\Security\Exception\AuthenticationException;
 use Symfony\Component\Security\Authentication\Token\TokenInterface;
 
 /*
@@ -46,8 +46,6 @@ abstract class FormAuthenticationListener
     {
         $this->securityContext = $securityContext;
         $this->authenticationManager = $authenticationManager;
-        $this->logger = $logger;
-
         $this->options = array_merge(array(
             'check_path'                     => '/login_check',
             'login_path'                     => '/login',
@@ -58,6 +56,7 @@ abstract class FormAuthenticationListener
             'failure_path'                   => null,
             'failure_forward'                => false,
         ), $options);
+        $this->logger = $logger;
     }
 
     /**
@@ -99,17 +98,6 @@ abstract class FormAuthenticationListener
         return true;
     }
 
-    /**
-     * Performs authentication.
-     *
-     * @param  Request $request A Request instance
-     *
-     * @return TokenInterface The authenticated token, or null if full authentication is not possible
-     *
-     * @throws AuthenticationException if the authentication fails
-     */
-    abstract protected function attemptAuthentication(Request $request);
-
     protected function onFailure(Request $request, \Exception $failed)
     {
         if (null !== $this->logger) {
@@ -191,4 +179,15 @@ abstract class FormAuthenticationListener
 
         return $this->options['default_target_path'];
     }
+
+    /**
+     * Performs authentication.
+     *
+     * @param  Request $request A Request instance
+     *
+     * @return TokenInterface The authenticated token, or null if full authentication is not possible
+     *
+     * @throws AuthenticationException if the authentication fails
+     */
+    abstract protected function attemptAuthentication(Request $request);
 }

+ 1 - 1
src/Symfony/Component/HttpKernel/Security/Firewall/LogoutListener.php

@@ -2,10 +2,10 @@
 
 namespace Symfony\Component\HttpKernel\Security\Firewall;
 
+use Symfony\Component\Security\SecurityContext;
 use Symfony\Component\EventDispatcher\EventDispatcher;
 use Symfony\Component\EventDispatcher\Event;
 use Symfony\Component\HttpFoundation\Response;
-use Symfony\Component\Security\SecurityContext;
 
 /*
  * This file is part of the Symfony framework.

+ 4 - 4
src/Symfony/Component/HttpKernel/Security/Firewall/PreAuthenticatedListener.php

@@ -4,12 +4,12 @@ namespace Symfony\Component\HttpKernel\Security\Firewall;
 
 use Symfony\Component\Security\SecurityContext;
 use Symfony\Component\Security\Authentication\AuthenticationManagerInterface;
-use Symfony\Component\Security\Exception\AuthenticationException;
-use Symfony\Component\Security\Authentication\Token\PreAuthenticatedToken;
-use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpKernel\Log\LoggerInterface;
 use Symfony\Component\EventDispatcher\EventDispatcher;
 use Symfony\Component\EventDispatcher\Event;
+use Symfony\Component\Security\Authentication\Token\PreAuthenticatedToken;
+use Symfony\Component\Security\Exception\AuthenticationException;
+use Symfony\Component\HttpFoundation\Request;
 
 /*
  * This file is part of the Symfony framework.
@@ -33,7 +33,7 @@ abstract class PreAuthenticatedListener
     protected $authenticationManager;
     protected $logger;
 
-    public function __construct(SecurityContext $securityContext, AuthenticationManagerInterface $authenticationManager, $logger = null)
+    public function __construct(SecurityContext $securityContext, AuthenticationManagerInterface $authenticationManager, LoggerInterface $logger = null)
     {
         $this->securityContext = $securityContext;
         $this->authenticationManager = $authenticationManager;

+ 10 - 7
src/Symfony/Component/HttpKernel/Security/Firewall/SwitchUserListener.php

@@ -2,14 +2,17 @@
 
 namespace Symfony\Component\HttpKernel\Security\Firewall;
 
+use Symfony\Component\Security\SecurityContext;
+use Symfony\Component\Security\User\UserProviderInterface;
+use Symfony\Component\Security\User\AccountCheckerInterface;
+use Symfony\Component\Security\Authorization\AccessDecisionManagerInterface;
+use Symfony\Component\HttpKernel\Log\LoggerInterface;
 use Symfony\Component\EventDispatcher\EventDispatcher;
 use Symfony\Component\EventDispatcher\Event;
-use Symfony\Component\Security\SecurityContext;
-use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\Security\Exception\AuthenticationException;
 use Symfony\Component\HttpFoundation\Response;
+use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\Security\Role\SwitchUserRole;
-use Symfony\Component\Security\User\UserProviderInterface;
-use Symfony\Component\Security\User\AccountCheckerInterface;
 use Symfony\Component\Security\Authentication\Token\UsernamePasswordToken;
 use Symfony\Component\Security\Exception\AuthenticationCredentialsNotFoundException;
 use Symfony\Component\Security\Authentication\Token\TokenInterface;
@@ -31,18 +34,18 @@ use Symfony\Component\Security\Authentication\Token\TokenInterface;
  */
 class SwitchUserListener
 {
-    protected $usernameParameter;
     protected $securityContext;
     protected $provider;
     protected $accountChecker;
     protected $accessDecisionManager;
-    protected $logger;
+    protected $usernameParameter;
     protected $role;
+    protected $logger;
 
     /**
      * Constructor.
      */
-    public function __construct(SecurityContext $securityContext, UserProviderInterface $provider, AccountCheckerInterface $accountChecker, $accessDecisionManager, $logger = null, $usernameParameter = '_switch_user', $role = 'ROLE_ALLOWED_TO_SWITCH')
+    public function __construct(SecurityContext $securityContext, UserProviderInterface $provider, AccountCheckerInterface $accountChecker, AccessDecisionManagerInterface $accessDecisionManager, LoggerInterface $logger = null, $usernameParameter = '_switch_user', $role = 'ROLE_ALLOWED_TO_SWITCH')
     {
         $this->securityContext = $securityContext;
         $this->provider = $provider;

+ 2 - 3
src/Symfony/Component/HttpKernel/Security/Firewall/UsernamePasswordFormAuthenticationListener.php

@@ -2,11 +2,10 @@
 
 namespace Symfony\Component\HttpKernel\Security\Firewall;
 
-use Symfony\Component\HttpKernel\Log\LoggerInterface;
-use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\Security\SecurityContext;
 use Symfony\Component\Security\Authentication\AuthenticationManagerInterface;
-use Symfony\Component\Security\Exception\AuthenticationServiceException;
+use Symfony\Component\HttpKernel\Log\LoggerInterface;
+use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\Security\Authentication\Token\UsernamePasswordToken;
 
 /*

+ 3 - 2
src/Symfony/Component/HttpKernel/Security/Firewall/X509AuthenticationListener.php

@@ -4,8 +4,9 @@ namespace Symfony\Component\HttpKernel\Security\Firewall;
 
 use Symfony\Component\Security\SecurityContext;
 use Symfony\Component\Security\Authentication\AuthenticationManagerInterface;
-use Symfony\Component\Security\Exception\BadCredentialsException;
+use Symfony\Component\HttpKernel\Log\LoggerInterface;
 use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\Security\Exception\BadCredentialsException;
 
 /*
  * This file is part of the Symfony framework.
@@ -26,7 +27,7 @@ class X509AuthenticationListener extends PreAuthenticatedListener
     protected $userKey;
     protected $credentialKey;
 
-    public function __construct(SecurityContext $securityContext, AuthenticationManagerInterface $authenticationManager, $userKey = 'SSL_CLIENT_S_DN_Email', $credentialKey = 'SSL_CLIENT_S_DN', $logger = null)
+    public function __construct(SecurityContext $securityContext, AuthenticationManagerInterface $authenticationManager, $userKey = 'SSL_CLIENT_S_DN_Email', $credentialKey = 'SSL_CLIENT_S_DN', LoggerInterface $logger = null)
     {
         parent::__construct($securityContext, $authenticationManager, $logger);
 

+ 1 - 1
src/Symfony/Component/HttpKernel/Security/FirewallMap.php

@@ -25,7 +25,7 @@ class FirewallMap
 {
     protected $map = array();
 
-    public function add(RequestMatcherInterface $requestMatcher = null, array $listeners, ExceptionListener $listener = null)
+    public function add(RequestMatcherInterface $requestMatcher = null, array $listeners = array(), ExceptionListener $listener = null)
     {
         $this->map[] = array($requestMatcher, $listeners, $listener);
     }