Skip to content

Commit b4a6940

Browse files
committed
Make saml:AnyURIList extend generic helper-class for anyURI list-values
1 parent 11a1c44 commit b4a6940

20 files changed

+83
-104
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"psr/http-message": "~2.0",
3232
"psr/log": "~2.3 || ~3.0",
3333
"simplesamlphp/assert": "~1.9",
34-
"simplesamlphp/xml-common": "~2.3",
34+
"simplesamlphp/xml-common": "~2.4",
3535
"simplesamlphp/xml-security": "~2.0",
3636
"simplesamlphp/xml-soap": "~2.0"
3737
},
Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,15 @@
99
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
1010
use SimpleSAML\SAML2\Type\SAMLAnyURIValue;
1111
use SimpleSAML\XMLSchema\Exception\SchemaViolationException;
12-
use SimpleSAML\XMLSchema\Type\Interface\ListTypeInterface;
12+
use SimpleSAML\XMLSchema\Type\Helper\AnyURIListValue;
1313

1414
use function array_map;
1515
use function preg_split;
16-
use function str_replace;
17-
use function trim;
1816

1917
/**
2018
* @package simplesaml/saml2
2119
*/
22-
class AnyURIListValue extends SAMLAnyURIValue implements ListTypeInterface
20+
class SAMLAnyURIListValue extends AnyURIListValue
2321
{
2422
/** @var string */
2523
public const SCHEMA_TYPE = 'AnyURIList';
@@ -42,23 +40,6 @@ protected function validateValue(string $value): void
4240
}
4341

4442

