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

Commit 0cf7e13

Browse files
committed
Migrate to xsd-types
1 parent 59476b6 commit 0cf7e13

14 files changed

Lines changed: 71 additions & 34 deletions

src/XML/wsse/AbstractSecurityTokenReferenceType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
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;
1112
use SimpleSAML\XML\ExtendableAttributesTrait;
1213
use SimpleSAML\XML\ExtendableElementTrait;
1314
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
1415
use SimpleSAML\XMLSchema\Type\AnyURIValue;
15-
use SimpleSAML\XMLSchema\Type\IDValue;
1616
use SimpleSAML\XMLSchema\XML\Constants\NS;
1717

1818
use function array_unshift;

src/XML/wsse/AbstractUsernameTokenType.php

Lines changed: 2 additions & 2 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;
1112
use SimpleSAML\XML\ExtendableAttributesTrait;
1213
use SimpleSAML\XML\ExtendableElementTrait;
1314
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
1415
use SimpleSAML\XMLSchema\Exception\MissingElementException;
1516
use SimpleSAML\XMLSchema\Exception\TooManyElementsException;
16-
use SimpleSAML\XMLSchema\Type\IDValue;
1717
use SimpleSAML\XMLSchema\XML\Constants\NS;
1818

1919
use function array_pop;
@@ -128,7 +128,7 @@ public function toXML(?DOMElement $parent = null): DOMElement
128128

129129
$attributes = $this->getAttributesNS();
130130
if ($this->getId() !== null) {
131-
$idAttr = new XMLAttribute(C::NS_SEC_UTIL, 'wsu', 'Id', $this->getId()->getValue());
131+
$idAttr = $this->getId()->toAttribute();
132132
array_unshift($attributes, $idAttr);
133133
}
134134

tests/WSSecurity/XML/wsse/BinarySecurityTokenTest.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@
1212
use SimpleSAML\WSSecurity\XML\wsse\AbstractEncodedString;
1313
use SimpleSAML\WSSecurity\XML\wsse\AbstractWsseElement;
1414
use SimpleSAML\WSSecurity\XML\wsse\BinarySecurityToken;
15+
use SimpleSAML\WSSecurity\XML\wsu\Type\IDValue;
1516
use SimpleSAML\XML\Attribute as XMLAttribute;
1617
use SimpleSAML\XML\DOMDocumentFactory;
1718
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
1819
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
20+
use SimpleSAML\XMLSchema\Type\AnyURIValue;
21+
use SimpleSAML\XMLSchema\Type\StringValue;
1922

