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

Commit ee7f794

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

37 files changed

Lines changed: 187 additions & 376 deletions

.github/workflows/php.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
matrix:
2222
php-version: ['8.2', '8.3', '8.4', '8.5']
2323

24-
uses: simplesamlphp/simplesamlphp-test-framework/.github/workflows/reusable_phplinter.yml@v1.10.3
24+
uses: simplesamlphp/simplesamlphp-test-framework/.github/workflows/reusable_phplinter.yml@v1.10.6
2525
with:
2626
php-version: ${{ matrix.php-version }}
2727

@@ -30,7 +30,7 @@ jobs:
3030
strategy:
3131
fail-fast: false
3232

33-
uses: simplesamlphp/simplesamlphp-test-framework/.github/workflows/reusable_linter.yml@v1.10.3
33+
uses: simplesamlphp/simplesamlphp-test-framework/.github/workflows/reusable_linter.yml@v1.10.6
3434
with:
3535
enable_eslinter: false
3636
enable_jsonlinter: true

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"ext-spl": "*",
1616

1717
"simplesamlphp/assert": "~1.9",
18-
"simplesamlphp/saml2": "dev-feature/xsd-types",
18+
"simplesamlphp/saml2": "~6.0",
1919
"simplesamlphp/xml-common": "~2.3",
2020
"simplesamlphp/xml-security": "~2.0",
2121
"simplesamlphp/xml-soap": "~2.0"

src/XML/wst_200512/AbstractAuthenticatorType.php

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

77
use DOMElement;
88
use SimpleSAML\WSSecurity\Assert\Assert;
9-
use SimpleSAML\XML\Exception\InvalidDOMElementException;
109
use SimpleSAML\XML\ExtendableElementTrait;
11-
use SimpleSAML\XML\XsNamespace as NS;
10+
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
11+
use SimpleSAML\XMLSchema\XML\Constants\NS;
1212

1313
use function array_pop;
1414

@@ -66,7 +66,7 @@ public function isEmptyElement(): bool
6666
* @param \DOMElement $xml
6767
* @return static
6868
*
69-
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
69+
* @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
7070
* if the qualified name of the supplied element is wrong
7171
*/
7272
public static function fromXML(DOMElement $xml): static

src/XML/wst_200512/AbstractBinaryExchangeType.php

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

77
use DOMElement;
88
use SimpleSAML\WSSecurity\Assert\Assert;
9-
use SimpleSAML\XML\Exception\InvalidDOMElementException;
10-
use SimpleSAML\XML\Exception\SchemaViolationException;
119
use SimpleSAML\XML\ExtendableAttributesTrait;
1210
use SimpleSAML\XML\TypedTextContentTrait;
13-
use SimpleSAML\XML\XsNamespace as NS;
11+
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
12+
use SimpleSAML\XMLSchema\Exception\SchemaViolationException;
1413
use SimpleSAML\XMLSchema\Type\AnyURIValue;
1514
use SimpleSAML\XMLSchema\Type\StringValue;
15+
use SimpleSAML\XMLSchema\XML\Constants\NS;
1616

1717
/**
1818
* A BinaryExchangeType element
@@ -77,7 +77,7 @@ public function getEncodingType(): AnyURIValue
7777
* @param \DOMElement $xml The XML element we should load
7878
* @return static
7979
*
80-
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
80+
* @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
8181
* If the qualified name of the supplied element is wrong
8282
*/
8383
public static function fromXML(DOMElement $xml): static

src/XML/wst_200512/AbstractBinarySecretType.php

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,13 @@
66

77
use DOMElement;
88
use SimpleSAML\WSSecurity\Assert\Assert;
9-
use SimpleSAML\XML\Exception\InvalidDOMElementException;
10-
use SimpleSAML\XML\Exception\SchemaViolationException;
119
use SimpleSAML\XML\ExtendableAttributesTrait;
1210
use SimpleSAML\XML\TypedTextContentTrait;
13-
use SimpleSAML\XML\XsNamespace as NS;
14-
use SimpleSAML\XMLSchema\Base64BinaryValue;
15-
16-
use function array_map;
17-
use function explode;
18-
use function implode;
11+
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
12+
use SimpleSAML\XMLSchema\Exception\SchemaViolationException;
13+
use SimpleSAML\XMLSchema\Type\Base64BinaryValue;
14+
use SimpleSAML\XMLSchema\Type\Helper\AnyURIListValue;
15+
use SimpleSAML\XMLSchema\XML\Constants\NS;
1916

