1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Happyr\ApiBundle\Security\Firewall; |
4
|
|
|
|
5
|
|
|
use Happyr\ApiBundle\Service\ResponseFactory; |
6
|
|
|
use Symfony\Component\HttpKernel\Event\GetResponseEvent; |
7
|
|
|
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface; |
8
|
|
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; |
9
|
|
|
use Symfony\Component\Security\Http\Firewall\ListenerInterface; |
10
|
|
|
use Happyr\ApiBundle\Security\Authentication\Token\WsseUserToken; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @author Tobias Nyholm <[email protected]> |
14
|
|
|
*/ |
15
|
|
|
class DebugListener implements ListenerInterface |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* @var TokenStorageInterface |
19
|
|
|
*/ |
20
|
|
|
protected $tokenStorage; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var AuthenticationManagerInterface |
24
|
|
|
*/ |
25
|
|
|
protected $authenticationManager; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* WsseListener constructor. |
29
|
|
|
* |
30
|
|
|
* @param TokenStorageInterface $tokenStorage |
31
|
|
|
* @param AuthenticationManagerInterface $authenticationManager |
32
|
|
|
*/ |
33
|
|
|
public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager) |
34
|
|
|
{ |
35
|
|
|
$this->tokenStorage = $tokenStorage; |
36
|
|
|
$this->authenticationManager = $authenticationManager; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @param GetResponseEvent $event |
41
|
|
|
*/ |
42
|
|
|
public function handle(GetResponseEvent $event) |
43
|
|
|
{ |
44
|
|
|
$token = new WsseUserToken(); |
45
|
|
|
$token->setUser('api_user'); |
46
|
|
|
|
47
|
|
|
$authToken = $this->authenticationManager->authenticate($token); |
48
|
|
|
$this->tokenStorage->setToken($authToken); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @param ResponseFactory $responseFactory |
53
|
|
|
**/ |
54
|
|
|
public function setResponseFactory(ResponseFactory $responseFactory) |
|
|
|
|
55
|
|
|
{ |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.