|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace SimpleSAML\SAML2\XML\saml; |
|
6
|
|
|
|
|
7
|
|
|
use DOMElement; |
|
8
|
|
|
use SimpleSAML\SAML2\Assert\Assert; |
|
9
|
|
|
use SimpleSAML\SAML2\XML\saml\AuthnContextClassRef; |
|
|
|
|
|
|
10
|
|
|
use SimpleSAML\SAML2\XML\saml\AuthnContextDecl; |
|
|
|
|
|
|
11
|
|
|
use SimpleSAML\SAML2\XML\saml\AuthnContextDeclRef; |
|
|
|
|
|
|
12
|
|
|
use SimpleSAML\XML\Constants as C; |
|
|
|
|
|
|
13
|
|
|
use SimpleSAML\XML\SchemaValidatableElementInterface; |
|
14
|
|
|
use SimpleSAML\XML\SchemaValidatableElementTrait; |
|
15
|
|
|
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException; |
|
16
|
|
|
use SimpleSAML\XMLSchema\Exception\TooManyElementsException; |
|
17
|
|
|
|
|
18
|
|
|
use function array_pop; |
|
19
|
|
|
use function is_null; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Class representing SAML2 AuthnContext |
|
23
|
|
|
* |
|
24
|
|
|
* @package simplesamlphp/saml2 |
|
25
|
|
|
*/ |
|
26
|
|
|
final class AuthnContext extends AbstractSamlElement implements SchemaValidatableElementInterface |
|
|
|
|
|
|
27
|
|
|
{ |
|
28
|
|
|
use SchemaValidatableElementTrait; |
|
29
|
|
|
|
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Initialize an AuthnContext. |
|
33
|
|
|
* |
|
34
|
|
|
* @param \SimpleSAML\SAML2\XML\saml\AuthnContextClassRef|null $authnContextClassRef |
|
35
|
|
|
* @param \SimpleSAML\SAML2\XML\saml\AuthnContextDecl|null $authnContextDecl |
|
36
|
|
|
* @param \SimpleSAML\SAML2\XML\saml\AuthnContextDeclRef|null $authnContextDeclRef |
|
37
|
|
|
* @param \SimpleSAML\SAML2\XML\saml\AuthenticatingAuthority[] $authenticatingAuthorities |
|
38
|
|
|
* @throws \SimpleSAML\Assert\AssertionFailedException |
|
39
|
|
|
*/ |
|
40
|
|
|
public function __construct( |
|
41
|
|
|
protected ?AuthnContextClassRef $authnContextClassRef, |
|
42
|
|
|
protected ?AuthnContextDecl $authnContextDecl, |
|
43
|
|
|
protected ?AuthnContextDeclRef $authnContextDeclRef, |
|
44
|
|
|
protected array $authenticatingAuthorities = [], |
|
45
|
|
|
) { |
|
46
|
|
|
if (is_null($authnContextClassRef)) { |
|
47
|
|
|
Assert::false( |
|
48
|
|
|
is_null($authnContextDecl) && is_null($authnContextDeclRef), |
|
49
|
|
|
'You need either an AuthnContextDecl or an AuthnContextDeclRef', |
|
50
|
|
|
); |
|
51
|
|
|
} |
|
52
|
|
|
Assert::oneOf( |
|
53
|
|
|
null, |
|
54
|
|
|
[$authnContextDecl, $authnContextDeclRef], |
|
55
|
|
|
'Can only have one of AuthnContextDecl/AuthnContextDeclRef', |
|
56
|
|
|
); |
|
57
|
|
|
|
|
58
|
|
|
Assert::maxCount($authenticatingAuthorities, C::UNBOUNDED_LIMIT); |
|
59
|
|
|
Assert::allIsInstanceOf($authenticatingAuthorities, AuthenticatingAuthority::class); |
|
|
|
|
|
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Collect the value of the authnContextClassRef-property |
|
65
|
|
|
* |
|
66
|
|
|
* @return \SimpleSAML\SAML2\XML\saml\AuthnContextClassRef|null |
|
67
|
|
|
*/ |
|
68
|
|
|
public function getAuthnContextClassRef(): ?AuthnContextClassRef |
|
69
|
|
|
{ |
|
70
|
|
|
return $this->authnContextClassRef; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* Collect the value of the authnContextDeclRef-property |
|
76
|
|
|
* |
|
77
|
|
|
* @return \SimpleSAML\SAML2\XML\saml\AuthnContextDeclRef|null |
|
78
|
|
|
*/ |
|
79
|
|
|
public function getAuthnContextDeclRef(): ?AuthnContextDeclRef |
|
80
|
|
|
{ |
|
81
|
|
|
return $this->authnContextDeclRef; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* Collect the value of the authnContextDecl-property |
|
87
|
|
|
* |
|
88
|
|
|
* @return \SimpleSAML\SAML2\XML\saml\AuthnContextDecl|null |
|
89
|
|
|
*/ |
|
90
|
|
|
public function getAuthnContextDecl(): ?AuthnContextDecl |
|
91
|
|
|
{ |
|
92
|
|
|
return $this->authnContextDecl; |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* Collect the value of the authenticatingAuthorities-property |
|
98
|
|
|
* |
|
99
|
|
|
* @return \SimpleSAML\SAML2\XML\saml\AuthenticatingAuthority[] |
|
100
|
|
|
*/ |
|
101
|
|
|
public function getAuthenticatingAuthorities(): array |
|
102
|
|
|
{ |
|
103
|
|
|
return $this->authenticatingAuthorities; |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* Convert XML into a AuthnContext |
|
109
|
|
|
* |
|
110
|
|
|
* @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException |
|
111
|
|
|
* if the qualified name of the supplied element is wrong |
|
112
|
|
|
*/ |
|
113
|
|
|
public static function fromXML(DOMElement $xml): static |
|
114
|
|
|
{ |
|
115
|
|
|
Assert::same($xml->localName, 'AuthnContext', InvalidDOMElementException::class); |
|
116
|
|
|
Assert::same($xml->namespaceURI, AuthnContext::NS, InvalidDOMElementException::class); |
|
117
|
|
|
|
|
118
|
|
|
$authnContextClassRef = AuthnContextClassRef::getChildrenOfClass($xml); |
|
119
|
|
|
Assert::maxCount( |
|
120
|
|
|
$authnContextClassRef, |
|
121
|
|
|
1, |
|
122
|
|
|
"More than one <saml:AuthnContextClassRef> found", |
|
123
|
|
|
TooManyElementsException::class, |
|
124
|
|
|
); |
|
125
|
|
|
|
|
126
|
|
|
$authnContextDeclRef = AuthnContextDeclRef::getChildrenOfClass($xml); |
|
127
|
|
|
Assert::maxCount( |
|
128
|
|
|
$authnContextDeclRef, |
|
129
|
|
|
1, |
|
130
|
|
|
"More than one <saml:AuthnContextDeclRef> found", |
|
131
|
|
|
TooManyElementsException::class, |
|
132
|
|
|
); |
|
133
|
|
|
|
|
134
|
|
|
$authnContextDecl = AuthnContextDecl::getChildrenOfClass($xml); |
|
135
|
|
|
Assert::maxCount( |
|
136
|
|
|
$authnContextDecl, |
|
137
|
|
|
1, |
|
138
|
|
|
"More than one <saml:AuthnContextDecl> found", |
|
139
|
|
|
TooManyElementsException::class, |
|
140
|
|
|
); |
|
141
|
|
|
|
|
142
|
|
|
$authorities = AuthenticatingAuthority::getChildrenOfClass($xml); |
|
143
|
|
|
|
|
144
|
|
|
return new static( |
|
145
|
|
|
array_pop($authnContextClassRef), |
|
146
|
|
|
array_pop($authnContextDecl), |
|
147
|
|
|
array_pop($authnContextDeclRef), |
|
148
|
|
|
$authorities, |
|
149
|
|
|
); |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
|
|
153
|
|
|
/** |
|
154
|
|
|
* Convert this AuthContextDeclRef to XML. |
|
155
|
|
|
*/ |
|
156
|
|
|
public function toXML(?DOMElement $parent = null): DOMElement |
|
157
|
|
|
{ |
|
158
|
|
|
$e = $this->instantiateParentElement($parent); |
|
159
|
|
|
|
|
160
|
|
|
$this->getAuthnContextClassRef()?->toXML($e); |
|
161
|
|
|
$this->getAuthnContextDecl()?->toXML($e); |
|
162
|
|
|
$this->getAuthnContextDeclRef()?->toXML($e); |
|
163
|
|
|
|
|
164
|
|
|
foreach ($this->getAuthenticatingAuthorities() as $authority) { |
|
165
|
|
|
$authority->toXML($e); |
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
|
return $e; |
|
169
|
|
|
} |
|
170
|
|
|
} |
|
171
|
|
|
|
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