2017
/**
2118
* A BinarySecertType element
@@ -35,31 +32,16 @@ abstract class AbstractBinarySecretType extends AbstractWstElement
3532
public const XS_ANY_ATTR_NAMESPACE = NS::OTHER;
3633

3734

38-
/** @var string[]|null */
39-
protected ?array $Type;
40-
41-
4235
/**
4336
* @param \SimpleSAML\XMLSchema\Type\Base64BinaryValue $content
44-
* @param (\SimpleSAML\WSSecurity\XML\wst_200512\BinarySecretTypeEnum|string)[]|null $Type
37+
* @param \SimpleSAML\XMLSchema\Type\Helper\AnyURIListValue|null $Type
4538
* @param array<\SimpleSAML\XML\Attribute> $namespacedAttributes
4639
*/
4740
final public function __construct(
4841
Base64BinaryValue $content,
49-
?array $Type = null,
42+
protected ?AnyURIListValue $Type = null,
5043
array $namespacedAttributes = [],
5144
) {
52-
if ($Type !== null) {
53-
$Type = array_map(
54-
function (BinarySecretTypeEnum|string $v): string {
55-
return ($v instanceof BinarySecretTypeEnum) ? $v->value : $v;
56-
},
57-
$Type,
58-
);
59-
Assert::allValidURI($Type, SchemaViolationException::class);
60-
$this->Type = $Type;
61-
}
62-
6345
$this->setContent($content);
6446
$this->setAttributesNS($namespacedAttributes);
6547
}
@@ -68,9 +50,9 @@ function (BinarySecretTypeEnum|string $v): string {
6850
/**
6951
* Get the Type property.
7052
*
71-
* @return string[]|null
53+
* @return \SimpleSAML\XMLSchema\Type\Helper\AnyURIListValue|null
7254
*/
73-
public function getType(): ?array
55+
public function getType(): ?AnyURIListValue
7456
{
7557
return $this->Type;
7658
}
@@ -82,7 +64,7 @@ public function getType(): ?array
8264
* @param \DOMElement $xml The XML element we should load
8365
* @return static
8466
*
85-
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
67+
* @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
8668
* If the qualified name of the supplied element is wrong
8769
*/
8870
public static function fromXML(DOMElement $xml): static
@@ -92,7 +74,7 @@ public static function fromXML(DOMElement $xml): static
9274

9375
return new static(
9476
Base64BinaryValue::fromString($xml->textContent),
95-
explode(' ', self::getAttribute($xml, 'Type')),
77+
self::getAttribute($xml, 'Type', AnyURIListValue::class),
9678
self::getAttributesNSFromXML($xml),
9779
);
9880
}
@@ -110,7 +92,7 @@ public function toXML(?DOMElement $parent = null): DOMElement
11092
$e->textContent = $this->getContent()->getValue();
11193

11294
if ($this->getType() !== null) {
113-
$e->setAttribute('Type', implode(' ', $this->getType()));
95+
$e->setAttribute('Type', $this->getType()->getValue());
11496
}
11597