2023
use function dirname;
2124
use function strval;
@@ -58,14 +61,14 @@ public static function setUpBeforeClass(): void
5861
public function testMarshalling(): void
5962
{
6063
$content = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=';
61-
$attr1 = new XMLAttribute('urn:x-simplesamlphp:namespace', 'ssp', 'attr1', 'testval1');
64+
$attr1 = new XMLAttribute('urn:x-simplesamlphp:namespace', 'ssp', 'attr1', StringValue::fromString('testval1'));
6265

6366
$binarySecurityToken = new BinarySecurityToken(
64-
$content,
65-
'http://schemas.microsoft.com/5.0.0.0/ConfigurationManager/Enrollment/DeviceEnrollmentUserToken',
66-
'SomeID',
67-
'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd#base64binary',
67+
StringValue::fromString($content),
68+
IDValue::fromString('SomeID'),
6869
[$attr1],
70+
AnyURIValue::fromString('http://schemas.microsoft.com/5.0.0.0/ConfigurationManager/Enrollment/DeviceEnrollmentUserToken'),
71+
AnyURIValue::fromString('http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd#base64binary'),
6972
);
7073

7174
$this->assertEquals(

tests/WSSecurity/XML/wsse/EmbeddedTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
use SimpleSAML\XML\DOMDocumentFactory;
1616
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
1717
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
18+
use SimpleSAML\XMLSchema\Type\AnyURIValue;
19+
use SimpleSAML\XMLSchema\Type\StringValue;
1820

1921
use function dirname;
2022
use function strval;
@@ -54,13 +56,13 @@ public static function setUpBeforeClass(): void
5456
*/
5557
public function testMarshalling(): void
5658
{
57-
$attr1 = new XMLAttribute('urn:x-simplesamlphp:namespace', 'ssp', 'attr1', 'testval1');
59+
$attr1 = new XMLAttribute('urn:x-simplesamlphp:namespace', 'ssp', 'attr1', StringValue::fromString('testval1'));
5860
$child = DOMDocumentFactory::fromString(
5961
'<ssp:Chunk xmlns:ssp="urn:x-simplesamlphp:namespace">SomeChunk</ssp:Chunk>',
6062
);
6163

6264
$embedded = new Embedded(
63-
'http://schemas.microsoft.com/5.0.0.0/ConfigurationManager/Enrollment/DeviceEnrollmentUserToken',
65+
AnyURIValue::fromString('http://schemas.microsoft.com/5.0.0.0/ConfigurationManager/Enrollment/DeviceEnrollmentUserToken'),
6466
[new Chunk($child->documentElement)],
6567
[$attr1],
6668
);

tests/WSSecurity/XML/wsse/KeyIdentifierTest.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@
1212
use SimpleSAML\WSSecurity\XML\wsse\AbstractKeyIdentifierType;
1313
use SimpleSAML\WSSecurity\XML\wsse\AbstractWsseElement;
1414
use SimpleSAML\WSSecurity\XML\wsse\KeyIdentifier;
15+
use SimpleSAML\WSSecurity\XML\wsu\Type\IDValue;
1516
use SimpleSAML\XML\Attribute as XMLAttribute;
1617
use SimpleSAML\XML\DOMDocumentFactory;
1718
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
1819
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
20+
use SimpleSAML\XMLSchema\Type\AnyURIValue;
21+
use SimpleSAML\XMLSchema\Type\StringValue;
1922

2023
use function dirname;
2124
use function strval;
@@ -58,14 +61,14 @@ public static function setUpBeforeClass(): void
5861
public function testMarshalling(): void
5962
{
6063
$content = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=';
61-
$attr1 = new XMLAttribute('urn:x-simplesamlphp:namespace', 'ssp', 'attr1', 'testval1');
64+
$attr1 = new XMLAttribute('urn:x-simplesamlphp:namespace', 'ssp', 'attr1', StringValue::fromString('testval1'));
6265

6366
$keyIdentifier = new KeyIdentifier(
64-
$content,
65-
'http://schemas.microsoft.com/5.0.0.0/ConfigurationManager/Enrollment/DeviceEnrollmentUserToken',
66-
'SomeID',
67-
'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd#base64binary',
67+
StringValue::fromString($content),
68+
IDValue::fromString('SomeID'),
6869
[$attr1],
70+
AnyURIValue::fromString('http://schemas.microsoft.com/5.0.0.0/ConfigurationManager/Enrollment/DeviceEnrollmentUserToken'),
71+
AnyURIValue::fromString('http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd#base64binary'),
6972
);
7073

7174
$this->assertEquals(

tests/WSSecurity/XML/wsse/NonceTest.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@
1111
use SimpleSAML\WSSecurity\XML\wsse\AbstractEncodedString;
1212
use SimpleSAML\WSSecurity\XML\wsse\AbstractWsseElement;
1313
use SimpleSAML\WSSecurity\XML\wsse\Nonce;
14+
use SimpleSAML\WSSecurity\XML\wsu\Type\IDValue;
1415
use SimpleSAML\XML\Attribute as XMLAttribute;
1516
use SimpleSAML\XML\DOMDocumentFactory;
1617
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
1718
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
19+
use SimpleSAML\XMLSchema\Type\AnyURIValue;
20+
use SimpleSAML\XMLSchema\Type\StringValue;
1821

1922
use function dirname;
2023
use function strval;
@@ -56,13 +59,13 @@ public static function setUpBeforeClass(): void
5659
public function testMarshalling(): void
5760
{
5861
$content = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=';
59-
$attr1 = new XMLAttribute('urn:x-simplesamlphp:namespace', 'ssp', 'attr1', 'testval1');
62+
$attr1 = new XMLAttribute('urn:x-simplesamlphp:namespace', 'ssp', 'attr1', StringValue::fromString('testval1'));
6063

6164
$nonce = new Nonce(
62-
$content,
63-
'SomeID',
64-
'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd#base64binary',
65+
StringValue::fromString($content),
66+
IDValue::fromString('SomeID'),
6567
[$attr1],
68+
AnyURIValue::fromString('http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd#base64binary'),
6669
);
6770

6871
$this->assertEquals(

tests/WSSecurity/XML/wsse/PasswordTest.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@
1111
use SimpleSAML\WSSecurity\XML\wsse\AbstractPasswordString;
1212
use SimpleSAML\WSSecurity\XML\wsse\AbstractWsseElement;
1313
use SimpleSAML\WSSecurity\XML\wsse\Password;
14+
use SimpleSAML\WSSecurity\XML\wsu\Type\IDValue;
1415
use SimpleSAML\XML\Attribute as XMLAttribute;
1516
use SimpleSAML\XML\DOMDocumentFactory;
1617
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
18+
use SimpleSAML\XMLSchema\Type\AnyURIValue;
19+
use SimpleSAML\XMLSchema\Type\StringValue;
1720

1821
use function dirname;
1922
use function strval;
@@ -53,8 +56,13 @@ public static function setUpBeforeClass(): void
5356
*/
5457
public function testMarshalling(): void
5558
{
56-
$attr = new XMLAttribute('urn:x-simplesamlphp:namespace', 'ssp', 'attr1', 'testval1');
57-
$password = new Password('secret', 'SomeID', 'SomeType', [$attr]);
59+
$attr = new XMLAttribute('urn:x-simplesamlphp:namespace', 'ssp', 'attr1', StringValue::fromString('testval1'));
60+
$password = new Password(
61+
StringValue::fromString('secret'),
62+
IDValue::fromString('SomeID'),
63+
[$attr],
64+
AnyURIValue::fromString('SomeType'),
65+
);
5866

5967
$this->assertEquals(
6068
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),

tests/WSSecurity/XML/wsse/ReferenceTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
use SimpleSAML\XML\DOMDocumentFactory;
1515
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
1616
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
17+
use SimpleSAML\XMLSchema\Type\AnyURIValue;
18+
use SimpleSAML\XMLSchema\Type\StringValue;
1719

1820
use function dirname;
1921
use function strval;
@@ -53,11 +55,11 @@ public static function setUpBeforeClass(): void
5355
*/
5456
public function testMarshalling(): void
5557
{
56-
$attr1 = new XMLAttribute('urn:x-simplesamlphp:namespace', 'ssp', 'attr1', 'testval1');
58+
$attr1 = new XMLAttribute('urn:x-simplesamlphp:namespace', 'ssp', 'attr1', StringValue::fromString('testval1'));
5759

5860
$reference = new Reference(
59-
'urn:some:uri',
60-
'http://schemas.microsoft.com/5.0.0.0/ConfigurationManager/Enrollment/DeviceEnrollmentUserToken',
61+
AnyURIValue::fromString('urn:some:uri'),
62+
AnyURIValue::fromString('http://schemas.microsoft.com/5.0.0.0/ConfigurationManager/Enrollment/DeviceEnrollmentUserToken'),
6163
[$attr1],
6264
);
6365

tests/WSSecurity/XML/wsse/SecurityTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use SimpleSAML\XML\DOMDocumentFactory;
1616
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
1717
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
18+
use SimpleSAML\XMLSchema\Type\StringValue;
1819

1920
use function dirname;
2021
use function strval;
@@ -54,7 +55,7 @@ public static function setUpBeforeClass(): void
5455
*/
5556
public function testMarshalling(): void
5657
{
57-
$attr1 = new XMLAttribute('urn:x-simplesamlphp:namespace', 'ssp', 'attr1', 'testval1');
58+
$attr1 = new XMLAttribute('urn:x-simplesamlphp:namespace', 'ssp', 'attr1', StringValue::fromString('testval1'));
5859
$child = DOMDocumentFactory::fromString(
5960
'<ssp:Chunk xmlns:ssp="urn:x-simplesamlphp:namespace">SomeChunk</ssp:Chunk>',
6061
);

tests/WSSecurity/XML/wsse/SecurityTokenReferenceTest.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@
1010
use SimpleSAML\WSSecurity\XML\wsse\AbstractSecurityTokenReferenceType;
1111
use SimpleSAML\WSSecurity\XML\wsse\AbstractWsseElement;
1212
use SimpleSAML\WSSecurity\XML\wsse\SecurityTokenReference;
13+
use SimpleSAML\WSSecurity\XML\wsu\Type\IDValue;
1314
use SimpleSAML\XML\Attribute as XMLAttribute;
1415
use SimpleSAML\XML\Chunk;
1516
use SimpleSAML\XML\DOMDocumentFactory;
1617
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
1718
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
19+
use SimpleSAML\XMLSchema\Type\AnyURIValue;
20+
use SimpleSAML\XMLSchema\Type\StringValue;
1821

1922
use function dirname;
2023
use function strval;
@@ -54,14 +57,14 @@ public static function setUpBeforeClass(): void
5457
*/
5558
public function testMarshalling(): void
5659
{
57-
$attr1 = new XMLAttribute('urn:x-simplesamlphp:namespace', 'ssp', 'attr1', 'testval1');
60+
$attr1 = new XMLAttribute('urn:x-simplesamlphp:namespace', 'ssp', 'attr1', StringValue::fromString('testval1'));
5861
$child = DOMDocumentFactory::fromString(
5962
'<ssp:Chunk xmlns:ssp="urn:x-simplesamlphp:namespace">SomeChunk</ssp:Chunk>',
6063
);
6164

6265
$securityTokenReference = new SecurityTokenReference(
63-
'SomeID',
64-
'SomeUsage',
66+
IDValue::fromString('SomeID'),
67+
AnyURIValue::fromString('SomeUsage'),
6568
[new Chunk($child->documentElement)],
6669
[$attr1],
6770
);

0 commit comments

Comments
 (0)