Skip to content
This repository was archived by the owner on Jan 21, 2026. It is now read-only.

Commit 3ac2d74

Browse files
committed
Migrate to xsd-types
1 parent ee7f794 commit 3ac2d74

12 files changed

Lines changed: 70 additions & 69 deletions

src/XML/wsse/AbstractAttributedString.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
use DOMElement;
88
use SimpleSAML\WSSecurity\Assert\Assert;
99
use SimpleSAML\WSSecurity\Constants as C;
10+
use SimpleSAML\WSSecurity\XML\wsu\Type\IDValue;
1011
use SimpleSAML\XML\Attribute as XMLAttribute;
11-
use SimpleSAML\XML\Exception\InvalidDOMElementException;
1212
use SimpleSAML\XML\ExtendableAttributesTrait;
1313
use SimpleSAML\XML\TypedTextContentTrait;
14-
use SimpleSAML\XML\XsNamespace as NS;
15-
use SimpleSAML\XMLSchema\Type\IDValue;
14+
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
1615
use SimpleSAML\XMLSchema\Type\StringValue;
16+
use SimpleSAML\XMLSchema\XML\Constants\NS;
1717

1818
use function array_unshift;
1919

@@ -41,7 +41,7 @@ abstract class AbstractAttributedString extends AbstractWsseElement
4141
* AbstractAttributedString constructor
4242
*
4343
* @param \SimpleSAML\XMLSchema\Type\StringValue $content
44-
* @param \SimpleSAML\XMLSchema\Type\IDValue|null $Id
44+
* @param \SimpleSAML\WSSecurity\XML\wsu\Type\IDValue|null $Id
4545
* @param array<\SimpleSAML\XML\Attribute> $namespacedAttributes
4646
*/
4747
public function __construct(
@@ -55,7 +55,7 @@ public function __construct(
5555

5656

5757
/**
58-
* @return \SimpleSAML\XMLSchema\Type\IDValue|null
58+
* @return \SimpleSAML\WSSecurity\XML\wsu\Type\IDValue|null
5959
*/
6060
public function getId(): ?IDValue
6161
{
@@ -69,7 +69,7 @@ public function getId(): ?IDValue
6969
* @param \DOMElement $xml
7070
* @return static
7171
*
72-
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
72+
* @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
7373
* if the qualified name of the supplied element is wrong
7474
*/
7575
public static function fromXML(DOMElement $xml): static
@@ -82,13 +82,13 @@ public static function fromXML(DOMElement $xml): static
8282
$Id = null;
8383
foreach ($nsAttributes as $i => $attr) {
8484
if ($attr->getNamespaceURI() === C::NS_SEC_UTIL && $attr->getAttrName() === 'Id') {
85-
$Id = $attr->getAttrValue();
85+
$Id = IDValue::fromString($attr->getAttrValue()->getValue());
8686
unset($nsAttributes[$i]);
8787
break;
8888
}
8989
}
9090

91-
return new static($xml->textContent, $Id, $nsAttributes);
91+
return new static(StringValue::fromString($xml->textContent), $Id, $nsAttributes);
9292
}
9393

9494

src/XML/wsse/AbstractBinarySecurityTokenType.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
use DOMElement;
88
use SimpleSAML\WSSecurity\Assert\Assert;
99
use SimpleSAML\WSSecurity\Constants as C;
10-
use SimpleSAML\XML\Exception\InvalidDOMElementException;
11-
use SimpleSAML\XML\XsNamespace as NS;
10+
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
1211
use SimpleSAML\XMLSchema\Type\AnyURIValue;
13-
use SimpleSAML\XMLSchema\Type\IDValue;
12+
use SimpleSAML\WSSecurity\XML\wsu\Type\IDValue;
13+
use SimpleSAML\XMLSchema\Type\Base64BinaryValue;
1414
use SimpleSAML\XMLSchema\Type\StringValue;
15+
use SimpleSAML\XMLSchema\XML\Constants\NS;
1516

1617
/**
1718
* Class defining the BinarySecurityTokenType element
@@ -28,20 +29,20 @@ abstract class AbstractBinarySecurityTokenType extends AbstractEncodedString
2829
* AbstractBinarySecurityTokenType constructor
2930
*
3031
* @param \SimpleSAML\XMLSchema\Type\StringValue $content
32+
* @param \SimpleSAML\WSSecurity\XML\wsu\Type\IDValue|null $Id
33+
* @param array<\SimpleSAML\XML\Attribute> $namespacedAttributes
3134
* @param \SimpleSAML\XMLSchema\Type\AnyURIValue|null $valueType
32-
* @param \SimpleSAML\XMLSchema\Type\IDValue|null $Id
3335
* @param \SimpleSAML\XMLSchema\Type\AnyURIValue|null $EncodingType
34-
* @param array<\SimpleSAML\XML\Attribute> $namespacedAttributes
3536
*/
3637
final public function __construct(
3738
StringValue $content,
38-
protected ?AnyURIValue $valueType = null,
3939
?IDValue $Id = null,
40-
?string $EncodingType = null,
4140
array $namespacedAttributes = [],
41+
protected ?AnyURIValue $valueType = null,
42+
?AnyURIValue $EncodingType = null,
4243
) {
4344
Assert::validBase64Binary($content->getValue());
44-
parent::__construct($content, $Id, $EncodingType, $namespacedAttributes);
45+
parent::__construct($content, $Id, $namespacedAttributes, $EncodingType);
4546
}
4647

4748

@@ -60,7 +61,7 @@ public function getValueType(): ?AnyURIValue
6061
* @param \DOMElement $xml
6162
* @return static
6263
*
63-
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
64+
* @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
6465
* if the qualified name of the supplied element is wrong
6566
*/
6667
public static function fromXML(DOMElement $xml): static
@@ -73,18 +74,18 @@ public static function fromXML(DOMElement $xml): static
7374
$Id = null;
7475
foreach ($nsAttributes as $i => $attr) {
7576
if ($attr->getNamespaceURI() === C::NS_SEC_UTIL && $attr->getAttrName() === 'Id') {
76-
$Id = $attr->getAttrValue();
77+
$Id = IDValue::fromString($attr->getAttrValue()->getValue());
7778
unset($nsAttributes[$i]);
7879
break;
7980
}
8081
}
8182

8283
return new static(
8384
StringValue::fromString($xml->textContent),
84-
self::getOptionalAttribute($xml, 'ValueType', AnyURIValue::class, null),
8585
$Id,
86-
self::getOptionalAttribute($xml, 'EncodingType', AnyURIValue::class, null),
8786
$nsAttributes,
87+
self::getOptionalAttribute($xml, 'ValueType', AnyURIValue::class, null),
88+
self::getOptionalAttribute($xml, 'EncodingType', AnyURIValue::class, null),
8889
);
8990
}
9091

src/XML/wsse/AbstractEmbeddedType.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
use DOMElement;
88
use SimpleSAML\WSSecurity\Assert\Assert;
9-
use SimpleSAML\XML\Exception\InvalidDOMElementException;
109
use SimpleSAML\XML\ExtendableAttributesTrait;
1110
use SimpleSAML\XML\ExtendableElementTrait;
12-
use SimpleSAML\XML\XsNamespace as NS;
11+
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
1312
use SimpleSAML\XMLSchema\Type\AnyURIValue;
13+
use SimpleSAML\XMLSchema\XML\Constants\NS;
1414

1515
/**
1616
* Class defining the EmbeddedType element
@@ -75,7 +75,7 @@ public function isEmptyElement(): bool
7575
* @param \DOMElement $xml
7676
* @return static
7777
*
78-
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
78+
* @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
7979
* if the qualified name of the supplied element is wrong
8080
*/
8181
public static function fromXML(DOMElement $xml): static

src/XML/wsse/AbstractEncodedString.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
use DOMElement;
88
use SimpleSAML\WSSecurity\Assert\Assert;
99
use SimpleSAML\WSSecurity\Constants as C;
10-
use SimpleSAML\XML\Exception\InvalidDOMElementException;
10+
use SimpleSAML\WSSecurity\XML\wsu\Type\IDValue;
11+
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
1112
use SimpleSAML\XMLSchema\Type\AnyURIValue;
12-
use SimpleSAML\XMLSchema\Type\IDValue;
1313
use SimpleSAML\XMLSchema\Type\StringValue;
1414

1515
/**
@@ -25,15 +25,15 @@ abstract class AbstractEncodedString extends AbstractAttributedString
2525
* AbstractEncodedString constructor
2626
*
2727
* @param \SimpleSAML\XMLSchema\Type\StringValue $content
28-
* @param \SimpleSAML\XMLSchema\Type\IDValue|null $Id
29-
* @param \SimpleSAML\XMLSchema\Type\AnyURIValue|null $EncodingType
28+
* @param \SimpleSAML\WSSecurity\XML\wsu\Type\IDValue|null $Id
3029
* @param array<\SimpleSAML\XML\Attribute> $namespacedAttributes
30+
* @param \SimpleSAML\XMLSchema\Type\AnyURIValue|null $EncodingType
3131
*/
3232
public function __construct(
3333
StringValue $content,
3434
?IDValue $Id = null,
35-
protected ?AnyURIValue $EncodingType = null,
3635
array $namespacedAttributes = [],
36+
protected ?AnyURIValue $EncodingType = null,
3737
) {
3838
parent::__construct($content, $Id, $namespacedAttributes);
3939
}
@@ -54,7 +54,7 @@ public function getEncodingType(): ?AnyURIValue
5454
* @param \DOMElement $xml
5555
* @return static
5656
*
57-
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
57+
* @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
5858
* if the qualified name of the supplied element is wrong
5959
*/
6060
public static function fromXML(DOMElement $xml): static
@@ -67,17 +67,17 @@ public static function fromXML(DOMElement $xml): static
6767
$Id = null;
6868
foreach ($nsAttributes as $i => $attr) {
6969
if ($attr->getNamespaceURI() === C::NS_SEC_UTIL && $attr->getAttrName() === 'Id') {
70-
$Id = $attr->getAttrValue();
70+
$Id = IDValue::fromString($attr->getAttrValue()->getValue());
7171
unset($nsAttributes[$i]);
7272
break;
7373
}
7474
}
7575

7676
return new static(
77-
$xml->textContent,
77+
StringValue::fromString($xml->textContent),
7878
$Id,
79-
self::getOptionalAttribute($xml, 'EncodingType', null),
8079
$nsAttributes,
80+
self::getOptionalAttribute($xml, 'EncodingType', AnyURIValue::class, null),
8181
);
8282
}
8383

