|
5 | 5 | namespace SimpleSAML\SAML2\XML\saml; |
6 | 6 |
|
7 | 7 | use DOMElement; |
8 | | -use SimpleSAML\Assert\AssertionFailedException; |
9 | 8 | use SimpleSAML\SAML2\Assert\Assert; |
10 | 9 | use SimpleSAML\SAML2\Type\EntityIDValue; |
11 | 10 | use SimpleSAML\SAML2\Type\SAMLDateTimeValue; |
12 | 11 | use SimpleSAML\SAML2\Type\SAMLStringValue; |
13 | | -use SimpleSAML\SAML2\Utils; |
14 | | -use SimpleSAML\XML\ExtendableAttributesTrait; |
15 | | -use SimpleSAML\XML\ExtendableElementTrait; |
16 | 12 | use SimpleSAML\XML\SchemaValidatableElementInterface; |
17 | 13 | use SimpleSAML\XML\SchemaValidatableElementTrait; |
18 | 14 | use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException; |
19 | 15 | use SimpleSAML\XMLSchema\Type\NCNameValue; |
20 | | -use SimpleSAML\XMLSchema\XML\Constants\NS; |
21 | | - |
22 | | -use function strval; |
23 | 16 |
|
24 | 17 | /** |
25 | 18 | * Class representing SAML 2 SubjectConfirmationData element. |
26 | 19 | * |
27 | 20 | * @package simplesamlphp/saml2 |
28 | 21 | */ |
29 | | -final class SubjectConfirmationData extends AbstractSamlElement implements SchemaValidatableElementInterface |
| 22 | +final class SubjectConfirmationData extends AbstractSubjectConfirmationData implements SchemaValidatableElementInterface |
30 | 23 | { |
31 | | - use ExtendableAttributesTrait; |
32 | | - use ExtendableElementTrait; |
33 | 24 | use SchemaValidatableElementTrait; |
34 | 25 |
|
35 | 26 |
|
36 | | - /** The namespace-attribute for the xs:any element */ |
37 | | - public const XS_ANY_ELT_NAMESPACE = NS::ANY; |
38 | | - |
39 | | - /** The namespace-attribute for the xs:anyAttribute element */ |
40 | | - public const XS_ANY_ATTR_NAMESPACE = NS::OTHER; |
41 | | - |
42 | | - |
43 | | - /** |
44 | | - * Initialize (and parse) a SubjectConfirmationData element. |
45 | | - * |
46 | | - * @param \SimpleSAML\SAML2\Type\SAMLDateTimeValue|null $notBefore |
47 | | - * @param \SimpleSAML\SAML2\Type\SAMLDateTimeValue|null $notOnOrAfter |
48 | | - * @param \SimpleSAML\SAML2\Type\EntityIDValue|null $recipient |
49 | | - * @param \SimpleSAML\XMLSchema\Type\NCNameValue|null $inResponseTo |
50 | | - * @param \SimpleSAML\SAML2\Type\SAMLStringValue|null $address |
51 | | - * @param \SimpleSAML\XML\SerializableElementInterface[] $children |
52 | | - * @param list<\SimpleSAML\XML\Attribute> $namespacedAttributes |
53 | | - */ |
54 | | - public function __construct( |
55 | | - protected ?SAMLDateTimeValue $notBefore = null, |
56 | | - protected ?SAMLDateTimeValue $notOnOrAfter = null, |
57 | | - protected ?EntityIDValue $recipient = null, |
58 | | - protected ?NCNameValue $inResponseTo = null, |
59 | | - protected ?SAMLStringValue $address = null, |
60 | | - array $children = [], |
61 | | - array $namespacedAttributes = [], |
62 | | - ) { |
63 | | - if ($address !== null) { |
64 | | - try { |
65 | | - /** |
66 | | - * IPv4 addresses SHOULD be represented in the usual dotted-decimal format (e.g., "1.2.3.4"). |
67 | | - * IPv6 addresses SHOULD be represented as defined by Section 2.2 of IETF RFC 3513 [RFC 3513] |
68 | | - * (e.g., "FEDC:BA98:7654:3210:FEDC:BA98:7654:3210"). |
69 | | - */ |
70 | | - Assert::ip($address->getValue()); |
71 | | - } catch (AssertionFailedException) { |
72 | | - Utils::getContainer()->getLogger()->warning( |
73 | | - sprintf('Provided address (%s) is not a valid IPv4 or IPv6 address.', $address->getValue()), |
74 | | - ); |
75 | | - } |
76 | | - } |
77 | | - |
78 | | - $this->setElements($children); |
79 | | - $this->setAttributesNS($namespacedAttributes); |
80 | | - } |
81 | | - |
82 | | - |
83 | | - /** |
84 | | - * Collect the value of the NotBefore-property |
85 | | - * |
86 | | - * @return \SimpleSAML\SAML2\Type\SAMLDateTimeValue|null |
87 | | - */ |
88 | | - public function getNotBefore(): ?SAMLDateTimeValue |
89 | | - { |
90 | | - return $this->notBefore; |
91 | | - } |
92 | | - |
93 | | - |
94 | | - /** |
95 | | - * Collect the value of the NotOnOrAfter-property |
96 | | - * |
97 | | - * @return \SimpleSAML\SAML2\Type\SAMLDateTimeValue|null |
98 | | - */ |
99 | | - public function getNotOnOrAfter(): ?SAMLDateTimeValue |
100 | | - { |
101 | | - return $this->notOnOrAfter; |
102 | | - } |
103 | | - |
104 | | - |
105 | | - /** |
106 | | - * Collect the value of the Recipient-property |
107 | | - * |
108 | | - * @return \SimpleSAML\SAML2\Type\EntityIDValue|null |
109 | | - */ |
110 | | - public function getRecipient(): ?EntityIDValue |
111 | | - { |
112 | | - return $this->recipient; |
113 | | - } |
114 | | - |
115 | | - |
116 | | - /** |
117 | | - * Collect the value of the InResponseTo-property |
118 | | - * |
119 | | - * @return \SimpleSAML\XMLSchema\Type\NCNameValue|null |
120 | | - */ |
121 | | - public function getInResponseTo(): ?NCNameValue |
122 | | - { |
123 | | - return $this->inResponseTo; |
124 | | - } |
125 | | - |
126 | | - |
127 | | - /** |
128 | | - * Collect the value of the Address-property |
129 | | - * |
130 | | - * @return \SimpleSAML\SAML2\Type\SAMLStringValue|null |
131 | | - */ |
132 | | - public function getAddress(): ?SAMLStringValue |
133 | | - { |
134 | | - return $this->address; |
135 | | - } |
136 | | - |
137 | | - |
138 | | - /** |
139 | | - * Test if an object, at the state it's in, would produce an empty XML-element |
140 | | - * |
141 | | - * @return bool |
142 | | - */ |
143 | | - public function isEmptyElement(): bool |
144 | | - { |
145 | | - return empty($this->getNotBefore()) |
146 | | - && empty($this->getNotOnOrAfter()) |
147 | | - && empty($this->getRecipient()) |
148 | | - && empty($this->getInResponseTo()) |
149 | | - && empty($this->getAddress()) |
150 | | - && empty($this->getElements()) |
151 | | - && empty($this->getAttributesNS()); |
152 | | - } |
153 | | - |
154 | | - |
155 | 27 | /** |
156 | 28 | * Convert XML into a SubjectConfirmationData |
157 | 29 | * |
@@ -180,42 +52,4 @@ public static function fromXML(DOMElement $xml): static |
180 | 52 | self::getAttributesNSFromXML($xml), |
181 | 53 | ); |
182 | 54 | } |
183 | | - |
184 | | - |
185 | | - /** |
186 | | - * Convert this element to XML. |
187 | | - * |
188 | | - * @param \DOMElement|null $parent The parent element we should append this element to. |
189 | | - * @return \DOMElement This element, as XML. |
190 | | - */ |
191 | | - public function toXML(?DOMElement $parent = null): DOMElement |
192 | | - { |
193 | | - $e = $this->instantiateParentElement($parent); |
194 | | - |
195 | | - if ($this->getNotBefore() !== null) { |
196 | | - $e->setAttribute('NotBefore', strval($this->getNotBefore())); |
197 | | - } |
198 | | - if ($this->getNotOnOrAfter() !== null) { |
199 | | - $e->setAttribute('NotOnOrAfter', strval($this->getNotOnOrAfter())); |
200 | | - } |
201 | | - if ($this->getRecipient() !== null) { |
202 | | - $e->setAttribute('Recipient', strval($this->getRecipient())); |
203 | | - } |
204 | | - if ($this->getInResponseTo() !== null) { |
205 | | - $e->setAttribute('InResponseTo', strval($this->getInResponseTo())); |
206 | | - } |
207 | | - if ($this->getAddress() !== null) { |
208 | | - $e->setAttribute('Address', strval($this->getAddress())); |
209 | | - } |
210 | | - |
211 | | - foreach ($this->getAttributesNS() as $attr) { |
212 | | - $attr->toXML($e); |
213 | | - } |
214 | | - |
215 | | - foreach ($this->getElements() as $n) { |
216 | | - $n->toXML($e); |
217 | | - } |
218 | | - |
219 | | - return $e; |
220 | | - } |
221 | 55 | } |
0 commit comments