diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 2d3ef18d9..6b4fd6386 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -3,209 +3,244 @@ parameters: - message: "#^Call to static method addSign\\(\\) on an unknown class SimpleSAML\\\\Module\\\\saml\\\\Message\\.$#" count: 1 - path: src/SAML2/Binding/HTTPArtifact.php + path: src/Binding/HTTPArtifact.php - message: "#^Call to static method getInstance\\(\\) on an unknown class SimpleSAML\\\\Configuration\\.$#" count: 2 - path: src/SAML2/Binding/HTTPArtifact.php + path: src/Binding/HTTPArtifact.php - message: "#^Call to static method getInstance\\(\\) on an unknown class SimpleSAML\\\\Store\\\\StoreFactory\\.$#" count: 1 - path: src/SAML2/Binding/HTTPArtifact.php + path: src/Binding/HTTPArtifact.php - message: "#^Call to static method getMetadataHandler\\(\\) on an unknown class SimpleSAML\\\\Metadata\\\\MetaDataStorageHandler\\.$#" count: 1 - path: src/SAML2/Binding/HTTPArtifact.php + path: src/Binding/HTTPArtifact.php - message: "#^Instantiated class SimpleSAML\\\\Utils\\\\HTTP not found\\.$#" count: 1 - path: src/SAML2/Binding/HTTPArtifact.php + path: src/Binding/HTTPArtifact.php - message: "#^Parameter \\$key of method SimpleSAML\\\\SAML2\\\\Binding\\\\HTTPArtifact\\:\\:validateSignature\\(\\) has invalid type SimpleSAML\\\\XMLSecurity\\\\XMLSecurityKey\\.$#" count: 1 - path: src/SAML2/Binding/HTTPArtifact.php + path: src/Binding/HTTPArtifact.php - message: "#^Parameter \\$sp of method SimpleSAML\\\\SAML2\\\\Binding\\\\HTTPArtifact\\:\\:setSPMetadata\\(\\) has invalid type SimpleSAML\\\\Configuration\\.$#" count: 1 - path: src/SAML2/Binding/HTTPArtifact.php + path: src/Binding/HTTPArtifact.php - message: "#^Property SimpleSAML\\\\SAML2\\\\Binding\\\\HTTPArtifact\\:\\:\\$spMetadata has unknown class SimpleSAML\\\\Configuration as its type\\.$#" count: 1 - path: src/SAML2/Binding/HTTPArtifact.php + path: src/Binding/HTTPArtifact.php - message: "#^Access to constant AES128_CBC on an unknown class SimpleSAML\\\\XMLSecurity\\\\XMLSecurityKey\\.$#" count: 1 - path: src/SAML2/Certificate/PrivateKeyLoader.php + path: src/Certificate/PrivateKeyLoader.php - message: "#^Access to constant RSA_1_5 on an unknown class SimpleSAML\\\\XMLSecurity\\\\XMLSecurityKey\\.$#" count: 1 - path: src/SAML2/Certificate/PrivateKeyLoader.php + path: src/Certificate/PrivateKeyLoader.php - message: "#^Instantiated class SimpleSAML\\\\XMLSecurity\\\\XMLSecurityKey not found\\.$#" count: 2 - path: src/SAML2/Certificate/PrivateKeyLoader.php + path: src/Certificate/PrivateKeyLoader.php - message: "#^Method SimpleSAML\\\\SAML2\\\\Certificate\\\\PrivateKeyLoader\\:\\:convertPrivateKeyToRsaKey\\(\\) has invalid return type SimpleSAML\\\\XMLSecurity\\\\XMLSecurityKey\\.$#" count: 1 - path: src/SAML2/Certificate/PrivateKeyLoader.php + path: src/Certificate/PrivateKeyLoader.php - message: "#^Parameter \\$configuration of method SimpleSAML\\\\SAML2\\\\Configuration\\\\SimpleSAMLConverter\\:\\:convertToIdentityProvider\\(\\) has invalid type SimpleSAML\\\\Configuration\\.$#" count: 1 - path: src/SAML2/Configuration/SimpleSAMLConverter.php + path: src/Configuration/SimpleSAMLConverter.php - message: "#^Parameter \\$configuration of method SimpleSAML\\\\SAML2\\\\Configuration\\\\SimpleSAMLConverter\\:\\:convertToServiceProvider\\(\\) has invalid type SimpleSAML\\\\Configuration\\.$#" count: 1 - path: src/SAML2/Configuration/SimpleSAMLConverter.php + path: src/Configuration/SimpleSAMLConverter.php - message: "#^Parameter \\$configuration of method SimpleSAML\\\\SAML2\\\\Configuration\\\\SimpleSAMLConverter\\:\\:enrichForDecryptionProvider\\(\\) has invalid type SimpleSAML\\\\Configuration\\.$#" count: 1 - path: src/SAML2/Configuration/SimpleSAMLConverter.php + path: src/Configuration/SimpleSAMLConverter.php - message: "#^Parameter \\$configuration of method SimpleSAML\\\\SAML2\\\\Configuration\\\\SimpleSAMLConverter\\:\\:enrichForIdentityProvider\\(\\) has invalid type SimpleSAML\\\\Configuration\\.$#" count: 1 - path: src/SAML2/Configuration/SimpleSAMLConverter.php + path: src/Configuration/SimpleSAMLConverter.php - message: "#^Parameter \\$configuration of method SimpleSAML\\\\SAML2\\\\Configuration\\\\SimpleSAMLConverter\\:\\:enrichForServiceProvider\\(\\) has invalid type SimpleSAML\\\\Configuration\\.$#" count: 1 - path: src/SAML2/Configuration/SimpleSAMLConverter.php + path: src/Configuration/SimpleSAMLConverter.php - message: "#^Parameter \\$configuration of method SimpleSAML\\\\SAML2\\\\Configuration\\\\SimpleSAMLConverter\\:\\:pluckConfiguration\\(\\) has invalid type SimpleSAML\\\\Configuration\\.$#" count: 1 - path: src/SAML2/Configuration/SimpleSAMLConverter.php + path: src/Configuration/SimpleSAMLConverter.php + + - + message: "#^Call to static method fromXML\\(\\) on an unknown class SimpleSAML\\\\SOAP11\\\\XML\\\\env\\\\Envelope\\.$#" + count: 1 + path: src/SOAPClient.php + + - + message: "#^Call to static method fromXML\\(\\) on an unknown class SimpleSAML\\\\SOAP11\\\\XML\\\\env\\\\Fault\\.$#" + count: 1 + path: src/SOAPClient.php + + - + message: "#^Call to static method getXPath\\(\\) on an unknown class SimpleSAML\\\\SOAP11\\\\Utils\\\\XPath\\.$#" + count: 1 + path: src/SOAPClient.php + + - + message: "#^Call to static method xpQuery\\(\\) on an unknown class SimpleSAML\\\\SOAP11\\\\Utils\\\\XPath\\.$#" + count: 1 + path: src/SOAPClient.php + + - + message: "#^Instantiated class SimpleSAML\\\\SOAP11\\\\XML\\\\env\\\\Body not found\\.$#" + count: 1 + path: src/SOAPClient.php + + - + message: "#^Instantiated class SimpleSAML\\\\SOAP11\\\\XML\\\\env\\\\Envelope not found\\.$#" + count: 1 + path: src/SOAPClient.php - message: "#^Instantiated class SimpleSAML\\\\Utils\\\\Config not found\\.$#" count: 1 - path: src/SAML2/SOAPClient.php + path: src/SOAPClient.php - message: "#^Instantiated class SimpleSAML\\\\Utils\\\\Crypto not found\\.$#" count: 1 - path: src/SAML2/SOAPClient.php + path: src/SOAPClient.php + + - + message: "#^Method SimpleSAML\\\\SAML2\\\\SOAPClient\\:\\:getSOAPFault\\(\\) has invalid return type SimpleSAML\\\\SOAP11\\\\XML\\\\env\\\\Fault\\.$#" + count: 1 + path: src/SOAPClient.php - message: "#^Parameter \\$dstMetadata of method SimpleSAML\\\\SAML2\\\\SOAPClient\\:\\:send\\(\\) has invalid type SimpleSAML\\\\Configuration\\.$#" count: 1 - path: src/SAML2/SOAPClient.php + path: src/SOAPClient.php - message: "#^Parameter \\$key of method SimpleSAML\\\\SAML2\\\\SOAPClient\\:\\:validateSSL\\(\\) has invalid type SimpleSAML\\\\XMLSecurity\\\\XMLSecurityKey\\.$#" count: 1 - path: src/SAML2/SOAPClient.php + path: src/SOAPClient.php - message: "#^Parameter \\$srcMetadata of method SimpleSAML\\\\SAML2\\\\SOAPClient\\:\\:send\\(\\) has invalid type SimpleSAML\\\\Configuration\\.$#" count: 1 - path: src/SAML2/SOAPClient.php + path: src/SOAPClient.php - message: "#^Unsafe usage of new static\\(\\)\\.$#" count: 2 - path: src/SAML2/XML/md/AbstractEndpointType.php + path: src/XML/md/AbstractEndpointType.php - message: "#^Unsafe usage of new static\\(\\)\\.$#" count: 2 - path: src/SAML2/XML/md/AbstractIndexedEndpointType.php + path: src/XML/md/AbstractIndexedEndpointType.php - message: "#^Access to undefined constant static\\(SimpleSAML\\\\SAML2\\\\XML\\\\md\\\\AbstractRoleDescriptor\\)\\:\\:XSI_TYPE_NAME\\.$#" count: 2 - path: src/SAML2/XML/md/AbstractRoleDescriptor.php + path: src/XML/md/AbstractRoleDescriptor.php - message: "#^Access to undefined constant static\\(SimpleSAML\\\\SAML2\\\\XML\\\\md\\\\AbstractRoleDescriptor\\)\\:\\:XSI_TYPE_NAMESPACE\\.$#" count: 2 - path: src/SAML2/XML/md/AbstractRoleDescriptor.php + path: src/XML/md/AbstractRoleDescriptor.php - message: "#^Access to undefined constant static\\(SimpleSAML\\\\SAML2\\\\XML\\\\md\\\\AbstractRoleDescriptor\\)\\:\\:XSI_TYPE_PREFIX\\.$#" count: 2 - path: src/SAML2/XML/md/AbstractRoleDescriptor.php + path: src/XML/md/AbstractRoleDescriptor.php - message: "#^Call to an undefined static method SimpleSAML\\\\SAML2\\\\XML\\\\md\\\\AbstractSignedMdElement\\:\\:getXsiTypeNamespaceURI\\(\\)\\.$#" count: 1 - path: src/SAML2/XML/md/AbstractSignedMdElement.php + path: src/XML/md/AbstractSignedMdElement.php - message: "#^Access to undefined constant static\\(SimpleSAML\\\\SAML2\\\\XML\\\\saml\\\\AbstractBaseID\\)\\:\\:XSI_TYPE_NAME\\.$#" count: 2 - path: src/SAML2/XML/saml/AbstractBaseID.php + path: src/XML/saml/AbstractBaseID.php - message: "#^Access to undefined constant static\\(SimpleSAML\\\\SAML2\\\\XML\\\\saml\\\\AbstractBaseID\\)\\:\\:XSI_TYPE_NAMESPACE\\.$#" count: 2 - path: src/SAML2/XML/saml/AbstractBaseID.php + path: src/XML/saml/AbstractBaseID.php - message: "#^Access to undefined constant static\\(SimpleSAML\\\\SAML2\\\\XML\\\\saml\\\\AbstractBaseID\\)\\:\\:XSI_TYPE_PREFIX\\.$#" count: 2 - path: src/SAML2/XML/saml/AbstractBaseID.php + path: src/XML/saml/AbstractBaseID.php - message: "#^Access to undefined constant static\\(SimpleSAML\\\\SAML2\\\\XML\\\\saml\\\\AbstractCondition\\)\\:\\:XSI_TYPE_NAME\\.$#" count: 2 - path: src/SAML2/XML/saml/AbstractCondition.php + path: src/XML/saml/AbstractCondition.php - message: "#^Access to undefined constant static\\(SimpleSAML\\\\SAML2\\\\XML\\\\saml\\\\AbstractCondition\\)\\:\\:XSI_TYPE_NAMESPACE\\.$#" count: 2 - path: src/SAML2/XML/saml/AbstractCondition.php + path: src/XML/saml/AbstractCondition.php - message: "#^Access to undefined constant static\\(SimpleSAML\\\\SAML2\\\\XML\\\\saml\\\\AbstractCondition\\)\\:\\:XSI_TYPE_PREFIX\\.$#" count: 2 - path: src/SAML2/XML/saml/AbstractCondition.php + path: src/XML/saml/AbstractCondition.php - message: "#^Access to undefined constant static\\(SimpleSAML\\\\SAML2\\\\XML\\\\saml\\\\AbstractStatement\\)\\:\\:XSI_TYPE_NAME\\.$#" count: 2 - path: src/SAML2/XML/saml/AbstractStatement.php + path: src/XML/saml/AbstractStatement.php - message: "#^Access to undefined constant static\\(SimpleSAML\\\\SAML2\\\\XML\\\\saml\\\\AbstractStatement\\)\\:\\:XSI_TYPE_NAMESPACE\\.$#" count: 2 - path: src/SAML2/XML/saml/AbstractStatement.php + path: src/XML/saml/AbstractStatement.php - message: "#^Access to undefined constant static\\(SimpleSAML\\\\SAML2\\\\XML\\\\saml\\\\AbstractStatement\\)\\:\\:XSI_TYPE_PREFIX\\.$#" count: 2 - path: src/SAML2/XML/saml/AbstractStatement.php + path: src/XML/saml/AbstractStatement.php - message: "#^Unsafe usage of new static\\(\\)\\.$#" count: 1 - path: src/SAML2/XML/saml/Attribute.php + path: src/XML/saml/Attribute.php - message: "#^Unsafe usage of new static\\(\\)\\.$#" count: 1 - path: src/SAML2/XML/saml/EncryptedAttribute.php + path: src/XML/saml/EncryptedAttribute.php - message: "#^Unsafe usage of new static\\(\\)\\.$#" count: 1 - path: src/SAML2/XML/saml/EncryptedID.php + path: src/XML/saml/EncryptedID.php - message: "#^Unsafe usage of new static\\(\\)\\.$#" count: 1 - path: src/SAML2/XML/saml/NameIDType.php + path: src/XML/saml/NameIDType.php diff --git a/src/Binding/SOAP.php b/src/Binding/SOAP.php index 9eb0fc40a..9b0b35ec1 100644 --- a/src/Binding/SOAP.php +++ b/src/Binding/SOAP.php @@ -16,10 +16,10 @@ use SimpleSAML\SAML2\XML\samlp\AbstractMessage; use SimpleSAML\SAML2\XML\samlp\MessageFactory; use SimpleSAML\SAML2\XML\samlp\Response as SAML2_Response; -use SimpleSAML\SOAP11\Utils\XPath; -use SimpleSAML\SOAP11\XML\env\Body; -use SimpleSAML\SOAP11\XML\env\Envelope; -use SimpleSAML\SOAP11\XML\env\Header; +use SimpleSAML\SOAP\Utils\XPath; +use SimpleSAML\SOAP\XML\env_200106\Body; +use SimpleSAML\SOAP\XML\env_200106\Envelope; +use SimpleSAML\SOAP\XML\env_200106\Header; use SimpleSAML\XML\DOMDocumentFactory; use function file_get_contents; @@ -100,7 +100,7 @@ public function receive(/** @scrutinizer ignore-unused */ServerRequestInterface $xpCache = XPath::getXPath($document->documentElement); /** @var \DOMElement[] $results */ - $results = XPath::xpQuery($xml, '/env:Envelope/env:Body/*[1]', $xpCache); + $results = XPath::xpQuery($xml, '/SOAP-ENV:Envelope/SOAP-ENV:Body/*[1]', $xpCache); return MessageFactory::fromXML($results[0]); } diff --git a/src/XML/alg/DigestMethod.php b/src/XML/alg/DigestMethod.php index 59d7cf525..b83519c29 100644 --- a/src/XML/alg/DigestMethod.php +++ b/src/XML/alg/DigestMethod.php @@ -7,7 +7,6 @@ use DOMElement; use SimpleSAML\Assert\Assert; use SimpleSAML\SAML2\Assert\Assert as SAMLAssert; -use SimpleSAML\XML\Chunk; use SimpleSAML\XML\Exception\InvalidDOMElementException; use SimpleSAML\XML\ExtendableElementTrait; use SimpleSAML\XML\XsNamespace as NS; @@ -68,18 +67,10 @@ public static function fromXML(DOMElement $xml): static Assert::same($xml->localName, 'DigestMethod', InvalidDOMElementException::class); Assert::same($xml->namespaceURI, DigestMethod::NS, InvalidDOMElementException::class); - $Algorithm = self::getAttribute($xml, 'Algorithm'); - - $elements = []; - foreach ($xml->childNodes as $element) { - if (!($element instanceof DOMElement)) { - continue; - } - - $elements[] = new Chunk($element); - } - - return new static($Algorithm, $elements); + return new static( + self::getAttribute($xml, 'Algorithm'), + self::getChildElementsFromXML($xml), + ); } diff --git a/src/XML/alg/SigningMethod.php b/src/XML/alg/SigningMethod.php index d572149b4..410fafd7e 100644 --- a/src/XML/alg/SigningMethod.php +++ b/src/XML/alg/SigningMethod.php @@ -7,7 +7,6 @@ use DOMElement; use SimpleSAML\Assert\Assert; use SimpleSAML\SAML2\Assert\Assert as SAMLAssert; -use SimpleSAML\XML\Chunk; use SimpleSAML\XML\Exception\InvalidDOMElementException; use SimpleSAML\XML\ExtendableElementTrait; use SimpleSAML\XML\XsNamespace as NS; @@ -99,20 +98,12 @@ public static function fromXML(DOMElement $xml): static Assert::same($xml->localName, 'SigningMethod', InvalidDOMElementException::class); Assert::same($xml->namespaceURI, SigningMethod::NS, InvalidDOMElementException::class); - $Algorithm = self::getAttribute($xml, 'Algorithm'); - $MinKeySize = self::getOptionalIntegerAttribute($xml, 'MinKeySize', null); - $MaxKeySize = self::getOptionalIntegerAttribute($xml, 'MaxKeySize', null); - - $elements = []; - foreach ($xml->childNodes as $element) { - if (!($element instanceof DOMElement)) { - continue; - } - - $elements[] = new Chunk($element); - } - - return new static($Algorithm, $MinKeySize, $MaxKeySize, $elements); + return new static( + self::getAttribute($xml, 'Algorithm'), + self::getOptionalIntegerAttribute($xml, 'MinKeySize', null), + self::getOptionalIntegerAttribute($xml, 'MaxKeySize', null), + self::getChildElementsFromXML($xml), + ); } diff --git a/src/XML/init/RequestInitiator.php b/src/XML/init/RequestInitiator.php index 658fa2111..ae4a28c4f 100644 --- a/src/XML/init/RequestInitiator.php +++ b/src/XML/init/RequestInitiator.php @@ -6,10 +6,8 @@ use DOMElement; use SimpleSAML\Assert\Assert; -use SimpleSAML\SAML2\Constants as C; use SimpleSAML\SAML2\Exception\ProtocolViolationException; use SimpleSAML\SAML2\XML\md\AbstractEndpointType; -use SimpleSAML\XML\Chunk; use SimpleSAML\XML\Exception\InvalidDOMElementException; /** @@ -74,19 +72,10 @@ public static function fromXML(DOMElement $xml): static ProtocolViolationException::class, ); - $children = []; - foreach ($xml->childNodes as $child) { - if (!($child instanceof DOMElement)) { - continue; - } elseif ($child->namespaceURI !== C::NS_MD) { - $children[] = new Chunk($child); - } // else continue - } - return new static( self::getAttribute($xml, 'Location'), self::getOptionalAttribute($xml, 'ResponseLocation', null), - $children, + self::getChildElementsFromXML($xml), self::getAttributesNSFromXML($xml), ); } diff --git a/src/XML/md/AbstractEndpointType.php b/src/XML/md/AbstractEndpointType.php index 4fb1326a8..d02b9868a 100644 --- a/src/XML/md/AbstractEndpointType.php +++ b/src/XML/md/AbstractEndpointType.php @@ -10,7 +10,6 @@ use SimpleSAML\SAML2\Exception\ArrayValidationException; use SimpleSAML\XML\ArrayizableElementInterface; use SimpleSAML\XML\Attribute as XMLAttribute; -use SimpleSAML\XML\Chunk; use SimpleSAML\XML\Exception\InvalidDOMElementException; use SimpleSAML\XML\ExtendableAttributesTrait; use SimpleSAML\XML\ExtendableElementTrait; @@ -132,23 +131,11 @@ public static function fromXML(DOMElement $xml): static InvalidDOMElementException::class, ); - $binding = self::getAttribute($xml, 'Binding'); - $location = self::getAttribute($xml, 'Location'); - - $children = []; - foreach ($xml->childNodes as $child) { - if (!($child instanceof DOMElement)) { - continue; - } elseif ($child->namespaceURI !== static::NS) { - $children[] = new Chunk($child); - } // else continue - } - return new static( - $binding, - $location, + self::getAttribute($xml, 'Binding'), + self::getAttribute($xml, 'Location'), self::getOptionalAttribute($xml, 'ResponseLocation', null), - $children, + self::getChildElementsFromXML($xml), self::getAttributesNSFromXML($xml), ); } diff --git a/src/XML/md/AbstractIndexedEndpointType.php b/src/XML/md/AbstractIndexedEndpointType.php index 5550fad61..c3795048e 100644 --- a/src/XML/md/AbstractIndexedEndpointType.php +++ b/src/XML/md/AbstractIndexedEndpointType.php @@ -6,11 +6,9 @@ use DOMElement; use SimpleSAML\Assert\Assert; -use SimpleSAML\SAML2\Constants as C; use SimpleSAML\SAML2\Exception\ArrayValidationException; use SimpleSAML\XML\ArrayizableElementInterface; use SimpleSAML\XML\Attribute as XMLAttribute; -use SimpleSAML\XML\Chunk; use SimpleSAML\XML\Exception\InvalidDOMElementException; use SimpleSAML\XML\SerializableElementInterface; @@ -83,26 +81,13 @@ public static function fromXML(DOMElement $xml): static InvalidDOMElementException::class, ); - $index = self::getIntegerAttribute($xml, 'index'); - $binding = self::getAttribute($xml, 'Binding'); - $location = self::getAttribute($xml, 'Location'); - - $children = []; - foreach ($xml->childNodes as $child) { - if (!($child instanceof DOMElement)) { - continue; - } elseif ($child->namespaceURI !== C::NS_MD) { - $children[] = new Chunk($child); - } // else continue - } - return new static( - $index, - $binding, - $location, + self::getIntegerAttribute($xml, 'index'), + self::getAttribute($xml, 'Binding'), + self::getAttribute($xml, 'Location'), self::getOptionalBooleanAttribute($xml, 'isDefault', null), self::getOptionalAttribute($xml, 'ResponseLocation', null), - $children, + self::getChildElementsFromXML($xml), self::getAttributesNSFromXML($xml), ); } diff --git a/src/XML/saml/Advice.php b/src/XML/saml/Advice.php index 3db3a11ab..13afc08dd 100644 --- a/src/XML/saml/Advice.php +++ b/src/XML/saml/Advice.php @@ -7,7 +7,6 @@ use DOMElement; use SimpleSAML\Assert\Assert; use SimpleSAML\SAML2\Constants as C; -use SimpleSAML\XML\Chunk; use SimpleSAML\XML\Exception\InvalidDOMElementException; use SimpleSAML\XML\Exception\SchemaViolationException; use SimpleSAML\XML\ExtendableElementTrait; @@ -128,23 +127,12 @@ public static function fromXML(DOMElement $xml): static $assertion = Assertion::getChildrenOfClass($xml); $encryptedAssertion = EncryptedAssertion::getChildrenOfClass($xml); - $elements = []; - foreach ($xml->childNodes as $element) { - if ($element->namespaceURI === C::NS_SAML) { - continue; - } elseif (!($element instanceof DOMElement)) { - continue; - } - - $elements[] = new Chunk($element); - } - return new static( $assertionIDRef, $assertionURIRef, $assertion, $encryptedAssertion, - $elements, + self::getChildElementsFromXML($xml), ); } diff --git a/src/XML/saml/AuthnContextDecl.php b/src/XML/saml/AuthnContextDecl.php index 9cddd5856..79beda286 100644 --- a/src/XML/saml/AuthnContextDecl.php +++ b/src/XML/saml/AuthnContextDecl.php @@ -6,7 +6,6 @@ use DOMElement; use SimpleSAML\Assert\Assert; -use SimpleSAML\XML\Chunk; use SimpleSAML\XML\Exception\InvalidDOMElementException; use SimpleSAML\XML\ExtendableAttributesTrait; use SimpleSAML\XML\ExtendableElementTrait; @@ -69,18 +68,10 @@ public static function fromXML(DOMElement $xml): static Assert::same($xml->localName, 'AuthnContextDecl', InvalidDOMElementException::class); Assert::same($xml->namespaceURI, AuthnContextDecl::NS, InvalidDOMElementException::class); - $elements = []; - foreach ($xml->childNodes as $element) { - if ($element->namespaceURI === static::NS) { - continue; - } elseif (!($element instanceof DOMElement)) { - continue; - } - - $elements[] = new Chunk($element); - } - - return new static($elements, self::getAttributesNSFromXML($xml)); + return new static( + self::getChildElementsFromXML($xml), + self::getAttributesNSFromXML($xml), + ); } diff --git a/src/XML/saml/SubjectConfirmationData.php b/src/XML/saml/SubjectConfirmationData.php index 08a68a0d4..88480ce11 100644 --- a/src/XML/saml/SubjectConfirmationData.php +++ b/src/XML/saml/SubjectConfirmationData.php @@ -11,12 +11,10 @@ use SimpleSAML\SAML2\Constants as C; use SimpleSAML\SAML2\Exception\ProtocolViolationException; use SimpleSAML\SAML2\Utils; -use SimpleSAML\XML\Chunk; use SimpleSAML\XML\Exception\InvalidDOMElementException; use SimpleSAML\XML\ExtendableAttributesTrait; use SimpleSAML\XML\ExtendableElementTrait; use SimpleSAML\XML\XsNamespace as NS; -use SimpleSAML\XMLSecurity\XML\ds\KeyInfo; use function filter_var; use function is_null; @@ -186,26 +184,13 @@ public static function fromXML(DOMElement $xml): static $InResponseTo = self::getOptionalAttribute($xml, 'InResponseTo', null); $Address = self::getOptionalAttribute($xml, 'Address', null); - $children = []; - foreach ($xml->childNodes as $n) { - if (!($n instanceof DOMElement)) { - continue; - } elseif ($n->namespaceURI === C::NS_XDSIG && $n->localName === 'KeyInfo') { - $children[] = KeyInfo::fromXML($n); - continue; - } else { - $children[] = new Chunk($n); - continue; - } - } - return new static( $NotBefore, $NotOnOrAfter, $Recipient, $InResponseTo, $Address, - $children, + self::getChildElementsFromXML($xml), self::getAttributesNSFromXML($xml), ); } diff --git a/src/XML/samlp/StatusDetail.php b/src/XML/samlp/StatusDetail.php index 2b13fa5da..b1ffda576 100644 --- a/src/XML/samlp/StatusDetail.php +++ b/src/XML/samlp/StatusDetail.php @@ -6,7 +6,6 @@ use DOMElement; use SimpleSAML\Assert\Assert; -use SimpleSAML\XML\Chunk; use SimpleSAML\XML\Exception\InvalidDOMElementException; use SimpleSAML\XML\ExtendableElementTrait; use SimpleSAML\XML\XsNamespace as NS; @@ -60,16 +59,9 @@ public static function fromXML(DOMElement $xml): static Assert::same($xml->localName, 'StatusDetail', InvalidDOMElementException::class); Assert::same($xml->namespaceURI, StatusDetail::NS, InvalidDOMElementException::class); - $details = []; - foreach ($xml->childNodes as $detail) { - if (!($detail instanceof DOMElement)) { - continue; - } - - $details[] = new Chunk($detail); - } - - return new static($details); + return new static( + self::getChildElementsFromXML($xml), + ); } diff --git a/tests/SAML2/Binding/SOAPTest.php b/tests/SAML2/Binding/SOAPTest.php index b45b8cf06..135611191 100644 --- a/tests/SAML2/Binding/SOAPTest.php +++ b/tests/SAML2/Binding/SOAPTest.php @@ -46,18 +46,17 @@ public function testRequestParsing(): void $issuer = 'https://ServiceProvider.com/SAML'; $stub = $this->getStubWithInput(<< - + + - {$issuer} + {$issuer} {$artifact} - - + + SOAP); $request = new ServerRequest('', ''); @@ -83,7 +82,7 @@ public function testSendArtifactResponse(): void $doc = DOMDocumentFactory::fromString(<< - + SOAP); /** @var \DOMElement $body */ @@ -108,7 +107,7 @@ public function testSendResponse(): void $doc = DOMDocumentFactory::fromString(<< - + SOAP); $requestAuthenticated = new RequestAuthenticated(true); $ecpResponse = new Response('https://example.org/metadata');