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

Commit b997e24

Browse files
committed
Migrate to xsd-types
1 parent 3fd7bc7 commit b997e24

119 files changed

Lines changed: 476 additions & 366 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/Constants.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class Constants extends \SimpleSAML\SAML2\Constants
1616
* The namespace for WS-Addressing protocol.
1717
*/
1818
public const NS_ADDR_200408 = 'http://schemas.xmlsoap.org/ws/2004/08/addressing';
19+
1920
public const NS_ADDR_200508 = 'http://www.w3.org/2005/08/addressing';
2021

2122
/**
@@ -37,6 +38,7 @@ class Constants extends \SimpleSAML\SAML2\Constants
3738
* The namespace for WS-Trust protocol.
3839
*/
3940
public const NS_TRUST_200502 = 'http://schemas.xmlsoap.org/ws/2005/02/trust';
41+
4042
public const NS_TRUST_200512 = 'http://docs.oasis-open.org/ws-sx/ws-trust/200512/';
4143

4244
/**
@@ -48,6 +50,7 @@ class Constants extends \SimpleSAML\SAML2\Constants
4850
* The namespace for the Web Service Security Policy protocol.
4951
*/
5052
public const NS_SEC_POLICY_11 = 'http://schemas.xmlsoap.org/ws/2005/07/securitypolicy';
53+
5154
public const NS_SEC_POLICY_12 = 'http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702';
5255

5356
/**
@@ -79,15 +82,25 @@ class Constants extends \SimpleSAML\SAML2\Constants
7982
* The schema-defined wsa fault codes
8083
*/
8184
public const WSA_FAULT_INVALID_ADDRESSING_HEADER = 'InvalidAddressingHeader';
85+
8286
public const WSA_FAULT_INVALID_ADDRESS = 'InvalidAddress';
87+
8388
public const WSA_FAULT_INVALID_EPR = 'InvalidEPR';
89+
8490
public const WSA_FAULT_INVALID_CARDINALITY = 'InvalidCardinality';
91+
8592
public const WSA_FAULT_MISSING_ADDRESS_IN_EPR = 'MissingAddressInEPR';
93+
8694
public const WSA_FAULT_DUPLICATE_MESSAGEID = 'DupicateMessageID';
95+
8796
public const WSA_FAULT_ACTION_MISMATCH = 'ActionMismatch';
97+
8898
public const WSA_FAULT_MESSAGE_ADDRESSING_HEADER_REQUIRED = 'MessageAddressingHeaderRequired';
99+
89100
public const WSA_FAULT_DESTINATION_UNREACHABLE = 'DestinationUnreachable';
101+
90102
public const WSA_FAULT_ACTION_NOT_SUPPORTED = 'ActionNotSupported';
103+
91104
public const WSA_FAULT_ENDPOINT_UNAVAILABLE = 'EndpointUnavailable';
92105

