66
77use DOMElement ;
88use SimpleSAML \WSSecurity \Assert \Assert ;
9+ use SimpleSAML \WSSecurity \XML \sp_200507 \Type \IncludeTokenValue ;
910use SimpleSAML \XML \ExtendableAttributesTrait ;
1011use SimpleSAML \XML \ExtendableElementTrait ;
1112use SimpleSAML \XMLSchema \Exception \InvalidDOMElementException ;
1213use SimpleSAML \XMLSchema \Exception \MissingElementException ;
1314use SimpleSAML \XMLSchema \Exception \TooManyElementsException ;
14- use SimpleSAML \XMLSchema \Type \StringValue ;
1515use SimpleSAML \XMLSchema \XML \Constants \NS ;
16- use ValueError ;
1716
1817use function array_pop ;
19- use function is_string ;
2018use function sprintf ;
2119
2220/**
@@ -48,14 +46,14 @@ abstract class AbstractIssuedTokenType extends AbstractSpElement
4846 *
4947 * @param \SimpleSAML\WSSecurity\XML\sp_200507\RequestSecurityTokenTemplate $requestSecurityTokenTemplate
5048 * @param \SimpleSAML\WSSecurity\XML\sp_200507\Issuer|null $issuer
51- * @param \SimpleSAML\WSSecurity\XML\sp_200507\IncludeToken|string |null $includeToken
49+ * @param \SimpleSAML\WSSecurity\XML\sp_200507\Type\IncludeTokenValue |null $includeToken
5250 * @param list<\SimpleSAML\XML\SerializableElementInterface> $elts
5351 * @param list<\SimpleSAML\XML\Attribute> $namespacedAttributes
5452 */
5553 final public function __construct (
5654 protected RequestSecurityTokenTemplate $ requestSecurityTokenTemplate ,
5755 protected ?Issuer $ issuer = null ,
58- IncludeToken | string | null $ includeToken = null ,
56+ ? IncludeTokenValue $ includeToken = null ,
5957 array $ elts = [],
6058 array $ namespacedAttributes = [],
6159 ) {
@@ -114,16 +112,10 @@ public static function fromXML(DOMElement $xml): static
114112 Assert::minCount ($ requestSecurityTokenTemplate , 1 , MissingElementException::class);
115113 Assert::maxCount ($ requestSecurityTokenTemplate , 1 , TooManyElementsException::class);
116114
117- $ includeToken = self ::getOptionalAttribute ($ xml , 'IncludeToken ' , StringValue::class, null );
118- try {
119- $ includeToken = IncludeToken::from ($ includeToken ->getValue ());
120- } catch (ValueError ) {
121- }
122-
123115 return new static (
124116 $ requestSecurityTokenTemplate [0 ],
125117 array_pop ($ issuer ),
126- $ includeToken ,
118+ self :: getOptionalAttribute ( $ xml , ' IncludeToken ' , IncludeTokenValue::class, null ) ,
127119 self ::getChildElementsFromXML ($ xml ),
128120 self ::getAttributesNSFromXML ($ xml ),
129121 );
@@ -141,10 +133,7 @@ public function toXML(?DOMElement $parent = null): DOMElement
141133 $ e = $ this ->instantiateParentElement ($ parent );
142134
143135 if ($ this ->getIncludeToken () !== null ) {
144- $ e ->setAttribute (
145- 'IncludeToken ' ,
146- is_string ($ this ->getIncludeToken ()) ? $ this ->getIncludeToken () : $ this ->getIncludeToken ()->value ,
147- );
136+ $ e ->setAttribute ('IncludeToken ' , $ this ->getIncludeToken ()->getValue ());
148137 }
149138
150139 if ($ this ->getIssuer () !== null ) {
@@ -154,7 +143,6 @@ public function toXML(?DOMElement $parent = null): DOMElement
154143 $ this ->getRequestSecurityTokenTemplate ()->toXML ($ e );
155144
156145 foreach ($ this ->getElements () as $ elt ) {
157- /** @psalm-var \SimpleSAML\XML\SerializableElementInterface $elt */
158146 $ elt ->toXML ($ e );
159147 }
160148
0 commit comments