|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the LdapToolsBundle package. |
|
4
|
|
|
* |
|
5
|
|
|
* (c) Chad Sikorra <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
8
|
|
|
* file that was distributed with this source code. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace LdapTools\Bundle\LdapToolsBundle\Event; |
|
12
|
|
|
|
|
13
|
|
|
use Symfony\Component\EventDispatcher\Event; |
|
14
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
15
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
16
|
|
|
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; |
|
17
|
|
|
use Symfony\Component\Security\Core\Exception\AuthenticationException; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Represents an authentication handler event, such as success or failure, where the response can be set. |
|
21
|
|
|
* |
|
22
|
|
|
* @author Chad Sikorra <[email protected]> |
|
23
|
|
|
*/ |
|
24
|
|
|
class AuthenticationHandlerEvent extends Event |
|
25
|
|
|
{ |
|
26
|
|
|
/** |
|
27
|
|
|
* The event name that happens after the default authentication success handler is called. |
|
28
|
|
|
*/ |
|
29
|
|
|
const SUCCESS = 'ldap_tools_bundle.guard.login.success'; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* The event name that happens after the default authentication failure handler is called. |
|
33
|
|
|
*/ |
|
34
|
|
|
const FAILURE = 'ldap_tools_bundle.guard.login.failure'; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* The event name that happens when the entry point is called for the guard and returns a redirect/response. |
|
38
|
|
|
*/ |
|
39
|
|
|
const START = 'ldap_tools_bundle.guard.login.start'; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @var Response |
|
43
|
|
|
*/ |
|
44
|
|
|
protected $response; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @var AuthenticationException|null |
|
48
|
|
|
*/ |
|
49
|
|
|
protected $exception; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @var Request |
|
53
|
|
|
*/ |
|
54
|
|
|
protected $request; |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @var TokenInterface|null |
|
58
|
|
|
*/ |
|
59
|
|
|
protected $token; |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @var string|null |
|
63
|
|
|
*/ |
|
64
|
|
|
protected $providerKey; |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @param Response $response |
|
68
|
|
|
* @param Request $request |
|
69
|
|
|
* @param null|AuthenticationException $exception |
|
70
|
|
|
* @param TokenInterface|null $token |
|
71
|
|
|
* @param string|null $providerKey |
|
72
|
|
|
*/ |
|
73
|
|
|
public function __construct(Response $response, Request $request, AuthenticationException $exception = null, TokenInterface $token = null, $providerKey = null) |
|
|
|
|
|
|
74
|
|
|
{ |
|
75
|
|
|
$this->request = $request; |
|
76
|
|
|
$this->response = $response; |
|
77
|
|
|
$this->exception = $exception; |
|
78
|
|
|
$this->token = $token; |
|
79
|
|
|
$this->providerKey = $providerKey; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* @return Response |
|
84
|
|
|
*/ |
|
85
|
|
|
public function getResponse() |
|
86
|
|
|
{ |
|
87
|
|
|
return $this->response; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* @return Request |
|
92
|
|
|
*/ |
|
93
|
|
|
public function getRequest() |
|
94
|
|
|
{ |
|
95
|
|
|
return $this->request; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* @param Response $response |
|
100
|
|
|
* @return $this |
|
101
|
|
|
*/ |
|
102
|
|
|
public function setResponse(Response $response) |
|
103
|
|
|
{ |
|
104
|
|
|
$this->response = $response; |
|
105
|
|
|
|
|
106
|
|
|
return $this; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* @return AuthenticationException|null |
|
111
|
|
|
*/ |
|
112
|
|
|
public function getException() |
|
113
|
|
|
{ |
|
114
|
|
|
return $this->exception; |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* @return null|TokenInterface |
|
119
|
|
|
*/ |
|
120
|
|
|
public function getToken() |
|
121
|
|
|
{ |
|
122
|
|
|
return $this->token; |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
/** |
|
126
|
|
|
* @return null|string |
|
127
|
|
|
*/ |
|
128
|
|
|
public function getProviderKey() |
|
129
|
|
|
{ |
|
130
|
|
|
return $this->providerKey; |
|
131
|
|
|
} |
|
132
|
|
|
} |
|
133
|
|
|
|