66
77use DOMElement ;
88use SimpleSAML \SAML2 \Assert \Assert ;
9- use SimpleSAML \SAML2 \Assert \Assert as SAMLAssert ;
109use SimpleSAML \SAML2 \Constants as C ;
11- use SimpleSAML \SAML2 \Type \{ SAMLAnyURIValue , SAMLDateTimeValue } ;
12- use SimpleSAML \XML \ Exception \ SchemaViolationException ;
10+ use SimpleSAML \SAML2 \Exception \ ProtocolViolationException ;
11+ use SimpleSAML \SAML2 \ Type \{ AnyURIListValue , SAMLAnyURIValue , SAMLDateTimeValue } ;
1312use SimpleSAML \XML \ExtendableAttributesTrait ;
1413use SimpleSAML \XML \Type \{DurationValue , IDValue };
1514use SimpleSAML \XML \XsNamespace as NS ;
1615
17- use function implode ;
16+ use function strval ;
1817
1918/**
2019 * Class representing SAML2 RoleDescriptorType.
@@ -33,7 +32,8 @@ abstract class AbstractRoleDescriptorType extends AbstractMetadataDocument
3332 /**
3433 * Initialize a RoleDescriptor.
3534 *
36- * @param string[] $protocolSupportEnumeration A set of URI specifying the protocols supported.
35+ * @param \SimpleSAML\SAML2\Type\AnyURIListValue $protocolSupportEnumeration
36+ * A set of URI specifying the protocols supported.
3737 * @param \SimpleSAML\XML\Type\IDValue|null $ID The ID for this document. Defaults to null.
3838 * @param \SimpleSAML\SAML2\Type\SAMLDateTimeValue|null $validUntil Unix time of validity for this document.
3939 * Defaults to null.
@@ -51,7 +51,7 @@ abstract class AbstractRoleDescriptorType extends AbstractMetadataDocument
5151 * @param list<\SimpleSAML\XML\Attribute> $namespacedAttributes
5252 */
5353 public function __construct (
54- protected array $ protocolSupportEnumeration ,
54+ protected AnyURIListValue $ protocolSupportEnumeration ,
5555 ?IDValue $ ID = null ,
5656 ?SAMLDateTimeValue $ validUntil = null ,
5757 ?DurationValue $ cacheDuration = null ,
@@ -62,13 +62,18 @@ public function __construct(
6262 protected array $ contact = [],
6363 array $ namespacedAttributes = [],
6464 ) {
65- Assert::maxCount ($ protocolSupportEnumeration , C::UNBOUNDED_LIMIT );
66- Assert::minCount (
67- $ protocolSupportEnumeration ,
68- 1 ,
69- 'At least one protocol must be supported by this ' . static ::NS_PREFIX . ': ' . static ::getLocalName () . '. ' ,
65+ /**
66+ * A whitespace-delimited set of URIs that identify the set of protocol specifications supported by the
67+ * role element. For SAML V2.0 entities, this set MUST include the SAML protocol namespace URI,
68+ * urn:oasis:names:tc:SAML:2.0:protocol.
69+ */
70+ Assert::contains (
71+ strval ($ protocolSupportEnumeration ),
72+ C::NS_SAMLP ,
73+ 'SAML v2.0 entities MUST include the SAML protocol namespace URI in their '
74+ . ' protocolSupportEnumeration attribute ' ,
75+ ProtocolViolationException::class,
7076 );
71- SAMLAssert::allValidURI ($ protocolSupportEnumeration , SchemaViolationException::class);
7277 Assert::maxCount ($ contact , C::UNBOUNDED_LIMIT );
7378 Assert::allIsInstanceOf (
7479 $ contact ,
@@ -102,9 +107,9 @@ public function getErrorURL(): ?SAMLAnyURIValue
102107 /**
103108 * Collect the value of the protocolSupportEnumeration property.
104109 *
105- * @return string[]
110+ * @return \SimpleSAML\SAML2\Type\AnyURIListValue
106111 */
107- public function getProtocolSupportEnumeration (): array
112+ public function getProtocolSupportEnumeration (): AnyURIListValue
108113 {
109114 return $ this ->protocolSupportEnumeration ;
110115 }
@@ -152,10 +157,10 @@ public function getKeyDescriptor(): array
152157 public function toUnsignedXML (?DOMElement $ parent = null ): DOMElement
153158 {
154159 $ e = parent ::toUnsignedXML ($ parent );
155- $ e ->setAttribute ('protocolSupportEnumeration ' , implode ( ' ' , $ this ->getProtocolSupportEnumeration ()));
160+ $ e ->setAttribute ('protocolSupportEnumeration ' , strval ( $ this ->getProtocolSupportEnumeration ()));
156161
157162 if ($ this ->getErrorURL () !== null ) {
158- $ e ->setAttribute ('errorURL ' , $ this ->getErrorURL ()-> getValue ( ));
163+ $ e ->setAttribute ('errorURL ' , strval ( $ this ->getErrorURL ()));
159164 }
160165
161166 foreach ($ this ->getKeyDescriptor () as $ kd ) {
0 commit comments