45-
/**
46-
* Convert an array of xs:anyURI items into a saml:AnyURIList
47-
*
48-
* @param string[] $uris
49-
* @return static
50-
*/
51-
public static function fromArray(array $uris): static
52-
{
53-
$str = '';
54-
foreach ($uris as $uri) {
55-
$str .= str_replace(' ', '+', $uri) . ' ';
56-
}
57-
58-
return new static(trim($str));
59-
}
60-
61-
6243
/**
6344
* Convert this saml:AnyURIList to an array of xs:anyURI items
6445
*

src/XML/md/AbstractRoleDescriptor.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use DOMElement;
88
use SimpleSAML\SAML2\Assert\Assert;
99
use SimpleSAML\SAML2\Constants as C;
10-
use SimpleSAML\SAML2\Type\AnyURIListValue;
10+
use SimpleSAML\SAML2\Type\SAMLAnyURIListValue;
1111
use SimpleSAML\SAML2\Type\SAMLAnyURIValue;
1212
use SimpleSAML\SAML2\Type\SAMLDateTimeValue;
1313
use SimpleSAML\SAML2\Utils;
@@ -47,7 +47,7 @@ abstract class AbstractRoleDescriptor extends AbstractRoleDescriptorType impleme
4747
* Initialize a md:RoleDescriptor from scratch.
4848
*
4949
* @param \SimpleSAML\XMLSchema\Type\QNameValue $type
50-
* @param \SimpleSAML\SAML2\Type\AnyURIListValue $protocolSupportEnumeration
50+
* @param \SimpleSAML\SAML2\Type\SAMLAnyURIListValue $protocolSupportEnumeration
5151
* A set of URI specifying the protocols supported.
5252
* @param \SimpleSAML\XMLSchema\Type\IDValue|null $ID The ID for this document. Defaults to null.
5353
* @param \SimpleSAML\SAML2\Type\SAMLDateTimeValue|null $validUntil Unix time of validity for this document.
@@ -67,7 +67,7 @@ abstract class AbstractRoleDescriptor extends AbstractRoleDescriptorType impleme
6767
*/
6868
public function __construct(
6969
protected QNameValue $type,
70-
AnyURIListValue $protocolSupportEnumeration,
70+
SAMLAnyURIListValue $protocolSupportEnumeration,
7171
?IDValue $ID = null,
7272
?SAMLDateTimeValue $validUntil = null,
7373
?DurationValue $cacheDuration = null,
@@ -147,7 +147,7 @@ public static function fromXML(DOMElement $xml): static
147147
return new UnknownRoleDescriptor(
148148
new Chunk($xml),
149149
$type,
150-
self::getAttribute($xml, 'protocolSupportEnumeration', AnyURIListValue::class),
150+
self::getAttribute($xml, 'protocolSupportEnumeration', SAMLAnyURIListValue::class),
151151
self::getOptionalAttribute($xml, 'ID', IDValue::class, null),
152152
self::getOptionalAttribute($xml, 'validUntil', SAMLDateTimeValue::class, null),
153153
self::getOptionalAttribute($xml, 'cacheDuration', DurationValue::class, null),

src/XML/md/AbstractRoleDescriptorType.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,14 @@
77
use DOMElement;
88
use SimpleSAML\SAML2\Assert\Assert;
99
use SimpleSAML\SAML2\Constants as C;
10-
use SimpleSAML\SAML2\Type\AnyURIListValue;
10+
use SimpleSAML\SAML2\Type\SAMLAnyURIListValue;
1111
use SimpleSAML\SAML2\Type\SAMLAnyURIValue;
1212
use SimpleSAML\SAML2\Type\SAMLDateTimeValue;
1313
use SimpleSAML\XML\ExtendableAttributesTrait;
1414
use SimpleSAML\XMLSchema\Type\DurationValue;
1515
use SimpleSAML\XMLSchema\Type\IDValue;
1616
use SimpleSAML\XMLSchema\XML\Constants\NS;
1717

18-
use function strval;
19-
2018
/**
2119
* Class representing SAML2 RoleDescriptorType.
2220
*
@@ -34,7 +32,7 @@ abstract class AbstractRoleDescriptorType extends AbstractMetadataDocument
3432
/**
3533
* Initialize a RoleDescriptor.
3634
*
37-
* @param \SimpleSAML\SAML2\Type\AnyURIListValue $protocolSupportEnumeration
35+
* @param \SimpleSAML\SAML2\Type\SAMLAnyURIListValue $protocolSupportEnumeration
3836
* A set of URI specifying the protocols supported.
3937
* @param \SimpleSAML\XMLSchema\Type\IDValue|null $ID The ID for this document. Defaults to null.
4038
* @param \SimpleSAML\SAML2\Type\SAMLDateTimeValue|null $validUntil Unix time of validity for this document.
@@ -53,7 +51,7 @@ abstract class AbstractRoleDescriptorType extends AbstractMetadataDocument
5351
* @param list<\SimpleSAML\XML\Attribute> $namespacedAttributes
5452
*/
5553
public function __construct(
56-
protected AnyURIListValue $protocolSupportEnumeration,
54+
protected SAMLAnyURIListValue $protocolSupportEnumeration,
5755
?IDValue $ID = null,
5856
?SAMLDateTimeValue $validUntil = null,
5957
?DurationValue $cacheDuration = null,
@@ -97,9 +95,9 @@ public function getErrorURL(): ?SAMLAnyURIValue
9795
/**
9896
* Collect the value of the protocolSupportEnumeration property.
9997
*
100-
* @return \SimpleSAML\SAML2\Type\AnyURIListValue
98+
* @return \SimpleSAML\SAML2\Type\SAMLAnyURIListValue
10199
*/
102-
public function getProtocolSupportEnumeration(): AnyURIListValue
100+
public function getProtocolSupportEnumeration(): SAMLAnyURIListValue
103101
{
104102
return $this->protocolSupportEnumeration;
105103
}
@@ -147,10 +145,10 @@ public function getKeyDescriptor(): array
147145
public function toUnsignedXML(?DOMElement $parent = null): DOMElement
148146
{
149147
$e = parent::toUnsignedXML($parent);
150-
$e->setAttribute('protocolSupportEnumeration', strval($this->getProtocolSupportEnumeration()));
148+
$e->setAttribute('protocolSupportEnumeration', $this->getProtocolSupportEnumeration()->getValue());
151149

152150
if ($this->getErrorURL() !== null) {
153-
$e->setAttribute('errorURL', strval($this->getErrorURL()));
151+
$e->setAttribute('errorURL', $this->getErrorURL()->getValue());
154152
}
155153

156154
foreach ($this->getKeyDescriptor() as $kd) {

src/XML/md/AbstractSSODescriptor.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use DOMElement;
88
use SimpleSAML\SAML2\Assert\Assert;
99
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
10-
use SimpleSAML\SAML2\Type\AnyURIListValue;
10+
use SimpleSAML\SAML2\Type\SAMLAnyURIListValue;
1111
use SimpleSAML\SAML2\Type\SAMLAnyURIValue;
1212
use SimpleSAML\SAML2\Type\SAMLDateTimeValue;
1313
use SimpleSAML\XML\Constants as C;
@@ -24,7 +24,7 @@ abstract class AbstractSSODescriptor extends AbstractRoleDescriptorType
2424
/**
2525
* Initialize a RoleDescriptor.
2626
*
27-
* @param \SimpleSAML\SAML2\Type\AnyURIListValue $protocolSupportEnumeration
27+
* @param \SimpleSAML\SAML2\Type\SAMLAnyURIListValue $protocolSupportEnumeration
2828
* A set of URI specifying the protocols supported.
2929
* @param \SimpleSAML\XMLSchema\Type\IDValue|null $ID The ID for this document. Defaults to null.
3030
* @param \SimpleSAML\SAML2\Type\SAMLDateTimeValue|null $validUntil Unix time of validity for this document.
@@ -50,7 +50,7 @@ abstract class AbstractSSODescriptor extends AbstractRoleDescriptorType
5050
* Defaults to an empty array.
5151
*/
5252
public function __construct(
53-
AnyURIListValue $protocolSupportEnumeration,
53+
SAMLAnyURIListValue $protocolSupportEnumeration,
5454
?IDValue $ID = null,
5555
?SAMLDateTimeValue $validUntil = null,
5656
?DurationValue $cacheDuration = null,

src/XML/md/AttributeAuthorityDescriptor.php

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

77
use DOMElement;
88
use SimpleSAML\SAML2\Assert\Assert;
9-
use SimpleSAML\SAML2\Type\AnyURIListValue;
9+
use SimpleSAML\SAML2\Type\SAMLAnyURIListValue;
1010
use SimpleSAML\SAML2\Type\SAMLAnyURIValue;
1111
use SimpleSAML\SAML2\Type\SAMLDateTimeValue;
1212
use SimpleSAML\SAML2\XML\saml\Attribute;
@@ -35,7 +35,7 @@ final class AttributeAuthorityDescriptor extends AbstractRoleDescriptorType impl
3535
* AttributeAuthorityDescriptor constructor.
3636
*
3737
* @param \SimpleSAML\SAML2\XML\md\AttributeService[] $attributeService
38-
* @param \SimpleSAML\SAML2\Type\AnyURIListValue $protocolSupportEnumeration
38+
* @param \SimpleSAML\SAML2\Type\SAMLAnyURIListValue $protocolSupportEnumeration
3939
* @param \SimpleSAML\SAML2\XML\md\AssertionIDRequestService[] $assertionIDRequestService
4040
* @param \SimpleSAML\SAML2\XML\md\NameIDFormat[] $nameIDFormat
4141
* @param \SimpleSAML\SAML2\XML\md\AttributeProfile[] $attributeProfile
@@ -52,7 +52,7 @@ final class AttributeAuthorityDescriptor extends AbstractRoleDescriptorType impl
5252
*/
5353
public function __construct(
5454
protected array $attributeService,
55-
AnyURIListValue $protocolSupportEnumeration,
55+
SAMLAnyURIListValue $protocolSupportEnumeration,
5656
protected array $assertionIDRequestService = [],
5757
protected array $nameIDFormat = [],
5858
protected array $attributeProfile = [],
@@ -217,7 +217,7 @@ public static function fromXML(DOMElement $xml): static
217217

218218
$authority = new static(
219219
$attrServices,
220-
self::getAttribute($xml, 'protocolSupportEnumeration', AnyURIListValue::class),
220+
self::getAttribute($xml, 'protocolSupportEnumeration', SAMLAnyURIListValue::class),
221221
$assertIDReqServices,
222222
$nameIDFormats,
223223
$attrProfiles,

src/XML/md/AuthnAuthorityDescriptor.php

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

77
use DOMElement;
88
use SimpleSAML\SAML2\Assert\Assert;
9-
use SimpleSAML\SAML2\Type\AnyURIListValue;
9+
use SimpleSAML\SAML2\Type\SAMLAnyURIListValue;
1010
use SimpleSAML\SAML2\Type\SAMLAnyURIValue;
1111
use SimpleSAML\SAML2\Type\SAMLDateTimeValue;
1212
use SimpleSAML\XML\Constants as C;
@@ -32,7 +32,7 @@ final class AuthnAuthorityDescriptor extends AbstractRoleDescriptorType implemen
3232
* AuthnAuthorityDescriptor constructor.
3333
*
3434
* @param array $authnQueryService
35-
* @param \SimpleSAML\SAML2\Type\AnyURIListValue $protocolSupportEnumeration
35+
* @param \SimpleSAML\SAML2\Type\SAMLAnyURIListValue $protocolSupportEnumeration
3636
* @param array $assertionIDRequestService
3737
* @param array $nameIDFormat
3838
* @param \SimpleSAML\XMLSchema\Type\IDValue|null $ID
@@ -47,7 +47,7 @@ final class AuthnAuthorityDescriptor extends AbstractRoleDescriptorType implemen
4747
*/
4848
public function __construct(
4949
protected array $authnQueryService,
50-
AnyURIListValue $protocolSupportEnumeration,
50+
SAMLAnyURIListValue $protocolSupportEnumeration,
5151
protected array $assertionIDRequestService = [],
5252
protected array $nameIDFormat = [],
5353
?IDValue $ID = null,
@@ -172,7 +172,7 @@ public static function fromXML(DOMElement $xml): static
172172

173173
$authority = new static(
174174
$authnQueryServices,
175-
self::getAttribute($xml, 'protocolSupportEnumeration', AnyURIListValue::class),
175+
self::getAttribute($xml, 'protocolSupportEnumeration', SAMLAnyURIListValue::class),
176176
$assertionIDRequestServices,
177177
$nameIDFormats,
178178
self::getOptionalAttribute($xml, 'ID', IDValue::class, null),

src/XML/md/IDPSSODescriptor.php

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

77
use DOMElement;
88
use SimpleSAML\SAML2\Assert\Assert;
9-
use SimpleSAML\SAML2\Type\AnyURIListValue;
9+
use SimpleSAML\SAML2\Type\SAMLAnyURIListValue;
1010
use SimpleSAML\SAML2\Type\SAMLAnyURIValue;
1111
use SimpleSAML\SAML2\Type\SAMLDateTimeValue;
1212
use SimpleSAML\SAML2\XML\saml\Attribute;
@@ -36,7 +36,7 @@ final class IDPSSODescriptor extends AbstractSSODescriptor implements SchemaVali
3636
* IDPSSODescriptor constructor.
3737
*
3838
* @param \SimpleSAML\SAML2\XML\md\SingleSignOnService[] $singleSignOnService
39-
* @param \SimpleSAML\SAML2\Type\AnyURIListValue $protocolSupportEnumeration
39+
* @param \SimpleSAML\SAML2\Type\SAMLAnyURIListValue $protocolSupportEnumeration
4040
* @param \SimpleSAML\XMLSchema\Type\BooleanValue|null $wantAuthnRequestsSigned
4141
* @param \SimpleSAML\SAML2\XML\md\NameIDMappingService[] $nameIDMappingService
4242
* @param \SimpleSAML\SAML2\XML\md\AssertionIDRequestService[] $assertionIDRequestService
@@ -57,7 +57,7 @@ final class IDPSSODescriptor extends AbstractSSODescriptor implements SchemaVali
5757
*/
5858
public function __construct(
5959
protected array $singleSignOnService,
60-
AnyURIListValue $protocolSupportEnumeration,
60+
SAMLAnyURIListValue $protocolSupportEnumeration,
6161
protected ?BooleanValue $wantAuthnRequestsSigned = null,
6262
protected array $nameIDMappingService = [],
6363
protected array $assertionIDRequestService = [],
@@ -232,7 +232,7 @@ public static function fromXML(DOMElement $xml): static
232232

233233
$idpssod = new static(
234234
SingleSignOnService::getChildrenOfClass($xml),
235-
self::getAttribute($xml, 'protocolSupportEnumeration', AnyURIListValue::class),
235+
self::getAttribute($xml, 'protocolSupportEnumeration', SAMLAnyURIListValue::class),
236236
self::getOptionalAttribute($xml, 'WantAuthnRequestsSigned', BooleanValue::class, null),
237237
NameIDMappingService::getChildrenOfClass($xml),
238238
AssertionIDRequestService::getChildrenOfClass($xml),

src/XML/md/PDPDescriptor.php

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

77
use DOMElement;
88
use SimpleSAML\SAML2\Assert\Assert;
9-
use SimpleSAML\SAML2\Type\AnyURIListValue;
9+
use SimpleSAML\SAML2\Type\SAMLAnyURIListValue;
1010
use SimpleSAML\SAML2\Type\SAMLAnyURIValue;
1111
use SimpleSAML\SAML2\Type\SAMLDateTimeValue;
1212
use SimpleSAML\XML\Constants as C;
@@ -32,7 +32,7 @@ final class PDPDescriptor extends AbstractRoleDescriptorType implements SchemaVa
3232
* PDPDescriptor constructor.
3333
*
3434
* @param \SimpleSAML\SAML2\XML\md\AuthzService[] $authzService
35-
* @param \SimpleSAML\SAML2\Type\AnyURIListValue $protocolSupportEnumeration
35+
* @param \SimpleSAML\SAML2\Type\SAMLAnyURIListValue $protocolSupportEnumeration
3636
* @param \SimpleSAML\SAML2\XML\md\AssertionIDRequestService[] $assertionIDRequestService
3737
* @param \SimpleSAML\SAML2\XML\md\NameIDFormat[] $nameIDFormat
3838
* @param \SimpleSAML\XMLSchema\Type\IDValue|null $ID
@@ -47,7 +47,7 @@ final class PDPDescriptor extends AbstractRoleDescriptorType implements SchemaVa
4747
*/
4848
public function __construct(
4949
protected array $authzService,
50-
AnyURIListValue $protocolSupportEnumeration,
50+
SAMLAnyURIListValue $protocolSupportEnumeration,
5151
protected array $assertionIDRequestService = [],
5252
protected array $nameIDFormat = [],
5353
?IDValue $ID = null,
@@ -163,7 +163,7 @@ public static function fromXML(DOMElement $xml): static
163163

164164
$pdp = new static(
165165
AuthzService::getChildrenOfClass($xml),
166-
self::getAttribute($xml, 'protocolSupportEnumeration', AnyURIListValue::class),
166+
self::getAttribute($xml, 'protocolSupportEnumeration', SAMLAnyURIListValue::class),
167167
AssertionIDRequestService::getChildrenOfClass($xml),
168168
NameIDFormat::getChildrenOfClass($xml),
169169
self::getOptionalAttribute($xml, 'ID', IDValue::class, null),

src/XML/md/SPSSODescriptor.php

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

77
use DOMElement;
88
use SimpleSAML\SAML2\Assert\Assert;
9-
use SimpleSAML\SAML2\Type\AnyURIListValue;
9+
use SimpleSAML\SAML2\Type\SAMLAnyURIListValue;
1010
use SimpleSAML\SAML2\Type\SAMLAnyURIValue;
1111
use SimpleSAML\SAML2\Type\SAMLDateTimeValue;
1212
use SimpleSAML\XML\Constants as C;
@@ -36,7 +36,7 @@ final class SPSSODescriptor extends AbstractSSODescriptor implements SchemaValid
3636
* SPSSODescriptor constructor.
3737
*
3838
* @param array<\SimpleSAML\SAML2\XML\md\AssertionConsumerService> $assertionConsumerService
39-
* @param \SimpleSAML\SAML2\Type\AnyURIListValue $protocolSupportEnumeration
39+
* @param \SimpleSAML\SAML2\Type\SAMLAnyURIListValue $protocolSupportEnumeration
4040
* @param \SimpleSAML\XMLSchema\Type\BooleanValue|null $authnRequestsSigned
4141
* @param \SimpleSAML\XMLSchema\Type\BooleanValue|null $wantAssertionsSigned
4242
* @param array<\SimpleSAML\SAML2\XML\md\AttributeConsumingService> $attributeConsumingService
@@ -55,7 +55,7 @@ final class SPSSODescriptor extends AbstractSSODescriptor implements SchemaValid
5555
*/
5656
public function __construct(
5757
protected array $assertionConsumerService,
58-
AnyURIListValue $protocolSupportEnumeration,
58+
SAMLAnyURIListValue $protocolSupportEnumeration,
5959
protected ?BooleanValue $authnRequestsSigned = null,
6060
protected ?BooleanValue $wantAssertionsSigned = null,
6161
protected array $attributeConsumingService = [],
@@ -206,7 +206,7 @@ public static function fromXML(DOMElement $xml): static
206206

207207
$spssod = new static(
208208
AssertionConsumerService::getChildrenOfClass($xml),
209-
self::getAttribute($xml, 'protocolSupportEnumeration', AnyURIListValue::class),
209+
self::getAttribute($xml, 'protocolSupportEnumeration', SAMLAnyURIListValue::class),
210210
self::getOptionalAttribute($xml, 'AuthnRequestsSigned', BooleanValue::class, null),
211211
self::getOptionalAttribute($xml, 'WantAssertionsSigned', BooleanValue::class, null),
212212
AttributeConsumingService::getChildrenOfClass($xml),

0 commit comments

Comments
 (0)