src/XML/wsse/AbstractKeyIdentifierType.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
use DOMElement;
88
use SimpleSAML\WSSecurity\Assert\Assert;
99
use SimpleSAML\WSSecurity\Constants as C;
10-
use SimpleSAML\XML\Exception\InvalidDOMElementException;
10+
use SimpleSAML\WSSecurity\XML\wsu\Type\IDValue;
11+
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
1112
use SimpleSAML\XMLSchema\Type\AnyURIValue;
12-
use SimpleSAML\XMLSchema\Type\IDValue;
1313
use SimpleSAML\XMLSchema\Type\StringValue;
1414

1515
/**
@@ -23,19 +23,19 @@ abstract class AbstractKeyIdentifierType extends AbstractEncodedString
2323
* AbstractKeyIdentifierType constructor
2424
*
2525
* @param \SimpleSAML\XMLSchema\Type\StringValue $content
26+
* @param \SimpleSAML\WSSecurity\XML\wsu\Type\IDValue|null $Id
27+
* @param array<\SimpleSAML\XML\Attribute> $namespacedAttributes
2628
* @param \SimpleSAML\XMLSchema\Type\AnyURIValue|null $valueType
27-
* @param \SimpleSAML\XMLSchema\Type\IDValue|null $Id
2829
* @param \SimpleSAML\XMLSchema\Type\AnyURIValue|null $EncodingType
29-
* @param array<\SimpleSAML\XML\Attribute> $namespacedAttributes
3030
*/
3131
final public function __construct(
3232
StringValue $content,
33-
protected ?AnyURIValue $valueType = null,
3433
?IDValue $Id = null,
35-
?AnyURIValue $EncodingType = null,
3634
array $namespacedAttributes = [],
35+
protected ?AnyURIValue $valueType = null,
36+
?AnyURIValue $EncodingType = null,
3737
) {
38-
parent::__construct($content, $Id, $EncodingType, $namespacedAttributes);
38+
parent::__construct($content, $Id, $namespacedAttributes, $EncodingType);
3939
}
4040

4141

@@ -54,7 +54,7 @@ public function getValueType(): ?AnyURIValue
5454
* @param \DOMElement $xml
5555
* @return static
5656
*
57-
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
57+
* @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
5858
* if the qualified name of the supplied element is wrong
5959
*/
6060
public static function fromXML(DOMElement $xml): static
@@ -67,18 +67,18 @@ public static function fromXML(DOMElement $xml): static
6767
$Id = null;
6868
foreach ($nsAttributes as $i => $attr) {
6969
if ($attr->getNamespaceURI() === C::NS_SEC_UTIL && $attr->getAttrName() === 'Id') {
70-
$Id = $attr->getAttrValue();
70+
$Id = IDValue::fromString($attr->getAttrValue()->getValue());
7171
unset($nsAttributes[$i]);
7272
break;
7373
}
7474
}
7575

7676
return new static(
7777
StringValue::fromString($xml->textContent),
78-
self::getOptionalAttribute($xml, 'ValueType', AnyURIValue::class, null),
7978
$Id,
80-
self::getOptionalAttribute($xml, 'EncodingType', AnyURIValue::class, null),
8179
$nsAttributes,
80+
self::getOptionalAttribute($xml, 'ValueType', AnyURIValue::class, null),
81+
self::getOptionalAttribute($xml, 'EncodingType', AnyURIValue::class, null),
8282
);
8383
}
8484

