1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\SAML11\XML\samlp; |
6
|
|
|
|
7
|
|
|
use DOMElement; |
8
|
|
|
use SimpleSAML\Assert\Assert; |
9
|
|
|
use SimpleSAML\SAML11\Type\SAMLAnyURIValue; |
10
|
|
|
use SimpleSAML\SAML11\XML\saml\{Action, Evidence, Subject}; |
11
|
|
|
use SimpleSAML\XMLSchema\Exception\{MissingElementException, SchemaViolationException}; |
12
|
|
|
|
13
|
|
|
use function strval; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Abstract class to be implemented by all the authorization decision queries in this namespace |
17
|
|
|
* |
18
|
|
|
* @package simplesamlphp/saml11 |
19
|
|
|
*/ |
20
|
|
|
abstract class AbstractAuthorizationDecisionQueryType extends AbstractSubjectQueryAbstractType |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* Initialize a samlp:AuthorizationDecisionQuery element. |
24
|
|
|
* |
25
|
|
|
* @param \SimpleSAML\SAML11\XML\saml\Subject $subject |
26
|
|
|
* @param \SimpleSAML\SAML11\Type\SAMLAnyURIValue $resource |
27
|
|
|
* @param \SimpleSAML\SAML11\XML\saml\Evidence|null $evidence |
28
|
|
|
* @param array<\SimpleSAML\SAML11\XML\saml\Action> $action |
29
|
|
|
*/ |
30
|
|
|
public function __construct( |
31
|
|
|
Subject $subject, |
32
|
|
|
protected SAMLAnyURIValue $resource, |
33
|
|
|
protected ?Evidence $evidence = null, |
34
|
|
|
protected array $action = [], |
35
|
|
|
) { |
36
|
|
|
Assert::allIsInstanceOf($action, Action::class, SchemaViolationException::class); |
37
|
|
|
Assert::minCount($action, 1, MissingElementException::class); |
38
|
|
|
|
39
|
|
|
parent::__construct($subject); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @return \SimpleSAML\SAML11\Type\SAMLAnyURIValue |
45
|
|
|
*/ |
46
|
|
|
public function getResource(): SAMLAnyURIValue |
47
|
|
|
{ |
48
|
|
|
return $this->resource; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @return \SimpleSAML\SAML11\XML\saml\Evidence|null |
54
|
|
|
*/ |
55
|
|
|
public function getEvidence(): ?Evidence |
56
|
|
|
{ |
57
|
|
|
return $this->evidence; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @return array<\SimpleSAML\SAML11\XML\saml\Action> |
63
|
|
|
*/ |
64
|
|
|
public function getAction(): array |
65
|
|
|
{ |
66
|
|
|
return $this->action; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Convert this AttributeQuery to XML. |
72
|
|
|
* |
73
|
|
|
* @param \DOMElement $parent The element we are converting to XML. |
74
|
|
|
* @return \DOMElement The XML element after adding the data corresponding to this AttributeQuery. |
75
|
|
|
*/ |
76
|
|
|
public function toXML(?DOMElement $parent = null): DOMElement |
77
|
|
|
{ |
78
|
|
|
$e = parent::toXML($parent); |
79
|
|
|
$e->setAttribute('Resource', strval($this->getResource())); |
80
|
|
|
|
81
|
|
|
foreach ($this->getAction() as $action) { |
82
|
|
|
$action->toXML($e); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
$this->getEvidence()?->toXML($e); |
86
|
|
|
|
87
|
|
|
return $e; |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|