11698
foreach ($this->getAttributesNS() as $attr) {

src/XML/wst_200512/AbstractCancelTargetType.php

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

77
use DOMElement;
88
use SimpleSAML\WSSecurity\Assert\Assert;
9-
use SimpleSAML\XML\Exception\InvalidDOMElementException;
10-
use SimpleSAML\XML\Exception\MissingElementException;
11-
use SimpleSAML\XML\Exception\TooManyElementsException;
129
use SimpleSAML\XML\ExtendableElementTrait;
1310
use SimpleSAML\XML\SerializableElementInterface;
14-
use SimpleSAML\XML\XsNamespace as NS;
11+
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
12+
use SimpleSAML\XMLSchema\Exception\MissingElementException;
13+
use SimpleSAML\XMLSchema\Exception\TooManyElementsException;
14+
use SimpleSAML\XMLSchema\XML\Constants\NS;
1515

1616
use function array_pop;
1717

@@ -46,7 +46,7 @@ final public function __construct(
4646
* @param \DOMElement $xml
4747
* @return static
4848
*
49-
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
49+
* @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
5050
* if the qualified name of the supplied element is wrong
5151
*/
5252
public static function fromXML(DOMElement $xml): static

src/XML/wst_200512/AbstractClaimsType.php

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

77
use DOMElement;
88
use SimpleSAML\WSSecurity\Assert\Assert;
9-
use SimpleSAML\XML\Exception\InvalidDOMElementException;
10-
use SimpleSAML\XML\Exception\SchemaViolationException;
119
use SimpleSAML\XML\ExtendableAttributesTrait;
1210
use SimpleSAML\XML\ExtendableElementTrait;
13-
use SimpleSAML\XML\XsNamespace as NS;
11+
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
12+
use SimpleSAML\XMLSchema\Exception\SchemaViolationException;
13+
use SimpleSAML\XMLSchema\Type\AnyURIValue;
14+
use SimpleSAML\XMLSchema\XML\Constants\NS;
1415

1516
/**
1617
* Class defining the ClaimsType element
@@ -32,26 +33,24 @@ abstract class AbstractClaimsType extends AbstractWstElement
3233
/**
3334
* AbstractClaimsType constructor
3435
*
35-
* @param string|null $dialect
36+
* @param \SimpleSAML\XMLSchema\Type\AnyURIValue|null $dialect
3637
* @param array<\SimpleSAML\XML\SerializableElementInterface> $children
3738
* @param array<\SimpleSAML\XML\Attribute> $namespacedAttributes
3839
*/
3940
final public function __construct(
40-
protected ?string $dialect = null,
41+
protected ?AnyURIValue $dialect = null,
4142
array $children = [],
4243
array $namespacedAttributes = [],
4344
) {
44-
Assert::nullOrValidURI($dialect, SchemaViolationException::class);
45-
4645
$this->setElements($children);
4746
$this->setAttributesNS($namespacedAttributes);
4847
}
4948

5049

5150
/**
52-
* @return string|null
51+
* @return \SimpleSAML\XMLSchema\Type\AnyURIValue|null
5352
*/
54-
public function getDialect(): ?string
53+
public function getDialect(): ?AnyURIValue
5554
{
5655
return $this->dialect;
5756
}
@@ -76,7 +75,7 @@ public function isEmptyElement(): bool
7675
* @param \DOMElement $xml
7776
* @return static
7877
*
79-
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
78+
* @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
8079
* if the qualified name of the supplied element is wrong
8180
*/
8281
public static function fromXML(DOMElement $xml): static
@@ -85,7 +84,7 @@ public static function fromXML(DOMElement $xml): static
8584
Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class);
8685

8786
return new static(
88-
self::getOptionalAttribute($xml, 'Dialect', null),
87+
self::getOptionalAttribute($xml, 'Dialect', AnyURIValue::class, null),
8988
self::getChildElementsFromXML($xml),
9089
self::getAttributesNSFromXML($xml),
9190
);
@@ -103,7 +102,7 @@ public function toXML(?DOMElement $parent = null): DOMElement
103102
$e = parent::instantiateParentElement($parent);
104103

105104
if ($this->getDialect() !== null) {
106-
$e->setAttribute('Dialect', $this->getDialect());
105+
$e->setAttribute('Dialect', $this->getDialect()->getValue());
107106
}
108107

109108
foreach ($this->getElements() as $child) {

src/XML/wst_200512/AbstractComputedKeyOpenEnum.php

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,8 @@
44

55
namespace SimpleSAML\WSSecurity\XML\wst_200512;
66

7-
use DOMElement;
8-
use SimpleSAML\WSSecurity\Assert\Assert;
9-
use SimpleSAML\XML\Exception\InvalidDOMElementException;
10-
use SimpleSAML\XML\Exception\SchemaViolationException;
117
use SimpleSAML\XML\TypedTextContentTrait;
12-
use SimpleSAML\XMLSchema\Type\StringValue;
13-
14-
use function array_map;
15-
use function explode;
16-
use function implode;
8+
use SimpleSAML\XMLSchema\Type\Helper\AnyURIListValue;
179

1810
/**
1911
* A ComputedKeyOpenEnum element
@@ -27,40 +19,5 @@ abstract class AbstractComputedKeyOpenEnum extends AbstractWstElement
2719
use TypedTextContentTrait;
2820

2921
/** @var string */
30-
public const TEXTCONTENT_TYPE = StringValue::class;
31-
32-
33-
/**
34-
* @param (\SimpleSAML\WSSecurity\XML\wst_200512\ComputedKeyEnum|string)[] $values
35-
*/
36-
public function __construct(array $values)
37-
{
38-
$values = array_map(
39-
function (ComputedKeyEnum|string $v): string {
40-
return ($v instanceof ComputedKeyEnum) ? $v->value : $v;
41-
},
42-
$values,
43-
);
44-
Assert::allValidURI($values, SchemaViolationException::class);
45-
46-
$this->setContent(implode(' ', $values));
47-
}
48-
49-
50-
/**
51-
* Convert XML into a class instance
52-
*
53-
* @param \DOMElement $xml The XML element we should load
54-
* @return static
55-
*
56-
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
57-
* If the qualified name of the supplied element is wrong
58-
*/
59-
public static function fromXML(DOMElement $xml): static
60-
{
61-
Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class);
62-
Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class);
63-
64-
return new static(explode(' ', $xml->textContent));
65-
}
22+
public const TEXTCONTENT_TYPE = AnyURIListValue::class;
6623
}

