|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* AppserverIo\Authenticator\AbstractAuthenticator |
|
5
|
|
|
* |
|
6
|
|
|
* NOTICE OF LICENSE |
|
7
|
|
|
* |
|
8
|
|
|
* This source file is subject to the Open Software License (OSL 3.0) |
|
9
|
|
|
* that is available through the world-wide-web at this URL: |
|
10
|
|
|
* http://opensource.org/licenses/osl-3.0.php |
|
11
|
|
|
* |
|
12
|
|
|
* PHP version 5 |
|
13
|
|
|
* |
|
14
|
|
|
* @author Tim Wagner <[email protected]> |
|
15
|
|
|
* @copyright 2016 TechDivision GmbH <[email protected]> |
|
16
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
17
|
|
|
* @link https://github.com/appserver-io/authenticator |
|
18
|
|
|
* @link http://www.appserver.io |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace AppserverIo\Authenticator; |
|
22
|
|
|
|
|
23
|
|
|
use Rhumsaa\Uuid\Uuid; |
|
24
|
|
|
use AppserverIo\Lang\Boolean; |
|
25
|
|
|
use AppserverIo\Psr\Auth\AuthenticatorInterface; |
|
26
|
|
|
use AppserverIo\Psr\Auth\LoginConfigurationInterface; |
|
27
|
|
|
use AppserverIo\Psr\Auth\AuthenticationManagerInterface; |
|
28
|
|
|
use AppserverIo\Appserver\Core\Api\Node\AuthenticatorNodeInterface; |
|
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Abstract authenticator base class providing generic functionality. |
|
32
|
|
|
* |
|
33
|
|
|
* @author Tim Wagner <[email protected]> |
|
34
|
|
|
* @copyright 2016 TechDivision GmbH <[email protected]> |
|
35
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
36
|
|
|
* @link https://github.com/appserver-io/authenticator |
|
37
|
|
|
* @link http://www.appserver.io |
|
38
|
|
|
*/ |
|
39
|
|
|
abstract class AbstractAuthenticator implements AuthenticatorInterface |
|
40
|
|
|
{ |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Mark's the authenticator as the default one. |
|
44
|
|
|
* |
|
45
|
|
|
* @var \AppserverIo\Lang\Boolean |
|
46
|
|
|
*/ |
|
47
|
|
|
protected $defaultAuthenticator; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* The authentication manager instance. |
|
51
|
|
|
* |
|
52
|
|
|
* @var \AppserverIo\Psr\Auth\AuthenticationManagerInterface |
|
53
|
|
|
*/ |
|
54
|
|
|
protected $authenticationManager; |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Holds the configuration data given for authentication type. |
|
58
|
|
|
* |
|
59
|
|
|
* @var \AppserverIo\Psr\Auth\LoginConfigurationInterface |
|
60
|
|
|
*/ |
|
61
|
|
|
protected $configData; |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* The authenticator configuration. |
|
65
|
|
|
* |
|
66
|
|
|
* @var \AppserverIo\Appserver\Core\Api\Node\AuthenticatorNodeInterface |
|
67
|
|
|
*/ |
|
68
|
|
|
protected $authenticatorConfiguration; |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* The name of the user to authenticate. |
|
72
|
|
|
* |
|
73
|
|
|
* @var string |
|
74
|
|
|
*/ |
|
75
|
|
|
protected $username; |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* Constructs the authentication type. |
|
79
|
|
|
* |
|
80
|
|
|
* @param \AppserverIo\Psr\Auth\LoginConfigurationInterface $configData The configuration data for auth type instance |
|
81
|
|
|
* @param \AppserverIo\Psr\Auth\AuthenticationManagerInterface $authenticationManager The authentication manager instance |
|
82
|
|
|
* @param \AppserverIo\Appserver\Core\Api\Node\AuthenticatorNodeInterface $authenticatorConfiguration The authenticator configuration instance |
|
83
|
1 |
|
*/ |
|
84
|
|
|
public function __construct( |
|
85
|
|
|
LoginConfigurationInterface $configData, |
|
86
|
|
|
AuthenticationManagerInterface $authenticationManager, |
|
87
|
|
|
AuthenticatorNodeInterface $authenticatorConfiguration |
|
88
|
|
|
) { |
|
89
|
|
|
|
|
90
|
1 |
|
// initialize the authenticator with the passed values |
|
91
|
|
|
$this->configData = $configData; |
|
92
|
|
|
$this->authenticationManager = $authenticationManager; |
|
93
|
1 |
|
$this->authenticatorConfiguration = $authenticatorConfiguration; |
|
94
|
1 |
|
|
|
95
|
|
|
// query whether or not the default flag has been passed |
|
96
|
|
|
if ($configData->getDefaultAuthenticator()) { |
|
|
|
|
|
|
97
|
1 |
|
$this->defaultAuthenticator = new Boolean($configData->getDefaultAuthenticator()->__toString()); |
|
98
|
1 |
|
} else { |
|
99
|
1 |
|
$this->defaultAuthenticator = new Boolean(false); |
|
100
|
|
|
} |
|
101
|
|
|
} |
|
102
|
1 |
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* Return's the authenticator's UUID. |
|
105
|
|
|
* |
|
106
|
|
|
* @return string The UUID |
|
107
|
|
|
* @deprecated since 1.1.29 |
|
108
|
|
|
*/ |
|
109
|
|
|
public function getSerial() |
|
110
|
|
|
{ |
|
111
|
|
|
return $this->getRealmName(); |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* Returns the configuration data given for authentication type. |
|
116
|
|
|
* |
|
117
|
|
|
* @return \AppserverIo\Psr\Auth\LoginConfigurationInterface The configuration data |
|
118
|
|
|
*/ |
|
119
|
1 |
|
public function getConfigData() |
|
120
|
|
|
{ |
|
121
|
1 |
|
return $this->configData; |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* The authenticator configuration instance. |
|
126
|
|
|
* |
|
127
|
|
|
* @return \AppserverIo\Appserver\Core\Api\Node\AuthenticatorNodeInterface The authenticator configuration instance |
|
128
|
|
|
*/ |
|
129
|
1 |
|
public function getAuthenticatorConfiguration() |
|
130
|
|
|
{ |
|
131
|
1 |
|
return $this->authenticatorConfiguration; |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
/** |
|
135
|
|
|
* Return's the authentication manager instance. |
|
136
|
|
|
* |
|
137
|
|
|
* @return \AppserverIo\Psr\Auth\AuthenticationManagerInterface The authentication manager instance |
|
138
|
|
|
*/ |
|
139
|
|
|
public function getAuthenticationManager() |
|
140
|
|
|
{ |
|
141
|
|
|
return $this->authenticationManager; |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
/** |
|
145
|
|
|
* Returns the authentication type token. |
|
146
|
|
|
* |
|
147
|
|
|
* @return string |
|
148
|
|
|
*/ |
|
149
|
1 |
|
public function getAuthType() |
|
150
|
|
|
{ |
|
151
|
1 |
|
return static::AUTH_TYPE; |
|
|
|
|
|
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
/** |
|
155
|
|
|
* Return's the realm name. |
|
156
|
|
|
* |
|
157
|
|
|
* @return string The realm name |
|
158
|
|
|
*/ |
|
159
|
|
|
public function getRealmName() |
|
160
|
|
|
{ |
|
161
|
|
|
return $this->getConfigData()->getRealmName(); |
|
162
|
|
|
} |
|
163
|
|
|
|
|
164
|
|
|
/** |
|
165
|
|
|
* Returns the parsed username. |
|
166
|
|
|
* |
|
167
|
|
|
* @return string|null The username |
|
168
|
|
|
*/ |
|
169
|
|
|
public function getUsername() |
|
170
|
|
|
{ |
|
171
|
|
|
return isset($this->username) ? $this->username : null; |
|
172
|
|
|
} |
|
173
|
|
|
|
|
174
|
|
|
/** |
|
175
|
|
|
* Mark's the authenticator as the default one. |
|
176
|
|
|
* |
|
177
|
|
|
* @return void |
|
178
|
|
|
*/ |
|
179
|
|
|
public function setDefaultAuthenticator() |
|
180
|
|
|
{ |
|
181
|
|
|
$this->defaultAuthenticator = new Boolean(true); |
|
182
|
|
|
} |
|
183
|
|
|
|
|
184
|
|
|
/** |
|
185
|
|
|
* Query whether or not this is the default authenticator. |
|
186
|
|
|
* |
|
187
|
|
|
* @return boolean TRUE if this is the default authenticator, else FALSE |
|
188
|
|
|
*/ |
|
189
|
|
|
public function isDefaultAuthenticator() |
|
190
|
|
|
{ |
|
191
|
|
|
return $this->defaultAuthenticator->booleanValue(); |
|
|
|
|
|
|
192
|
|
|
} |
|
193
|
|
|
} |
|
194
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths