diff --git a/src/XML/sp_200702/AbstractIssuedTokenType.php b/src/XML/sp_200702/AbstractIssuedTokenType.php index b8da24c9..554946de 100644 --- a/src/XML/sp_200702/AbstractIssuedTokenType.php +++ b/src/XML/sp_200702/AbstractIssuedTokenType.php @@ -27,7 +27,6 @@ abstract class AbstractIssuedTokenType extends AbstractSpElement { use ExtendableAttributesTrait; use ExtendableElementTrait; - use IncludeTokenTypeTrait; /** The namespace-attribute for the xs:any element */ public const XS_ANY_ELT_NAMESPACE = NS::OTHER; @@ -35,29 +34,21 @@ abstract class AbstractIssuedTokenType extends AbstractSpElement /** The namespace-attribute for the xs:anyAttribute element */ public const XS_ANY_ATTR_NAMESPACE = NS::ANY; - /** The exclusions for the xs:anyAttribute element */ - public const XS_ANY_ATTR_EXCLUSIONS = [ - [null, 'IncludeToken'], - ]; - /** * IssuedTokenType constructor. * * @param \SimpleSAML\WSSecurity\XML\sp_200702\RequestSecurityTokenTemplate $requestSecurityTokenTemplate * @param \SimpleSAML\WSSecurity\XML\sp_200702\Issuer|\SimpleSAML\WSSecurity\XML\sp_200702\IssuerName|null $issuer - * @param \SimpleSAML\WSSecurity\XML\sp_200702\IncludeToken|null $includeToken * @param list<\SimpleSAML\XML\SerializableElementInterface> $elts * @param list<\SimpleSAML\XML\Attribute> $namespacedAttributes */ final public function __construct( protected RequestSecurityTokenTemplate $requestSecurityTokenTemplate, protected Issuer|IssuerName|null $issuer = null, - ?IncludeToken $includeToken = null, array $elts = [], array $namespacedAttributes = [], ) { - $this->setIncludeToken($includeToken); $this->setElements($elts); $this->setAttributesNS($namespacedAttributes); } @@ -114,16 +105,9 @@ public static function fromXML(DOMElement $xml): static Assert::minCount($requestSecurityTokenTemplate, 1, MissingElementException::class); Assert::maxCount($requestSecurityTokenTemplate, 1, TooManyElementsException::class); - $includeToken = self::getOptionalAttribute($xml, 'IncludeToken', null); - try { - $includeToken = IncludeToken::from($includeToken); - } catch (ValueError) { - } - return new static( $requestSecurityTokenTemplate[0], array_pop($issuer), - $includeToken, self::getChildElementsFromXML($xml), self::getAttributesNSFromXML($xml), ); @@ -140,13 +124,6 @@ public function toXML(DOMElement $parent = null): DOMElement { $e = $this->instantiateParentElement($parent); - if ($this->getIncludeToken() !== null) { - $e->setAttribute( - 'IncludeToken', - is_string($this->getIncludeToken()) ? $this->getIncludeToken() : $this->getIncludeToken()->value, - ); - } - if ($this->getIssuer() !== null) { $this->getIssuer()->toXML($e); } diff --git a/src/XML/sp_200702/AbstractKeyValueTokenType.php b/src/XML/sp_200702/AbstractKeyValueTokenType.php index be65449b..c8fb4fbd 100644 --- a/src/XML/sp_200702/AbstractKeyValueTokenType.php +++ b/src/XML/sp_200702/AbstractKeyValueTokenType.php @@ -24,7 +24,6 @@ abstract class AbstractKeyValueTokenType extends AbstractSpElement { use ExtendableAttributesTrait; use ExtendableElementTrait; - use IncludeTokenTypeTrait; /** The namespace-attribute for the xs:any element */ public const XS_ANY_ELT_NAMESPACE = NS::OTHER; @@ -32,25 +31,17 @@ abstract class AbstractKeyValueTokenType extends AbstractSpElement /** The namespace-attribute for the xs:anyAttribute element */ public const XS_ANY_ATTR_NAMESPACE = NS::ANY; - /** The exclusions for the xs:anyAttribute element */ - public const XS_ANY_ATTR_EXCLUSIONS = [ - [null, 'IncludeToken'], - ]; - /** * KeyValueTokenType constructor. * - * @param \SimpleSAML\WSSecurity\XML\sp_200702\IncludeToken|null $includeToken * @param list<\SimpleSAML\XML\SerializableElementInterface> $elts * @param list<\SimpleSAML\XML\Attribute> $namespacedAttributes */ final public function __construct( - ?IncludeToken $includeToken = null, array $elts = [], array $namespacedAttributes = [], ) { - $this->setIncludeToken($includeToken); $this->setElements($elts); $this->setAttributesNS($namespacedAttributes); } @@ -63,8 +54,7 @@ final public function __construct( */ public function isEmptyElement(): bool { - return empty($this->getIncludeToken()) - && empty($this->getAttributesNS()) + return empty($this->getAttributesNS()) && empty($this->getElements()); } @@ -90,14 +80,7 @@ public static function fromXML(DOMElement $xml): static InvalidDOMElementException::class, ); - $includeToken = self::getOptionalAttribute($xml, 'IncludeToken', null); - try { - $includeToken = IncludeToken::from($includeToken); - } catch (ValueError) { - } - return new static( - $includeToken, self::getChildElementsFromXML($xml), self::getAttributesNSFromXML($xml), ); @@ -114,13 +97,6 @@ public function toXML(DOMElement $parent = null): DOMElement { $e = $this->instantiateParentElement($parent); - if ($this->getIncludeToken() !== null) { - $e->setAttribute( - 'IncludeToken', - is_string($this->getIncludeToken()) ? $this->getIncludeToken() : $this->getIncludeToken()->value, - ); - } - foreach ($this->getElements() as $elt) { /** @psalm-var \SimpleSAML\XML\SerializableElementInterface $elt */ $elt->toXML($e); diff --git a/src/XML/sp_200702/AbstractSecureConversationTokenType.php b/src/XML/sp_200702/AbstractSecureConversationTokenType.php index dcb231bc..fc2b14a1 100644 --- a/src/XML/sp_200702/AbstractSecureConversationTokenType.php +++ b/src/XML/sp_200702/AbstractSecureConversationTokenType.php @@ -25,7 +25,6 @@ abstract class AbstractSecureConversationTokenType extends AbstractSpElement { use ExtendableAttributesTrait; use ExtendableElementTrait; - use IncludeTokenTypeTrait; /** The namespace-attribute for the xs:any element */ public const XS_ANY_ELT_NAMESPACE = NS::OTHER; @@ -33,27 +32,19 @@ abstract class AbstractSecureConversationTokenType extends AbstractSpElement /** The namespace-attribute for the xs:anyAttribute element */ public const XS_ANY_ATTR_NAMESPACE = NS::ANY; - /** The exclusions for the xs:anyAttribute element */ - public const XS_ANY_ATTR_EXCLUSIONS = [ - [null, 'IncludeToken'], - ]; - /** * SecureConversationTokenType constructor. * * @param \SimpleSAML\WSSecurity\XML\sp_200702\Issuer|\SimpleSAML\WSSecurity\XML\sp_200702\IssuerName|null $issuer - * @param \SimpleSAML\WSSecurity\XML\sp_200702\IncludeToken|null $includeToken * @param array<\SimpleSAML\XML\SerializableElementInterface> $elts * @param array<\SimpleSAML\XML\Attribute> $namespacedAttributes */ final public function __construct( protected Issuer|IssuerName|null $issuer, - ?IncludeToken $includeToken = null, array $elts = [], array $namespacedAttributes = [], ) { - $this->setIncludeToken($includeToken); $this->setElements($elts); $this->setAttributesNS($namespacedAttributes); } @@ -78,7 +69,6 @@ public function getIssuer(): Issuer|IssuerName|null public function isEmptyElement(): bool { return empty($this->getIssuer()) - && empty($this->getIncludeToken()) && empty($this->getAttributesNS()) && empty($this->getElements()); } @@ -109,15 +99,8 @@ public static function fromXML(DOMElement $xml): static $issuerName = IssuerName::getChildrenOfClass($xml); $issuer = array_merge($issuer, $issuerName); - $includeToken = self::getOptionalAttribute($xml, 'IncludeToken', null); - try { - $includeToken = IncludeToken::from($includeToken); - } catch (ValueError) { - } - return new static( array_pop($issuer), - $includeToken, self::getChildElementsFromXML($xml), self::getAttributesNSFromXML($xml), ); @@ -134,13 +117,6 @@ public function toXML(DOMElement $parent = null): DOMElement { $e = $this->instantiateParentElement($parent); - if ($this->getIncludeToken() !== null) { - $e->setAttribute( - 'IncludeToken', - is_string($this->getIncludeToken()) ? $this->getIncludeToken() : $this->getIncludeToken()->value, - ); - } - if ($this->getIssuer() !== null) { $this->getIssuer()->toXML($e); } diff --git a/src/XML/sp_200702/AbstractSpnegoContextTokenType.php b/src/XML/sp_200702/AbstractSpnegoContextTokenType.php index ea0b797d..1056edc1 100644 --- a/src/XML/sp_200702/AbstractSpnegoContextTokenType.php +++ b/src/XML/sp_200702/AbstractSpnegoContextTokenType.php @@ -25,7 +25,6 @@ abstract class AbstractSpnegoContextTokenType extends AbstractSpElement { use ExtendableAttributesTrait; use ExtendableElementTrait; - use IncludeTokenTypeTrait; /** The namespace-attribute for the xs:any element */ public const XS_ANY_ELT_NAMESPACE = NS::OTHER; @@ -33,27 +32,19 @@ abstract class AbstractSpnegoContextTokenType extends AbstractSpElement /** The namespace-attribute for the xs:anyAttribute element */ public const XS_ANY_ATTR_NAMESPACE = NS::ANY; - /** The exclusions for the xs:anyAttribute element */ - public const XS_ANY_ATTR_EXCLUSIONS = [ - [null, 'IncludeToken'], - ]; - /** * SpnegoContextTokenType constructor. * * @param \SimpleSAML\WSSecurity\XML\sp_200702\Issuer|\SimpleSAML\WSSecurity\XML\sp_200702\IssuerName|null $issuer - * @param \SimpleSAML\WSSecurity\XML\sp_200702\IncludeToken|null $includeToken * @param array<\SimpleSAML\XML\SerializableElementInterface> $elts * @param array<\SimpleSAML\XML\Attribute> $namespacedAttributes */ final public function __construct( protected Issuer|IssuerName|null $issuer, - ?IncludeToken $includeToken = null, array $elts = [], array $namespacedAttributes = [], ) { - $this->setIncludeToken($includeToken); $this->setElements($elts); $this->setAttributesNS($namespacedAttributes); } @@ -78,7 +69,6 @@ public function getIssuer(): Issuer|IssuerName|null public function isEmptyElement(): bool { return empty($this->getIssuer()) - && empty($this->getIncludeToken()) && empty($this->getAttributesNS()) && empty($this->getElements()); } @@ -109,15 +99,8 @@ public static function fromXML(DOMElement $xml): static $issuerName = IssuerName::getChildrenOfClass($xml); $issuer = array_merge($issuer, $issuerName); - $includeToken = self::getOptionalAttribute($xml, 'IncludeToken', null); - try { - $includeToken = IncludeToken::from($includeToken); - } catch (ValueError) { - } - return new static( array_pop($issuer), - $includeToken, self::getChildElementsFromXML($xml), self::getAttributesNSFromXML($xml), ); @@ -134,13 +117,6 @@ public function toXML(DOMElement $parent = null): DOMElement { $e = $this->instantiateParentElement($parent); - if ($this->getIncludeToken() !== null) { - $e->setAttribute( - 'IncludeToken', - is_string($this->getIncludeToken()) ? $this->getIncludeToken() : $this->getIncludeToken()->value, - ); - } - if ($this->getIssuer() !== null) { $this->getIssuer()->toXML($e); } diff --git a/tests/WSSecurity/XML/sp_200702/IssuedTokenTest.php b/tests/WSSecurity/XML/sp_200702/IssuedTokenTest.php index e3454239..2af54dc9 100644 --- a/tests/WSSecurity/XML/sp_200702/IssuedTokenTest.php +++ b/tests/WSSecurity/XML/sp_200702/IssuedTokenTest.php @@ -12,7 +12,6 @@ use SimpleSAML\WSSecurity\XML\sp_200702\AbstractIssuedTokenType; use SimpleSAML\WSSecurity\XML\sp_200702\AbstractSpElement; use SimpleSAML\WSSecurity\XML\sp_200702\IncludeToken; -use SimpleSAML\WSSecurity\XML\sp_200702\IncludeTokenTypeTrait; use SimpleSAML\WSSecurity\XML\sp_200702\IssuedToken; use SimpleSAML\WSSecurity\XML\sp_200702\IssuerName; use SimpleSAML\WSSecurity\XML\sp_200702\RequestSecurityTokenTemplate; @@ -31,7 +30,6 @@ */ #[Group('sp')] #[CoversClass(IssuedToken::class)] -#[CoversClass(IncludeTokenTypeTrait::class)] #[CoversClass(AbstractIssuedTokenType::class)] #[CoversClass(AbstractSpElement::class)] final class IssuedTokenTest extends TestCase @@ -60,6 +58,7 @@ public function testMarshallingElementOrdering(): void { $issuer = new IssuerName('urn:x-simplesamlphp:issuer'); $attr = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr1', 'value1'); + $includeToken = new XMLAttribute(C::NS_SEC_POLICY_12, 'sp', 'IncludeToken', IncludeToken::Always->value); $chunk = new Chunk(DOMDocumentFactory::fromString( 'some', )->documentElement); @@ -69,7 +68,7 @@ public function testMarshallingElementOrdering(): void [$attr], ); - $issuedToken = new IssuedToken($requestSecurityTokenTemplate, $issuer, IncludeToken::Always, [$chunk], [$attr]); + $issuedToken = new IssuedToken($requestSecurityTokenTemplate, $issuer, [$chunk], [$includeToken, $attr]); $issuedTokenElement = $issuedToken->toXML(); // Test for a Issuer @@ -95,6 +94,7 @@ public function testMarshallingElementOrdering(): void public function testMarshalling(): void { $attr = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr1', 'value1'); + $includeToken = new XMLAttribute(C::NS_SEC_POLICY_12, 'sp', 'IncludeToken', IncludeToken::Always->value); $chunk = new Chunk(DOMDocumentFactory::fromString( 'some', )->documentElement); @@ -106,7 +106,7 @@ public function testMarshalling(): void [$attr], ); - $issuedToken = new IssuedToken($requestSecurityTokenTemplate, $issuer, IncludeToken::Always, [$chunk], [$attr]); + $issuedToken = new IssuedToken($requestSecurityTokenTemplate, $issuer, [$chunk], [$includeToken, $attr]); $this->assertEquals( self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), strval($issuedToken), diff --git a/tests/WSSecurity/XML/sp_200702/KeyValueTokenTest.php b/tests/WSSecurity/XML/sp_200702/KeyValueTokenTest.php index bc5466cc..9972af03 100644 --- a/tests/WSSecurity/XML/sp_200702/KeyValueTokenTest.php +++ b/tests/WSSecurity/XML/sp_200702/KeyValueTokenTest.php @@ -11,7 +11,6 @@ use SimpleSAML\WSSecurity\XML\sp_200702\AbstractKeyValueTokenType; use SimpleSAML\WSSecurity\XML\sp_200702\AbstractSpElement; use SimpleSAML\WSSecurity\XML\sp_200702\IncludeToken; -use SimpleSAML\WSSecurity\XML\sp_200702\IncludeTokenTypeTrait; use SimpleSAML\WSSecurity\XML\sp_200702\KeyValueToken; use SimpleSAML\XML\Attribute as XMLAttribute; use SimpleSAML\XML\Chunk; @@ -28,7 +27,6 @@ */ #[Group('sp')] #[CoversClass(KeyValueToken::class)] -#[CoversClass(IncludeTokenTypeTrait::class)] #[CoversClass(AbstractKeyValueTokenType::class)] #[CoversClass(AbstractSpElement::class)] final class KeyValueTokenTest extends TestCase @@ -75,11 +73,12 @@ public function testMarshallingEmptyElement(): void public function testMarshalling(): void { $attr = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr1', 'value1'); + $includeToken = new XMLAttribute(C::NS_SEC_POLICY_12, 'sp', 'IncludeToken', IncludeToken::Always->value); $chunk = new Chunk(DOMDocumentFactory::fromString( 'some', )->documentElement); - $keyValueToken = new KeyValueToken(IncludeToken::Always, [$chunk], [$attr]); + $keyValueToken = new KeyValueToken([$chunk], [$includeToken, $attr]); $this->assertEquals( self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), strval($keyValueToken), diff --git a/tests/WSSecurity/XML/sp_200702/SecureConversationTokenTest.php b/tests/WSSecurity/XML/sp_200702/SecureConversationTokenTest.php index 91029c3c..72143800 100644 --- a/tests/WSSecurity/XML/sp_200702/SecureConversationTokenTest.php +++ b/tests/WSSecurity/XML/sp_200702/SecureConversationTokenTest.php @@ -12,7 +12,6 @@ use SimpleSAML\WSSecurity\XML\sp_200702\AbstractSecureConversationTokenType; use SimpleSAML\WSSecurity\XML\sp_200702\AbstractSpElement; use SimpleSAML\WSSecurity\XML\sp_200702\IncludeToken; -use SimpleSAML\WSSecurity\XML\sp_200702\IncludeTokenTypeTrait; use SimpleSAML\WSSecurity\XML\sp_200702\IssuerName; use SimpleSAML\WSSecurity\XML\sp_200702\SecureConversationToken; use SimpleSAML\XML\Attribute as XMLAttribute; @@ -30,7 +29,6 @@ */ #[Group('sp')] #[CoversClass(SecureConversationToken::class)] -#[CoversClass(IncludeTokenTypeTrait::class)] #[CoversClass(AbstractSecureConversationTokenType::class)] #[CoversClass(AbstractSpElement::class)] final class SecureConversationTokenTest extends TestCase @@ -59,11 +57,12 @@ public function testMarshallingElementOrdering(): void { $issuer = new IssuerName('urn:x-simplesamlphp:issuer'); $attr = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr1', 'value1'); + $includeToken = new XMLAttribute(C::NS_SEC_POLICY_12, 'sp', 'IncludeToken', IncludeToken::Always->value); $chunk = new Chunk(DOMDocumentFactory::fromString( 'some', )->documentElement); - $secureConversationToken = new SecureConversationToken($issuer, IncludeToken::Always, [$chunk], [$attr]); + $secureConversationToken = new SecureConversationToken($issuer, [$chunk], [$includeToken, $attr]); $secureConversationTokenElement = $secureConversationToken->toXML(); // Test for a IssuerName @@ -92,13 +91,14 @@ public function testMarshallingElementOrdering(): void public function testMarshalling(): void { $attr = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr1', 'value1'); + $includeToken = new XMLAttribute(C::NS_SEC_POLICY_12, 'sp', 'IncludeToken', IncludeToken::Always->value); $chunk = new Chunk(DOMDocumentFactory::fromString( 'some', )->documentElement); $issuer = new IssuerName('urn:x-simplesamlphp:issuer'); - $secureConversationToken = new SecureConversationToken($issuer, IncludeToken::Always, [$chunk], [$attr]); + $secureConversationToken = new SecureConversationToken($issuer, [$chunk], [$includeToken, $attr]); $this->assertEquals( self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), strval($secureConversationToken), diff --git a/tests/WSSecurity/XML/sp_200702/SpnegoContextTokenTest.php b/tests/WSSecurity/XML/sp_200702/SpnegoContextTokenTest.php index 59d2f126..428fdf3c 100644 --- a/tests/WSSecurity/XML/sp_200702/SpnegoContextTokenTest.php +++ b/tests/WSSecurity/XML/sp_200702/SpnegoContextTokenTest.php @@ -12,7 +12,6 @@ use SimpleSAML\WSSecurity\XML\sp_200702\AbstractSpElement; use SimpleSAML\WSSecurity\XML\sp_200702\AbstractSpnegoContextTokenType; use SimpleSAML\WSSecurity\XML\sp_200702\IncludeToken; -use SimpleSAML\WSSecurity\XML\sp_200702\IncludeTokenTypeTrait; use SimpleSAML\WSSecurity\XML\sp_200702\IssuerName; use SimpleSAML\WSSecurity\XML\sp_200702\SpnegoContextToken; use SimpleSAML\XML\Attribute as XMLAttribute; @@ -30,7 +29,6 @@ */ #[Group('sp')] #[CoversClass(SpnegoContextToken::class)] -#[CoversClass(IncludeTokenTypeTrait::class)] #[CoversClass(AbstractSpnegoContextTokenType::class)] #[CoversClass(AbstractSpElement::class)] final class SpnegoContextTokenTest extends TestCase @@ -59,11 +57,12 @@ public function testMarshallingElementOrdering(): void { $issuer = new IssuerName('urn:x-simplesamlphp:issuer'); $attr = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr1', 'value1'); + $includeToken = new XMLAttribute(C::NS_SEC_POLICY_12, 'sp', 'IncludeToken', IncludeToken::Always->value); $chunk = new Chunk(DOMDocumentFactory::fromString( 'some', )->documentElement); - $spnegoContextToken = new SpnegoContextToken($issuer, IncludeToken::Always, [$chunk], [$attr]); + $spnegoContextToken = new SpnegoContextToken($issuer, [$chunk], [$includeToken, $attr]); $spnegoContextTokenElement = $spnegoContextToken->toXML(); // Test for a IssuerName @@ -92,13 +91,14 @@ public function testMarshallingElementOrdering(): void public function testMarshalling(): void { $attr = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr1', 'value1'); + $includeToken = new XMLAttribute(C::NS_SEC_POLICY_12, 'sp', 'IncludeToken', IncludeToken::Always->value); $chunk = new Chunk(DOMDocumentFactory::fromString( 'some', )->documentElement); $issuer = new IssuerName('urn:x-simplesamlphp:issuer'); - $spnegoContextToken = new SpnegoContextToken($issuer, IncludeToken::Always, [$chunk], [$attr]); + $spnegoContextToken = new SpnegoContextToken($issuer, [$chunk], [$includeToken, $attr]); $this->assertEquals( self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), strval($spnegoContextToken), diff --git a/tests/resources/xml/sp/200702/IssuedToken.xml b/tests/resources/xml/sp/200702/IssuedToken.xml index 05bfd422..ffca8358 100644 --- a/tests/resources/xml/sp/200702/IssuedToken.xml +++ b/tests/resources/xml/sp/200702/IssuedToken.xml @@ -1,4 +1,4 @@ - + urn:x-simplesamlphp:issuer some diff --git a/tests/resources/xml/sp/200702/KeyValueToken.xml b/tests/resources/xml/sp/200702/KeyValueToken.xml index 9dfa1952..1d73b0ef 100644 --- a/tests/resources/xml/sp/200702/KeyValueToken.xml +++ b/tests/resources/xml/sp/200702/KeyValueToken.xml @@ -1,3 +1,3 @@ - + some diff --git a/tests/resources/xml/sp/200702/SecureConversationToken.xml b/tests/resources/xml/sp/200702/SecureConversationToken.xml index 7e23eef1..077430da 100644 --- a/tests/resources/xml/sp/200702/SecureConversationToken.xml +++ b/tests/resources/xml/sp/200702/SecureConversationToken.xml @@ -1,4 +1,4 @@ - + urn:x-simplesamlphp:issuer some diff --git a/tests/resources/xml/sp/200702/SpnegoContextToken.xml b/tests/resources/xml/sp/200702/SpnegoContextToken.xml index 0db1d87a..3eb22219 100644 --- a/tests/resources/xml/sp/200702/SpnegoContextToken.xml +++ b/tests/resources/xml/sp/200702/SpnegoContextToken.xml @@ -1,4 +1,4 @@ - + urn:x-simplesamlphp:issuer some