src/XML/wsse/AbstractPasswordString.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
use DOMElement;
88
use SimpleSAML\WSSecurity\Assert\Assert;
99
use SimpleSAML\WSSecurity\Constants as C;
10-
use SimpleSAML\XML\Exception\InvalidDOMElementException;
10+
use SimpleSAML\WSSecurity\XML\wsu\Type\IDValue;
11+
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
1112
use SimpleSAML\XMLSchema\Type\AnyURIValue;
12-
use SimpleSAML\XMLSchema\Type\IDValue;
1313
use SimpleSAML\XMLSchema\Type\StringValue;
1414

1515
/**
@@ -23,16 +23,16 @@ abstract class AbstractPasswordString extends AbstractAttributedString
2323
* AbstractPasswordString constructor
2424
*
2525
* @param \SimpleSAML\XMLSchema\Type\StringValue $content
26-
* @param \SimpleSAML\XMLSchema\Type\IDValue|null $Id
27-
* @param \SimpleSAML\XMLSchema\Type\AnyURIValue|null $Type
26+
* @param \SimpleSAML\WSSecurity\XML\wsu\Type\IDValue|null $Id
2827
* @param array<\SimpleSAML\XML\Attribute> $namespacedAttributes
28+
* @param \SimpleSAML\XMLSchema\Type\AnyURIValue|null $Type
2929
*/
3030
final public function __construct(
3131
#[\SensitiveParameter]
3232
StringValue $content,
3333
?IDValue $Id = null,
34-
protected ?AnyURIValue $Type = null,
3534
array $namespacedAttributes = [],
35+
protected ?AnyURIValue $Type = null,
3636
) {
3737
parent::__construct($content, $Id, $namespacedAttributes);
3838
}
@@ -53,7 +53,7 @@ public function getType(): ?AnyURIValue
5353
* @param \DOMElement $xml
5454
* @return static
5555
*
56-
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
56+
* @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
5757
* if the qualified name of the supplied element is wrong
5858
*/
5959
public static function fromXML(DOMElement $xml): static
@@ -66,7 +66,7 @@ public static function fromXML(DOMElement $xml): static
6666
$Id = null;
6767
foreach ($nsAttributes as $i => $attr) {
6868
if ($attr->getNamespaceURI() === C::NS_SEC_UTIL && $attr->getAttrName() === 'Id') {
69-
$Id = $attr->getAttrValue();
69+
$Id = IDValue::fromString($attr->getAttrValue()->getValue());
7070
unset($nsAttributes[$i]);
7171
break;
7272
}
@@ -75,8 +75,8 @@ public static function fromXML(DOMElement $xml): static
7575
return new static(
7676
StringValue::fromString($xml->textContent),
7777
$Id,
78-
self::getOptionalAttribute($xml, 'Type', AnyURIValue::class, null),
7978
$nsAttributes,
79+
self::getOptionalAttribute($xml, 'Type', AnyURIValue::class, null),
8080
);
8181
}
8282

src/XML/wsse/AbstractReferenceType.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
use DOMElement;
88
use SimpleSAML\WSSecurity\Assert\Assert;
9-
use SimpleSAML\XML\Exception\InvalidDOMElementException;
109
use SimpleSAML\XML\ExtendableAttributesTrait;
11-
use SimpleSAML\XML\XsNamespace as NS;
1210
use SimpleSAML\XMLSchema\Type\AnyURIValue;
11+
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
12+
use SimpleSAML\XMLSchema\XML\Constants\NS;
1313

1414
/**
1515
* Class defining the ReferenceType element
@@ -65,7 +65,7 @@ public function getURI(): ?AnyURIValue
6565
* @param \DOMElement $xml
6666
* @return static
6767
*
68-
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
68+
* @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
6969
* if the qualified name of the supplied element is wrong
7070
*/
7171
public static function fromXML(DOMElement $xml): static

src/XML/wsse/AbstractSecurityHeaderType.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
use DOMElement;
88
use SimpleSAML\WSSecurity\Assert\Assert;
9-
use SimpleSAML\XML\Exception\InvalidDOMElementException;
109
use SimpleSAML\XML\ExtendableAttributesTrait;
1110
use SimpleSAML\XML\ExtendableElementTrait;
12-
use SimpleSAML\XML\XsNamespace as NS;
11+
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
12+
use SimpleSAML\XMLSchema\XML\Constants\NS;
1313

1414
/**
1515
* Class defining the SecurityHeaderType element
@@ -62,7 +62,7 @@ public function isEmptyElement(): bool
6262
* @param \DOMElement $xml
6363
* @return static
6464
*
65-
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
65+
* @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
6666
* if the qualified name of the supplied element is wrong
6767
*/
6868
public static function fromXML(DOMElement $xml): static

0 commit comments

Comments
 (0)