|
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\XML\saml\AttributeDesignator; |
|
10
|
|
|
use SimpleSAML\SAML11\XML\saml\Subject; |
|
11
|
|
|
use SimpleSAML\XML\Exception\SchemaViolationException; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Abstract class to be implemented by all the attributes queries in this namespace |
|
15
|
|
|
* |
|
16
|
|
|
* @package simplesamlphp/saml11 |
|
17
|
|
|
*/ |
|
18
|
|
|
abstract class AbstractAttributeQueryType extends AbstractSubjectQueryAbstractType |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* Initialize a samlp:AttributeQuery element. |
|
22
|
|
|
* |
|
23
|
|
|
* @param \SimpleSAML\SAML11\XML\saml\Subject $subject |
|
24
|
|
|
* @param string|null $resource |
|
25
|
|
|
* @param array<\SimpleSAML\SAML11\XML\saml\AttributeDesignator> $attributeDesignator |
|
26
|
|
|
*/ |
|
27
|
|
|
public function __construct( |
|
28
|
|
|
Subject $subject, |
|
29
|
|
|
protected ?string $resource = null, |
|
30
|
|
|
protected array $attributeDesignator = [], |
|
31
|
|
|
) { |
|
32
|
|
|
Assert::nullOrValidURI($resource, SchemaViolationException::class); |
|
33
|
|
|
Assert::allIsInstanceOf($attributeDesignator, AttributeDesignator::class, SchemaViolationException::class); |
|
34
|
|
|
|
|
35
|
|
|
parent::__construct($subject); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @return string|null |
|
41
|
|
|
*/ |
|
42
|
|
|
public function getResource(): ?string |
|
43
|
|
|
{ |
|
44
|
|
|
return $this->resource; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @return array<\SimpleSAML\SAML11\XML\saml\AttributeDesignator> |
|
50
|
|
|
*/ |
|
51
|
|
|
public function getAttributeDesignator(): array |
|
52
|
|
|
{ |
|
53
|
|
|
return $this->attributeDesignator; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Convert this AttributeQuery to XML. |
|
59
|
|
|
* |
|
60
|
|
|
* @param \DOMElement $parent The element we are converting to XML. |
|
61
|
|
|
* @return \DOMElement The XML element after adding the data corresponding to this AttributeQuery. |
|
62
|
|
|
*/ |
|
63
|
|
|
public function toXML(?DOMElement $parent = null): DOMElement |
|
64
|
|
|
{ |
|
65
|
|
|
$e = parent::toXML($parent); |
|
66
|
|
|
|
|
67
|
|
|
if ($this->getResource() !== null) { |
|
68
|
|
|
$e->setAttribute('Resource', $this->getResource()); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
foreach ($this->getAttributeDesignator() as $attrDesignator) { |
|
72
|
|
|
$attrDesignator->toXML($e); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
return $e; |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|