93106
public const FAULT_CODES = [
@@ -107,6 +120,7 @@ class Constants extends \SimpleSAML\SAML2\Constants
107120
/**
108121
*/
109122
public const WST_REFID_PIN = 'http://docs.oasis-open.org/ws-sx/ws-trust/200802/challenge/PIN';
123+
110124
public const WST_REFID_OTP = 'http://docs.oasis-open.org/ws-sx/ws-trust/200802/challenge/OTP';
111125

112126
/**

src/XML/wst_200512/AbstractKeyTypeOpenEnum.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
use SimpleSAML\WSSecurity\Assert\Assert;
99
use SimpleSAML\XML\Exception\InvalidDOMElementException;
1010
use SimpleSAML\XML\Exception\SchemaViolationException;
11-
use SimpleSAML\XML\StringElementTrait;
11+
use SimpleSAML\XML\TypedTextContentTrait;
12+
use SimpleSAML\XMLSchema\Type\StringValue;
1213

1314
use function array_map;
1415
use function explode;
@@ -23,7 +24,11 @@
2324
*/
2425
abstract class AbstractKeyTypeOpenEnum extends AbstractWstElement
2526
{
26-
use StringElementTrait;
27+
use TypedTextContentTrait;
28+
29+
30+
/** @var string */
31+
public const TEXTCONTENT_TYPE = StringValue::class;
2732

2833

2934
/**
@@ -39,7 +44,7 @@ function (KeyTypeEnum|string $v): string {
3944
);
4045
Assert::allValidURI($values, SchemaViolationException::class);
4146

42-
$this->setContent(implode(' ', $values));
47+
$this->setContent(StringValue::fromString(implode(' ', $values)));
4348
}
4449

4550

src/XML/wst_200512/AbstractRequestTypeOpenEnum.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
use SimpleSAML\WSSecurity\Assert\Assert;
99
use SimpleSAML\XML\Exception\InvalidDOMElementException;
1010
use SimpleSAML\XML\Exception\SchemaViolationException;
11-
use SimpleSAML\XML\StringElementTrait;
11+
use SimpleSAML\XML\TypedTextContentTrait;
12+
use SimpleSAML\XMLSchema\Type\StringValue;
1213

1314
use function array_map;
1415
use function explode;
@@ -23,7 +24,11 @@
2324
*/
2425
abstract class AbstractRequestTypeOpenEnum extends AbstractWstElement
2526
{
26-
use StringElementTrait;
27+
use TypedTextContentTrait;
28+
29+
30+
/** @var string */
31+
public const TEXTCONTENT_TYPE = StringValue::class;
2732

2833

2934
/**
@@ -39,7 +44,7 @@ function (RequestTypeEnum|string $v): string {
3944
);
4045
Assert::allValidURI($values, SchemaViolationException::class);
4146

42-
$this->setContent(implode(' ', $values));
47+
$this->setContent(StringValue::fromString(implode(' ', $values)));
4348
}
4449

4550

src/XML/wst_200512/Delegatable.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44

55
namespace SimpleSAML\WSSecurity\XML\wst_200512;
66

7-
use SimpleSAML\XML\BooleanElementTrait;
8-
use SimpleSAML\XML\{SchemaValidatableElementInterface, SchemaValidatableElementTrait};
7+
use SimpleSAML\XML\TypedTextContentTrait;
8+
use SimpleSAML\XML\SchemaValidatableElementInterface;
9+
use SimpleSAML\XML\SchemaValidatableElementTrait;
910

1011
/**
1112
* A Delegatable element
@@ -14,15 +15,10 @@
1415
*/
1516
final class Delegatable extends AbstractWstElement implements SchemaValidatableElementInterface
1617
{
17-
use BooleanElementTrait;
18+
use TypedTextContentTrait;
1819
use SchemaValidatableElementTrait;
1920

2021

21-
/**
22-
* @param string $content
23-
*/
24-
public function __construct(string $content)
25-
{
26-
$this->setContent($content);
27-
}
22+
/** @var string */
23+
public const TEXTCONTENT_TYPE = BooleanValue::class;
2824
}

src/XML/wst_200512/EncryptWith.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44

55
namespace SimpleSAML\WSSecurity\XML\wst_200512;
66

7-
use SimpleSAML\XML\{SchemaValidatableElementInterface, SchemaValidatableElementTrait};
8-
use SimpleSAML\XML\URIElementTrait;
7+
use SimpleSAML\XML\SchemaValidatableElementInterface;
8+
use SimpleSAML\XML\SchemaValidatableElementTrait;
9+
use SimpleSAML\XML\TypedTextContentTrait;
10+
use SimpleSAML\XMLSchema\Type\AnyURIValue;
911

1012
/**
1113
* An EncryptWith element
@@ -15,14 +17,9 @@
1517
final class EncryptWith extends AbstractWstElement implements SchemaValidatableElementInterface
1618
{
1719
use SchemaValidatableElementTrait;
18-
use URIElementTrait;
20+
use TypedTextContentTrait;
1921

2022

21-
/**
22-
* @param string $content
23-
*/
24-
public function __construct(string $content)
25-
{
26-
$this->setContent($content);
27-
}
23+
/** @var string */
24+
public const TEXTCONTENT_TYPE = AnyURIValue::class;
2825
}

src/XML/wst_200512/EncryptionAlgorithm.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44

55
namespace SimpleSAML\WSSecurity\XML\wst_200512;
66

7-
use SimpleSAML\XML\{SchemaValidatableElementInterface, SchemaValidatableElementTrait};
8-
use SimpleSAML\XML\URIElementTrait;
7+
use SimpleSAML\XML\SchemaValidatableElementInterface;
8+
use SimpleSAML\XML\SchemaValidatableElementTrait;
9+
use SimpleSAML\XML\TypedTextContentTrait;
10+
use SimpleSAML\XMLSchema\Type\AnyURIValue;
911

1012
/**
1113
* A EncryptionAlgorithm element
@@ -15,14 +17,9 @@
1517
final class EncryptionAlgorithm extends AbstractWstElement implements SchemaValidatableElementInterface
1618
{
1719
use SchemaValidatableElementTrait;
18-
use URIElementTrait;
20+
use TypedTextContentTrait;
1921

2022

21-
/**
22-
* @param string $content
23-
*/
24-
public function __construct(string $content)
25-
{
26-
$this->setContent($content);
27-
}
23+
/** @var string */
24+
public const TEXTCONTENT_TYPE = AnyURIValue::class;
2825
}

src/XML/wst_200512/Forwardable.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44

55
namespace SimpleSAML\WSSecurity\XML\wst_200512;
66

7-
use SimpleSAML\XML\BooleanElementTrait;
8-
use SimpleSAML\XML\{SchemaValidatableElementInterface, SchemaValidatableElementTrait};
7+
use SimpleSAML\XML\SchemaValidatableElementInterface;
8+
use SimpleSAML\XML\SchemaValidatableElementTrait;
9+
use SimpleSAML\XML\TypedTextContentTrait;
10+
use SimpleSAML\XMLSchema\Type\BooleanValue
911

1012
/**
1113
* A Forwardable element
@@ -14,15 +16,10 @@
1416
*/
1517
final class Forwardable extends AbstractWstElement implements SchemaValidatableElementInterface
1618
{
17-
use BooleanElementTrait;
1819
use SchemaValidatableElementTrait;
20+
use TypedTextContentTrait;
1921

2022

21-
/**
22-
* @param string $content
23-
*/
24-
public function __construct(string $content)
25-
{
26-
$this->setContent($content);
27-
}
23+
/** @var string */
24+
public const TEXTCONTENT_TYPE = BooleanValue::class;
2825
}

src/XML/wst_200512/KeySize.php

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

77
use SimpleSAML\WSSecurity\Assert\Assert;
88
use SimpleSAML\XML\Exception\SchemaViolationException;
9-
use SimpleSAML\XML\IntegerElementTrait;
10-
use SimpleSAML\XML\{SchemaValidatableElementInterface, SchemaValidatableElementTrait};
9+
use SimpleSAML\XML\SchemaValidatableElementInterface;
10+
use SimpleSAML\XML\SchemaValidatableElementTrait;
11+
use SimpleSAML\XML\TypedTextContentTrait;
12+
use SimpleSAML\XMLSchema\Type\UnsignedIntValue;
1113

1214
/**
1315
* Class representing WS-trust KeySize.
@@ -16,32 +18,10 @@
1618
*/
1719
final class KeySize extends AbstractWstElement implements SchemaValidatableElementInterface
1820
{
19-
use IntegerElementTrait;
2021
use SchemaValidatableElementTrait;
22+
use TypedTextContentTrait;
2123

2224

23-
/**
24-
* KeySize constructor.
25-
*
26-
* @param string $value The long.
27-
*/
28-
final public function __construct(string $value)
29-
{
30-
$this->setContent($value);
31-
}
32-
33-
34-
/**
35-
* Validate the content of the element.
36-
*
37-
* @param string $content The value to go in the XML textContent
38-
* @throws \SimpleSAML\XML\Exception\SchemaViolationException on failure
39-
* @return void
40-
*/
41-
protected function validateContent(string $content): void
42-
{
43-
$content = intval($content);
44-
Assert::natural($content, SchemaViolationException::class);
45-
Assert::range($content, 0, 4294967295, SchemaViolationException::class);
46-
}
25+
/** @var string */
26+
public const TEXTCONTENT_TYPE = UnsignedIntValue::class;
4727
}

src/XML/wst_200512/KeyWrapAlgorithm.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44

55
namespace SimpleSAML\WSSecurity\XML\wst_200512;
66

7-
use SimpleSAML\XML\{SchemaValidatableElementInterface, SchemaValidatableElementTrait};
8-
use SimpleSAML\XML\URIElementTrait;
7+
use SimpleSAML\XML\SchemaValidatableElementInterface;
8+
use SimpleSAML\XML\SchemaValidatableElementTrait;
9+
use SimpleSAML\XML\TypedTextContentTrait;
10+
use SimpleSAML\XMLSchema\Type\AnyURIValue;
911

1012
/**
1113
* A KeyWrapAlgorithm element
@@ -15,14 +17,9 @@
1517
final class KeyWrapAlgorithm extends AbstractWstElement implements SchemaValidatableElementInterface
1618
{
1719
use SchemaValidatableElementTrait;
18-
use URIElementTrait;
20+
use TypedTextContentTrait;
1921

2022

21-
/**
22-
* @param string $content
23-
*/
24-
public function __construct(string $content)
25-
{
26-
$this->setContent($content);
27-
}
23+
/** @var string */
24+
public const TEXTCONTENT_TYPE = AnyURIValue::class;
2825
}

src/XML/wst_200512/Reason.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
namespace SimpleSAML\WSSecurity\XML\wst_200512;
66

7-
use SimpleSAML\XML\StringElementTrait;
7+
use SimpleSAML\XML\TypedTextContentTrait;
8+
use SimpleSAML\XMLSchema\Type\StringValue;
89

910
/**
1011
* A Reason element
@@ -13,14 +14,9 @@
1314
*/
1415
final class Reason extends AbstractWstElement
1516
{
16-
use StringElementTrait;
17+
use TypedTextContentTrait;
1718

1819

19-
/**
20-
* @param string $content
21-
*/
22-
public function __construct(string $content)
23-
{
24-
$this->setContent($content);
25-
}
20+
/** @var string */
21+
public const TEXTCONTENT_TYPE = StringValue::class;
2622
}

0 commit comments

Comments
 (0)