diff --git a/src/XML/element.registry.php b/src/XML/element.registry.php index 136e9970..96b40314 100644 --- a/src/XML/element.registry.php +++ b/src/XML/element.registry.php @@ -352,6 +352,55 @@ 'TransformationParameters' => '\SimpleSAML\WSSecurity\XML\wsse\TransformationParameters', 'UsernameToken' => '\SimpleSAML\WSSecurity\XML\wsse\UsernameToken', ], + 'http://schemas.xmlsoap.org/ws/2005/02/trust' => [ + 'AllowPostdating' => '\SimpleSAML\WSSecurity\XML\wst_200502\AllowPostdating', + 'AuthenticationType' => '\SimpleSAML\WSSecurity\XML\wst_200502\AuthenticationType', + 'Authenticator' => '\SimpleSAML\WSSecurity\XML\wst_200502\Authenticator', + 'BinaryExchange' => '\SimpleSAML\WSSecurity\XML\wst_200502\BinaryExchange', + 'BinarySecret' => '\SimpleSAML\WSSecurity\XML\wst_200502\BinarySecret', + 'CancelTarget' => '\SimpleSAML\WSSecurity\XML\wst_200502\CancelTarget', + 'CanonicalizationAlgorithm' => '\SimpleSAML\WSSecurity\XML\wst_200502\CanonicalizationAlgorithm', + 'Challenge' => '\SimpleSAML\WSSecurity\XML\wst_200502\Challenge', + 'Claims' => '\SimpleSAML\WSSecurity\XML\wst_200502\Claims', + 'CombinedHash' => '\SimpleSAML\WSSecurity\XML\wst_200502\CombinedHash', + 'ComputedKey' => '\SimpleSAML\WSSecurity\XML\wst_200502\ComputedKey', + 'ComputedKeyAlgorithm' => '\SimpleSAML\WSSecurity\XML\wst_200502\ComputedKeyAlgorithm', + 'Delegatable' => '\SimpleSAML\WSSecurity\XML\wst_200502\Delegatable', + 'DelegateTo' => '\SimpleSAML\WSSecurity\XML\wst_200502\DelegateTo', + 'EncryptWith' => '\SimpleSAML\WSSecurity\XML\wst_200502\EncryptWith', + 'Encryption' => '\SimpleSAML\WSSecurity\XML\wst_200502\Encryption', + 'EncryptionAlgorithm' => '\SimpleSAML\WSSecurity\XML\wst_200502\EncryptionAlgorithm', + 'Entropy' => '\SimpleSAML\WSSecurity\XML\wst_200502\Entropy', + 'Forwardable' => '\SimpleSAML\WSSecurity\XML\wst_200502\Forwardable', + 'IssuedTokens' => '\SimpleSAML\WSSecurity\XML\wst_200502\IssuedTokens', + 'Issuer' => '\SimpleSAML\WSSecurity\XML\wst_200502\Issuer', + 'KeyExchangeToken' => '\SimpleSAML\WSSecurity\XML\wst_200502\KeyExchangeToken', + 'KeySize' => '\SimpleSAML\WSSecurity\XML\wst_200502\KeySize', + 'KeyType' => '\SimpleSAML\WSSecurity\XML\wst_200502\KeyType', + 'Lifetime' => '\SimpleSAML\WSSecurity\XML\wst_200502\Lifetime', + 'OnBehalfOf' => '\SimpleSAML\WSSecurity\XML\wst_200502\OnBehalfOf', + 'Participants' => '\SimpleSAML\WSSecurity\XML\wst_200502\Participants', + 'ProofEncryption' => '\SimpleSAML\WSSecurity\XML\wst_200502\ProofEncryption', + 'RenewTarget' => '\SimpleSAML\WSSecurity\XML\wst_200502\RenewTarget', + 'Renewing' => '\SimpleSAML\WSSecurity\XML\wst_200502\Renewing', + 'RequestKET' => '\SimpleSAML\WSSecurity\XML\wst_200502\RequestKET', + 'RequestSecurityToken' => '\SimpleSAML\WSSecurity\XML\wst_200502\RequestSecurityToken', + 'RequestSecurityTokenResponse' => '\SimpleSAML\WSSecurity\XML\wst_200502\RequestSecurityTokenResponse', + 'RequestSecurityTokenResponseCollection' => '\SimpleSAML\WSSecurity\XML\wst_200502\RequestSecurityTokenResponseCollection', + 'RequestType' => '\SimpleSAML\WSSecurity\XML\wst_200502\RequestType', + 'RequestedAttachedReference' => '\SimpleSAML\WSSecurity\XML\wst_200502\RequestedAttachedReference', + 'RequestedProofToken' => '\SimpleSAML\WSSecurity\XML\wst_200502\RequestedProofToken', + 'RequestedSecurityToken' => '\SimpleSAML\WSSecurity\XML\wst_200502\RequestedSecurityToken', + 'RequestedTokenCancelled' => '\SimpleSAML\WSSecurity\XML\wst_200502\RequestedTokenCancelled', + 'RequestedUnattachedReference' => '\SimpleSAML\WSSecurity\XML\wst_200502\RequestedUnattachedReference', + 'SignChallenge' => '\SimpleSAML\WSSecurity\XML\wst_200502\SignChallenge', + 'SignChallengeResponse' => '\SimpleSAML\WSSecurity\XML\wst_200502\SignChallengeResponse', + 'SignWith' => '\SimpleSAML\WSSecurity\XML\wst_200502\SignWith', + 'SignatureAlgorithm' => '\SimpleSAML\WSSecurity\XML\wst_200502\SignatureAlgorithm', + 'Status' => '\SimpleSAML\WSSecurity\XML\wst_200502\Status', + 'TokenType' => '\SimpleSAML\WSSecurity\XML\wst_200502\TokenType', + 'UseKey' => '\SimpleSAML\WSSecurity\XML\wst_200502\UseKey', + ], 'http://docs.oasis-open.org/ws-sx/ws-trust/200512/' => [ 'AllowPostdating' => '\SimpleSAML\WSSecurity\XML\wst_200512\AllowPostdating', 'AuthenticationType' => '\SimpleSAML\WSSecurity\XML\wst_200512\AuthenticationType', diff --git a/src/XML/wst_200502/AbstractAuthenticatorType.php b/src/XML/wst_200502/AbstractAuthenticatorType.php new file mode 100644 index 00000000..9ac9f436 --- /dev/null +++ b/src/XML/wst_200502/AbstractAuthenticatorType.php @@ -0,0 +1,106 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use DOMElement; +use SimpleSAML\Assert\Assert; +use SimpleSAML\XML\Exception\InvalidDOMElementException; +use SimpleSAML\XML\ExtendableElementTrait; +use SimpleSAML\XML\XsNamespace as NS; + +use function array_pop; + +/** + * Class defining the AuthenticatorType element + * + * @package simplesamlphp/ws-security + */ +abstract class AbstractAuthenticatorType extends AbstractWstElement +{ + use ExtendableElementTrait; + + /** The namespace-attribute for the xs:any element */ + public const XS_ANY_ELT_NAMESPACE = NS::OTHER; + + + /** + * AbstractAuthenticatorType constructor + * + * @param \SimpleSAML\WSSecurity\XML\wst_200502\CombinedHash|null $combinedHash + * @param array<\SimpleSAML\XML\SerializableElementInterface> $children + */ + final public function __construct( + protected ?CombinedHash $combinedHash = null, + array $children = [], + ) { + $this->setElements($children); + } + + + /** + * @return \SimpleSAML\WSSecurity\XML\wst_200502\CombinedHash|null + */ + public function getCombinedHash(): ?CombinedHash + { + return $this->combinedHash; + } + + + /** + * Test if an object, at the state it's in, would produce an empty XML-element + * + * @return bool + */ + public function isEmptyElement(): bool + { + return empty($this->getCombinedHash()) + && empty($this->getElements()); + } + + + /** + * Create an instance of this object from its XML representation. + * + * @param \DOMElement $xml + * @return static + * + * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException + * if the qualified name of the supplied element is wrong + */ + public static function fromXML(DOMElement $xml): static + { + Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + $combinedHash = CombinedHash::getChildrenOfClass($xml); + + return new static( + array_pop($combinedHash), + self::getChildElementsFromXML($xml), + ); + } + + + /** + * Add this AuthenticatorType to an XML element. + * + * @param \DOMElement $parent The element we should append this username token to. + * @return \DOMElement + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = parent::instantiateParentElement($parent); + + $this->getCombinedHash()?->toXML($e); + + foreach ($this->getElements() as $child) { + if (!$child->isEmptyElement()) { + $child->toXML($e); + } + } + + return $e; + } +} diff --git a/src/XML/wst_200502/AbstractBinaryExchangeType.php b/src/XML/wst_200502/AbstractBinaryExchangeType.php new file mode 100644 index 00000000..77131145 --- /dev/null +++ b/src/XML/wst_200502/AbstractBinaryExchangeType.php @@ -0,0 +1,114 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use DOMElement; +use SimpleSAML\Assert\Assert; +use SimpleSAML\XML\Exception\InvalidDOMElementException; +use SimpleSAML\XML\Exception\SchemaViolationException; +use SimpleSAML\XML\ExtendableAttributesTrait; +use SimpleSAML\XML\StringElementTrait; +use SimpleSAML\XML\XsNamespace as NS; + +/** + * A BinaryExchangeType element + * + * @package simplesamlphp/ws-security + */ +abstract class AbstractBinaryExchangeType extends AbstractWstElement +{ + use ExtendableAttributesTrait; + use StringElementTrait; + + /** The namespace-attribute for the xs:anyAttribute element */ + public const XS_ANY_ATTR_NAMESPACE = NS::OTHER; + + + /** + * @param string $content + * @param string $valueType + * @param string $encodingType + * @param array<\SimpleSAML\XML\Attribute> $namespacedAttributes + */ + final public function __construct( + string $content, + protected string $valueType, + protected string $encodingType, + array $namespacedAttributes, + ) { + Assert::validURI($valueType, SchemaViolationException::class); + Assert::validURI($encodingType, SchemaViolationException::class); + + $this->setContent($content); + $this->setAttributesNS($namespacedAttributes); + } + + + /** + * Get the valueType property. + * + * @return string + */ + public function getValueType(): string + { + return $this->valueType; + } + + + /** + * Get the valueType property. + * + * @return string + */ + public function getEncodingType(): string + { + return $this->encodingType; + } + + + /** + * Convert XML into a class instance + * + * @param \DOMElement $xml The XML element we should load + * @return static + * + * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException + * If the qualified name of the supplied element is wrong + */ + public static function fromXML(DOMElement $xml): static + { + Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + return new static( + $xml->textContent, + self::getAttribute($xml, 'ValueType'), + self::getAttribute($xml, 'EncodingType'), + self::getAttributesNSFromXML($xml), + ); + } + + + /** + * Convert this element to XML. + * + * @param \DOMElement|null $parent The element we should append this element to. + * @return \DOMElement + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = $this->instantiateParentElement($parent); + $e->textContent = $this->getContent(); + + $e->setAttribute('ValueType', $this->getValueType()); + $e->setAttribute('EncodingType', $this->getEncodingType()); + + foreach ($this->getAttributesNS() as $attr) { + $attr->toXML($e); + } + + return $e; + } +} diff --git a/src/XML/wst_200502/AbstractBinarySecretType.php b/src/XML/wst_200502/AbstractBinarySecretType.php new file mode 100644 index 00000000..971e3a8b --- /dev/null +++ b/src/XML/wst_200502/AbstractBinarySecretType.php @@ -0,0 +1,116 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use DOMElement; +use SimpleSAML\Assert\Assert; +use SimpleSAML\XML\Base64ElementTrait; +use SimpleSAML\XML\Exception\InvalidDOMElementException; +use SimpleSAML\XML\Exception\SchemaViolationException; +use SimpleSAML\XML\ExtendableAttributesTrait; +use SimpleSAML\XML\XsNamespace as NS; + +use function array_map; +use function explode; +use function implode; + +/** + * A BinarySecertType element + * + * @package simplesamlphp/ws-security + */ +abstract class AbstractBinarySecretType extends AbstractWstElement +{ + use Base64ElementTrait; + use ExtendableAttributesTrait; + + /** @var string|\SimpleSAML\XML\XsNamespace */ + public const XS_ANY_ATTR_NAMESPACE = NS::OTHER; + + /** @var string[]|null */ + protected ?array $Type; + + + /** + * @param string $content + * @param (\SimpleSAML\WSSecurity\XML\wst_200502\BinarySecretTypeEnum|string)[]|null $Type + * @param array<\SimpleSAML\XML\Attribute> $namespacedAttributes + */ + final public function __construct( + string $content, + ?array $Type = null, + array $namespacedAttributes = [], + ) { + if ($Type !== null) { + $Type = array_map( + function (BinarySecretTypeEnum|string $v): string { + return ($v instanceof BinarySecretTypeEnum) ? $v->value : $v; + }, + $Type, + ); + Assert::allValidURI($Type, SchemaViolationException::class); + $this->Type = $Type; + } + + $this->setContent($content); + $this->setAttributesNS($namespacedAttributes); + } + + + /** + * Get the Type property. + * + * @return string[]|null + */ + public function getType(): ?array + { + return $this->Type; + } + + + /** + * Convert XML into a class instance + * + * @param \DOMElement $xml The XML element we should load + * @return static + * + * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException + * If the qualified name of the supplied element is wrong + */ + public static function fromXML(DOMElement $xml): static + { + Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + return new static( + $xml->textContent, + explode(' ', self::getAttribute($xml, 'Type')), + self::getAttributesNSFromXML($xml), + ); + } + + + /** + * Convert this element to XML. + * + * @param \DOMElement|null $parent The element we should append this element to. + * @return \DOMElement + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = $this->instantiateParentElement($parent); + $e->textContent = $this->getContent(); + + if ($this->getType() !== null) { + $e->setAttribute('Type', implode(' ', $this->getType())); + } + + foreach ($this->getAttributesNS() as $attr) { + $attr->toXML($e); + } + + return $e; + } +} diff --git a/src/XML/wst_200502/AbstractCancelTargetType.php b/src/XML/wst_200502/AbstractCancelTargetType.php new file mode 100644 index 00000000..0b118aa0 --- /dev/null +++ b/src/XML/wst_200502/AbstractCancelTargetType.php @@ -0,0 +1,85 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use DOMElement; +use SimpleSAML\Assert\Assert; +use SimpleSAML\XML\Exception\InvalidDOMElementException; +use SimpleSAML\XML\Exception\MissingElementException; +use SimpleSAML\XML\Exception\TooManyElementsException; +use SimpleSAML\XML\ExtendableElementTrait; +use SimpleSAML\XML\SerializableElementInterface; +use SimpleSAML\XML\XsNamespace as NS; + +use function array_pop; + +/** + * Class defining the CancelTargetType element + * + * @package simplesamlphp/ws-security + */ +abstract class AbstractCancelTargetType extends AbstractWstElement +{ + use ExtendableElementTrait; + + /** The namespace-attribute for the xs:any element */ + public const XS_ANY_ELT_NAMESPACE = NS::OTHER; + + + /** + * AbstractCancelTargetType constructor + * + * @param \SimpleSAML\XML\SerializableElementInterface $child + */ + final public function __construct( + SerializableElementInterface $child, + ) { + $this->setElements([$child]); + } + + + /** + * Create an instance of this object from its XML representation. + * + * @param \DOMElement $xml + * @return static + * + * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException + * if the qualified name of the supplied element is wrong + */ + public static function fromXML(DOMElement $xml): static + { + Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + $children = self::getChildElementsFromXML($xml); + Assert::minCount($children, 1, MissingElementException::class); + Assert::maxCount($children, 1, TooManyElementsException::class); + + return new static( + array_pop($children), + ); + } + + + /** + * Add this CancelTargetType to an XML element. + * + * @param \DOMElement $parent The element we should append this username token to. + * @return \DOMElement + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = parent::instantiateParentElement($parent); + + foreach ($this->getElements() as $child) { + if (!$child->isEmptyElement()) { + $child->toXML($e); + } + } + + return $e; + } +} diff --git a/src/XML/wst_200502/AbstractClaimsType.php b/src/XML/wst_200502/AbstractClaimsType.php new file mode 100644 index 00000000..e2333d83 --- /dev/null +++ b/src/XML/wst_200502/AbstractClaimsType.php @@ -0,0 +1,121 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use DOMElement; +use SimpleSAML\Assert\Assert; +use SimpleSAML\XML\Exception\InvalidDOMElementException; +use SimpleSAML\XML\Exception\SchemaViolationException; +use SimpleSAML\XML\ExtendableAttributesTrait; +use SimpleSAML\XML\ExtendableElementTrait; +use SimpleSAML\XML\XsNamespace as NS; + +/** + * Class defining the ClaimsType element + * + * @package simplesamlphp/ws-security + */ +abstract class AbstractClaimsType extends AbstractWstElement +{ + use ExtendableAttributesTrait; + use ExtendableElementTrait; + + /** The namespace-attribute for the xs:any element */ + public const XS_ANY_ELT_NAMESPACE = NS::ANY; + + /** The namespace-attribute for the xs:anyAttribute element */ + public const XS_ANY_ATTR_NAMESPACE = NS::OTHER; + + + /** + * AbstractClaimsType constructor + * + * @param string|null $dialect + * @param array<\SimpleSAML\XML\SerializableElementInterface> $children + * @param array<\SimpleSAML\XML\Attribute> $namespacedAttributes + */ + final public function __construct( + protected ?string $dialect = null, + array $children = [], + array $namespacedAttributes = [], + ) { + Assert::nullOrValidURI($dialect, SchemaViolationException::class); + + $this->setElements($children); + $this->setAttributesNS($namespacedAttributes); + } + + + /** + * @return string|null + */ + public function getDialect(): ?string + { + return $this->dialect; + } + + + /** + * Test if an object, at the state it's in, would produce an empty XML-element + * + * @return bool + */ + public function isEmptyElement(): bool + { + return empty($this->getDialect()) + && empty($this->getElements()) + && empty($this->getAttributesNS()); + } + + + /** + * Create an instance of this object from its XML representation. + * + * @param \DOMElement $xml + * @return static + * + * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException + * if the qualified name of the supplied element is wrong + */ + public static function fromXML(DOMElement $xml): static + { + Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + return new static( + self::getOptionalAttribute($xml, 'Dialect', null), + self::getChildElementsFromXML($xml), + self::getAttributesNSFromXML($xml), + ); + } + + + /** + * Add this ClaimsType to an XML element. + * + * @param \DOMElement $parent The element we should append this element to. + * @return \DOMElement + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = parent::instantiateParentElement($parent); + + if ($this->getDialect() !== null) { + $e->setAttribute('Dialect', $this->getDialect()); + } + + foreach ($this->getElements() as $child) { + if (!$child->isEmptyElement()) { + $child->toXML($e); + } + } + + foreach ($this->getAttributesNS() as $attr) { + $attr->toXML($e); + } + + return $e; + } +} diff --git a/src/XML/wst_200502/AbstractComputedKeyOpenEnum.php b/src/XML/wst_200502/AbstractComputedKeyOpenEnum.php new file mode 100644 index 00000000..3f8c46c5 --- /dev/null +++ b/src/XML/wst_200502/AbstractComputedKeyOpenEnum.php @@ -0,0 +1,62 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use DOMElement; +use SimpleSAML\Assert\Assert; +use SimpleSAML\XML\Exception\InvalidDOMElementException; +use SimpleSAML\XML\Exception\SchemaViolationException; +use SimpleSAML\XML\StringElementTrait; + +use function array_map; +use function explode; +use function implode; + +/** + * A ComputedKeyOpenEnum element + * + * @package simplesamlphp/ws-security + * + * @phpstan-consistent-constructor + */ +abstract class AbstractComputedKeyOpenEnum extends AbstractWstElement +{ + use StringElementTrait; + + + /** + * @param (\SimpleSAML\WSSecurity\XML\wst_200502\ComputedKeyEnum|string)[] $values + */ + public function __construct(array $values) + { + $values = array_map( + function (ComputedKeyEnum|string $v): string { + return ($v instanceof ComputedKeyEnum) ? $v->value : $v; + }, + $values, + ); + Assert::allValidURI($values, SchemaViolationException::class); + + $this->setContent(implode(' ', $values)); + } + + + /** + * Convert XML into a class instance + * + * @param \DOMElement $xml The XML element we should load + * @return static + * + * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException + * If the qualified name of the supplied element is wrong + */ + public static function fromXML(DOMElement $xml): static + { + Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + return new static(explode(' ', $xml->textContent)); + } +} diff --git a/src/XML/wst_200502/AbstractDelegateToType.php b/src/XML/wst_200502/AbstractDelegateToType.php new file mode 100644 index 00000000..26cdfc5c --- /dev/null +++ b/src/XML/wst_200502/AbstractDelegateToType.php @@ -0,0 +1,83 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use DOMElement; +use SimpleSAML\Assert\Assert; +use SimpleSAML\XML\Exception\InvalidDOMElementException; +use SimpleSAML\XML\Exception\MissingElementException; +use SimpleSAML\XML\Exception\TooManyElementsException; +use SimpleSAML\XML\ExtendableElementTrait; +use SimpleSAML\XML\SerializableElementInterface; +use SimpleSAML\XML\XsNamespace as NS; + +/** + * Class defining the DelegateToType element + * + * @package simplesamlphp/ws-security + */ +abstract class AbstractDelegateToType extends AbstractWstElement +{ + use ExtendableElementTrait; + + /** The namespace-attribute for the xs:any element */ + public const XS_ANY_ELT_NAMESPACE = NS::ANY; + + + /** + * AbstractDelegateToType constructor + * + * @param \SimpleSAML\XML\SerializableElementInterface $child + */ + final public function __construct( + SerializableElementInterface $child, + ) { + $this->setElements([$child]); + } + + + /** + * Create an instance of this object from its XML representation. + * + * @param \DOMElement $xml + * @return static + * + * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException + * if the qualified name of the supplied element is wrong + */ + public static function fromXML(DOMElement $xml): static + { + Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + $children = self::getChildElementsFromXML($xml); + Assert::minCount($children, 1, MissingElementException::class); + Assert::maxCount($children, 1, TooManyElementsException::class); + + return new static( + array_pop($children), + ); + } + + + /** + * Add this DelegateToType to an XML element. + * + * @param \DOMElement $parent The element we should append this username token to. + * @return \DOMElement + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = parent::instantiateParentElement($parent); + + foreach ($this->getElements() as $child) { + if (!$child->isEmptyElement()) { + $child->toXML($e); + } + } + + return $e; + } +} diff --git a/src/XML/wst_200502/AbstractEncryptionType.php b/src/XML/wst_200502/AbstractEncryptionType.php new file mode 100644 index 00000000..e8e3a287 --- /dev/null +++ b/src/XML/wst_200502/AbstractEncryptionType.php @@ -0,0 +1,83 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use DOMElement; +use SimpleSAML\Assert\Assert; +use SimpleSAML\XML\Exception\InvalidDOMElementException; +use SimpleSAML\XML\Exception\MissingElementException; +use SimpleSAML\XML\Exception\TooManyElementsException; +use SimpleSAML\XML\ExtendableElementTrait; +use SimpleSAML\XML\SerializableElementInterface; +use SimpleSAML\XML\XsNamespace as NS; + +/** + * Class defining the EncryptionType element + * + * @package simplesamlphp/ws-security + */ +abstract class AbstractEncryptionType extends AbstractWstElement +{ + use ExtendableElementTrait; + + /** The namespace-attribute for the xs:any element */ + public const XS_ANY_ELT_NAMESPACE = NS::ANY; + + + /** + * AbstractEncryptionType constructor + * + * @param \SimpleSAML\XML\SerializableElementInterface $child + */ + final public function __construct( + SerializableElementInterface $child, + ) { + $this->setElements([$child]); + } + + + /** + * Create an instance of this object from its XML representation. + * + * @param \DOMElement $xml + * @return static + * + * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException + * if the qualified name of the supplied element is wrong + */ + public static function fromXML(DOMElement $xml): static + { + Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + $children = self::getChildElementsFromXML($xml); + Assert::minCount($children, 1, MissingElementException::class); + Assert::maxCount($children, 1, TooManyElementsException::class); + + return new static( + array_pop($children), + ); + } + + + /** + * Add this EncryptionType to an XML element. + * + * @param \DOMElement $parent The element we should append this username token to. + * @return \DOMElement + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = parent::instantiateParentElement($parent); + + foreach ($this->getElements() as $child) { + if (!$child->isEmptyElement()) { + $child->toXML($e); + } + } + + return $e; + } +} diff --git a/src/XML/wst_200502/AbstractEntropyType.php b/src/XML/wst_200502/AbstractEntropyType.php new file mode 100644 index 00000000..e498287b --- /dev/null +++ b/src/XML/wst_200502/AbstractEntropyType.php @@ -0,0 +1,101 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use DOMElement; +use SimpleSAML\Assert\Assert; +use SimpleSAML\XML\Exception\InvalidDOMElementException; +use SimpleSAML\XML\ExtendableAttributesTrait; +use SimpleSAML\XML\ExtendableElementTrait; +use SimpleSAML\XML\XsNamespace as NS; + +/** + * Class defining the EntropyType element + * + * @package simplesamlphp/ws-security + */ +abstract class AbstractEntropyType extends AbstractWstElement +{ + use ExtendableAttributesTrait; + use ExtendableElementTrait; + + /** The namespace-attribute for the xs:any element */ + public const XS_ANY_ELT_NAMESPACE = NS::ANY; + + /** The namespace-attribute for the xs:anyAttribute element */ + public const XS_ANY_ATTR_NAMESPACE = NS::OTHER; + + + /** + * AbstractEntropyType constructor + * + * @param array<\SimpleSAML\XML\SerializableElementInterface> $children + * @param array<\SimpleSAML\XML\Attribute> $namespacedAttributes + */ + final public function __construct( + array $children = [], + array $namespacedAttributes = [], + ) { + $this->setElements($children); + $this->setAttributesNS($namespacedAttributes); + } + + + /** + * Test if an object, at the state it's in, would produce an empty XML-element + * + * @return bool + */ + public function isEmptyElement(): bool + { + return empty($this->getElements()) + && empty($this->getAttributesNS()); + } + + + /** + * Create an instance of this object from its XML representation. + * + * @param \DOMElement $xml + * @return static + * + * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException + * if the qualified name of the supplied element is wrong + */ + public static function fromXML(DOMElement $xml): static + { + Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + return new static( + self::getChildElementsFromXML($xml), + self::getAttributesNSFromXML($xml), + ); + } + + + /** + * Add this EntropyType to an XML element. + * + * @param \DOMElement $parent The element we should append this element to. + * @return \DOMElement + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = parent::instantiateParentElement($parent); + + foreach ($this->getElements() as $child) { + if (!$child->isEmptyElement()) { + $child->toXML($e); + } + } + + foreach ($this->getAttributesNS() as $attr) { + $attr->toXML($e); + } + + return $e; + } +} diff --git a/src/XML/wst_200502/AbstractKeyExchangeTokenType.php b/src/XML/wst_200502/AbstractKeyExchangeTokenType.php new file mode 100644 index 00000000..946616e9 --- /dev/null +++ b/src/XML/wst_200502/AbstractKeyExchangeTokenType.php @@ -0,0 +1,87 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use DOMElement; +use SimpleSAML\Assert\Assert; +use SimpleSAML\XML\Exception\InvalidDOMElementException; +use SimpleSAML\XML\ExtendableElementTrait; +use SimpleSAML\XML\XsNamespace as NS; + +/** + * Class defining the KeyExchangeTokenType element + * + * @package simplesamlphp/ws-security + */ +abstract class AbstractKeyExchangeTokenType extends AbstractWstElement +{ + use ExtendableElementTrait; + + /** The namespace-attribute for the xs:any element */ + public const XS_ANY_ELT_NAMESPACE = NS::ANY; + + + /** + * AbstractKeyExchangeTokenType constructor + * + * @param array<\SimpleSAML\XML\SerializableElementInterface> $children + */ + final public function __construct( + array $children = [], + ) { + $this->setElements($children); + } + + + /** + * Test if an object, at the state it's in, would produce an empty XML-element + * + * @return bool + */ + public function isEmptyElement(): bool + { + return empty($this->getElements()); + } + + + /** + * Create an instance of this object from its XML representation. + * + * @param \DOMElement $xml + * @return static + * + * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException + * if the qualified name of the supplied element is wrong + */ + public static function fromXML(DOMElement $xml): static + { + Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + return new static( + self::getChildElementsFromXML($xml), + ); + } + + + /** + * Add this KeyExchangeTokenType to an XML element. + * + * @param \DOMElement $parent The element we should append this username token to. + * @return \DOMElement + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = parent::instantiateParentElement($parent); + + foreach ($this->getElements() as $child) { + if (!$child->isEmptyElement()) { + $child->toXML($e); + } + } + + return $e; + } +} diff --git a/src/XML/wst_200502/AbstractKeyTypeOpenEnum.php b/src/XML/wst_200502/AbstractKeyTypeOpenEnum.php new file mode 100644 index 00000000..500eda7c --- /dev/null +++ b/src/XML/wst_200502/AbstractKeyTypeOpenEnum.php @@ -0,0 +1,62 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use DOMElement; +use SimpleSAML\Assert\Assert; +use SimpleSAML\XML\Exception\InvalidDOMElementException; +use SimpleSAML\XML\Exception\SchemaViolationException; +use SimpleSAML\XML\StringElementTrait; + +use function array_map; +use function explode; +use function implode; + +/** + * A KeyTypeOpenEnum element + * + * @package simplesamlphp/ws-security + * + * @phpstan-consistent-constructor + */ +abstract class AbstractKeyTypeOpenEnum extends AbstractWstElement +{ + use StringElementTrait; + + + /** + * @param (\SimpleSAML\WSSecurity\XML\wst_200502\KeyTypeEnum|string)[] $values + */ + public function __construct(array $values) + { + $values = array_map( + function (KeyTypeEnum|string $v): string { + return ($v instanceof KeyTypeEnum) ? $v->value : $v; + }, + $values, + ); + Assert::allValidURI($values, SchemaViolationException::class); + + $this->setContent(implode(' ', $values)); + } + + + /** + * Convert XML into a class instance + * + * @param \DOMElement $xml The XML element we should load + * @return static + * + * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException + * If the qualified name of the supplied element is wrong + */ + public static function fromXML(DOMElement $xml): static + { + Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + return new static(explode(' ', $xml->textContent)); + } +} diff --git a/src/XML/wst_200502/AbstractLifetimeType.php b/src/XML/wst_200502/AbstractLifetimeType.php new file mode 100644 index 00000000..d96cfbd1 --- /dev/null +++ b/src/XML/wst_200502/AbstractLifetimeType.php @@ -0,0 +1,107 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use DOMElement; +use SimpleSAML\Assert\Assert; +use SimpleSAML\WSSecurity\XML\wsu\Created; +use SimpleSAML\WSSecurity\XML\wsu\Expires; +use SimpleSAML\XML\Exception\InvalidDOMElementException; +use SimpleSAML\XML\Exception\TooManyElementsException; + +/** + * Class defining the LifetimeType element + * + * @package simplesamlphp/ws-security + */ +abstract class AbstractLifetimeType extends AbstractWstElement +{ + /** + * AbstractLifetimeType constructor + * + * @param \SimpleSAML\WSSecurity\XML\wsu\Created|null $created + * @param \SimpleSAML\WSSecurity\XML\wsu\Expires|null $expires + */ + final public function __construct( + protected ?Created $created = null, + protected ?Expires $expires = null, + ) { + } + + + /** + * @return \SimpleSAML\WSSecurity\XML\wsu\Created|null + */ + public function getCreated(): ?Created + { + return $this->created; + } + + + /** + * @return \SimpleSAML\WSSecurity\XML\wsu\Expires|null + */ + public function getExpires(): ?Expires + { + return $this->expires; + } + + + /** + * Test if an object, at the state it's in, would produce an empty XML-element + * + * @return bool + */ + public function isEmptyElement(): bool + { + return empty($this->getCreated()) + && empty($this->getExpires()); + } + + + /** + * Create an instance of this object from its XML representation. + * + * @param \DOMElement $xml + * @return static + * + * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException + * if the qualified name of the supplied element is wrong + */ + public static function fromXML(DOMElement $xml): static + { + Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + $created = Created::getChildrenOfClass($xml); + Assert::maxCount($created, 1, TooManyElementsException::class); + + $expires = Expires::getChildrenOfClass($xml); + Assert::maxCount($expires, 1, TooManyElementsException::class); + + + return new static( + array_pop($created), + array_pop($expires), + ); + } + + + /** + * Add this LifetimeType to an XML element. + * + * @param \DOMElement $parent The element we should append this element to. + * @return \DOMElement + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = parent::instantiateParentElement($parent); + + $this->getCreated()?->toXML($e); + $this->getExpires()?->toXML($e); + + return $e; + } +} diff --git a/src/XML/wst_200502/AbstractOnBehalfOfType.php b/src/XML/wst_200502/AbstractOnBehalfOfType.php new file mode 100644 index 00000000..f47946a9 --- /dev/null +++ b/src/XML/wst_200502/AbstractOnBehalfOfType.php @@ -0,0 +1,83 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use DOMElement; +use SimpleSAML\Assert\Assert; +use SimpleSAML\XML\Exception\InvalidDOMElementException; +use SimpleSAML\XML\Exception\MissingElementException; +use SimpleSAML\XML\Exception\TooManyElementsException; +use SimpleSAML\XML\ExtendableElementTrait; +use SimpleSAML\XML\SerializableElementInterface; +use SimpleSAML\XML\XsNamespace as NS; + +/** + * Class defining the OnBehalfOfType element + * + * @package simplesamlphp/ws-security + */ +abstract class AbstractOnBehalfOfType extends AbstractWstElement +{ + use ExtendableElementTrait; + + /** The namespace-attribute for the xs:any element */ + public const XS_ANY_ELT_NAMESPACE = NS::ANY; + + + /** + * AbstractOnBehalfOfType constructor + * + * @param \SimpleSAML\XML\SerializableElementInterface $child + */ + final public function __construct( + SerializableElementInterface $child, + ) { + $this->setElements([$child]); + } + + + /** + * Create an instance of this object from its XML representation. + * + * @param \DOMElement $xml + * @return static + * + * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException + * if the qualified name of the supplied element is wrong + */ + public static function fromXML(DOMElement $xml): static + { + Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + $children = self::getChildElementsFromXML($xml); + Assert::minCount($children, 1, MissingElementException::class); + Assert::maxCount($children, 1, TooManyElementsException::class); + + return new static( + array_pop($children), + ); + } + + + /** + * Add this OnBehalfOfType to an XML element. + * + * @param \DOMElement $parent The element we should append this username token to. + * @return \DOMElement + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = parent::instantiateParentElement($parent); + + foreach ($this->getElements() as $child) { + if (!$child->isEmptyElement()) { + $child->toXML($e); + } + } + + return $e; + } +} diff --git a/src/XML/wst_200502/AbstractParticipantType.php b/src/XML/wst_200502/AbstractParticipantType.php new file mode 100644 index 00000000..de40a4a1 --- /dev/null +++ b/src/XML/wst_200502/AbstractParticipantType.php @@ -0,0 +1,83 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use DOMElement; +use SimpleSAML\Assert\Assert; +use SimpleSAML\XML\Exception\InvalidDOMElementException; +use SimpleSAML\XML\Exception\MissingElementException; +use SimpleSAML\XML\Exception\TooManyElementsException; +use SimpleSAML\XML\ExtendableElementTrait; +use SimpleSAML\XML\SerializableElementInterface; +use SimpleSAML\XML\XsNamespace as NS; + +/** + * Class defining the ParticipantType element + * + * @package simplesamlphp/ws-security + */ +abstract class AbstractParticipantType extends AbstractWstElement +{ + use ExtendableElementTrait; + + /** The namespace-attribute for the xs:any element */ + public const XS_ANY_ELT_NAMESPACE = NS::ANY; + + + /** + * AbstractParticipantType constructor + * + * @param \SimpleSAML\XML\SerializableElementInterface $child + */ + final public function __construct( + SerializableElementInterface $child, + ) { + $this->setElements([$child]); + } + + + /** + * Create an instance of this object from its XML representation. + * + * @param \DOMElement $xml + * @return static + * + * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException + * if the qualified name of the supplied element is wrong + */ + public static function fromXML(DOMElement $xml): static + { + Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + $children = self::getChildElementsFromXML($xml); + Assert::minCount($children, 1, MissingElementException::class); + Assert::maxCount($children, 1, TooManyElementsException::class); + + return new static( + array_pop($children), + ); + } + + + /** + * Add this ParticipantType to an XML element. + * + * @param \DOMElement $parent The element we should append this username token to. + * @return \DOMElement + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = parent::instantiateParentElement($parent); + + foreach ($this->getElements() as $child) { + if (!$child->isEmptyElement()) { + $child->toXML($e); + } + } + + return $e; + } +} diff --git a/src/XML/wst_200502/AbstractParticipantsType.php b/src/XML/wst_200502/AbstractParticipantsType.php new file mode 100644 index 00000000..1b6140cf --- /dev/null +++ b/src/XML/wst_200502/AbstractParticipantsType.php @@ -0,0 +1,123 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use DOMElement; +use SimpleSAML\Assert\Assert; +use SimpleSAML\XML\Exception\InvalidDOMElementException; +use SimpleSAML\XML\Exception\TooManyElementsException; +use SimpleSAML\XML\ExtendableElementTrait; +use SimpleSAML\XML\XsNamespace as NS; + +/** + * Class defining the ParticipantsType element + * + * @package simplesamlphp/ws-security + */ +abstract class AbstractParticipantsType extends AbstractWstElement +{ + use ExtendableElementTrait; + + /** The namespace-attribute for the xs:any element */ + public const XS_ANY_ELT_NAMESPACE = NS::OTHER; + + + /** + * AbstractParticipantsType constructor + * + * @param \SimpleSAML\WSSecurity\XML\wst_200502\Primary|null $primary + * @param array<\SimpleSAML\WSSecurity\XML\wst_200502\Participant> $participant + * @param array<\SimpleSAML\XML\SerializableElementInterface> $children + */ + final public function __construct( + protected ?Primary $primary = null, + protected array $participant = [], + array $children = [], + ) { + $this->setElements($children); + } + + + /** + * @return \SimpleSAML\WSSecurity\XML\wst_200502\Primary|null + */ + public function getPrimary(): ?Primary + { + return $this->primary; + } + + + /** + * @return \SimpleSAML\WSSecurity\XML\wst_200502\Participant[] + */ + public function getParticipant(): array + { + return $this->participant; + } + + + /** + * Test if an object, at the state it's in, would produce an empty XML-element + * + * @return bool + */ + public function isEmptyElement(): bool + { + return empty($this->getPrimary()) + && empty($this->getParticipant()) + && empty($this->getElements()); + } + + + /** + * Create an instance of this object from its XML representation. + * + * @param \DOMElement $xml + * @return static + * + * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException + * if the qualified name of the supplied element is wrong + */ + public static function fromXML(DOMElement $xml): static + { + Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + $primary = Primary::getChildrenOfClass($xml); + Assert::maxCount($primary, 1, TooManyElementsException::class); + + return new static( + array_pop($primary), + Participant::getChildrenOfClass($xml), + self::getChildElementsFromXML($xml), + ); + } + + + /** + * Add this ParticipantsType to an XML element. + * + * @param \DOMElement $parent The element we should append this element to. + * @return \DOMElement + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = parent::instantiateParentElement($parent); + + $this->getPrimary()?->toXML($e); + + foreach ($this->getParticipant() as $p) { + $p->toXML($e); + } + + foreach ($this->getElements() as $child) { + if (!$child->isEmptyElement()) { + $child->toXML($e); + } + } + + return $e; + } +} diff --git a/src/XML/wst_200502/AbstractProofEncryptionType.php b/src/XML/wst_200502/AbstractProofEncryptionType.php new file mode 100644 index 00000000..a53dbf2b --- /dev/null +++ b/src/XML/wst_200502/AbstractProofEncryptionType.php @@ -0,0 +1,83 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use DOMElement; +use SimpleSAML\Assert\Assert; +use SimpleSAML\XML\Exception\InvalidDOMElementException; +use SimpleSAML\XML\Exception\MissingElementException; +use SimpleSAML\XML\Exception\TooManyElementsException; +use SimpleSAML\XML\ExtendableElementTrait; +use SimpleSAML\XML\SerializableElementInterface; +use SimpleSAML\XML\XsNamespace as NS; + +/** + * Class defining the ProofEncryptionType element + * + * @package simplesamlphp/ws-security + */ +abstract class AbstractProofEncryptionType extends AbstractWstElement +{ + use ExtendableElementTrait; + + /** The namespace-attribute for the xs:any element */ + public const XS_ANY_ELT_NAMESPACE = NS::ANY; + + + /** + * AbstractProofEncryptionType constructor + * + * @param \SimpleSAML\XML\SerializableElementInterface $child + */ + final public function __construct( + SerializableElementInterface $child, + ) { + $this->setElements([$child]); + } + + + /** + * Create an instance of this object from its XML representation. + * + * @param \DOMElement $xml + * @return static + * + * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException + * if the qualified name of the supplied element is wrong + */ + public static function fromXML(DOMElement $xml): static + { + Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + $children = self::getChildElementsFromXML($xml); + Assert::minCount($children, 1, MissingElementException::class); + Assert::maxCount($children, 1, TooManyElementsException::class); + + return new static( + array_pop($children), + ); + } + + + /** + * Add this ProofEncryptionType to an XML element. + * + * @param \DOMElement $parent The element we should append this username token to. + * @return \DOMElement + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = parent::instantiateParentElement($parent); + + foreach ($this->getElements() as $child) { + if (!$child->isEmptyElement()) { + $child->toXML($e); + } + } + + return $e; + } +} diff --git a/src/XML/wst_200502/AbstractRenewTargetType.php b/src/XML/wst_200502/AbstractRenewTargetType.php new file mode 100644 index 00000000..6c047e0b --- /dev/null +++ b/src/XML/wst_200502/AbstractRenewTargetType.php @@ -0,0 +1,85 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use DOMElement; +use SimpleSAML\Assert\Assert; +use SimpleSAML\XML\Exception\InvalidDOMElementException; +use SimpleSAML\XML\Exception\MissingElementException; +use SimpleSAML\XML\Exception\TooManyElementsException; +use SimpleSAML\XML\ExtendableElementTrait; +use SimpleSAML\XML\SerializableElementInterface; +use SimpleSAML\XML\XsNamespace as NS; + +use function array_pop; + +/** + * Class defining the RenewTargetType element + * + * @package simplesamlphp/ws-security + */ +abstract class AbstractRenewTargetType extends AbstractWstElement +{ + use ExtendableElementTrait; + + /** The namespace-attribute for the xs:any element */ + public const XS_ANY_ELT_NAMESPACE = NS::OTHER; + + + /** + * AbstractRenewTargetType constructor + * + * @param \SimpleSAML\XML\SerializableElementInterface $child + */ + final public function __construct( + SerializableElementInterface $child, + ) { + $this->setElements([$child]); + } + + + /** + * Create an instance of this object from its XML representation. + * + * @param \DOMElement $xml + * @return static + * + * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException + * if the qualified name of the supplied element is wrong + */ + public static function fromXML(DOMElement $xml): static + { + Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + $children = self::getChildElementsFromXML($xml); + Assert::minCount($children, 1, MissingElementException::class); + Assert::maxCount($children, 1, TooManyElementsException::class); + + return new static( + array_pop($children), + ); + } + + + /** + * Add this RenewTargetType to an XML element. + * + * @param \DOMElement $parent The element we should append this username token to. + * @return \DOMElement + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = parent::instantiateParentElement($parent); + + foreach ($this->getElements() as $child) { + if (!$child->isEmptyElement()) { + $child->toXML($e); + } + } + + return $e; + } +} diff --git a/src/XML/wst_200502/AbstractRenewingType.php b/src/XML/wst_200502/AbstractRenewingType.php new file mode 100644 index 00000000..fe49ec04 --- /dev/null +++ b/src/XML/wst_200502/AbstractRenewingType.php @@ -0,0 +1,102 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use DOMElement; +use SimpleSAML\Assert\Assert; +use SimpleSAML\XML\Exception\InvalidDOMElementException; + +/** + * Class defining the RenewingType element + * + * @package simplesamlphp/ws-security + */ +abstract class AbstractRenewingType extends AbstractWstElement +{ + /** + * AbstractRenewingType constructor + * + * @param bool|null $allow + * @param bool|null $ok + */ + final public function __construct( + protected ?bool $allow = null, + protected ?bool $ok = null, + ) { + } + + + /** + * @return bool|null + */ + public function getAllow(): ?bool + { + return $this->allow; + } + + + /** + * @return bool|null + */ + public function getOk(): ?bool + { + return $this->ok; + } + + + /** + * Test if an object, at the state it's in, would produce an empty XML-element + * + * @return bool + */ + public function isEmptyElement(): bool + { + return empty($this->getAllow()) + && empty($this->getOk()); + } + + + /** + * Create an instance of this object from its XML representation. + * + * @param \DOMElement $xml + * @return static + * + * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException + * if the qualified name of the supplied element is wrong + */ + public static function fromXML(DOMElement $xml): static + { + Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + return new static( + self::getOptionalBooleanAttribute($xml, 'Allow', null), + self::getOptionalBooleanAttribute($xml, 'OK', null), + ); + } + + + /** + * Add this UseKeyType to an XML element. + * + * @param \DOMElement $parent The element we should append this username token to. + * @return \DOMElement + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = parent::instantiateParentElement($parent); + + if ($this->getAllow() !== null) { + $e->setAttribute('Allow', $this->getAllow() ? 'true' : 'false'); + } + + if ($this->getOk() !== null) { + $e->setAttribute('OK', $this->getOk() ? 'true' : 'false'); + } + + return $e; + } +} diff --git a/src/XML/wst_200502/AbstractRequestSecurityTokenResponseCollectionType.php b/src/XML/wst_200502/AbstractRequestSecurityTokenResponseCollectionType.php new file mode 100644 index 00000000..33aae0b4 --- /dev/null +++ b/src/XML/wst_200502/AbstractRequestSecurityTokenResponseCollectionType.php @@ -0,0 +1,99 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use DOMElement; +use SimpleSAML\Assert\Assert; +use SimpleSAML\XML\Exception\InvalidDOMElementException; +use SimpleSAML\XML\Exception\MissingElementException; +use SimpleSAML\XML\Exception\SchemaViolationException; +use SimpleSAML\XML\ExtendableAttributesTrait; +use SimpleSAML\XML\XsNamespace as NS; + +/** + * A RequestSecurityTokenResponseCollectionType element + * + * @package simplesamlphp/ws-security + */ +abstract class AbstractRequestSecurityTokenResponseCollectionType extends AbstractWstElement +{ + use ExtendableAttributesTrait; + + /** @var string|\SimpleSAML\XML\XsNamespace */ + public const XS_ANY_ATTR_NAMESPACE = NS::OTHER; + + + /** + * @param array<\SimpleSAML\WSSecurity\XML\wst_200502\RequestSecurityTokenResponse> $requestSecurityTokenResponse + * @param array<\SimpleSAML\XML\Attribute> $namespacedAttributes + */ + final public function __construct( + protected array $requestSecurityTokenResponse, + array $namespacedAttributes, + ) { + Assert::minCount($requestSecurityTokenResponse, 1, MissingElementException::class); + Assert::allIsInstanceOf( + $requestSecurityTokenResponse, + RequestSecurityTokenResponse::class, + SchemaViolationException::class, + ); + + $this->setAttributesNS($namespacedAttributes); + } + + + /** + * Get the requestSecurityTokenResponse property. + * + * @return \SimpleSAML\WSSecurity\XML\wst_200502\RequestSecurityTokenResponse[] + */ + public function getRequestSecurityTokenResponse(): array + { + return $this->requestSecurityTokenResponse; + } + + + /** + * Convert XML into a class instance + * + * @param \DOMElement $xml The XML element we should load + * @return static + * + * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException + * If the qualified name of the supplied element is wrong + */ + public static function fromXML(DOMElement $xml): static + { + Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + return new static( + RequestSecurityTokenResponse::getChildrenOfClass($xml), + self::getAttributesNSFromXML($xml), + ); + } + + + /** + * Convert this element to XML. + * + * @param \DOMElement|null $parent The element we should append this element to. + * @return \DOMElement + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = $this->instantiateParentElement($parent); + + foreach ($this->getRequestSecurityTokenResponse() as $r) { + $r->toXML($e); + } + + foreach ($this->getAttributesNS() as $attr) { + $attr->toXML($e); + } + + return $e; + } +} diff --git a/src/XML/wst_200502/AbstractRequestSecurityTokenResponseType.php b/src/XML/wst_200502/AbstractRequestSecurityTokenResponseType.php new file mode 100644 index 00000000..0c93349f --- /dev/null +++ b/src/XML/wst_200502/AbstractRequestSecurityTokenResponseType.php @@ -0,0 +1,121 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use DOMElement; +use SimpleSAML\Assert\Assert; +use SimpleSAML\XML\Exception\InvalidDOMElementException; +use SimpleSAML\XML\Exception\SchemaViolationException; +use SimpleSAML\XML\ExtendableAttributesTrait; +use SimpleSAML\XML\ExtendableElementTrait; +use SimpleSAML\XML\XsNamespace as NS; + +/** + * Class defining the RequestSecurityTokenResponseType element + * + * @package simplesamlphp/ws-security + */ +abstract class AbstractRequestSecurityTokenResponseType extends AbstractWstElement +{ + use ExtendableAttributesTrait; + use ExtendableElementTrait; + + /** The namespace-attribute for the xs:any element */ + public const XS_ANY_ELT_NAMESPACE = NS::ANY; + + /** The namespace-attribute for the xs:anyAttribute element */ + public const XS_ANY_ATTR_NAMESPACE = NS::OTHER; + + + /** + * AbstractRequestSecurityTokenResponseType constructor + * + * @param string|null $context + * @param array<\SimpleSAML\XML\SerializableElementInterface> $children + * @param array<\SimpleSAML\XML\Attribute> $namespacedAttributes + */ + final public function __construct( + protected ?string $context = null, + array $children = [], + array $namespacedAttributes = [], + ) { + Assert::nullOrValidURI($context, SchemaViolationException::class); + + $this->setElements($children); + $this->setAttributesNS($namespacedAttributes); + } + + + /** + * @return string|null + */ + public function getContext(): ?string + { + return $this->context; + } + + + /** + * Test if an object, at the state it's in, would produce an empty XML-element + * + * @return bool + */ + public function isEmptyElement(): bool + { + return empty($this->getContext()) + && empty($this->getElements()) + && empty($this->getAttributesNS()); + } + + + /** + * Create an instance of this object from its XML representation. + * + * @param \DOMElement $xml + * @return static + * + * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException + * if the qualified name of the supplied element is wrong + */ + public static function fromXML(DOMElement $xml): static + { + Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + return new static( + self::getOptionalAttribute($xml, 'Context'), + self::getChildElementsFromXML($xml), + self::getAttributesNSFromXML($xml), + ); + } + + + /** + * Add this RequestSecurityTokenResponseType to an XML element. + * + * @param \DOMElement $parent The element we should append this username token to. + * @return \DOMElement + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = parent::instantiateParentElement($parent); + + if ($this->getContext() !== null) { + $e->setAttribute('Context', $this->getContext()); + } + + foreach ($this->getAttributesNS() as $attr) { + $attr->toXML($e); + } + + foreach ($this->getElements() as $child) { + if (!$child->isEmptyElement()) { + $child->toXML($e); + } + } + + return $e; + } +} diff --git a/src/XML/wst_200502/AbstractRequestSecurityTokenType.php b/src/XML/wst_200502/AbstractRequestSecurityTokenType.php new file mode 100644 index 00000000..d088f0f7 --- /dev/null +++ b/src/XML/wst_200502/AbstractRequestSecurityTokenType.php @@ -0,0 +1,123 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use DOMElement; +use SimpleSAML\Assert\Assert; +use SimpleSAML\XML\Exception\InvalidDOMElementException; +use SimpleSAML\XML\Exception\SchemaViolationException; +use SimpleSAML\XML\ExtendableAttributesTrait; +use SimpleSAML\XML\ExtendableElementTrait; +use SimpleSAML\XML\XsNamespace as NS; + +/** + * Class defining the RequestSecurityTokenType element + * + * @package simplesamlphp/ws-security + * + * @phpstan-consistent-constructor + */ +abstract class AbstractRequestSecurityTokenType extends AbstractWstElement +{ + use ExtendableAttributesTrait; + use ExtendableElementTrait; + + /** The namespace-attribute for the xs:any element */ + public const XS_ANY_ELT_NAMESPACE = NS::ANY; + + /** The namespace-attribute for the xs:anyAttribute element */ + public const XS_ANY_ATTR_NAMESPACE = NS::OTHER; + + + /** + * AbstractRequestSecurityTokenType constructor + * + * @param string|null $context + * @param array<\SimpleSAML\XML\SerializableElementInterface> $children + * @param array<\SimpleSAML\XML\Attribute> $namespacedAttributes + */ + final public function __construct( + protected ?string $context = null, + array $children = [], + array $namespacedAttributes = [], + ) { + Assert::nullOrValidURI($context, SchemaViolationException::class); + + $this->setElements($children); + $this->setAttributesNS($namespacedAttributes); + } + + + /** + * @return string|null + */ + public function getContext(): ?string + { + return $this->context; + } + + + /** + * Test if an object, at the state it's in, would produce an empty XML-element + * + * @return bool + */ + public function isEmptyElement(): bool + { + return empty($this->getContext()) + && empty($this->getElements()) + && empty($this->getAttributesNS()); + } + + + /** + * Create an instance of this object from its XML representation. + * + * @param \DOMElement $xml + * @return static + * + * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException + * if the qualified name of the supplied element is wrong + */ + public static function fromXML(DOMElement $xml): static + { + Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + return new static( + self::getOptionalAttribute($xml, 'Context'), + self::getChildElementsFromXML($xml), + self::getAttributesNSFromXML($xml), + ); + } + + + /** + * Add this RequestSecurityTokenType to an XML element. + * + * @param \DOMElement $parent The element we should append this username token to. + * @return \DOMElement + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = parent::instantiateParentElement($parent); + + if ($this->getContext() !== null) { + $e->setAttribute('Context', $this->getContext()); + } + + foreach ($this->getAttributesNS() as $attr) { + $attr->toXML($e); + } + + foreach ($this->getElements() as $child) { + if (!$child->isEmptyElement()) { + $child->toXML($e); + } + } + + return $e; + } +} diff --git a/src/XML/wst_200502/AbstractRequestTypeOpenEnum.php b/src/XML/wst_200502/AbstractRequestTypeOpenEnum.php new file mode 100644 index 00000000..f9c776df --- /dev/null +++ b/src/XML/wst_200502/AbstractRequestTypeOpenEnum.php @@ -0,0 +1,62 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use DOMElement; +use SimpleSAML\Assert\Assert; +use SimpleSAML\XML\Exception\InvalidDOMElementException; +use SimpleSAML\XML\Exception\SchemaViolationException; +use SimpleSAML\XML\StringElementTrait; + +use function array_map; +use function explode; +use function implode; + +/** + * A RequestTypeOpenEnum element + * + * @package simplesamlphp/ws-security + * + * @phpstan-consistent-constructor + */ +abstract class AbstractRequestTypeOpenEnum extends AbstractWstElement +{ + use StringElementTrait; + + + /** + * @param (\SimpleSAML\WSSecurity\XML\wst_200502\RequestTypeEnum|string)[] $values + */ + public function __construct(array $values) + { + $values = array_map( + function (RequestTypeEnum|string $v): string { + return ($v instanceof RequestTypeEnum) ? $v->value : $v; + }, + $values, + ); + Assert::allValidURI($values, SchemaViolationException::class); + + $this->setContent(implode(' ', $values)); + } + + + /** + * Convert XML into a class instance + * + * @param \DOMElement $xml The XML element we should load + * @return static + * + * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException + * If the qualified name of the supplied element is wrong + */ + public static function fromXML(DOMElement $xml): static + { + Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + return new static(explode(' ', $xml->textContent)); + } +} diff --git a/src/XML/wst_200502/AbstractRequestedProofTokenType.php b/src/XML/wst_200502/AbstractRequestedProofTokenType.php new file mode 100644 index 00000000..d83c6a69 --- /dev/null +++ b/src/XML/wst_200502/AbstractRequestedProofTokenType.php @@ -0,0 +1,83 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use DOMElement; +use SimpleSAML\Assert\Assert; +use SimpleSAML\XML\Exception\InvalidDOMElementException; +use SimpleSAML\XML\Exception\MissingElementException; +use SimpleSAML\XML\Exception\TooManyElementsException; +use SimpleSAML\XML\ExtendableElementTrait; +use SimpleSAML\XML\SerializableElementInterface; +use SimpleSAML\XML\XsNamespace as NS; + +/** + * Class defining the RequestedProofTokenType element + * + * @package simplesamlphp/ws-security + */ +abstract class AbstractRequestedProofTokenType extends AbstractWstElement +{ + use ExtendableElementTrait; + + /** The namespace-attribute for the xs:any element */ + public const XS_ANY_ELT_NAMESPACE = NS::ANY; + + + /** + * AbstractRequestedProofTokenType constructor + * + * @param \SimpleSAML\XML\SerializableElementInterface $child + */ + final public function __construct( + SerializableElementInterface $child, + ) { + $this->setElements([$child]); + } + + + /** + * Create an instance of this object from its XML representation. + * + * @param \DOMElement $xml + * @return static + * + * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException + * if the qualified name of the supplied element is wrong + */ + public static function fromXML(DOMElement $xml): static + { + Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + $children = self::getChildElementsFromXML($xml); + Assert::minCount($children, 1, MissingElementException::class); + Assert::maxCount($children, 1, TooManyElementsException::class); + + return new static( + array_pop($children), + ); + } + + + /** + * Add this RequestedProofTokenType to an XML element. + * + * @param \DOMElement $parent The element we should append this username token to. + * @return \DOMElement + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = parent::instantiateParentElement($parent); + + foreach ($this->getElements() as $child) { + if (!$child->isEmptyElement()) { + $child->toXML($e); + } + } + + return $e; + } +} diff --git a/src/XML/wst_200502/AbstractRequestedReferenceType.php b/src/XML/wst_200502/AbstractRequestedReferenceType.php new file mode 100644 index 00000000..3472225b --- /dev/null +++ b/src/XML/wst_200502/AbstractRequestedReferenceType.php @@ -0,0 +1,81 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use DOMElement; +use SimpleSAML\Assert\Assert; +use SimpleSAML\WSSecurity\XML\wsse\SecurityTokenReference; +use SimpleSAML\XML\Exception\InvalidDOMElementException; +use SimpleSAML\XML\Exception\MissingElementException; +use SimpleSAML\XML\Exception\TooManyElementsException; + +use function array_pop; + +/** + * Class defining the RequestedReferenceType element + * + * @package simplesamlphp/ws-security + */ +abstract class AbstractRequestedReferenceType extends AbstractWstElement +{ + /** + * AbstractRequestedReferenceType constructor + * + * @param \SimpleSAML\WSSecurity\XML\wsse\SecurityTokenReference $securityTokenReference + */ + final public function __construct( + protected SecurityTokenReference $securityTokenReference, + ) { + } + + + /** + * Collect the value of the securityTokenReference property. + * + * @return \SimpleSAML\WSSecurity\XML\wsse\SecurityTokenReference + */ + public function getSecurityTokenReference(): SecurityTokenReference + { + return $this->securityTokenReference; + } + + + /** + * Create an instance of this object from its XML representation. + * + * @param \DOMElement $xml + * @return static + * + * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException + * if the qualified name of the supplied element is wrong + */ + public static function fromXML(DOMElement $xml): static + { + Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + $securityTokenReference = SecurityTokenReference::getChildrenOfClass($xml); + Assert::minCount($securityTokenReference, 1, MissingElementException::class); + Assert::maxCount($securityTokenReference, 1, TooManyElementsException::class); + + return new static(array_pop($securityTokenReference)); + } + + + /** + * Add this RequestedReferenceType to an XML element. + * + * @param \DOMElement $parent The element we should append this element to. + * @return \DOMElement + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = parent::instantiateParentElement($parent); + + $this->getSecurityTokenReference()->toXML($e); + + return $e; + } +} diff --git a/src/XML/wst_200502/AbstractRequestedSecurityTokenType.php b/src/XML/wst_200502/AbstractRequestedSecurityTokenType.php new file mode 100644 index 00000000..f6e4cbd6 --- /dev/null +++ b/src/XML/wst_200502/AbstractRequestedSecurityTokenType.php @@ -0,0 +1,83 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use DOMElement; +use SimpleSAML\Assert\Assert; +use SimpleSAML\XML\Exception\InvalidDOMElementException; +use SimpleSAML\XML\Exception\MissingElementException; +use SimpleSAML\XML\Exception\TooManyElementsException; +use SimpleSAML\XML\ExtendableElementTrait; +use SimpleSAML\XML\SerializableElementInterface; +use SimpleSAML\XML\XsNamespace as NS; + +use function array_pop; + +/** + * Class defining the RequestedSecurityTokenType element + * + * @package simplesamlphp/ws-security + */ +abstract class AbstractRequestedSecurityTokenType extends AbstractWstElement +{ + use ExtendableElementTrait; + + /** The namespace-attribute for the xs:any element */ + public const XS_ANY_ELT_NAMESPACE = NS::ANY; + + + /** + * AbstractRequestedSecurityTokenType constructor + * + * @param \SimpleSAML\XML\SerializableElementInterface $child + */ + final public function __construct( + SerializableElementInterface $child, + ) { + $this->setElements([$child]); + } + + + /** + * Create an instance of this object from its XML representation. + * + * @param \DOMElement $xml + * @return static + * + * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException + * if the qualified name of the supplied element is wrong + */ + public static function fromXML(DOMElement $xml): static + { + Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + $children = self::getChildElementsFromXML($xml); + Assert::minCount($children, 1, MissingElementException::class); + Assert::maxCount($children, 1, TooManyElementsException::class); + + return new static(array_pop($children)); + } + + + /** + * Add this RequestedSecurityTokenType to an XML element. + * + * @param \DOMElement $parent The element we should append this element to. + * @return \DOMElement + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = parent::instantiateParentElement($parent); + + foreach ($this->getElements() as $child) { + if (!$child->isEmptyElement()) { + $child->toXML($e); + } + } + + return $e; + } +} diff --git a/src/XML/wst_200502/AbstractSignChallengeType.php b/src/XML/wst_200502/AbstractSignChallengeType.php new file mode 100644 index 00000000..223338da --- /dev/null +++ b/src/XML/wst_200502/AbstractSignChallengeType.php @@ -0,0 +1,126 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use DOMElement; +use SimpleSAML\Assert\Assert; +use SimpleSAML\XML\Exception\InvalidDOMElementException; +use SimpleSAML\XML\ExtendableAttributesTrait; +use SimpleSAML\XML\ExtendableElementTrait; +use SimpleSAML\XML\XsNamespace as NS; + +use function array_pop; + +/** + * Class defining the SignChallengeType element + * + * @package simplesamlphp/ws-security + */ +abstract class AbstractSignChallengeType extends AbstractWstElement +{ + use ExtendableAttributesTrait; + use ExtendableElementTrait; + + /** The namespace-attribute for the xs:any element */ + public const XS_ANY_ELT_NAMESPACE = NS::ANY; + + /** The exclusions for the xs:any element */ + public const XS_ANY_ELT_EXCLUSIONS = [ + ['http://schemas.xmlsoap.org/ws/2005/02/trust', 'Challenge'], + ]; + + /** The namespace-attribute for the xs:anyAttribute element */ + public const XS_ANY_ATTR_NAMESPACE = NS::ANY; + + + /** + * AbstractSignChallengeType constructor + * + * @param \SimpleSAML\WSSecurity\XML\wst_200502\Challenge|null $challenge + * @param array<\SimpleSAML\XML\SerializableElementInterface> $children + * @param array<\SimpleSAML\XML\Attribute> $namespacedAttributes + */ + final public function __construct( + protected ?Challenge $challenge = null, + array $children = [], + array $namespacedAttributes = [], + ) { + $this->setElements($children); + $this->setAttributesNS($namespacedAttributes); + } + + + /** + * @return \SimpleSAML\WSSecurity\XML\wst_200502\Challenge|null + */ + public function getChallenge(): ?Challenge + { + return $this->challenge; + } + + + /** + * Test if an object, at the state it's in, would produce an empty XML-element + * + * @return bool + */ + public function isEmptyElement(): bool + { + return empty($this->getChallenge()) + && empty($this->getElements()) + && empty($this->getAttributesNS()); + } + + + /** + * Create an instance of this object from its XML representation. + * + * @param \DOMElement $xml + * @return static + * + * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException + * if the qualified name of the supplied element is wrong + */ + public static function fromXML(DOMElement $xml): static + { + Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + $challenge = Challenge::getChildrenOfClass($xml); + $children = self::getChildElementsFromXML($xml); + + return new static( + array_pop($challenge), + $children, + self::getAttributesNSFromXML($xml), + ); + } + + + /** + * Add this SignChallengeType to an XML element. + * + * @param \DOMElement $parent The element we should append this username token to. + * @return \DOMElement + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = parent::instantiateParentElement($parent); + + $this->getChallenge()?->toXML($e); + + foreach ($this->getElements() as $child) { + if (!$child->isEmptyElement()) { + $child->toXML($e); + } + } + + foreach ($this->getAttributesNS() as $attr) { + $attr->toXML($e); + } + + return $e; + } +} diff --git a/src/XML/wst_200502/AbstractStatusCodeOpenEnum.php b/src/XML/wst_200502/AbstractStatusCodeOpenEnum.php new file mode 100644 index 00000000..5d416bed --- /dev/null +++ b/src/XML/wst_200502/AbstractStatusCodeOpenEnum.php @@ -0,0 +1,62 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use DOMElement; +use SimpleSAML\Assert\Assert; +use SimpleSAML\XML\Exception\InvalidDOMElementException; +use SimpleSAML\XML\Exception\SchemaViolationException; +use SimpleSAML\XML\StringElementTrait; + +use function array_map; +use function explode; +use function implode; + +/** + * A StatusCodeOpenEnum element + * + * @package simplesamlphp/ws-security + * + * @phpstan-consistent-constructor + */ +abstract class AbstractStatusCodeOpenEnum extends AbstractWstElement +{ + use StringElementTrait; + + + /** + * @param (\SimpleSAML\WSSecurity\XML\wst_200502\StatusCodeEnum|string)[] $values + */ + public function __construct(array $values) + { + $values = array_map( + function (StatusCodeEnum|string $v): string { + return ($v instanceof StatusCodeEnum) ? $v->value : $v; + }, + $values, + ); + Assert::allValidURI($values, SchemaViolationException::class); + + $this->setContent(implode(' ', $values)); + } + + + /** + * Convert XML into a class instance + * + * @param \DOMElement $xml The XML element we should load + * @return static + * + * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException + * If the qualified name of the supplied element is wrong + */ + public static function fromXML(DOMElement $xml): static + { + Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + return new static(explode(' ', $xml->textContent)); + } +} diff --git a/src/XML/wst_200502/AbstractStatusType.php b/src/XML/wst_200502/AbstractStatusType.php new file mode 100644 index 00000000..b4e823ea --- /dev/null +++ b/src/XML/wst_200502/AbstractStatusType.php @@ -0,0 +1,95 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use DOMElement; +use SimpleSAML\Assert\Assert; +use SimpleSAML\XML\Exception\InvalidDOMElementException; +use SimpleSAML\XML\Exception\MissingElementException; +use SimpleSAML\XML\Exception\TooManyElementsException; + +/** + * Class defining the StatusType element + * + * @package simplesamlphp/ws-security + */ +abstract class AbstractStatusType extends AbstractWstElement +{ + /** + * AbstractStatusType constructor + * + * @param \SimpleSAML\WSSecurity\XML\wst_200502\Code $code + * @param \SimpleSAML\WSSecurity\XML\wst_200502\Reason|null $reason + */ + final public function __construct( + protected Code $code, + protected ?Reason $reason = null, + ) { + } + + + /** + * @return \SimpleSAML\WSSecurity\XML\wst_200502\Code + */ + public function getCode(): Code + { + return $this->code; + } + + + /** + * @return \SimpleSAML\WSSecurity\XML\wst_200502\Reason|null + */ + public function getReason(): ?Reason + { + return $this->reason; + } + + + /** + * Create an instance of this object from its XML representation. + * + * @param \DOMElement $xml + * @return static + * + * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException + * if the qualified name of the supplied element is wrong + */ + public static function fromXML(DOMElement $xml): static + { + Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + $code = Code::getChildrenOfClass($xml); + Assert::minCount($code, 1, MissingElementException::class); + Assert::maxCount($code, 1, TooManyElementsException::class); + + $reason = Reason::getChildrenOfClass($xml); + Assert::maxCount($reason, 1, TooManyElementsException::class); + + + return new static( + array_pop($code), + array_pop($reason), + ); + } + + + /** + * Add this UseKeyType to an XML element. + * + * @param \DOMElement $parent The element we should append this username token to. + * @return \DOMElement + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = parent::instantiateParentElement($parent); + + $this->getCode()->toXML($e); + $this->getReason()?->toXML($e); + + return $e; + } +} diff --git a/src/XML/wst_200502/AbstractUseKeyType.php b/src/XML/wst_200502/AbstractUseKeyType.php new file mode 100644 index 00000000..e5f5c989 --- /dev/null +++ b/src/XML/wst_200502/AbstractUseKeyType.php @@ -0,0 +1,114 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use DOMElement; +use SimpleSAML\Assert\Assert; +use SimpleSAML\XML\Exception\InvalidDOMElementException; +use SimpleSAML\XML\Exception\SchemaViolationException; +use SimpleSAML\XML\Exception\TooManyElementsException; +use SimpleSAML\XML\ExtendableElementTrait; +use SimpleSAML\XML\SerializableElementInterface; +use SimpleSAML\XML\XsNamespace as NS; + +/** + * Class defining the UseKeyType element + * + * @package simplesamlphp/ws-security + */ +abstract class AbstractUseKeyType extends AbstractWstElement +{ + use ExtendableElementTrait; + + /** The namespace-attribute for the xs:any element */ + public const XS_ANY_ELT_NAMESPACE = NS::ANY; + + + /** + * AbstractUseKeyType constructor + * + * @param \SimpleSAML\XML\SerializableElementInterface|null $child + * @param string|null $Sig + */ + final public function __construct( + ?SerializableElementInterface $child = null, + protected ?string $Sig = null, + ) { + Assert::nullOrValidURI($Sig, SchemaViolationException::class); + + if ($child !== null) { + $this->setElements([$child]); + } + } + + + /** + * @return string|null + */ + public function getSig(): ?string + { + return $this->Sig; + } + + + /** + * Test if an object, at the state it's in, would produce an empty XML-element + * + * @return bool + */ + public function isEmptyElement(): bool + { + return empty($this->getSig()) + && empty($this->getElements()); + } + + + /** + * Create an instance of this object from its XML representation. + * + * @param \DOMElement $xml + * @return static + * + * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException + * if the qualified name of the supplied element is wrong + */ + public static function fromXML(DOMElement $xml): static + { + Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + $children = self::getChildElementsFromXML($xml); + Assert::maxCount($children, 1, TooManyElementsException::class); + + return new static( + array_pop($children), + self::getOptionalAttribute($xml, 'Sig', null), + ); + } + + + /** + * Add this UseKeyType to an XML element. + * + * @param \DOMElement $parent The element we should append this username token to. + * @return \DOMElement + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = parent::instantiateParentElement($parent); + + if ($this->getSig() !== null) { + $e->setAttribute('Sig', $this->getSig()); + } + + foreach ($this->getElements() as $child) { + if (!$child->isEmptyElement()) { + $child->toXML($e); + } + } + + return $e; + } +} diff --git a/src/XML/wst_200502/AbstractWstElement.php b/src/XML/wst_200502/AbstractWstElement.php new file mode 100644 index 00000000..7156911f --- /dev/null +++ b/src/XML/wst_200502/AbstractWstElement.php @@ -0,0 +1,22 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use SimpleSAML\WSSecurity\Constants as C; +use SimpleSAML\XML\AbstractElement; + +/** + * Abstract class to be implemented by all the classes in this namespace + * + * @package simplesamlphp/ws-security + */ +abstract class AbstractWstElement extends AbstractElement +{ + /** @var string */ + public const NS = C::NS_TRUST_200502; + + /** @var string */ + public const NS_PREFIX = 't'; +} diff --git a/src/XML/wst_200502/AllowPostdating.php b/src/XML/wst_200502/AllowPostdating.php new file mode 100644 index 00000000..f41e415d --- /dev/null +++ b/src/XML/wst_200502/AllowPostdating.php @@ -0,0 +1,46 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use DOMElement; +use SimpleSAML\Assert\Assert; +use SimpleSAML\XML\Exception\InvalidDOMElementException; + +/** + * A AllowPostdating element + * + * @package simplesamlphp/ws-security + */ +final class AllowPostdating extends AbstractWstElement +{ + /** + * Convert XML into a class instance + * + * @param \DOMElement $xml The XML element we should load + * @return static + * + * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException + * If the qualified name of the supplied element is wrong + */ + public static function fromXML(DOMElement $xml): static + { + Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + return new static(); + } + + + /** + * Convert this element to XML. + * + * @param \DOMElement|null $parent The element we should append this element to. + * @return \DOMElement + */ + public function toXML(DOMElement $parent = null): DOMElement + { + return $this->instantiateParentElement($parent); + } +} diff --git a/src/XML/wst_200502/AuthenticationType.php b/src/XML/wst_200502/AuthenticationType.php new file mode 100644 index 00000000..b164479e --- /dev/null +++ b/src/XML/wst_200502/AuthenticationType.php @@ -0,0 +1,26 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use SimpleSAML\XML\URIElementTrait; + +/** + * A AuthenticationType element + * + * @package simplesamlphp/ws-security + */ +final class AuthenticationType extends AbstractWstElement +{ + use URIElementTrait; + + + /** + * @param string $content + */ + public function __construct(string $content) + { + $this->setContent($content); + } +} diff --git a/src/XML/wst_200502/Authenticator.php b/src/XML/wst_200502/Authenticator.php new file mode 100644 index 00000000..26ae8f7d --- /dev/null +++ b/src/XML/wst_200502/Authenticator.php @@ -0,0 +1,14 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +/** + * An Authenticator element + * + * @package simplesamlphp/ws-security + */ +final class Authenticator extends AbstractAuthenticatorType +{ +} diff --git a/src/XML/wst_200502/BinaryExchange.php b/src/XML/wst_200502/BinaryExchange.php new file mode 100644 index 00000000..d4d9dd50 --- /dev/null +++ b/src/XML/wst_200502/BinaryExchange.php @@ -0,0 +1,14 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +/** + * A BinaryExchange element + * + * @package simplesamlphp/ws-security + */ +final class BinaryExchange extends AbstractBinaryExchangeType +{ +} diff --git a/src/XML/wst_200502/BinarySecret.php b/src/XML/wst_200502/BinarySecret.php new file mode 100644 index 00000000..39f42ef4 --- /dev/null +++ b/src/XML/wst_200502/BinarySecret.php @@ -0,0 +1,14 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +/** + * A BinarySecret element + * + * @package simplesamlphp/ws-security + */ +final class BinarySecret extends AbstractBinarySecretType +{ +} diff --git a/src/XML/wst_200502/BinarySecretTypeEnum.php b/src/XML/wst_200502/BinarySecretTypeEnum.php new file mode 100644 index 00000000..c280cd6b --- /dev/null +++ b/src/XML/wst_200502/BinarySecretTypeEnum.php @@ -0,0 +1,12 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +enum BinarySecretTypeEnum: string +{ + case Asymmetric = 'http://schemas.xmlsoap.org/ws/2005/02/trust/AsymmetricKey'; + case Nonce = 'http://schemas.xmlsoap.org/ws/2005/02/trust/Nonce'; + case Symmetric = 'http://schemas.xmlsoap.org/ws/2005/02/trust/SymmetricKey'; +} diff --git a/src/XML/wst_200502/CancelTarget.php b/src/XML/wst_200502/CancelTarget.php new file mode 100644 index 00000000..7b1abfa5 --- /dev/null +++ b/src/XML/wst_200502/CancelTarget.php @@ -0,0 +1,14 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +/** + * A CancelTarget element + * + * @package simplesamlphp/ws-security + */ +final class CancelTarget extends AbstractCancelTargetType +{ +} diff --git a/src/XML/wst_200502/CanonicalizationAlgorithm.php b/src/XML/wst_200502/CanonicalizationAlgorithm.php new file mode 100644 index 00000000..b4c647aa --- /dev/null +++ b/src/XML/wst_200502/CanonicalizationAlgorithm.php @@ -0,0 +1,26 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use SimpleSAML\XML\URIElementTrait; + +/** + * A CanonicalizationAlgorithm element + * + * @package simplesamlphp/ws-security + */ +final class CanonicalizationAlgorithm extends AbstractWstElement +{ + use URIElementTrait; + + + /** + * @param string $content + */ + public function __construct(string $content) + { + $this->setContent($content); + } +} diff --git a/src/XML/wst_200502/Challenge.php b/src/XML/wst_200502/Challenge.php new file mode 100644 index 00000000..0773f8f3 --- /dev/null +++ b/src/XML/wst_200502/Challenge.php @@ -0,0 +1,26 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use SimpleSAML\XML\StringElementTrait; + +/** + * A Challenge element + * + * @package simplesamlphp/ws-security + */ +final class Challenge extends AbstractWstElement +{ + use StringElementTrait; + + + /** + * @param string $content + */ + public function __construct(string $content) + { + $this->setContent($content); + } +} diff --git a/src/XML/wst_200502/Claims.php b/src/XML/wst_200502/Claims.php new file mode 100644 index 00000000..296813bb --- /dev/null +++ b/src/XML/wst_200502/Claims.php @@ -0,0 +1,14 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +/** + * A Claims element + * + * @package simplesamlphp/ws-security + */ +final class Claims extends AbstractClaimsType +{ +} diff --git a/src/XML/wst_200502/Code.php b/src/XML/wst_200502/Code.php new file mode 100644 index 00000000..35618cbb --- /dev/null +++ b/src/XML/wst_200502/Code.php @@ -0,0 +1,14 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +/** + * A Code element + * + * @package simplesamlphp/ws-security + */ +final class Code extends AbstractStatusCodeOpenEnum +{ +} diff --git a/src/XML/wst_200502/CombinedHash.php b/src/XML/wst_200502/CombinedHash.php new file mode 100644 index 00000000..4d64ee69 --- /dev/null +++ b/src/XML/wst_200502/CombinedHash.php @@ -0,0 +1,26 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use SimpleSAML\XML\Base64ElementTrait; + +/** + * A CombinedHash element + * + * @package simplesamlphp/ws-security + */ +final class CombinedHash extends AbstractWstElement +{ + use Base64ElementTrait; + + + /** + * @param string $content + */ + public function __construct(string $content) + { + $this->setContent($content); + } +} diff --git a/src/XML/wst_200502/ComputedKey.php b/src/XML/wst_200502/ComputedKey.php new file mode 100644 index 00000000..e3b96ce8 --- /dev/null +++ b/src/XML/wst_200502/ComputedKey.php @@ -0,0 +1,14 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +/** + * A ComputedKey element + * + * @package simplesamlphp/ws-security + */ +final class ComputedKey extends AbstractComputedKeyOpenEnum +{ +} diff --git a/src/XML/wst_200502/ComputedKeyAlgorithm.php b/src/XML/wst_200502/ComputedKeyAlgorithm.php new file mode 100644 index 00000000..42408e1e --- /dev/null +++ b/src/XML/wst_200502/ComputedKeyAlgorithm.php @@ -0,0 +1,26 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use SimpleSAML\XML\URIElementTrait; + +/** + * A ComputedKeyAlgorithm element + * + * @package simplesamlphp/ws-security + */ +final class ComputedKeyAlgorithm extends AbstractWstElement +{ + use URIElementTrait; + + + /** + * @param string $content + */ + public function __construct(string $content) + { + $this->setContent($content); + } +} diff --git a/src/XML/wst_200502/ComputedKeyEnum.php b/src/XML/wst_200502/ComputedKeyEnum.php new file mode 100644 index 00000000..9b42e242 --- /dev/null +++ b/src/XML/wst_200502/ComputedKeyEnum.php @@ -0,0 +1,11 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +enum ComputedKeyEnum: string +{ + case HASH = 'http://schemas.xmlsoap.org/ws/2005/02/trust/CK/HASH'; + case PSHA1 = 'http://schemas.xmlsoap.org/ws/2005/02/trust/CK/PSHA1'; +} diff --git a/src/XML/wst_200502/Delegatable.php b/src/XML/wst_200502/Delegatable.php new file mode 100644 index 00000000..41d32442 --- /dev/null +++ b/src/XML/wst_200502/Delegatable.php @@ -0,0 +1,26 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use SimpleSAML\XML\BooleanElementTrait; + +/** + * A Delegatable element + * + * @package simplesamlphp/ws-security + */ +final class Delegatable extends AbstractWstElement +{ + use BooleanElementTrait; + + + /** + * @param string $content + */ + public function __construct(string $content) + { + $this->setContent($content); + } +} diff --git a/src/XML/wst_200502/DelegateTo.php b/src/XML/wst_200502/DelegateTo.php new file mode 100644 index 00000000..86f3724e --- /dev/null +++ b/src/XML/wst_200502/DelegateTo.php @@ -0,0 +1,14 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +/** + * A DelegateTo element + * + * @package simplesamlphp/ws-security + */ +final class DelegateTo extends AbstractDelegateToType +{ +} diff --git a/src/XML/wst_200502/EncryptWith.php b/src/XML/wst_200502/EncryptWith.php new file mode 100644 index 00000000..c8d7f542 --- /dev/null +++ b/src/XML/wst_200502/EncryptWith.php @@ -0,0 +1,26 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use SimpleSAML\XML\URIElementTrait; + +/** + * An EncryptWith element + * + * @package simplesamlphp/ws-security + */ +final class EncryptWith extends AbstractWstElement +{ + use URIElementTrait; + + + /** + * @param string $content + */ + public function __construct(string $content) + { + $this->setContent($content); + } +} diff --git a/src/XML/wst_200502/Encryption.php b/src/XML/wst_200502/Encryption.php new file mode 100644 index 00000000..4f158897 --- /dev/null +++ b/src/XML/wst_200502/Encryption.php @@ -0,0 +1,14 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +/** + * A Encryption element + * + * @package simplesamlphp/ws-security + */ +final class Encryption extends AbstractEncryptionType +{ +} diff --git a/src/XML/wst_200502/EncryptionAlgorithm.php b/src/XML/wst_200502/EncryptionAlgorithm.php new file mode 100644 index 00000000..7a9759d2 --- /dev/null +++ b/src/XML/wst_200502/EncryptionAlgorithm.php @@ -0,0 +1,26 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use SimpleSAML\XML\URIElementTrait; + +/** + * A EncryptionAlgorithm element + * + * @package simplesamlphp/ws-security + */ +final class EncryptionAlgorithm extends AbstractWstElement +{ + use URIElementTrait; + + + /** + * @param string $content + */ + public function __construct(string $content) + { + $this->setContent($content); + } +} diff --git a/src/XML/wst_200502/Entropy.php b/src/XML/wst_200502/Entropy.php new file mode 100644 index 00000000..6f32df6d --- /dev/null +++ b/src/XML/wst_200502/Entropy.php @@ -0,0 +1,14 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +/** + * An Entropy element + * + * @package simplesamlphp/ws-security + */ +final class Entropy extends AbstractEntropyType +{ +} diff --git a/src/XML/wst_200502/Forwardable.php b/src/XML/wst_200502/Forwardable.php new file mode 100644 index 00000000..2aa92091 --- /dev/null +++ b/src/XML/wst_200502/Forwardable.php @@ -0,0 +1,26 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use SimpleSAML\XML\BooleanElementTrait; + +/** + * A Forwardable element + * + * @package simplesamlphp/ws-security + */ +final class Forwardable extends AbstractWstElement +{ + use BooleanElementTrait; + + + /** + * @param string $content + */ + public function __construct(string $content) + { + $this->setContent($content); + } +} diff --git a/src/XML/wst_200502/IssuedTokens.php b/src/XML/wst_200502/IssuedTokens.php new file mode 100644 index 00000000..a734822f --- /dev/null +++ b/src/XML/wst_200502/IssuedTokens.php @@ -0,0 +1,14 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +/** + * A IssuedTokens element + * + * @package simplesamlphp/ws-security + */ +final class IssuedTokens extends AbstractRequestSecurityTokenResponseCollectionType +{ +} diff --git a/src/XML/wst_200502/Issuer.php b/src/XML/wst_200502/Issuer.php new file mode 100644 index 00000000..c3fd31c7 --- /dev/null +++ b/src/XML/wst_200502/Issuer.php @@ -0,0 +1,29 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use SimpleSAML\WSSecurity\Constants as C; +use SimpleSAML\WSSecurity\XML\wsa_200508\AbstractEndpointReferenceType; + +/** + * An Issuer element + * + * @package simplesamlphp/ws-security + */ +final class Issuer extends AbstractEndpointReferenceType +{ + /** @var string */ + public const NS = C::NS_TRUST_200502; + + /** @var string */ + public const NS_PREFIX = 't'; + + /** The exclusions for the xs:any element */ + public const XS_ANY_ELT_EXCLUSIONS = [ + ['http://www.w3.org/2005/08/addressing', 'Address'], + ['http://www.w3.org/2005/08/addressing', 'Metadata'], + ['http://www.w3.org/2005/08/addressing', 'ReferenceParameters'], + ]; +} diff --git a/src/XML/wst_200502/KeyExchangeToken.php b/src/XML/wst_200502/KeyExchangeToken.php new file mode 100644 index 00000000..9db75620 --- /dev/null +++ b/src/XML/wst_200502/KeyExchangeToken.php @@ -0,0 +1,14 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +/** + * A KeyEchangeToken element + * + * @package simplesamlphp/ws-security + */ +final class KeyExchangeToken extends AbstractKeyExchangeTokenType +{ +} diff --git a/src/XML/wst_200502/KeySize.php b/src/XML/wst_200502/KeySize.php new file mode 100644 index 00000000..669e3129 --- /dev/null +++ b/src/XML/wst_200502/KeySize.php @@ -0,0 +1,79 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use DOMElement; +use SimpleSAML\Assert\Assert; +use SimpleSAML\XML\Exception\InvalidDOMElementException; +use SimpleSAML\XML\Exception\SchemaViolationException; +use SimpleSAML\XML\StringElementTrait; + +/** + * Class representing WS-trust KeySize. + * + * @package simplesamlphp/ws-security + */ +final class KeySize extends AbstractWstElement +{ + use StringElementTrait; + + /** + * KeySize constructor. + * + * @param string $value The long. + */ + final public function __construct(string $value) + { + $this->setContent($value); + } + + + /** + * Validate the content of the element. + * + * @param string $content The value to go in the XML textContent + * @throws \SimpleSAML\XML\Exception\SchemaViolationException on failure + * @return void + */ + protected function validateContent(string $content): void + { + $content = intval($content); + Assert::natural($content); + Assert::range($content, 0, 4294967295, SchemaViolationException::class); + } + + + /** + * Convert XML into a class instance + * + * @param \DOMElement $xml The XML element we should load + * @return static + * + * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException + * If the qualified name of the supplied element is wrong + */ + public static function fromXML(DOMElement $xml): static + { + Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + return new static($xml->textContent); + } + + + /** + * Convert this element to XML. + * + * @param \DOMElement|null $parent The element we should append this element to. + * @return \DOMElement + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = $this->instantiateParentElement($parent); + $e->textContent = $this->getContent(); + + return $e; + } +} diff --git a/src/XML/wst_200502/KeyType.php b/src/XML/wst_200502/KeyType.php new file mode 100644 index 00000000..c7e965a1 --- /dev/null +++ b/src/XML/wst_200502/KeyType.php @@ -0,0 +1,14 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +/** + * A KeyType element + * + * @package simplesamlphp/ws-security + */ +final class KeyType extends AbstractKeyTypeOpenEnum +{ +} diff --git a/src/XML/wst_200502/KeyTypeEnum.php b/src/XML/wst_200502/KeyTypeEnum.php new file mode 100644 index 00000000..931b294a --- /dev/null +++ b/src/XML/wst_200502/KeyTypeEnum.php @@ -0,0 +1,11 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +enum KeyTypeEnum: string +{ + case PublicKey = 'http://schemas.xmlsoap.org/ws/2005/02/trust/PublicKey'; + case SymmetricKey = 'http://schemas.xmlsoap.org/ws/2005/02/trust/SymmetricKey'; +} diff --git a/src/XML/wst_200502/Lifetime.php b/src/XML/wst_200502/Lifetime.php new file mode 100644 index 00000000..d6f215fb --- /dev/null +++ b/src/XML/wst_200502/Lifetime.php @@ -0,0 +1,14 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +/** + * A Lifetime element + * + * @package simplesamlphp/ws-security + */ +final class Lifetime extends AbstractLifetimeType +{ +} diff --git a/src/XML/wst_200502/OnBehalfOf.php b/src/XML/wst_200502/OnBehalfOf.php new file mode 100644 index 00000000..33d98513 --- /dev/null +++ b/src/XML/wst_200502/OnBehalfOf.php @@ -0,0 +1,14 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +/** + * A OnBehalfOf element + * + * @package simplesamlphp/ws-security + */ +final class OnBehalfOf extends AbstractOnBehalfOfType +{ +} diff --git a/src/XML/wst_200502/Participant.php b/src/XML/wst_200502/Participant.php new file mode 100644 index 00000000..ce4ba785 --- /dev/null +++ b/src/XML/wst_200502/Participant.php @@ -0,0 +1,14 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +/** + * A Participant element + * + * @package simplesamlphp/ws-security + */ +final class Participant extends AbstractParticipantType +{ +} diff --git a/src/XML/wst_200502/Participants.php b/src/XML/wst_200502/Participants.php new file mode 100644 index 00000000..54d927cf --- /dev/null +++ b/src/XML/wst_200502/Participants.php @@ -0,0 +1,14 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +/** + * A Participants element + * + * @package simplesamlphp/ws-security + */ +final class Participants extends AbstractParticipantsType +{ +} diff --git a/src/XML/wst_200502/Primary.php b/src/XML/wst_200502/Primary.php new file mode 100644 index 00000000..691f884e --- /dev/null +++ b/src/XML/wst_200502/Primary.php @@ -0,0 +1,14 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +/** + * A Primary element + * + * @package simplesamlphp/ws-security + */ +final class Primary extends AbstractParticipantType +{ +} diff --git a/src/XML/wst_200502/ProofEncryption.php b/src/XML/wst_200502/ProofEncryption.php new file mode 100644 index 00000000..96dc030a --- /dev/null +++ b/src/XML/wst_200502/ProofEncryption.php @@ -0,0 +1,14 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +/** + * A ProofEncryption element + * + * @package simplesamlphp/ws-security + */ +final class ProofEncryption extends AbstractProofEncryptionType +{ +} diff --git a/src/XML/wst_200502/Reason.php b/src/XML/wst_200502/Reason.php new file mode 100644 index 00000000..091ab130 --- /dev/null +++ b/src/XML/wst_200502/Reason.php @@ -0,0 +1,26 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use SimpleSAML\XML\StringElementTrait; + +/** + * A Reason element + * + * @package simplesamlphp/ws-security + */ +final class Reason extends AbstractWstElement +{ + use StringElementTrait; + + + /** + * @param string $content + */ + public function __construct(string $content) + { + $this->setContent($content); + } +} diff --git a/src/XML/wst_200502/RenewTarget.php b/src/XML/wst_200502/RenewTarget.php new file mode 100644 index 00000000..5c6ff994 --- /dev/null +++ b/src/XML/wst_200502/RenewTarget.php @@ -0,0 +1,14 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +/** + * A RenewTarget element + * + * @package simplesamlphp/ws-security + */ +final class RenewTarget extends AbstractRenewTargetType +{ +} diff --git a/src/XML/wst_200502/Renewing.php b/src/XML/wst_200502/Renewing.php new file mode 100644 index 00000000..2dbfbc45 --- /dev/null +++ b/src/XML/wst_200502/Renewing.php @@ -0,0 +1,14 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +/** + * A Renewing element + * + * @package simplesamlphp/ws-security + */ +final class Renewing extends AbstractRenewingType +{ +} diff --git a/src/XML/wst_200502/RequestKET.php b/src/XML/wst_200502/RequestKET.php new file mode 100644 index 00000000..961b9e53 --- /dev/null +++ b/src/XML/wst_200502/RequestKET.php @@ -0,0 +1,46 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use DOMElement; +use SimpleSAML\Assert\Assert; +use SimpleSAML\XML\Exception\InvalidDOMElementException; + +/** + * A RequestKET element + * + * @package simplesamlphp/ws-security + */ +final class RequestKET extends AbstractWstElement +{ + /** + * Convert XML into a class instance + * + * @param \DOMElement $xml The XML element we should load + * @return static + * + * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException + * If the qualified name of the supplied element is wrong + */ + public static function fromXML(DOMElement $xml): static + { + Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + return new static(); + } + + + /** + * Convert this element to XML. + * + * @param \DOMElement|null $parent The element we should append this element to. + * @return \DOMElement + */ + public function toXML(DOMElement $parent = null): DOMElement + { + return $this->instantiateParentElement($parent); + } +} diff --git a/src/XML/wst_200502/RequestSecurityToken.php b/src/XML/wst_200502/RequestSecurityToken.php new file mode 100644 index 00000000..52a12b0d --- /dev/null +++ b/src/XML/wst_200502/RequestSecurityToken.php @@ -0,0 +1,14 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +/** + * A RequestSecurityToken element + * + * @package simplesamlphp/ws-security + */ +final class RequestSecurityToken extends AbstractRequestSecurityTokenType +{ +} diff --git a/src/XML/wst_200502/RequestSecurityTokenResponse.php b/src/XML/wst_200502/RequestSecurityTokenResponse.php new file mode 100644 index 00000000..4fbead9e --- /dev/null +++ b/src/XML/wst_200502/RequestSecurityTokenResponse.php @@ -0,0 +1,14 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +/** + * A RequestSecurityTokenResponse element + * + * @package simplesamlphp/ws-security + */ +final class RequestSecurityTokenResponse extends AbstractRequestSecurityTokenResponseType +{ +} diff --git a/src/XML/wst_200502/RequestSecurityTokenResponseCollection.php b/src/XML/wst_200502/RequestSecurityTokenResponseCollection.php new file mode 100644 index 00000000..2c26ffbe --- /dev/null +++ b/src/XML/wst_200502/RequestSecurityTokenResponseCollection.php @@ -0,0 +1,14 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +/** + * A RequestSecurityTokenResponseCollection element + * + * @package simplesamlphp/ws-security + */ +final class RequestSecurityTokenResponseCollection extends AbstractRequestSecurityTokenResponseCollectionType +{ +} diff --git a/src/XML/wst_200502/RequestType.php b/src/XML/wst_200502/RequestType.php new file mode 100644 index 00000000..9d376827 --- /dev/null +++ b/src/XML/wst_200502/RequestType.php @@ -0,0 +1,14 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +/** + * A RequestType element + * + * @package simplesamlphp/ws-security + */ +final class RequestType extends AbstractRequestTypeOpenEnum +{ +} diff --git a/src/XML/wst_200502/RequestTypeEnum.php b/src/XML/wst_200502/RequestTypeEnum.php new file mode 100644 index 00000000..eff0c1e3 --- /dev/null +++ b/src/XML/wst_200502/RequestTypeEnum.php @@ -0,0 +1,12 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +enum RequestTypeEnum: string +{ + case Cancel = 'http://schemas.xmlsoap.org/ws/2005/02/trust/Cancel'; + case Issue = 'http://schemas.xmlsoap.org/ws/2005/02/trust/Issue'; + case Renew = 'http://schemas.xmlsoap.org/ws/2005/02/trust/Renew'; +} diff --git a/src/XML/wst_200502/RequestedAttachedReference.php b/src/XML/wst_200502/RequestedAttachedReference.php new file mode 100644 index 00000000..81ffac07 --- /dev/null +++ b/src/XML/wst_200502/RequestedAttachedReference.php @@ -0,0 +1,14 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +/** + * A RequestedAttachedReference element + * + * @package simplesamlphp/ws-security + */ +final class RequestedAttachedReference extends AbstractRequestedReferenceType +{ +} diff --git a/src/XML/wst_200502/RequestedProofToken.php b/src/XML/wst_200502/RequestedProofToken.php new file mode 100644 index 00000000..95090df8 --- /dev/null +++ b/src/XML/wst_200502/RequestedProofToken.php @@ -0,0 +1,14 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +/** + * A RequestedProofToken element + * + * @package simplesamlphp/ws-security + */ +final class RequestedProofToken extends AbstractRequestedProofTokenType +{ +} diff --git a/src/XML/wst_200502/RequestedSecurityToken.php b/src/XML/wst_200502/RequestedSecurityToken.php new file mode 100644 index 00000000..dd32e458 --- /dev/null +++ b/src/XML/wst_200502/RequestedSecurityToken.php @@ -0,0 +1,14 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +/** + * A RequestedSecurityToken element + * + * @package simplesamlphp/ws-security + */ +final class RequestedSecurityToken extends AbstractRequestedSecurityTokenType +{ +} diff --git a/src/XML/wst_200502/RequestedTokenCancelled.php b/src/XML/wst_200502/RequestedTokenCancelled.php new file mode 100644 index 00000000..bb5c9e55 --- /dev/null +++ b/src/XML/wst_200502/RequestedTokenCancelled.php @@ -0,0 +1,46 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use DOMElement; +use SimpleSAML\Assert\Assert; +use SimpleSAML\XML\Exception\InvalidDOMElementException; + +/** + * A RequestedTokenCancelled element + * + * @package simplesamlphp/ws-security + */ +final class RequestedTokenCancelled extends AbstractWstElement +{ + /** + * Convert XML into a class instance + * + * @param \DOMElement $xml The XML element we should load + * @return static + * + * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException + * If the qualified name of the supplied element is wrong + */ + public static function fromXML(DOMElement $xml): static + { + Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + return new static(); + } + + + /** + * Convert this element to XML. + * + * @param \DOMElement|null $parent The element we should append this element to. + * @return \DOMElement + */ + public function toXML(DOMElement $parent = null): DOMElement + { + return $this->instantiateParentElement($parent); + } +} diff --git a/src/XML/wst_200502/RequestedUnattachedReference.php b/src/XML/wst_200502/RequestedUnattachedReference.php new file mode 100644 index 00000000..db8523e1 --- /dev/null +++ b/src/XML/wst_200502/RequestedUnattachedReference.php @@ -0,0 +1,14 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +/** + * A RequestedUnattachedReference element + * + * @package simplesamlphp/ws-security + */ +final class RequestedUnattachedReference extends AbstractRequestedReferenceType +{ +} diff --git a/src/XML/wst_200502/SignChallenge.php b/src/XML/wst_200502/SignChallenge.php new file mode 100644 index 00000000..4683ed27 --- /dev/null +++ b/src/XML/wst_200502/SignChallenge.php @@ -0,0 +1,14 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +/** + * An SignChallenge element + * + * @package simplesamlphp/ws-security + */ +final class SignChallenge extends AbstractSignChallengeType +{ +} diff --git a/src/XML/wst_200502/SignChallengeResponse.php b/src/XML/wst_200502/SignChallengeResponse.php new file mode 100644 index 00000000..ee50fba6 --- /dev/null +++ b/src/XML/wst_200502/SignChallengeResponse.php @@ -0,0 +1,14 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +/** + * An SignChallengeResponse element + * + * @package simplesamlphp/ws-security + */ +final class SignChallengeResponse extends AbstractSignChallengeType +{ +} diff --git a/src/XML/wst_200502/SignWith.php b/src/XML/wst_200502/SignWith.php new file mode 100644 index 00000000..cad43396 --- /dev/null +++ b/src/XML/wst_200502/SignWith.php @@ -0,0 +1,26 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use SimpleSAML\XML\URIElementTrait; + +/** + * A SignWith element + * + * @package simplesamlphp/ws-security + */ +final class SignWith extends AbstractWstElement +{ + use URIElementTrait; + + + /** + * @param string $content + */ + public function __construct(string $content) + { + $this->setContent($content); + } +} diff --git a/src/XML/wst_200502/SignatureAlgorithm.php b/src/XML/wst_200502/SignatureAlgorithm.php new file mode 100644 index 00000000..d704ef1a --- /dev/null +++ b/src/XML/wst_200502/SignatureAlgorithm.php @@ -0,0 +1,26 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use SimpleSAML\XML\URIElementTrait; + +/** + * A SignatureAlgorithm element + * + * @package simplesamlphp/ws-security + */ +final class SignatureAlgorithm extends AbstractWstElement +{ + use URIElementTrait; + + + /** + * @param string $content + */ + public function __construct(string $content) + { + $this->setContent($content); + } +} diff --git a/src/XML/wst_200502/Status.php b/src/XML/wst_200502/Status.php new file mode 100644 index 00000000..6f32e92f --- /dev/null +++ b/src/XML/wst_200502/Status.php @@ -0,0 +1,14 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +/** + * A Status element + * + * @package simplesamlphp/ws-security + */ +final class Status extends AbstractStatusType +{ +} diff --git a/src/XML/wst_200502/StatusCodeEnum.php b/src/XML/wst_200502/StatusCodeEnum.php new file mode 100644 index 00000000..2e53b0f4 --- /dev/null +++ b/src/XML/wst_200502/StatusCodeEnum.php @@ -0,0 +1,11 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +enum StatusCodeEnum: string +{ + case Invalid = 'http://schemas.xmlsoap.org/ws/2005/02/trust/status/invalid'; + case Valid = 'http://schemas.xmlsoap.org/ws/2005/02/trust/status/valid'; +} diff --git a/src/XML/wst_200502/TokenType.php b/src/XML/wst_200502/TokenType.php new file mode 100644 index 00000000..0973b62f --- /dev/null +++ b/src/XML/wst_200502/TokenType.php @@ -0,0 +1,26 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +use SimpleSAML\XML\URIElementTrait; + +/** + * A TokenType element + * + * @package simplesamlphp/ws-security + */ +final class TokenType extends AbstractWstElement +{ + use URIElementTrait; + + + /** + * @param string $content + */ + public function __construct(string $content) + { + $this->setContent($content); + } +} diff --git a/src/XML/wst_200502/UseKey.php b/src/XML/wst_200502/UseKey.php new file mode 100644 index 00000000..53a2b127 --- /dev/null +++ b/src/XML/wst_200502/UseKey.php @@ -0,0 +1,14 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\WSSecurity\XML\wst_200502; + +/** + * A UseKey element + * + * @package simplesamlphp/ws-security + */ +final class UseKey extends AbstractUseKeyType +{ +} diff --git a/tests/WSSecurity/XML/wst_200502/AllowPostdatingTest.php b/tests/WSSecurity/XML/wst_200502/AllowPostdatingTest.php new file mode 100644 index 00000000..1fb907b0 --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/AllowPostdatingTest.php @@ -0,0 +1,73 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\AllowPostdating; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\AllowPostdatingTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(AllowPostdating::class)] +#[CoversClass(AbstractWstElement::class)] +final class AllowPostdatingTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = AllowPostdating::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/AllowPostdating.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a AllowPostdating object from scratch. + */ + public function testMarshalling(): void + { + $allowPostdating = new AllowPostdating(); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($allowPostdating), + ); + } + + + /** + * Test creating an empty AllowPostdating object from scratch. + * + * NOTE: This element is empty per definition! + */ + public function testMarshallingEmpty(): void + { + $allowPostdating = new AllowPostdating(); + $this->assertFalse($allowPostdating->isEmptyElement()); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/AuthenticationTypeTest.php b/tests/WSSecurity/XML/wst_200502/AuthenticationTypeTest.php new file mode 100644 index 00000000..cb12750a --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/AuthenticationTypeTest.php @@ -0,0 +1,62 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\Test\WSSecurity\Constants as C; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\AuthenticationType; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\AuthenticationTypeTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(AuthenticationType::class)] +#[CoversClass(AbstractWstElement::class)] +final class AuthenticationTypeTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = AuthenticationType::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/AuthenticationType.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a AuthenticationType object from scratch. + */ + public function testMarshalling(): void + { + $authenticationType = new AuthenticationType(C::NAMESPACE); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($authenticationType), + ); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/AuthenticatorTest.php b/tests/WSSecurity/XML/wst_200502/AuthenticatorTest.php new file mode 100644 index 00000000..8cbe4699 --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/AuthenticatorTest.php @@ -0,0 +1,82 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\SOAP\Constants as SOAP; +use SimpleSAML\WSSecurity\XML\wsa_200508\MessageID; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractAuthenticatorType; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\Authenticator; +use SimpleSAML\WSSecurity\XML\wst_200502\CombinedHash; +use SimpleSAML\XML\Attribute as XMLAttribute; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\AuthenticatorTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(Authenticator::class)] +#[CoversClass(AbstractAuthenticatorType::class)] +#[CoversClass(AbstractWstElement::class)] +final class AuthenticatorTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = Authenticator::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/Authenticator.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a Authenticator object from scratch. + */ + public function testMarshalling(): void + { + $attr1 = new XMLAttribute(SOAP::NS_SOAP_ENV_11, 'soapenv', 'mustUnderstand', '1'); + $msgId = new MessageID('uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de', [$attr1]); + + $combinedHash = new CombinedHash('/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI='); + $authenticator = new Authenticator($combinedHash, [$msgId]); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($authenticator), + ); + } + + + /** + * Test creating an empty Authenticator object from scratch. + */ + public function testMarshallingEmpty(): void + { + $authenticator = new Authenticator(); + + $this->assertTrue($authenticator->isEmptyElement()); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/BinaryExchangeTest.php b/tests/WSSecurity/XML/wst_200502/BinaryExchangeTest.php new file mode 100644 index 00000000..f60a37ca --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/BinaryExchangeTest.php @@ -0,0 +1,66 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\Test\WSSecurity\Constants as C; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractBinaryExchangeType; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\BinaryExchange; +use SimpleSAML\XML\Attribute as XMLAttribute; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\BinaryExchangeTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(BinaryExchange::class)] +#[CoversClass(AbstractBinaryExchangeType::class)] +#[CoversClass(AbstractWstElement::class)] +final class BinaryExchangeTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = BinaryExchange::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/BinaryExchange.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a BinaryExchange object from scratch. + */ + public function testMarshalling(): void + { + $attr1 = new XMLAttribute('urn:x-simplesamlphp:namespace', 'ssp', 'attr1', 'testval1'); + $binaryExchange = new BinaryExchange('phpunit', C::NAMESPACE, C::NAMESPACE, [$attr1]); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($binaryExchange), + ); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/BinarySecretTest.php b/tests/WSSecurity/XML/wst_200502/BinarySecretTest.php new file mode 100644 index 00000000..4bb4b80c --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/BinarySecretTest.php @@ -0,0 +1,72 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\Test\WSSecurity\Constants as C; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractBinarySecretType; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\BinarySecret; +use SimpleSAML\WSSecurity\XML\wst_200502\BinarySecretTypeEnum; +use SimpleSAML\XML\Attribute as XMLAttribute; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\BinarySecretTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(BinarySecret::class)] +#[CoversClass(AbstractBinarySecretType::class)] +#[CoversClass(AbstractWstElement::class)] +final class BinarySecretTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = BinarySecret::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/BinarySecret.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a BinarySecret object from scratch. + */ + public function testMarshalling(): void + { + $attr1 = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr1', 'testval1'); + + $binarySecret = new BinarySecret( + '/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI=', + [BinarySecretTypeEnum::Nonce], + [$attr1], + ); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($binarySecret), + ); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/CancelTargetTest.php b/tests/WSSecurity/XML/wst_200502/CancelTargetTest.php new file mode 100644 index 00000000..9aa39757 --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/CancelTargetTest.php @@ -0,0 +1,69 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\SOAP\Constants as SOAP; +use SimpleSAML\WSSecurity\XML\wsa_200408\MessageID; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractCancelTargetType; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\CancelTarget; +use SimpleSAML\XML\Attribute as XMLAttribute; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\CancelTargetTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(CancelTarget::class)] +#[CoversClass(AbstractCancelTargetType::class)] +#[CoversClass(AbstractWstElement::class)] +final class CancelTargetTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = CancelTarget::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/CancelTarget.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a CancelTarget object from scratch. + */ + public function testMarshalling(): void + { + $attr1 = new XMLAttribute(SOAP::NS_SOAP_ENV_11, 'soapenv', 'mustUnderstand', '1'); + $msgId = new MessageID('uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de', [$attr1]); + + $cancelTarget = new CancelTarget($msgId); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($cancelTarget), + ); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/CanonicalizationAlgorithmTest.php b/tests/WSSecurity/XML/wst_200502/CanonicalizationAlgorithmTest.php new file mode 100644 index 00000000..914b28c0 --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/CanonicalizationAlgorithmTest.php @@ -0,0 +1,62 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\Test\WSSecurity\Constants as C; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\CanonicalizationAlgorithm; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\CanonicalizationAlgorithmTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(CanonicalizationAlgorithm::class)] +#[CoversClass(AbstractWstElement::class)] +final class CanonicalizationAlgorithmTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = CanonicalizationAlgorithm::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/CanonicalizationAlgorithm.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a CanonicalizationAlgorithm object from scratch. + */ + public function testMarshalling(): void + { + $canonicalizationAlgorithm = new CanonicalizationAlgorithm(C::NAMESPACE); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($canonicalizationAlgorithm), + ); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/ChallengeTest.php b/tests/WSSecurity/XML/wst_200502/ChallengeTest.php new file mode 100644 index 00000000..000bcb8b --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/ChallengeTest.php @@ -0,0 +1,61 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\Challenge; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\ChallengeTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(Challenge::class)] +#[CoversClass(AbstractWstElement::class)] +final class ChallengeTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = Challenge::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/Challenge.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a Challenge object from scratch. + */ + public function testMarshalling(): void + { + $challenge = new Challenge('accepted'); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($challenge), + ); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/ClaimsTest.php b/tests/WSSecurity/XML/wst_200502/ClaimsTest.php new file mode 100644 index 00000000..786e1bc4 --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/ClaimsTest.php @@ -0,0 +1,82 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\SOAP\Constants as SOAP; +use SimpleSAML\Test\WSSecurity\Constants as C; +use SimpleSAML\WSSecurity\XML\wsa_200508\MessageID; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractClaimsType; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\Claims; +use SimpleSAML\XML\Attribute as XMLAttribute; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\ClaimsTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(Claims::class)] +#[CoversClass(AbstractClaimsType::class)] +#[CoversClass(AbstractWstElement::class)] +final class ClaimsTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = Claims::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/Claims.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a Claims object from scratch. + */ + public function testMarshalling(): void + { + $attr1 = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr1', 'testval1'); + $attr2 = new XMLAttribute(SOAP::NS_SOAP_ENV_11, 'soapenv', 'mustUnderstand', '1'); + $msgId = new MessageID('uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de', [$attr2]); + + $claims = new Claims(C::NAMESPACE, [$msgId], [$attr1]); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($claims), + ); + } + + + /** + * Test creating an empty Claims object from scratch. + */ + public function testMarshallingEmpty(): void + { + $claims = new Claims(); + + $this->assertTrue($claims->isEmptyElement()); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/CodeTest.php b/tests/WSSecurity/XML/wst_200502/CodeTest.php new file mode 100644 index 00000000..31b8d4f3 --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/CodeTest.php @@ -0,0 +1,60 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractStatusCodeOpenEnum; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\Code; +use SimpleSAML\WSSecurity\XML\wst_200502\StatusCodeEnum; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\CodeTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(Code::class)] +#[CoversClass(AbstractStatusCodeOpenEnum::class)] +#[CoversClass(AbstractWstElement::class)] +final class CodeTest extends TestCase +{ + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$testedClass = Code::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/Code.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a Code object from scratch. + */ + public function testMarshalling(): void + { + $code = new Code([StatusCodeEnum::Invalid]); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($code), + ); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/CombinedHashTest.php b/tests/WSSecurity/XML/wst_200502/CombinedHashTest.php new file mode 100644 index 00000000..4a26667b --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/CombinedHashTest.php @@ -0,0 +1,61 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\CombinedHash; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\CombinedHashTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(CombinedHash::class)] +#[CoversClass(AbstractWstElement::class)] +final class CombinedHashTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = CombinedHash::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/CombinedHash.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a CombinedHash object from scratch. + */ + public function testMarshalling(): void + { + $combinedHash = new CombinedHash('/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI='); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($combinedHash), + ); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/ComputedKeyAlgorithmTest.php b/tests/WSSecurity/XML/wst_200502/ComputedKeyAlgorithmTest.php new file mode 100644 index 00000000..17e35bf3 --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/ComputedKeyAlgorithmTest.php @@ -0,0 +1,62 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\Test\WSSecurity\Constants as C; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\ComputedKeyAlgorithm; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\ComputedKeyAlgorithmTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(ComputedKeyAlgorithm::class)] +#[CoversClass(AbstractWstElement::class)] +final class ComputedKeyAlgorithmTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = ComputedKeyAlgorithm::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/ComputedKeyAlgorithm.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a ComputedKeyAlgorithm object from scratch. + */ + public function testMarshalling(): void + { + $computedKeyAlgorithm = new ComputedKeyAlgorithm(C::NAMESPACE); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($computedKeyAlgorithm), + ); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/ComputedKeyTest.php b/tests/WSSecurity/XML/wst_200502/ComputedKeyTest.php new file mode 100644 index 00000000..2ed60b88 --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/ComputedKeyTest.php @@ -0,0 +1,64 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractComputedKeyOpenEnum; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\ComputedKey; +use SimpleSAML\WSSecurity\XML\wst_200502\ComputedKeyEnum; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\ComputedKeyTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(ComputedKey::class)] +#[CoversClass(AbstractComputedKeyOpenEnum::class)] +#[CoversClass(AbstractWstElement::class)] +final class ComputedKeyTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = ComputedKey::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/ComputedKey.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a ComputedKey object from scratch. + */ + public function testMarshalling(): void + { + $computedKey = new ComputedKey([ComputedKeyEnum::PSHA1]); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($computedKey), + ); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/DelegatableTest.php b/tests/WSSecurity/XML/wst_200502/DelegatableTest.php new file mode 100644 index 00000000..7f35761d --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/DelegatableTest.php @@ -0,0 +1,61 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\Delegatable; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\DelegatableTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(Delegatable::class)] +#[CoversClass(AbstractWstElement::class)] +final class DelegatableTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = Delegatable::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/Delegatable.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a Delegatable object from scratch. + */ + public function testMarshalling(): void + { + $delegatable = new Delegatable('true'); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($delegatable), + ); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/DelegateToTest.php b/tests/WSSecurity/XML/wst_200502/DelegateToTest.php new file mode 100644 index 00000000..2f6810e2 --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/DelegateToTest.php @@ -0,0 +1,69 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\SOAP\Constants as SOAP; +use SimpleSAML\WSSecurity\XML\wsa_200508\MessageID; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractDelegateToType; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\DelegateTo; +use SimpleSAML\XML\Attribute as XMLAttribute; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\DelegateToTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(DelegateTo::class)] +#[CoversClass(AbstractDelegateToType::class)] +#[CoversClass(AbstractWstElement::class)] +final class DelegateToTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = DelegateTo::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/DelegateTo.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a DelegateTo object from scratch. + */ + public function testMarshalling(): void + { + $attr1 = new XMLAttribute(SOAP::NS_SOAP_ENV_11, 'soapenv', 'mustUnderstand', '1'); + $msgId = new MessageID('uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de', [$attr1]); + + $delegateTo = new DelegateTo($msgId); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($delegateTo), + ); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/EncryptWithTest.php b/tests/WSSecurity/XML/wst_200502/EncryptWithTest.php new file mode 100644 index 00000000..a6f77f3f --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/EncryptWithTest.php @@ -0,0 +1,62 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\Test\WSSecurity\Constants as C; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\EncryptWith; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\EncryptWithTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(EncryptWith::class)] +#[CoversClass(AbstractWstElement::class)] +final class EncryptWithTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = EncryptWith::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/EncryptWith.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a EncryptWith object from scratch. + */ + public function testMarshalling(): void + { + $encryptWith = new EncryptWith(C::NAMESPACE); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($encryptWith), + ); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/EncryptionAlgorithmTest.php b/tests/WSSecurity/XML/wst_200502/EncryptionAlgorithmTest.php new file mode 100644 index 00000000..a7536aa8 --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/EncryptionAlgorithmTest.php @@ -0,0 +1,62 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\Test\WSSecurity\Constants as C; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\EncryptionAlgorithm; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\EncryptionAlgorithmTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(EncryptionAlgorithm::class)] +#[CoversClass(AbstractWstElement::class)] +final class EncryptionAlgorithmTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = EncryptionAlgorithm::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/EncryptionAlgorithm.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a EncryptionAlgorithm object from scratch. + */ + public function testMarshalling(): void + { + $encryptionAlgorithm = new EncryptionAlgorithm(C::NAMESPACE); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($encryptionAlgorithm), + ); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/EncryptionTest.php b/tests/WSSecurity/XML/wst_200502/EncryptionTest.php new file mode 100644 index 00000000..68391f4b --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/EncryptionTest.php @@ -0,0 +1,69 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\SOAP\Constants as SOAP; +use SimpleSAML\WSSecurity\XML\wsa_200508\MessageID; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractEncryptionType; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\Encryption; +use SimpleSAML\XML\Attribute as XMLAttribute; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\EncryptionTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(Encryption::class)] +#[CoversClass(AbstractEncryptionType::class)] +#[CoversClass(AbstractWstElement::class)] +final class EncryptionTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = Encryption::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/Encryption.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a Encryption object from scratch. + */ + public function testMarshalling(): void + { + $attr1 = new XMLAttribute(SOAP::NS_SOAP_ENV_11, 'soapenv', 'mustUnderstand', '1'); + $msgId = new MessageID('uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de', [$attr1]); + + $encryption = new Encryption($msgId); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($encryption), + ); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/EntropyTest.php b/tests/WSSecurity/XML/wst_200502/EntropyTest.php new file mode 100644 index 00000000..9972026d --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/EntropyTest.php @@ -0,0 +1,82 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\SOAP\Constants as SOAP; +use SimpleSAML\Test\WSSecurity\Constants as C; +use SimpleSAML\WSSecurity\XML\wsa_200508\MessageID; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractEntropyType; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\Entropy; +use SimpleSAML\XML\Attribute as XMLAttribute; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\EntropyTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(Entropy::class)] +#[CoversClass(AbstractEntropyType::class)] +#[CoversClass(AbstractWstElement::class)] +final class EntropyTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = Entropy::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/Entropy.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a Entropy object from scratch. + */ + public function testMarshalling(): void + { + $attr1 = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr1', 'testval1'); + $attr2 = new XMLAttribute(SOAP::NS_SOAP_ENV_11, 'soapenv', 'mustUnderstand', '1'); + $msgId = new MessageID('uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de', [$attr2]); + + $entropy = new Entropy([$msgId], [$attr1]); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($entropy), + ); + } + + + /** + * Test creating an empty Entropy object from scratch. + */ + public function testMarshallingEmpty(): void + { + $entropy = new Entropy(); + + $this->assertTrue($entropy->isEmptyElement()); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/ForwardableTest.php b/tests/WSSecurity/XML/wst_200502/ForwardableTest.php new file mode 100644 index 00000000..065cfa1e --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/ForwardableTest.php @@ -0,0 +1,61 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\Forwardable; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\ForwardableTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(Forwardable::class)] +#[CoversClass(AbstractWstElement::class)] +final class ForwardableTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = Forwardable::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/Forwardable.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a Forwardable object from scratch. + */ + public function testMarshalling(): void + { + $forwardable = new Forwardable('true'); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($forwardable), + ); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/IssuedTokensTest.php b/tests/WSSecurity/XML/wst_200502/IssuedTokensTest.php new file mode 100644 index 00000000..1d8203b5 --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/IssuedTokensTest.php @@ -0,0 +1,78 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\SOAP\Constants as SOAP; +use SimpleSAML\Test\WSSecurity\Constants as C; +use SimpleSAML\WSSecurity\XML\wsa_200508\AbstractEndpointReferenceType; +use SimpleSAML\WSSecurity\XML\wsa_200508\MessageID; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\IssuedTokens; +use SimpleSAML\WSSecurity\XML\wst_200502\RequestSecurityTokenResponse; +use SimpleSAML\XML\Attribute as XMLAttribute; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\IssuedTokensTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(IssuedTokens::class)] +#[CoversClass(AbstractEndpointReferenceType::class)] +#[CoversClass(AbstractWstElement::class)] +final class IssuedTokensTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = IssuedTokens::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/IssuedTokens.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a IssuedTokens object from scratch. + */ + public function testMarshalling(): void + { + $attr1 = new XMLAttribute(SOAP::NS_SOAP_ENV_11, 'soapenv', 'mustUnderstand', '1'); + $attr2 = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr1', 'testval1'); + $attr3 = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr2', 'testval2'); + $msgId = new MessageID('uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de', [$attr1]); + + $requestSecurityTokenResponse = new RequestSecurityTokenResponse(C::NAMESPACE, [$msgId], [$attr2]); + + $issuedTokens = new IssuedTokens( + [$requestSecurityTokenResponse], + [$attr3], + ); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($issuedTokens), + ); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/IssuerTest.php b/tests/WSSecurity/XML/wst_200502/IssuerTest.php new file mode 100644 index 00000000..58709364 --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/IssuerTest.php @@ -0,0 +1,102 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use DOMElement; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\WSSecurity\XML\wsa_200508\AbstractEndpointReferenceType; +use SimpleSAML\WSSecurity\XML\wsa_200508\Address; +use SimpleSAML\WSSecurity\XML\wsa_200508\Metadata; +use SimpleSAML\WSSecurity\XML\wsa_200508\ReferenceParameters; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\Issuer; +use SimpleSAML\XML\Attribute; +use SimpleSAML\XML\Chunk; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; +use function strval; + +/** + * Tests for wst:Issuer. + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(Issuer::class)] +#[CoversClass(AbstractEndpointReferenceType::class)] +#[CoversClass(AbstractWstElement::class)] +final class IssuerTest extends TestCase +{ + use SerializableElementTestTrait; + + /** @var \DOMElement $referenceParametersContent */ + protected static DOMElement $referenceParametersContent; + + /** @var \DOMElement $metadataContent */ + protected static DOMElement $metadataContent; + + /** @var \DOMElement $customContent */ + protected static DOMElement $customContent; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$testedClass = Issuer::class; + + self::$xmlRepresentation = DOMDocumentFactory::FromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/Issuer.xml', + ); + + self::$referenceParametersContent = DOMDocumentFactory::fromString( + '<m:GetPrice xmlns:m="https://www.w3schools.com/prices"><m:Item>Pears</m:Item></m:GetPrice>', + )->documentElement; + + self::$metadataContent = DOMDocumentFactory::fromString( + '<m:GetPrice xmlns:m="https://www.w3schools.com/prices"><m:Item>Apples</m:Item></m:GetPrice>', + )->documentElement; + + self::$customContent = DOMDocumentFactory::fromString( + '<ssp:Chunk xmlns:ssp="urn:x-simplesamlphp:namespace">SomeChunk</ssp:Chunk>', + )->documentElement; + } + + + // test marshalling + + + /** + * Test creating an Issuer object from scratch. + */ + public function testMarshalling(): void + { + $attr1 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test1', 'value1'); + $attr2 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test2', 'value2'); + $attr3 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test3', 'value3'); + $attr4 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test4', 'value4'); + + $referenceParameters = new ReferenceParameters([new Chunk(self::$referenceParametersContent)], [$attr4]); + $metadata = new Metadata([new Chunk(self::$metadataContent)], [$attr3]); + $chunk = new Chunk(self::$customContent); + + $issuer = new Issuer( + new Address('https://login.microsoftonline.com/login.srf', [$attr2]), + $referenceParameters, + $metadata, + [$chunk], + [$attr1], + ); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($issuer), + ); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/KeyExchangeTokenTest.php b/tests/WSSecurity/XML/wst_200502/KeyExchangeTokenTest.php new file mode 100644 index 00000000..a2e0788a --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/KeyExchangeTokenTest.php @@ -0,0 +1,80 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\SOAP\Constants as SOAP; +use SimpleSAML\WSSecurity\XML\wsa_200508\MessageID; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractKeyExchangeTokenType; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\KeyExchangeToken; +use SimpleSAML\XML\Attribute as XMLAttribute; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\KeyExchangeTokenTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(KeyExchangeToken::class)] +#[CoversClass(AbstractKeyExchangeTokenType::class)] +#[CoversClass(AbstractWstElement::class)] +final class KeyExchangeTokenTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = KeyExchangeToken::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/KeyExchangeToken.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a KeyExchangeToken object from scratch. + */ + public function testMarshalling(): void + { + $attr1 = new XMLAttribute(SOAP::NS_SOAP_ENV_11, 'soapenv', 'mustUnderstand', '1'); + $msgId = new MessageID('uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de', [$attr1]); + + $keyExchangeToken = new KeyExchangeToken([$msgId]); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($keyExchangeToken), + ); + } + + + /** + * Test creating an empty KeyExchangeToken object from scratch. + */ + public function testMarshallingEmpty(): void + { + $keyExchangeToken = new KeyExchangeToken(); + + $this->assertTrue($keyExchangeToken->isEmptyElement()); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/KeySizeTest.php b/tests/WSSecurity/XML/wst_200502/KeySizeTest.php new file mode 100644 index 00000000..6d590962 --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/KeySizeTest.php @@ -0,0 +1,61 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\KeySize; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\KeySizeTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(KeySize::class)] +#[CoversClass(AbstractWstElement::class)] +final class KeySizeTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = KeySize::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/KeySize.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a KeySize object from scratch. + */ + public function testMarshalling(): void + { + $keySize = new KeySize('4096'); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($keySize), + ); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/KeyTypeTest.php b/tests/WSSecurity/XML/wst_200502/KeyTypeTest.php new file mode 100644 index 00000000..c0d29bcc --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/KeyTypeTest.php @@ -0,0 +1,64 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractKeyTypeOpenEnum; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\KeyType; +use SimpleSAML\WSSecurity\XML\wst_200502\KeyTypeEnum; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\KeyTypeTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(KeyType::class)] +#[CoversClass(AbstractKeyTypeOpenEnum::class)] +#[CoversClass(AbstractWstElement::class)] +final class KeyTypeTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = KeyType::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/KeyType.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a KeyType object from scratch. + */ + public function testMarshalling(): void + { + $keyType = new KeyType([KeyTypeEnum::PublicKey]); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($keyType), + ); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/LifetimeTest.php b/tests/WSSecurity/XML/wst_200502/LifetimeTest.php new file mode 100644 index 00000000..7b8a1483 --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/LifetimeTest.php @@ -0,0 +1,79 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use DateTimeImmutable; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractLifetimeType; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\Lifetime; +use SimpleSAML\WSSecurity\XML\wsu\Created; +use SimpleSAML\WSSecurity\XML\wsu\Expires; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst\LifetimeTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(Lifetime::class)] +#[CoversClass(AbstractLifetimeType::class)] +#[CoversClass(AbstractWstElement::class)] +final class LifetimeTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = Lifetime::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/Lifetime.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a Lifetime object from scratch. + */ + public function testMarshalling(): void + { + $created = new Created(new DateTimeImmutable('2001-09-13T08:42:00Z')); + $expires = new Expires(new DateTimeImmutable('2001-10-13T09:00:00Z')); + $lifetime = new Lifetime($created, $expires); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($lifetime), + ); + } + + + /** + * Test creating an empty Lifetime object from scratch. + */ + public function testMarshallingEmpty(): void + { + $lifetime = new Lifetime(); + + $this->assertTrue($lifetime->isEmptyElement()); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/OnBehalfOfTest.php b/tests/WSSecurity/XML/wst_200502/OnBehalfOfTest.php new file mode 100644 index 00000000..88774311 --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/OnBehalfOfTest.php @@ -0,0 +1,69 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\SOAP\Constants as SOAP; +use SimpleSAML\WSSecurity\XML\wsa_200508\MessageID; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractOnBehalfOfType; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\OnBehalfOf; +use SimpleSAML\XML\Attribute as XMLAttribute; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\OnBehalfOfTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(OnBehalfOf::class)] +#[CoversClass(AbstractOnBehalfOfType::class)] +#[CoversClass(AbstractWstElement::class)] +final class OnBehalfOfTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = OnBehalfOf::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/OnBehalfOf.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a OnBehalfOf object from scratch. + */ + public function testMarshalling(): void + { + $attr1 = new XMLAttribute(SOAP::NS_SOAP_ENV_11, 'soapenv', 'mustUnderstand', '1'); + $msgId = new MessageID('uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de', [$attr1]); + + $onBehalfOf = new OnBehalfOf($msgId); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($onBehalfOf), + ); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/ParticipantTest.php b/tests/WSSecurity/XML/wst_200502/ParticipantTest.php new file mode 100644 index 00000000..fce43df8 --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/ParticipantTest.php @@ -0,0 +1,65 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\SOAP\Constants as SOAP; +use SimpleSAML\WSSecurity\XML\wsa_200508\MessageID; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractParticipantType; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\Participant; +use SimpleSAML\XML\Attribute as XMLAttribute; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\ParticipantTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(Participant::class)] +#[CoversClass(AbstractParticipantType::class)] +#[CoversClass(AbstractWstElement::class)] +final class ParticipantTest extends TestCase +{ + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$testedClass = Participant::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/Participant.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a Participant object from scratch. + */ + public function testMarshalling(): void + { + $attr1 = new XMLAttribute(SOAP::NS_SOAP_ENV_11, 'soapenv', 'mustUnderstand', '1'); + $msgId = new MessageID('uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de', [$attr1]); + + $participant = new Participant($msgId); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($participant), + ); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/ParticipantsTest.php b/tests/WSSecurity/XML/wst_200502/ParticipantsTest.php new file mode 100644 index 00000000..b3e0f7cd --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/ParticipantsTest.php @@ -0,0 +1,89 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\SOAP\Constants as SOAP; +use SimpleSAML\WSSecurity\Constants as C; +use SimpleSAML\WSSecurity\XML\wsa_200508\MessageID; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractParticipantsType; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\Participant; +use SimpleSAML\WSSecurity\XML\wst_200502\Participants; +use SimpleSAML\WSSecurity\XML\wst_200502\Primary; +use SimpleSAML\XML\Attribute as XMLAttribute; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\ParticipantsTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(Participants::class)] +#[CoversClass(AbstractParticipantsType::class)] +#[CoversClass(AbstractWstElement::class)] +final class ParticipantsTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = Participants::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/Participants.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a Participants object from scratch. + */ + public function testMarshalling(): void + { + $attr1 = new XMLAttribute(SOAP::NS_SOAP_ENV_11, 'soapenv', 'mustUnderstand', '1'); + $msgId = new MessageID('uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de', [$attr1]); + + $primary = new Primary($msgId); + $participant = new Participant($msgId); + $participants = new Participants($primary, [$participant], [$msgId]); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($participants), + ); + } + + + /** + * Adding an empty Participants element should yield an empty element. + */ + public function testMarshallingEmptyElement(): void + { + $wstns = C::NS_TRUST_200502; + $participants = new Participants(); + $this->assertEquals( + "<t:Participants xmlns:t=\"$wstns\"/>", + strval($participants), + ); + $this->assertTrue($participants->isEmptyElement()); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/PrimaryTest.php b/tests/WSSecurity/XML/wst_200502/PrimaryTest.php new file mode 100644 index 00000000..eea202a1 --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/PrimaryTest.php @@ -0,0 +1,65 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\SOAP\Constants as SOAP; +use SimpleSAML\WSSecurity\XML\wsa_200508\MessageID; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractParticipantType; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\Primary; +use SimpleSAML\XML\Attribute as XMLAttribute; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\PrimaryTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(Primary::class)] +#[CoversClass(AbstractParticipantType::class)] +#[CoversClass(AbstractWstElement::class)] +final class PrimaryTest extends TestCase +{ + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$testedClass = Primary::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/Primary.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a Primary object from scratch. + */ + public function testMarshalling(): void + { + $attr1 = new XMLAttribute(SOAP::NS_SOAP_ENV_11, 'soapenv', 'mustUnderstand', '1'); + $msgId = new MessageID('uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de', [$attr1]); + + $primary = new Primary($msgId); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($primary), + ); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/ProofEncryptionTest.php b/tests/WSSecurity/XML/wst_200502/ProofEncryptionTest.php new file mode 100644 index 00000000..3b1e15f5 --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/ProofEncryptionTest.php @@ -0,0 +1,69 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\SOAP\Constants as SOAP; +use SimpleSAML\WSSecurity\XML\wsa_200508\MessageID; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractProofEncryptionType; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\ProofEncryption; +use SimpleSAML\XML\Attribute as XMLAttribute; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\ProofEncryptionTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(ProofEncryption::class)] +#[CoversClass(AbstractProofEncryptionType::class)] +#[CoversClass(AbstractWstElement::class)] +final class ProofEncryptionTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = ProofEncryption::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/ProofEncryption.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a ProofEncryption object from scratch. + */ + public function testMarshalling(): void + { + $attr1 = new XMLAttribute(SOAP::NS_SOAP_ENV_11, 'soapenv', 'mustUnderstand', '1'); + $msgId = new MessageID('uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de', [$attr1]); + + $proofEncryption = new ProofEncryption($msgId); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($proofEncryption), + ); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/ReasonTest.php b/tests/WSSecurity/XML/wst_200502/ReasonTest.php new file mode 100644 index 00000000..8ee6987b --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/ReasonTest.php @@ -0,0 +1,57 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\Reason; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\ReasonTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(Reason::class)] +#[CoversClass(AbstractWstElement::class)] +final class ReasonTest extends TestCase +{ + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$testedClass = Reason::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/Reason.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a Reason object from scratch. + */ + public function testMarshalling(): void + { + $reason = new Reason('phpunit'); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($reason), + ); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/RenewTargetTest.php b/tests/WSSecurity/XML/wst_200502/RenewTargetTest.php new file mode 100644 index 00000000..03e97983 --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/RenewTargetTest.php @@ -0,0 +1,69 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\SOAP\Constants as SOAP; +use SimpleSAML\WSSecurity\XML\wsa_200408\MessageID; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractRenewTargetType; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\RenewTarget; +use SimpleSAML\XML\Attribute as XMLAttribute; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\RenewTargetTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(RenewTarget::class)] +#[CoversClass(AbstractRenewTargetType::class)] +#[CoversClass(AbstractWstElement::class)] +final class RenewTargetTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = RenewTarget::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/RenewTarget.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a RenewTarget object from scratch. + */ + public function testMarshalling(): void + { + $attr1 = new XMLAttribute(SOAP::NS_SOAP_ENV_11, 'soapenv', 'mustUnderstand', '1'); + $msgId = new MessageID('uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de', [$attr1]); + + $renewTarget = new RenewTarget($msgId); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($renewTarget), + ); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/RenewingTest.php b/tests/WSSecurity/XML/wst_200502/RenewingTest.php new file mode 100644 index 00000000..2f61f1f5 --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/RenewingTest.php @@ -0,0 +1,74 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractRenewingType; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\Renewing; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\RenewingTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(Renewing::class)] +#[CoversClass(AbstractRenewingType::class)] +#[CoversClass(AbstractWstElement::class)] +final class RenewingTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = Renewing::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/Renewing.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a Renewing object from scratch. + */ + public function testMarshalling(): void + { + $renewing = new Renewing(true, false); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($renewing), + ); + } + + + /** + * Test creating an empty Renewing object from scratch. + */ + public function testMarshallingEmpty(): void + { + $renewing = new Renewing(); + + $this->assertTrue($renewing->isEmptyElement()); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/RequestKETTest.php b/tests/WSSecurity/XML/wst_200502/RequestKETTest.php new file mode 100644 index 00000000..0be9613a --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/RequestKETTest.php @@ -0,0 +1,73 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\RequestKET; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\RequestKETTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(RequestKET::class)] +#[CoversClass(AbstractWstElement::class)] +final class RequestKETTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = RequestKET::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/RequestKET.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a RequestKET object from scratch. + */ + public function testMarshalling(): void + { + $requestKET = new RequestKET(); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($requestKET), + ); + } + + + /** + * Test creating an empty RequestKET object from scratch. + * + * NOTE: This element is empty per definition! + */ + public function testMarshallingEmpty(): void + { + $requestKET = new RequestKET(); + $this->assertFalse($requestKET->isEmptyElement()); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/RequestSecurityTokenResponseCollectionTest.php b/tests/WSSecurity/XML/wst_200502/RequestSecurityTokenResponseCollectionTest.php new file mode 100644 index 00000000..b1a3adfc --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/RequestSecurityTokenResponseCollectionTest.php @@ -0,0 +1,78 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\SOAP\Constants as SOAP; +use SimpleSAML\Test\WSSecurity\Constants as C; +use SimpleSAML\WSSecurity\XML\wsa_200508\MessageID; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractRequestSecurityTokenResponseCollectionType; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\RequestSecurityTokenResponse; +use SimpleSAML\WSSecurity\XML\wst_200502\RequestSecurityTokenResponseCollection; +use SimpleSAML\XML\Attribute as XMLAttribute; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\RequestSecurityTokenResponseCollectionTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(RequestSecurityTokenResponseCollection::class)] +#[CoversClass(AbstractRequestSecurityTokenResponseCollectionType::class)] +#[CoversClass(AbstractWstElement::class)] +final class RequestSecurityTokenResponseCollectionTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = RequestSecurityTokenResponseCollection::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/RequestSecurityTokenResponseCollection.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a RequestSecurityTokenResponseCollection object from scratch. + */ + public function testMarshalling(): void + { + $attr1 = new XMLAttribute(SOAP::NS_SOAP_ENV_11, 'soapenv', 'mustUnderstand', '1'); + $attr2 = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr1', 'testval1'); + $attr3 = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr2', 'testval2'); + $msgId = new MessageID('uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de', [$attr1]); + + $requestSecurityTokenResponse = new RequestSecurityTokenResponse(C::NAMESPACE, [$msgId], [$attr2]); + + $requestSecurityTokenResponseCollection = new RequestSecurityTokenResponseCollection( + [$requestSecurityTokenResponse], + [$attr3], + ); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($requestSecurityTokenResponseCollection), + ); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/RequestSecurityTokenResponseTest.php b/tests/WSSecurity/XML/wst_200502/RequestSecurityTokenResponseTest.php new file mode 100644 index 00000000..54f511f2 --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/RequestSecurityTokenResponseTest.php @@ -0,0 +1,82 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\SOAP\Constants as SOAP; +use SimpleSAML\Test\WSSecurity\Constants as C; +use SimpleSAML\WSSecurity\XML\wsa_200508\MessageID; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractRequestSecurityTokenResponseType; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\RequestSecurityTokenResponse; +use SimpleSAML\XML\Attribute as XMLAttribute; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\RequestSecurityTokenResponseTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(RequestSecurityTokenResponse::class)] +#[CoversClass(AbstractRequestSecurityTokenResponseType::class)] +#[CoversClass(AbstractWstElement::class)] +final class RequestSecurityTokenResponseTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = RequestSecurityTokenResponse::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/RequestSecurityTokenResponse.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a RequestSecurityTokenResponse object from scratch. + */ + public function testMarshalling(): void + { + $attr1 = new XMLAttribute(SOAP::NS_SOAP_ENV_11, 'soapenv', 'mustUnderstand', '1'); + $attr2 = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr1', 'testval1'); + $msgId = new MessageID('uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de', [$attr1]); + + $RequestSecurityTokenResponse = new RequestSecurityTokenResponse(C::NAMESPACE, [$msgId], [$attr2]); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($RequestSecurityTokenResponse), + ); + } + + + /** + * Test creating an empty RequestSecurityTokenResponse object from scratch. + */ + public function testMarshallingEmpty(): void + { + $RequestSecurityTokenResponse = new RequestSecurityTokenResponse(); + + $this->assertTrue($RequestSecurityTokenResponse->isEmptyElement()); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/RequestSecurityTokenTest.php b/tests/WSSecurity/XML/wst_200502/RequestSecurityTokenTest.php new file mode 100644 index 00000000..ab635bc6 --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/RequestSecurityTokenTest.php @@ -0,0 +1,82 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\SOAP\Constants as SOAP; +use SimpleSAML\Test\WSSecurity\Constants as C; +use SimpleSAML\WSSecurity\XML\wsa_200508\MessageID; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractRequestSecurityTokenType; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\RequestSecurityToken; +use SimpleSAML\XML\Attribute as XMLAttribute; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\RequestSecurityTokenTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(RequestSecurityToken::class)] +#[CoversClass(AbstractRequestSecurityTokenType::class)] +#[CoversClass(AbstractWstElement::class)] +final class RequestSecurityTokenTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = RequestSecurityToken::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/RequestSecurityToken.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a RequestSecurityToken object from scratch. + */ + public function testMarshalling(): void + { + $attr1 = new XMLAttribute(SOAP::NS_SOAP_ENV_11, 'soapenv', 'mustUnderstand', '1'); + $attr2 = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr1', 'testval1'); + $msgId = new MessageID('uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de', [$attr1]); + + $RequestSecurityToken = new RequestSecurityToken(C::NAMESPACE, [$msgId], [$attr2]); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($RequestSecurityToken), + ); + } + + + /** + * Test creating an empty RequestSecurityToken object from scratch. + */ + public function testMarshallingEmpty(): void + { + $RequestSecurityToken = new RequestSecurityToken(); + + $this->assertTrue($RequestSecurityToken->isEmptyElement()); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/RequestTypeTest.php b/tests/WSSecurity/XML/wst_200502/RequestTypeTest.php new file mode 100644 index 00000000..933cd1b8 --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/RequestTypeTest.php @@ -0,0 +1,64 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractRequestTypeOpenEnum; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\RequestType; +use SimpleSAML\WSSecurity\XML\wst_200502\RequestTypeEnum; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\RequestTypeTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(RequestType::class)] +#[CoversClass(AbstractRequestTypeOpenEnum::class)] +#[CoversClass(AbstractWstElement::class)] +final class RequestTypeTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = RequestType::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/RequestType.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a RequestType object from scratch. + */ + public function testMarshalling(): void + { + $requestType = new RequestType([RequestTypeEnum::Issue]); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($requestType), + ); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/RequestedAttachedReferenceTest.php b/tests/WSSecurity/XML/wst_200502/RequestedAttachedReferenceTest.php new file mode 100644 index 00000000..bdc2b463 --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/RequestedAttachedReferenceTest.php @@ -0,0 +1,78 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\WSSecurity\XML\wsse\SecurityTokenReference; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractRequestedReferenceType; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\RequestedAttachedReference; +use SimpleSAML\XML\Attribute as XMLAttribute; +use SimpleSAML\XML\Chunk; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\RequestedAttachedReferenceTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(RequestedAttachedReference::class)] +#[CoversClass(AbstractRequestedReferenceType::class)] +#[CoversClass(AbstractWstElement::class)] +final class RequestedAttachedReferenceTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = RequestedAttachedReference::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/RequestedAttachedReference.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a RequestedAttachedReference object from scratch. + */ + public function testMarshalling(): void + { + $attr1 = new XMLAttribute('urn:x-simplesamlphp:namespace', 'ssp', 'attr1', 'testval1'); + $child = DOMDocumentFactory::fromString( + '<ssp:Chunk xmlns:ssp="urn:x-simplesamlphp:namespace">SomeChunk</ssp:Chunk>', + ); + + $securityTokenReference = new SecurityTokenReference( + 'SomeID', + 'SomeUsage', + [new Chunk($child->documentElement)], + [$attr1], + ); + + $requestedAttachedReference = new RequestedAttachedReference($securityTokenReference); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($requestedAttachedReference), + ); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/RequestedProofTokenTest.php b/tests/WSSecurity/XML/wst_200502/RequestedProofTokenTest.php new file mode 100644 index 00000000..ecd8b9a8 --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/RequestedProofTokenTest.php @@ -0,0 +1,69 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\SOAP\Constants as SOAP; +use SimpleSAML\WSSecurity\XML\wsa_200508\MessageID; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractRequestedProofTokenType; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\RequestedProofToken; +use SimpleSAML\XML\Attribute as XMLAttribute; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\RequestedProofTokenTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(RequestedProofToken::class)] +#[CoversClass(AbstractRequestedProofTokenType::class)] +#[CoversClass(AbstractWstElement::class)] +final class RequestedProofTokenTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = RequestedProofToken::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/RequestedProofToken.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a RequestedProofToken object from scratch. + */ + public function testMarshalling(): void + { + $attr1 = new XMLAttribute(SOAP::NS_SOAP_ENV_11, 'soapenv', 'mustUnderstand', '1'); + $msgId = new MessageID('uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de', [$attr1]); + + $requestedProofToken = new RequestedProofToken($msgId); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($requestedProofToken), + ); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/RequestedSecurityTokenTest.php b/tests/WSSecurity/XML/wst_200502/RequestedSecurityTokenTest.php new file mode 100644 index 00000000..7e791532 --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/RequestedSecurityTokenTest.php @@ -0,0 +1,69 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\SOAP\Constants as SOAP; +use SimpleSAML\WSSecurity\XML\wsa_200508\MessageID; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractRequestedSecurityTokenType; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\RequestedSecurityToken; +use SimpleSAML\XML\Attribute as XMLAttribute; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\RequestedSecurityTokenTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(RequestedSecurityToken::class)] +#[CoversClass(AbstractRequestedSecurityTokenType::class)] +#[CoversClass(AbstractWstElement::class)] +final class RequestedSecurityTokenTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = RequestedSecurityToken::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/RequestedSecurityToken.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a RequestedSecurityToken object from scratch. + */ + public function testMarshalling(): void + { + $attr1 = new XMLAttribute(SOAP::NS_SOAP_ENV_11, 'soapenv', 'mustUnderstand', '1'); + $msgId = new MessageID('uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de', [$attr1]); + + $requestedSecurityToken = new RequestedSecurityToken($msgId); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($requestedSecurityToken), + ); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/RequestedTokenCancelledTest.php b/tests/WSSecurity/XML/wst_200502/RequestedTokenCancelledTest.php new file mode 100644 index 00000000..bf13f631 --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/RequestedTokenCancelledTest.php @@ -0,0 +1,73 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\RequestedTokenCancelled; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\RequestedTokenCancelledTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(RequestedTokenCancelled::class)] +#[CoversClass(AbstractWstElement::class)] +final class RequestedTokenCancelledTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = RequestedTokenCancelled::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/RequestedTokenCancelled.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a RequestedTokenCancelled object from scratch. + */ + public function testMarshalling(): void + { + $requestedTokenCancelled = new RequestedTokenCancelled(); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($requestedTokenCancelled), + ); + } + + + /** + * Test creating an empty RequestedTokenCancelled object from scratch. + * + * NOTE: This element is empty per definition! + */ + public function testMarshallingEmpty(): void + { + $requestedTokenCancelled = new RequestedTokenCancelled(); + $this->assertFalse($requestedTokenCancelled->isEmptyElement()); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/RequestedUnattachedReferenceTest.php b/tests/WSSecurity/XML/wst_200502/RequestedUnattachedReferenceTest.php new file mode 100644 index 00000000..24c238bb --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/RequestedUnattachedReferenceTest.php @@ -0,0 +1,78 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\WSSecurity\XML\wsse\SecurityTokenReference; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractRequestedReferenceType; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\RequestedUnattachedReference; +use SimpleSAML\XML\Attribute as XMLAttribute; +use SimpleSAML\XML\Chunk; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\RequestedUnattachedReferenceTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(RequestedUnattachedReference::class)] +#[CoversClass(AbstractRequestedReferenceType::class)] +#[CoversClass(AbstractWstElement::class)] +final class RequestedUnattachedReferenceTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = RequestedUnattachedReference::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/RequestedUnattachedReference.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a RequestedUnattachedReference object from scratch. + */ + public function testMarshalling(): void + { + $attr1 = new XMLAttribute('urn:x-simplesamlphp:namespace', 'ssp', 'attr1', 'testval1'); + $child = DOMDocumentFactory::fromString( + '<ssp:Chunk xmlns:ssp="urn:x-simplesamlphp:namespace">SomeChunk</ssp:Chunk>', + ); + + $securityTokenReference = new SecurityTokenReference( + 'SomeID', + 'SomeUsage', + [new Chunk($child->documentElement)], + [$attr1], + ); + + $requestedUnattachedReference = new RequestedUnattachedReference($securityTokenReference); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($requestedUnattachedReference), + ); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/SignChallengeResponseTest.php b/tests/WSSecurity/XML/wst_200502/SignChallengeResponseTest.php new file mode 100644 index 00000000..86445fc7 --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/SignChallengeResponseTest.php @@ -0,0 +1,74 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\SOAP\Constants as SOAP; +use SimpleSAML\Test\WSSecurity\Constants as C; +use SimpleSAML\WSSecurity\XML\wsa_200508\MessageID; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractSignChallengeType; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\Challenge; +use SimpleSAML\WSSecurity\XML\wst_200502\SignChallengeResponse; +use SimpleSAML\XML\Attribute as XMLAttribute; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\SignChallengeResponseTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(SignChallengeResponse::class)] +#[CoversClass(AbstractSignChallengeType::class)] +#[CoversClass(AbstractWstElement::class)] +final class SignChallengeResponseTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = SignChallengeResponse::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/SignChallengeResponse.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a SignChallengeResponse object from scratch. + */ + public function testMarshalling(): void + { + $attr1 = new XMLAttribute(SOAP::NS_SOAP_ENV_11, 'soapenv', 'mustUnderstand', '1'); + $msgId = new MessageID('uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de', [$attr1]); + + $challenge = new Challenge('accepted'); + $attr2 = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr1', 'testval1'); + + $signChallengeResponse = new SignChallengeResponse($challenge, [$msgId], [$attr2]); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($signChallengeResponse), + ); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/SignChallengeTest.php b/tests/WSSecurity/XML/wst_200502/SignChallengeTest.php new file mode 100644 index 00000000..6c5b54f6 --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/SignChallengeTest.php @@ -0,0 +1,84 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\SOAP\Constants as SOAP; +use SimpleSAML\Test\WSSecurity\Constants as C; +use SimpleSAML\WSSecurity\XML\wsa_200508\MessageID; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractSignChallengeType; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\Challenge; +use SimpleSAML\WSSecurity\XML\wst_200502\SignChallenge; +use SimpleSAML\XML\Attribute as XMLAttribute; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\SignChallengeTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(SignChallenge::class)] +#[CoversClass(AbstractSignChallengeType::class)] +#[CoversClass(AbstractWstElement::class)] +final class SignChallengeTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = SignChallenge::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/SignChallenge.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a SignChallenge object from scratch. + */ + public function testMarshalling(): void + { + $attr1 = new XMLAttribute(SOAP::NS_SOAP_ENV_11, 'soapenv', 'mustUnderstand', '1'); + $msgId = new MessageID('uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de', [$attr1]); + + $challenge = new Challenge('accepted'); + $attr2 = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr1', 'testval1'); + $signChallenge = new SignChallenge($challenge, [$msgId], [$attr2]); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($signChallenge), + ); + } + + + /** + * Test creating an empty SignChallenge object from scratch. + */ + public function testMarshallingEmpty(): void + { + $signChallenge = new SignChallenge(); + + $this->assertTrue($signChallenge->isEmptyElement()); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/SignWithTest.php b/tests/WSSecurity/XML/wst_200502/SignWithTest.php new file mode 100644 index 00000000..bcb8f67a --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/SignWithTest.php @@ -0,0 +1,62 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\Test\WSSecurity\Constants as C; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\SignWith; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\SignWithTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(SignWith::class)] +#[CoversClass(AbstractWstElement::class)] +final class SignWithTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = SignWith::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/SignWith.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a SignWith object from scratch. + */ + public function testMarshalling(): void + { + $signWith = new SignWith(C::NAMESPACE); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($signWith), + ); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/SignatureAlgorithmTest.php b/tests/WSSecurity/XML/wst_200502/SignatureAlgorithmTest.php new file mode 100644 index 00000000..024c7781 --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/SignatureAlgorithmTest.php @@ -0,0 +1,62 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\Test\WSSecurity\Constants as C; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\SignatureAlgorithm; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\SignatureAlgorithmTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(SignatureAlgorithm::class)] +#[CoversClass(AbstractWstElement::class)] +final class SignatureAlgorithmTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = SignatureAlgorithm::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/SignatureAlgorithm.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a SignatureAlgorithm object from scratch. + */ + public function testMarshalling(): void + { + $signatureAlgorithm = new SignatureAlgorithm(C::NAMESPACE); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($signatureAlgorithm), + ); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/StatusTest.php b/tests/WSSecurity/XML/wst_200502/StatusTest.php new file mode 100644 index 00000000..765889c5 --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/StatusTest.php @@ -0,0 +1,68 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractStatusType; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\Code; +use SimpleSAML\WSSecurity\XML\wst_200502\Reason; +use SimpleSAML\WSSecurity\XML\wst_200502\Status; +use SimpleSAML\WSSecurity\XML\wst_200502\StatusCodeEnum; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\StatusTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(Status::class)] +#[CoversClass(AbstractStatusType::class)] +#[CoversClass(AbstractWstElement::class)] +final class StatusTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = Status::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/Status.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a Status object from scratch. + */ + public function testMarshalling(): void + { + $code = new Code([StatusCodeEnum::Invalid]); + $reason = new Reason('phpunit'); + $status = new Status($code, $reason); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($status), + ); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/TokenTypeTest.php b/tests/WSSecurity/XML/wst_200502/TokenTypeTest.php new file mode 100644 index 00000000..af796ab4 --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/TokenTypeTest.php @@ -0,0 +1,62 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\Test\WSSecurity\Constants as C; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\TokenType; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\TokenTypeTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(TokenType::class)] +#[CoversClass(AbstractWstElement::class)] +final class TokenTypeTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = TokenType::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/TokenType.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a TokenType object from scratch. + */ + public function testMarshalling(): void + { + $tokenType = new TokenType(C::NAMESPACE); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($tokenType), + ); + } +} diff --git a/tests/WSSecurity/XML/wst_200502/UseKeyTest.php b/tests/WSSecurity/XML/wst_200502/UseKeyTest.php new file mode 100644 index 00000000..7a987930 --- /dev/null +++ b/tests/WSSecurity/XML/wst_200502/UseKeyTest.php @@ -0,0 +1,81 @@ +<?php + +declare(strict_types=1); + +namespace SimpleSAML\Test\WSSecurity\XML\wst_200502; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; +use SimpleSAML\SOAP\Constants as SOAP; +use SimpleSAML\Test\WSSecurity\Constants as C; +use SimpleSAML\WSSecurity\XML\wsa_200508\MessageID; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractUseKeyType; +use SimpleSAML\WSSecurity\XML\wst_200502\AbstractWstElement; +use SimpleSAML\WSSecurity\XML\wst_200502\UseKey; +use SimpleSAML\XML\Attribute as XMLAttribute; +use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; + +use function dirname; + +/** + * Class \SimpleSAML\WSSecurity\XML\wst_200502\UseKeyTest + * + * @package simplesamlphp/ws-security + */ +#[Group('wst')] +#[CoversClass(UseKey::class)] +#[CoversClass(AbstractUseKeyType::class)] +#[CoversClass(AbstractWstElement::class)] +final class UseKeyTest extends TestCase +{ + use SchemaValidationTestTrait; + use SerializableElementTestTrait; + + + /** + */ + public static function setUpBeforeClass(): void + { + self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust-200502.xsd'; + + self::$testedClass = UseKey::class; + + self::$xmlRepresentation = DOMDocumentFactory::fromFile( + dirname(__FILE__, 4) . '/resources/xml/wst/200502/UseKey.xml', + ); + } + + + // test marshalling + + + /** + * Test creating a UseKey object from scratch. + */ + public function testMarshalling(): void + { + $attr1 = new XMLAttribute(SOAP::NS_SOAP_ENV_11, 'soapenv', 'mustUnderstand', '1'); + $msgId = new MessageID('uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de', [$attr1]); + + $useKey = new UseKey($msgId, C::NAMESPACE); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($useKey), + ); + } + + + /** + * Test creating an empty UseKey object from scratch. + */ + public function testMarshallingEmpty(): void + { + $useKey = new UseKey(); + + $this->assertTrue($useKey->isEmptyElement()); + } +} diff --git a/tests/resources/xml/wst/200502/AllowPostdating.xml b/tests/resources/xml/wst/200502/AllowPostdating.xml new file mode 100644 index 00000000..669a25a2 --- /dev/null +++ b/tests/resources/xml/wst/200502/AllowPostdating.xml @@ -0,0 +1 @@ +<t:AllowPostdating xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust" /> diff --git a/tests/resources/xml/wst/200502/AuthenticationType.xml b/tests/resources/xml/wst/200502/AuthenticationType.xml new file mode 100644 index 00000000..df963aa1 --- /dev/null +++ b/tests/resources/xml/wst/200502/AuthenticationType.xml @@ -0,0 +1 @@ +<t:AuthenticationType xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust">urn:x-simplesamlphp:namespace</t:AuthenticationType> diff --git a/tests/resources/xml/wst/200502/Authenticator.xml b/tests/resources/xml/wst/200502/Authenticator.xml new file mode 100644 index 00000000..a837cfce --- /dev/null +++ b/tests/resources/xml/wst/200502/Authenticator.xml @@ -0,0 +1,4 @@ +<t:Authenticator xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust"> + <t:CombinedHash>/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI=</t:CombinedHash> + <wsa:MessageID xmlns:wsa="http://www.w3.org/2005/08/addressing" soapenv:mustUnderstand="1" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de</wsa:MessageID> +</t:Authenticator> diff --git a/tests/resources/xml/wst/200502/BinaryExchange.xml b/tests/resources/xml/wst/200502/BinaryExchange.xml new file mode 100644 index 00000000..c8fdb0ea --- /dev/null +++ b/tests/resources/xml/wst/200502/BinaryExchange.xml @@ -0,0 +1 @@ +<t:BinaryExchange xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust" xmlns:ssp="urn:x-simplesamlphp:namespace" ValueType="urn:x-simplesamlphp:namespace" EncodingType="urn:x-simplesamlphp:namespace" ssp:attr1="testval1">phpunit</t:BinaryExchange> diff --git a/tests/resources/xml/wst/200502/BinarySecret.xml b/tests/resources/xml/wst/200502/BinarySecret.xml new file mode 100644 index 00000000..69ea1d42 --- /dev/null +++ b/tests/resources/xml/wst/200502/BinarySecret.xml @@ -0,0 +1 @@ +<t:BinarySecret xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust" xmlns:ssp="urn:x-simplesamlphp:namespace" Type="http://schemas.xmlsoap.org/ws/2005/02/trust/Nonce" ssp:attr1="testval1">/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI=</t:BinarySecret> diff --git a/tests/resources/xml/wst/200502/CancelTarget.xml b/tests/resources/xml/wst/200502/CancelTarget.xml new file mode 100644 index 00000000..b4add4ad --- /dev/null +++ b/tests/resources/xml/wst/200502/CancelTarget.xml @@ -0,0 +1,3 @@ +<t:CancelTarget xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust"> + <wsa:MessageID xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" soapenv:mustUnderstand="1" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de</wsa:MessageID> +</t:CancelTarget> diff --git a/tests/resources/xml/wst/200502/CanonicalizationAlgorithm.xml b/tests/resources/xml/wst/200502/CanonicalizationAlgorithm.xml new file mode 100644 index 00000000..179ed95d --- /dev/null +++ b/tests/resources/xml/wst/200502/CanonicalizationAlgorithm.xml @@ -0,0 +1 @@ +<t:CanonicalizationAlgorithm xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust">urn:x-simplesamlphp:namespace</t:CanonicalizationAlgorithm> diff --git a/tests/resources/xml/wst/200502/Challenge.xml b/tests/resources/xml/wst/200502/Challenge.xml new file mode 100644 index 00000000..f75db88e --- /dev/null +++ b/tests/resources/xml/wst/200502/Challenge.xml @@ -0,0 +1 @@ +<t:Challenge xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust">accepted</t:Challenge> diff --git a/tests/resources/xml/wst/200502/Claims.xml b/tests/resources/xml/wst/200502/Claims.xml new file mode 100644 index 00000000..6fcc5d27 --- /dev/null +++ b/tests/resources/xml/wst/200502/Claims.xml @@ -0,0 +1,3 @@ +<t:Claims xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust" xmlns:ssp="urn:x-simplesamlphp:namespace" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" Dialect="urn:x-simplesamlphp:namespace" ssp:attr1="testval1"> + <wsa:MessageID soapenv:mustUnderstand="1">uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de</wsa:MessageID> +</t:Claims> diff --git a/tests/resources/xml/wst/200502/Code.xml b/tests/resources/xml/wst/200502/Code.xml new file mode 100644 index 00000000..adeef3a1 --- /dev/null +++ b/tests/resources/xml/wst/200502/Code.xml @@ -0,0 +1 @@ +<t:Code xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust">http://schemas.xmlsoap.org/ws/2005/02/trust/status/invalid</t:Code> diff --git a/tests/resources/xml/wst/200502/CombinedHash.xml b/tests/resources/xml/wst/200502/CombinedHash.xml new file mode 100644 index 00000000..c0d7fa01 --- /dev/null +++ b/tests/resources/xml/wst/200502/CombinedHash.xml @@ -0,0 +1 @@ +<t:CombinedHash xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust">/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI=</t:CombinedHash> diff --git a/tests/resources/xml/wst/200502/ComputedKey.xml b/tests/resources/xml/wst/200502/ComputedKey.xml new file mode 100644 index 00000000..04362a4d --- /dev/null +++ b/tests/resources/xml/wst/200502/ComputedKey.xml @@ -0,0 +1 @@ +<t:ComputedKey xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust">http://schemas.xmlsoap.org/ws/2005/02/trust/CK/PSHA1</t:ComputedKey> diff --git a/tests/resources/xml/wst/200502/ComputedKeyAlgorithm.xml b/tests/resources/xml/wst/200502/ComputedKeyAlgorithm.xml new file mode 100644 index 00000000..b78220ba --- /dev/null +++ b/tests/resources/xml/wst/200502/ComputedKeyAlgorithm.xml @@ -0,0 +1 @@ +<t:ComputedKeyAlgorithm xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust">urn:x-simplesamlphp:namespace</t:ComputedKeyAlgorithm> diff --git a/tests/resources/xml/wst/200502/Delegatable.xml b/tests/resources/xml/wst/200502/Delegatable.xml new file mode 100644 index 00000000..6d969188 --- /dev/null +++ b/tests/resources/xml/wst/200502/Delegatable.xml @@ -0,0 +1 @@ +<t:Delegatable xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust">true</t:Delegatable> diff --git a/tests/resources/xml/wst/200502/DelegateTo.xml b/tests/resources/xml/wst/200502/DelegateTo.xml new file mode 100644 index 00000000..f070ba25 --- /dev/null +++ b/tests/resources/xml/wst/200502/DelegateTo.xml @@ -0,0 +1,3 @@ +<t:DelegateTo xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust"> + <wsa:MessageID xmlns:wsa="http://www.w3.org/2005/08/addressing" soapenv:mustUnderstand="1" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de</wsa:MessageID> +</t:DelegateTo> diff --git a/tests/resources/xml/wst/200502/EncryptWith.xml b/tests/resources/xml/wst/200502/EncryptWith.xml new file mode 100644 index 00000000..a153980d --- /dev/null +++ b/tests/resources/xml/wst/200502/EncryptWith.xml @@ -0,0 +1 @@ +<t:EncryptWith xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust">urn:x-simplesamlphp:namespace</t:EncryptWith> diff --git a/tests/resources/xml/wst/200502/Encryption.xml b/tests/resources/xml/wst/200502/Encryption.xml new file mode 100644 index 00000000..a05a1852 --- /dev/null +++ b/tests/resources/xml/wst/200502/Encryption.xml @@ -0,0 +1,3 @@ +<t:Encryption xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust"> + <wsa:MessageID xmlns:wsa="http://www.w3.org/2005/08/addressing" soapenv:mustUnderstand="1" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de</wsa:MessageID> +</t:Encryption> diff --git a/tests/resources/xml/wst/200502/EncryptionAlgorithm.xml b/tests/resources/xml/wst/200502/EncryptionAlgorithm.xml new file mode 100644 index 00000000..06447dd1 --- /dev/null +++ b/tests/resources/xml/wst/200502/EncryptionAlgorithm.xml @@ -0,0 +1 @@ +<t:EncryptionAlgorithm xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust">urn:x-simplesamlphp:namespace</t:EncryptionAlgorithm> diff --git a/tests/resources/xml/wst/200502/Entropy.xml b/tests/resources/xml/wst/200502/Entropy.xml new file mode 100644 index 00000000..1555a08e --- /dev/null +++ b/tests/resources/xml/wst/200502/Entropy.xml @@ -0,0 +1,3 @@ +<t:Entropy xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust" xmlns:ssp="urn:x-simplesamlphp:namespace" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" ssp:attr1="testval1"> + <wsa:MessageID soapenv:mustUnderstand="1">uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de</wsa:MessageID> +</t:Entropy> diff --git a/tests/resources/xml/wst/200502/Forwardable.xml b/tests/resources/xml/wst/200502/Forwardable.xml new file mode 100644 index 00000000..06dbe3e3 --- /dev/null +++ b/tests/resources/xml/wst/200502/Forwardable.xml @@ -0,0 +1 @@ +<t:Forwardable xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust">true</t:Forwardable> diff --git a/tests/resources/xml/wst/200502/IssuedTokens.xml b/tests/resources/xml/wst/200502/IssuedTokens.xml new file mode 100644 index 00000000..9240bfab --- /dev/null +++ b/tests/resources/xml/wst/200502/IssuedTokens.xml @@ -0,0 +1,5 @@ +<t:IssuedTokens xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust" xmlns:ssp="urn:x-simplesamlphp:namespace" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" ssp:attr2="testval2"> + <t:RequestSecurityTokenResponse Context="urn:x-simplesamlphp:namespace" ssp:attr1="testval1"> + <wsa:MessageID soapenv:mustUnderstand="1">uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de</wsa:MessageID> + </t:RequestSecurityTokenResponse> +</t:IssuedTokens> diff --git a/tests/resources/xml/wst/200502/Issuer.xml b/tests/resources/xml/wst/200502/Issuer.xml new file mode 100644 index 00000000..36455907 --- /dev/null +++ b/tests/resources/xml/wst/200502/Issuer.xml @@ -0,0 +1,14 @@ +<t:Issuer xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust" xmlns:ssp="urn:x-simplesamlphp:namespace" ssp:test1="value1"> + <wsa:Address xmlns:wsa="http://www.w3.org/2005/08/addressing" ssp:test2="value2">https://login.microsoftonline.com/login.srf</wsa:Address> + <wsa:ReferenceParameters xmlns:wsa="http://www.w3.org/2005/08/addressing" ssp:test4="value4"> + <m:GetPrice xmlns:m="https://www.w3schools.com/prices"> + <m:Item>Pears</m:Item> + </m:GetPrice> + </wsa:ReferenceParameters> + <wsa:Metadata xmlns:wsa="http://www.w3.org/2005/08/addressing" ssp:test3="value3"> + <m:GetPrice xmlns:m="https://www.w3schools.com/prices"> + <m:Item>Apples</m:Item> + </m:GetPrice> + </wsa:Metadata> + <ssp:Chunk>SomeChunk</ssp:Chunk> +</t:Issuer> diff --git a/tests/resources/xml/wst/200502/KeyExchangeToken.xml b/tests/resources/xml/wst/200502/KeyExchangeToken.xml new file mode 100644 index 00000000..a7e7b89b --- /dev/null +++ b/tests/resources/xml/wst/200502/KeyExchangeToken.xml @@ -0,0 +1,3 @@ +<t:KeyExchangeToken xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust"> + <wsa:MessageID xmlns:wsa="http://www.w3.org/2005/08/addressing" soapenv:mustUnderstand="1" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de</wsa:MessageID> +</t:KeyExchangeToken> diff --git a/tests/resources/xml/wst/200502/KeySize.xml b/tests/resources/xml/wst/200502/KeySize.xml new file mode 100644 index 00000000..274337dc --- /dev/null +++ b/tests/resources/xml/wst/200502/KeySize.xml @@ -0,0 +1 @@ +<t:KeySize xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust">4096</t:KeySize> diff --git a/tests/resources/xml/wst/200502/KeyType.xml b/tests/resources/xml/wst/200502/KeyType.xml new file mode 100644 index 00000000..78d3bfb8 --- /dev/null +++ b/tests/resources/xml/wst/200502/KeyType.xml @@ -0,0 +1 @@ +<t:KeyType xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust">http://schemas.xmlsoap.org/ws/2005/02/trust/PublicKey</t:KeyType> diff --git a/tests/resources/xml/wst/200502/Lifetime.xml b/tests/resources/xml/wst/200502/Lifetime.xml new file mode 100644 index 00000000..4e68c2eb --- /dev/null +++ b/tests/resources/xml/wst/200502/Lifetime.xml @@ -0,0 +1,4 @@ +<t:Lifetime xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust"> + <wsu:Created xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2001-09-13T08:42:00Z</wsu:Created> + <wsu:Expires xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2001-10-13T09:00:00Z</wsu:Expires> +</t:Lifetime> diff --git a/tests/resources/xml/wst/200502/OnBehalfOf.xml b/tests/resources/xml/wst/200502/OnBehalfOf.xml new file mode 100644 index 00000000..06842b29 --- /dev/null +++ b/tests/resources/xml/wst/200502/OnBehalfOf.xml @@ -0,0 +1,3 @@ +<t:OnBehalfOf xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust"> + <wsa:MessageID xmlns:wsa="http://www.w3.org/2005/08/addressing" soapenv:mustUnderstand="1" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de</wsa:MessageID> +</t:OnBehalfOf> diff --git a/tests/resources/xml/wst/200502/Participant.xml b/tests/resources/xml/wst/200502/Participant.xml new file mode 100644 index 00000000..e404f832 --- /dev/null +++ b/tests/resources/xml/wst/200502/Participant.xml @@ -0,0 +1,3 @@ +<t:Participant xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust"> + <wsa:MessageID xmlns:wsa="http://www.w3.org/2005/08/addressing" soapenv:mustUnderstand="1" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de</wsa:MessageID> +</t:Participant> diff --git a/tests/resources/xml/wst/200502/Participants.xml b/tests/resources/xml/wst/200502/Participants.xml new file mode 100644 index 00000000..c84e3ba3 --- /dev/null +++ b/tests/resources/xml/wst/200502/Participants.xml @@ -0,0 +1,9 @@ +<t:Participants xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust"> + <t:Primary> + <wsa:MessageID xmlns:wsa="http://www.w3.org/2005/08/addressing" soapenv:mustUnderstand="1" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de</wsa:MessageID> + </t:Primary> + <t:Participant> + <wsa:MessageID xmlns:wsa="http://www.w3.org/2005/08/addressing" soapenv:mustUnderstand="1" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de</wsa:MessageID> + </t:Participant> + <wsa:MessageID xmlns:wsa="http://www.w3.org/2005/08/addressing" soapenv:mustUnderstand="1" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de</wsa:MessageID> +</t:Participants> diff --git a/tests/resources/xml/wst/200502/Primary.xml b/tests/resources/xml/wst/200502/Primary.xml new file mode 100644 index 00000000..f2a2daf4 --- /dev/null +++ b/tests/resources/xml/wst/200502/Primary.xml @@ -0,0 +1,3 @@ +<t:Primary xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust"> + <wsa:MessageID xmlns:wsa="http://www.w3.org/2005/08/addressing" soapenv:mustUnderstand="1" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de</wsa:MessageID> +</t:Primary> diff --git a/tests/resources/xml/wst/200502/ProofEncryption.xml b/tests/resources/xml/wst/200502/ProofEncryption.xml new file mode 100644 index 00000000..bf99fe41 --- /dev/null +++ b/tests/resources/xml/wst/200502/ProofEncryption.xml @@ -0,0 +1,3 @@ +<t:ProofEncryption xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust"> + <wsa:MessageID xmlns:wsa="http://www.w3.org/2005/08/addressing" soapenv:mustUnderstand="1" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de</wsa:MessageID> +</t:ProofEncryption> diff --git a/tests/resources/xml/wst/200502/Reason.xml b/tests/resources/xml/wst/200502/Reason.xml new file mode 100644 index 00000000..011f8386 --- /dev/null +++ b/tests/resources/xml/wst/200502/Reason.xml @@ -0,0 +1 @@ +<t:Reason xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust">phpunit</t:Reason> diff --git a/tests/resources/xml/wst/200502/RenewTarget.xml b/tests/resources/xml/wst/200502/RenewTarget.xml new file mode 100644 index 00000000..76b10231 --- /dev/null +++ b/tests/resources/xml/wst/200502/RenewTarget.xml @@ -0,0 +1,3 @@ +<t:RenewTarget xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust"> + <wsa:MessageID xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" soapenv:mustUnderstand="1" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de</wsa:MessageID> +</t:RenewTarget> diff --git a/tests/resources/xml/wst/200502/Renewing.xml b/tests/resources/xml/wst/200502/Renewing.xml new file mode 100644 index 00000000..b2baba1f --- /dev/null +++ b/tests/resources/xml/wst/200502/Renewing.xml @@ -0,0 +1 @@ +<t:Renewing xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust" Allow="true" OK="false"/> diff --git a/tests/resources/xml/wst/200502/RequestKET.xml b/tests/resources/xml/wst/200502/RequestKET.xml new file mode 100644 index 00000000..6f9aac69 --- /dev/null +++ b/tests/resources/xml/wst/200502/RequestKET.xml @@ -0,0 +1 @@ +<t:RequestKET xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust" /> diff --git a/tests/resources/xml/wst/200502/RequestSecurityToken.xml b/tests/resources/xml/wst/200502/RequestSecurityToken.xml new file mode 100644 index 00000000..33d0d05f --- /dev/null +++ b/tests/resources/xml/wst/200502/RequestSecurityToken.xml @@ -0,0 +1,3 @@ +<t:RequestSecurityToken xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust" xmlns:ssp="urn:x-simplesamlphp:namespace" Context="urn:x-simplesamlphp:namespace" ssp:attr1="testval1"> + <wsa:MessageID xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" soapenv:mustUnderstand="1">uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de</wsa:MessageID> +</t:RequestSecurityToken> diff --git a/tests/resources/xml/wst/200502/RequestSecurityTokenResponse.xml b/tests/resources/xml/wst/200502/RequestSecurityTokenResponse.xml new file mode 100644 index 00000000..2b9b11c2 --- /dev/null +++ b/tests/resources/xml/wst/200502/RequestSecurityTokenResponse.xml @@ -0,0 +1,3 @@ +<t:RequestSecurityTokenResponse xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust" xmlns:ssp="urn:x-simplesamlphp:namespace" Context="urn:x-simplesamlphp:namespace" ssp:attr1="testval1"> + <wsa:MessageID xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" soapenv:mustUnderstand="1">uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de</wsa:MessageID> +</t:RequestSecurityTokenResponse> diff --git a/tests/resources/xml/wst/200502/RequestSecurityTokenResponseCollection.xml b/tests/resources/xml/wst/200502/RequestSecurityTokenResponseCollection.xml new file mode 100644 index 00000000..b17babed --- /dev/null +++ b/tests/resources/xml/wst/200502/RequestSecurityTokenResponseCollection.xml @@ -0,0 +1,5 @@ +<t:RequestSecurityTokenResponseCollection xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust" xmlns:ssp="urn:x-simplesamlphp:namespace" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" ssp:attr2="testval2"> + <t:RequestSecurityTokenResponse Context="urn:x-simplesamlphp:namespace" ssp:attr1="testval1"> + <wsa:MessageID soapenv:mustUnderstand="1">uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de</wsa:MessageID> + </t:RequestSecurityTokenResponse> +</t:RequestSecurityTokenResponseCollection> diff --git a/tests/resources/xml/wst/200502/RequestType.xml b/tests/resources/xml/wst/200502/RequestType.xml new file mode 100644 index 00000000..93388f88 --- /dev/null +++ b/tests/resources/xml/wst/200502/RequestType.xml @@ -0,0 +1 @@ +<t:RequestType xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust">http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</t:RequestType> diff --git a/tests/resources/xml/wst/200502/RequestedAttachedReference.xml b/tests/resources/xml/wst/200502/RequestedAttachedReference.xml new file mode 100644 index 00000000..e8b56c33 --- /dev/null +++ b/tests/resources/xml/wst/200502/RequestedAttachedReference.xml @@ -0,0 +1,5 @@ +<t:RequestedAttachedReference xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust"> + <wsse:SecurityTokenReference xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:ssp="urn:x-simplesamlphp:namespace" wsse:Usage="SomeUsage" wsu:Id="SomeID" ssp:attr1="testval1"> + <ssp:Chunk>SomeChunk</ssp:Chunk> + </wsse:SecurityTokenReference> +</t:RequestedAttachedReference> diff --git a/tests/resources/xml/wst/200502/RequestedProofToken.xml b/tests/resources/xml/wst/200502/RequestedProofToken.xml new file mode 100644 index 00000000..6fc7b986 --- /dev/null +++ b/tests/resources/xml/wst/200502/RequestedProofToken.xml @@ -0,0 +1,3 @@ +<t:RequestedProofToken xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust"> + <wsa:MessageID xmlns:wsa="http://www.w3.org/2005/08/addressing" soapenv:mustUnderstand="1" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de</wsa:MessageID> +</t:RequestedProofToken> diff --git a/tests/resources/xml/wst/200502/RequestedSecurityToken.xml b/tests/resources/xml/wst/200502/RequestedSecurityToken.xml new file mode 100644 index 00000000..ea5080b1 --- /dev/null +++ b/tests/resources/xml/wst/200502/RequestedSecurityToken.xml @@ -0,0 +1,3 @@ +<t:RequestedSecurityToken xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust"> + <wsa:MessageID xmlns:wsa="http://www.w3.org/2005/08/addressing" soapenv:mustUnderstand="1" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de</wsa:MessageID> +</t:RequestedSecurityToken> diff --git a/tests/resources/xml/wst/200502/RequestedTokenCancelled.xml b/tests/resources/xml/wst/200502/RequestedTokenCancelled.xml new file mode 100644 index 00000000..888f5975 --- /dev/null +++ b/tests/resources/xml/wst/200502/RequestedTokenCancelled.xml @@ -0,0 +1 @@ +<t:RequestedTokenCancelled xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust" /> diff --git a/tests/resources/xml/wst/200502/RequestedUnattachedReference.xml b/tests/resources/xml/wst/200502/RequestedUnattachedReference.xml new file mode 100644 index 00000000..3d44296c --- /dev/null +++ b/tests/resources/xml/wst/200502/RequestedUnattachedReference.xml @@ -0,0 +1,5 @@ +<t:RequestedUnattachedReference xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust"> + <wsse:SecurityTokenReference xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:ssp="urn:x-simplesamlphp:namespace" wsse:Usage="SomeUsage" wsu:Id="SomeID" ssp:attr1="testval1"> + <ssp:Chunk>SomeChunk</ssp:Chunk> + </wsse:SecurityTokenReference> +</t:RequestedUnattachedReference> diff --git a/tests/resources/xml/wst/200502/SignChallenge.xml b/tests/resources/xml/wst/200502/SignChallenge.xml new file mode 100644 index 00000000..b0dcf186 --- /dev/null +++ b/tests/resources/xml/wst/200502/SignChallenge.xml @@ -0,0 +1,4 @@ +<t:SignChallenge xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust" xmlns:ssp="urn:x-simplesamlphp:namespace" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" ssp:attr1="testval1"> + <t:Challenge>accepted</t:Challenge> + <wsa:MessageID soapenv:mustUnderstand="1">uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de</wsa:MessageID> +</t:SignChallenge> diff --git a/tests/resources/xml/wst/200502/SignChallengeResponse.xml b/tests/resources/xml/wst/200502/SignChallengeResponse.xml new file mode 100644 index 00000000..dd084297 --- /dev/null +++ b/tests/resources/xml/wst/200502/SignChallengeResponse.xml @@ -0,0 +1,4 @@ +<t:SignChallengeResponse xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust" xmlns:ssp="urn:x-simplesamlphp:namespace" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" ssp:attr1="testval1"> + <t:Challenge>accepted</t:Challenge> + <wsa:MessageID soapenv:mustUnderstand="1">uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de</wsa:MessageID> +</t:SignChallengeResponse> diff --git a/tests/resources/xml/wst/200502/SignWith.xml b/tests/resources/xml/wst/200502/SignWith.xml new file mode 100644 index 00000000..41cbe72f --- /dev/null +++ b/tests/resources/xml/wst/200502/SignWith.xml @@ -0,0 +1 @@ +<t:SignWith xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust">urn:x-simplesamlphp:namespace</t:SignWith> diff --git a/tests/resources/xml/wst/200502/SignatureAlgorithm.xml b/tests/resources/xml/wst/200502/SignatureAlgorithm.xml new file mode 100644 index 00000000..6c304aff --- /dev/null +++ b/tests/resources/xml/wst/200502/SignatureAlgorithm.xml @@ -0,0 +1 @@ +<t:SignatureAlgorithm xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust">urn:x-simplesamlphp:namespace</t:SignatureAlgorithm> diff --git a/tests/resources/xml/wst/200502/Status.xml b/tests/resources/xml/wst/200502/Status.xml new file mode 100644 index 00000000..753c438c --- /dev/null +++ b/tests/resources/xml/wst/200502/Status.xml @@ -0,0 +1,4 @@ +<t:Status xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust"> + <t:Code>http://schemas.xmlsoap.org/ws/2005/02/trust/status/invalid</t:Code> + <t:Reason>phpunit</t:Reason> +</t:Status> diff --git a/tests/resources/xml/wst/200502/TokenType.xml b/tests/resources/xml/wst/200502/TokenType.xml new file mode 100644 index 00000000..c5890edd --- /dev/null +++ b/tests/resources/xml/wst/200502/TokenType.xml @@ -0,0 +1 @@ +<t:TokenType xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust">urn:x-simplesamlphp:namespace</t:TokenType> diff --git a/tests/resources/xml/wst/200502/UseKey.xml b/tests/resources/xml/wst/200502/UseKey.xml new file mode 100644 index 00000000..7bbd65c8 --- /dev/null +++ b/tests/resources/xml/wst/200502/UseKey.xml @@ -0,0 +1,3 @@ +<t:UseKey xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust" Sig="urn:x-simplesamlphp:namespace"> + <wsa:MessageID xmlns:wsa="http://www.w3.org/2005/08/addressing" soapenv:mustUnderstand="1" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de</wsa:MessageID> +</t:UseKey>