src/XML/wst_200512/AbstractDelegateToType.php

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

77
use DOMElement;
88
use SimpleSAML\WSSecurity\Assert\Assert;
9-
use SimpleSAML\XML\Exception\InvalidDOMElementException;
10-
use SimpleSAML\XML\Exception\MissingElementException;
11-
use SimpleSAML\XML\Exception\TooManyElementsException;
129
use SimpleSAML\XML\ExtendableElementTrait;
1310
use SimpleSAML\XML\SerializableElementInterface;
14-
use SimpleSAML\XML\XsNamespace as NS;
11+
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
12+
use SimpleSAML\XMLSchema\Exception\MissingElementException;
13+
use SimpleSAML\XMLSchema\Exception\TooManyElementsException;
14+
use SimpleSAML\XMLSchema\XML\Constants\NS;
1515

1616
/**
1717
* Class defining the DelegateToType element
@@ -44,7 +44,7 @@ final public function __construct(
4444
* @param \DOMElement $xml
4545
* @return static
4646
*
47-
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
47+
* @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
4848
* if the qualified name of the supplied element is wrong
4949
*/
5050
public static function fromXML(DOMElement $xml): static

src/XML/wst_200512/AbstractEncryptionType.php

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

77
use DOMElement;
88
use SimpleSAML\WSSecurity\Assert\Assert;
9-
use SimpleSAML\XML\Exception\InvalidDOMElementException;
10-
use SimpleSAML\XML\Exception\MissingElementException;
11-
use SimpleSAML\XML\Exception\TooManyElementsException;
129
use SimpleSAML\XML\ExtendableElementTrait;
1310
use SimpleSAML\XML\SerializableElementInterface;
14-
use SimpleSAML\XML\XsNamespace as NS;
11+
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
12+
use SimpleSAML\XMLSchema\Exception\MissingElementException;
13+
use SimpleSAML\XMLSchema\Exception\TooManyElementsException;
14+
use SimpleSAML\XMLSchema\XML\Constants\NS;
1515

1616
/**
1717
* Class defining the EncryptionType element
@@ -44,7 +44,7 @@ final public function __construct(
4444
* @param \DOMElement $xml
4545
* @return static
4646
*
47-
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
47+
* @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
4848
* if the qualified name of the supplied element is wrong
4949
*/
5050
public static function fromXML(DOMElement $xml): static

0 commit comments

Comments
 (0)