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.
@@ -32,7 +31,8 @@ abstract class AbstractRoleDescriptorType extends AbstractMetadataDocument
3231 /**
3332 * Initialize a RoleDescriptor.
3433 *
35- * @param string[] $protocolSupportEnumeration A set of URI specifying the protocols supported.
34+ * @param \SimpleSAML\SAML2\Type\AnyURIListValue $protocolSupportEnumeration
35+ * A set of URI specifying the protocols supported.
3636 * @param \SimpleSAML\XML\Type\IDValue|null $ID The ID for this document. Defaults to null.
3737 * @param \SimpleSAML\SAML2\Type\SAMLDateTimeValue|null $validUntil Unix time of validity for this document.
3838 * Defaults to null.
@@ -50,7 +50,7 @@ abstract class AbstractRoleDescriptorType extends AbstractMetadataDocument
5050 * @param list<\SimpleSAML\XML\Attribute> $namespacedAttributes
5151 */
5252 public function __construct (
53- protected array $ protocolSupportEnumeration ,
53+ protected AnyURIListValue $ protocolSupportEnumeration ,
5454 ?IDValue $ ID = null ,
5555 ?SAMLDateTimeValue $ validUntil = null ,
5656 ?DurationValue $ cacheDuration = null ,
@@ -61,13 +61,18 @@ public function __construct(
6161 protected array $ contact = [],
6262 array $ namespacedAttributes = [],
6363 ) {
64- Assert::maxCount ($ protocolSupportEnumeration , C::UNBOUNDED_LIMIT );
65- Assert::minCount (
66- $ protocolSupportEnumeration ,
67- 1 ,
68- 'At least one protocol must be supported by this ' . static ::NS_PREFIX . ': ' . static ::getLocalName () . '. ' ,
64+ /**
65+ * A whitespace-delimited set of URIs that identify the set of protocol specifications supported by the
66+ * role element. For SAML V2.0 entities, this set MUST include the SAML protocol namespace URI,
67+ * urn:oasis:names:tc:SAML:2.0:protocol.
68+ */
69+ Assert::contains (
70+ strval ($ protocolSupportEnumeration ),
71+ C::NS_SAMLP ,
72+ 'SAML v2.0 entities MUST include the SAML protocol namespace URI in their '
73+ . ' protocolSupportEnumeration attribute ' ,
74+ ProtocolViolationException::class,
6975 );
70- SAMLAssert::allValidURI ($ protocolSupportEnumeration , SchemaViolationException::class);
7176 Assert::maxCount ($ contact , C::UNBOUNDED_LIMIT );
7277 Assert::allIsInstanceOf (
7378 $ contact ,
@@ -101,9 +106,9 @@ public function getErrorURL(): ?SAMLAnyURIValue
101106 /**
102107 * Collect the value of the protocolSupportEnumeration property.
103108 *
104- * @return string[]
109+ * @return \SimpleSAML\SAML2\Type\AnyURIListValue
105110 */
106- public function getProtocolSupportEnumeration (): array
111+ public function getProtocolSupportEnumeration (): AnyURIListValue
107112 {
108113 return $ this ->protocolSupportEnumeration ;
109114 }
@@ -151,10 +156,10 @@ public function getKeyDescriptor(): array
151156 public function toUnsignedXML (?DOMElement $ parent = null ): DOMElement
152157 {
153158 $ e = parent ::toUnsignedXML ($ parent );
154- $ e ->setAttribute ('protocolSupportEnumeration ' , implode ( ' ' , $ this ->getProtocolSupportEnumeration ()));
159+ $ e ->setAttribute ('protocolSupportEnumeration ' , strval ( $ this ->getProtocolSupportEnumeration ()));
155160
156161 if ($ this ->getErrorURL () !== null ) {
157- $ e ->setAttribute ('errorURL ' , $ this ->getErrorURL ()-> getValue ( ));
162+ $ e ->setAttribute ('errorURL ' , strval ( $ this ->getErrorURL ()));
158163 }
159164
160165 foreach ($ this ->getKeyDescriptor () as $ kd ) {
0 commit comments