1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\SAML2\XML\samlp; |
6
|
|
|
|
7
|
|
|
use DOMElement; |
8
|
|
|
use SimpleSAML\Assert\Assert; |
9
|
|
|
use SimpleSAML\SAML2\Constants as C; |
10
|
|
|
//use SimpleSAML\SAML2\Exception\ProtocolViolationException; |
11
|
|
|
use SimpleSAML\XML\Exception\InvalidDOMElementException; |
12
|
|
|
//use SimpleSAML\XML\Exception\MissingElementException; |
13
|
|
|
//use SimpleSAML\XML\Exception\SchemaViolationException; |
14
|
|
|
//use SimpleSAML\XML\Exception\TooManyElementsException; |
15
|
|
|
//use SimpleSAML\XML\Utils as XMLUtils; |
16
|
|
|
|
17
|
|
|
//use function array_pop; |
18
|
|
|
//use function gmdate; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Class representing a SAML2 AuthzDecisionQuery |
22
|
|
|
* |
23
|
|
|
* @package simplesamlphp/saml2 |
24
|
|
|
*/ |
25
|
|
|
final class AuthzDecisionQuery extends AbstractSubjectQuery |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* Initialize an AuthzDecisionQuery. |
29
|
|
|
* |
30
|
|
|
* @param string $resource |
31
|
|
|
* @param string $decision |
32
|
|
|
* @param \SimpleSAML\SAML2\XML\saml\Action[] $action |
33
|
|
|
* @param \SimpleSAML\SAML2\XML\saml\Evidence|null |
34
|
|
|
*/ |
35
|
|
|
public function __construct( |
36
|
|
|
protected string $resource, |
37
|
|
|
protected string $decision, |
38
|
|
|
protected array $action, |
39
|
|
|
protected ?Evidence $evidence = null, |
|
|
|
|
40
|
|
|
) { |
41
|
|
|
Assert::validURI($resource); |
42
|
|
|
Assert::oneOf($decision, C::AUTHZ_DECISIONS, ProtocolViolationException::class); |
|
|
|
|
43
|
|
|
Assert::allIsInstanceOf($action, Action::class, SchemaViolationException::class); |
|
|
|
|
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Collect the value of the resource-property |
49
|
|
|
* |
50
|
|
|
* @return string |
51
|
|
|
*/ |
52
|
|
|
public function getResource(): string |
53
|
|
|
{ |
54
|
|
|
return $this->resource; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Collect the value of the decision-property |
60
|
|
|
* |
61
|
|
|
* @return string |
62
|
|
|
*/ |
63
|
|
|
public function getDecision(): string |
64
|
|
|
{ |
65
|
|
|
return $this->decision; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Collect the value of the action-property |
71
|
|
|
* |
72
|
|
|
* @return array |
73
|
|
|
*/ |
74
|
|
|
public function getAction(): array |
75
|
|
|
{ |
76
|
|
|
return $this->action; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Collect the value of the evidence-property |
82
|
|
|
* |
83
|
|
|
* @return \SimpleSAML\SAML2\XML\saml\Evidence|null |
84
|
|
|
*/ |
85
|
|
|
public function getEvidence(): ?Evidence |
86
|
|
|
{ |
87
|
|
|
return $this->evidence; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Convert XML into an AuthzDecisionQuery |
93
|
|
|
* |
94
|
|
|
* @param \DOMElement $xml The XML element we should load |
95
|
|
|
* |
96
|
|
|
* @return static |
97
|
|
|
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException |
98
|
|
|
* if the qualified name of the supplied element is wrong |
99
|
|
|
* @throws \SimpleSAML\XML\Exception\MissingElementException |
100
|
|
|
* if one of the mandatory child-elements is missing |
101
|
|
|
* @throws \Exception if the authentication instant is not a valid timestamp. |
102
|
|
|
*/ |
103
|
|
|
public static function fromXML(DOMElement $xml): static |
104
|
|
|
{ |
105
|
|
|
Assert::same($xml->localName, 'AuthzDecisionQuery', InvalidDOMElementException::class); |
106
|
|
|
Assert::same($xml->namespaceURI, AuthzDecisionQuery::NS, InvalidDOMElementException::class); |
107
|
|
|
|
108
|
|
|
$action = Action::getChildrenOfClass($xml); |
109
|
|
|
Assert::minCount( |
110
|
|
|
$action, |
111
|
|
|
1, |
112
|
|
|
'Missing <saml:Action> in <saml:AuthzDecisionQuery>', |
113
|
|
|
MissingElementException::class, |
|
|
|
|
114
|
|
|
); |
115
|
|
|
|
116
|
|
|
$evidence = Evidence::getChildrenOfClass($xml); |
117
|
|
|
Assert::maxCount( |
118
|
|
|
$evidence, |
119
|
|
|
1, |
120
|
|
|
'Too many <saml:Evidence> in <saml:AuthzDecisionQuery>', |
121
|
|
|
TooManyElementsException::class, |
|
|
|
|
122
|
|
|
); |
123
|
|
|
|
124
|
|
|
return new static( |
125
|
|
|
self::getAttribute($xml, 'Resource'), |
|
|
|
|
126
|
|
|
self::getAttribute($xml, 'Decision'), |
|
|
|
|
127
|
|
|
$action, |
128
|
|
|
array_pop($evidence), |
129
|
|
|
); |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* Convert this AuthzDecisionQuery to XML. |
135
|
|
|
* |
136
|
|
|
* @param \DOMElement|null $parent The element we should append this AuthzDecisionQuery to. |
137
|
|
|
* @return \DOMElement |
138
|
|
|
*/ |
139
|
|
|
public function toXML(DOMElement $parent = null): DOMElement |
140
|
|
|
{ |
141
|
|
|
$e = $this->instantiateParentElement($parent); |
142
|
|
|
|
143
|
|
|
$e->setAttribute('Resource', $this->getResource()); |
144
|
|
|
$e->setAttribute('Decision', $this->getDecision()); |
145
|
|
|
|
146
|
|
|
foreach ($this->getAction() as $action) { |
147
|
|
|
$action->toXML($e); |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
if ($this->getEvidence() !== null && !$this->getEvidence()->isEmptyElement()) { |
151
|
|
|
$this->getEvidence()->toXML($e); |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
return $e; |
155
|
|
|
} |
156
|
|
|
} |
157
|
|
|
|
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