Skip to content

Commit

Permalink
Merge pull request #5 from simplesamlphp/feature/class-registry
Browse files Browse the repository at this point in the history
Feature/class registry
  • Loading branch information
tvdijen authored Sep 13, 2024
2 parents c930353 + e47621e commit 6d9219f
Show file tree
Hide file tree
Showing 80 changed files with 320 additions and 393 deletions.
18 changes: 9 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "simplesamlphp/xml-soap",
"description": "SimpleSAMLphp library for XML SOAP",
"type": "simplesamlphp-xmlprovider",
"license": "LGPL-2.1-or-later",
"authors": [
{
Expand All @@ -13,23 +14,21 @@
"ext-dom": "*",
"ext-pcre": "*",

"simplesamlphp/assert": "^1.0",
"simplesamlphp/xml-common": "^1.14"
"simplesamlphp/assert": "^1.3",
"simplesamlphp/composer-xmlprovider-installer": "~1.0.0",
"simplesamlphp/xml-common": "~1.18.0"
},
"require-dev": {
"simplesamlphp/simplesamlphp-test-framework": "^1.5"
"simplesamlphp/simplesamlphp-test-framework": "^1.7"
},
"autoload": {
"psr-4": {
"SimpleSAML\\SOAP\\": "src/",
"SimpleSAML\\SOAP11\\": "src/SOAP11/",
"SimpleSAML\\SOAP12\\": "src/SOAP12/"
"SimpleSAML\\SOAP\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"SimpleSAML\\Test\\SOAP11\\": ["tests/SOAP11/"],
"SimpleSAML\\Test\\SOAP12\\": ["tests/SOAP12/"]
"SimpleSAML\\Test\\SOAP\\": ["tests/"]
}
},
"extra": {
Expand All @@ -41,7 +40,8 @@
"allow-plugins": {
"composer/package-versions-deprecated": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
"phpstan/extension-installer": true
"phpstan/extension-installer": true,
"simplesamlphp/composer-xmlprovider-installer": true
}
}
}
9 changes: 7 additions & 2 deletions src/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,14 @@ class Constants extends \SimpleSAML\XML\Constants
public const NS_SOAP_ENV_12 = 'http://www.w3.org/2003/05/soap-envelope/';

/**
* The namespace for SOAP encoding.
* The namespace for SOAP encoding 1.1.
*/
public const NS_SOAP_ENC = 'http://www.w3.org/2003/05/soap-encoding';
public const NS_SOAP_ENC_11 = 'https://schemas.xmlsoap.org/soap/encoding/';

/**
* The namespace for SOAP encoding 1.2.
*/
public const NS_SOAP_ENC_12 = 'http://www.w3.org/2003/05/soap-encoding';

/**
*/
Expand Down
34 changes: 0 additions & 34 deletions src/SOAP12/Utils/XPath.php

This file was deleted.

6 changes: 4 additions & 2 deletions src/SOAP11/Utils/XPath.php → src/Utils/XPath.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ class XPath extends \SimpleSAML\XML\Utils\XPath
public static function getXPath(DOMNode $node): DOMXPath
{
$xp = parent::getXPath($node);
$xp->registerNamespace('env', C::NS_SOAP_ENV_11);
$xp->registerNamespace('enc', C::NS_SOAP_ENC);
$xp->registerNamespace('env11', C::NS_SOAP_ENV_11);
$xp->registerNamespace('enc11', C::NS_SOAP_ENC_11);
$xp->registerNamespace('env12', C::NS_SOAP_ENV_12);
$xp->registerNamespace('enc12', C::NS_SOAP_ENC_12);

return $xp;
}
Expand Down
33 changes: 33 additions & 0 deletions src/XML/element.registry.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

declare(strict_types=1);

return [
'http://schemas.xmlsoap.org/soap/envelope/' => [
'Body' => '\SimpleSAML\SOAP\XML\env_200106\Body',
'Detail' => '\SimpleSAML\SOAP\XML\env_200106\Detail',
'Envelope' => '\SimpleSAML\SOAP\XML\env_200106\Envelope',
'Fault' => '\SimpleSAML\SOAP\XML\env_200106\Fault',
'FaultActor' => '\SimpleSAML\SOAP\XML\env_200106\FaultActor',
'FaultCode' => '\SimpleSAML\SOAP\XML\env_200106\FaultCode',
'FaultString' => '\SimpleSAML\SOAP\XML\env_200106\FaultString',
'Header' => '\SimpleSAML\SOAP\XML\env_200106\Header',
],
'http://www.w3.org/2003/05/soap-envelope/' => [
'Body' => '\SimpleSAML\SOAP\XML\env_200305\Body',
'Code' => '\SimpleSAML\SOAP\XML\env_200305\Code',
'Detail' => '\SimpleSAML\SOAP\XML\env_200305\Detail',
'Envelope' => '\SimpleSAML\SOAP\XML\env_200305\Envelope',
'Fault' => '\SimpleSAML\SOAP\XML\env_200305\Fault',
'Header' => '\SimpleSAML\SOAP\XML\env_200305\Header',
'Node' => '\SimpleSAML\SOAP\XML\env_200305\Node',
'NotUnderstood' => '\SimpleSAML\SOAP\XML\env_200305\NotUnderstood',
'Reason' => '\SimpleSAML\SOAP\XML\env_200305\Reason',
'Role' => '\SimpleSAML\SOAP\XML\env_200305\Role',
'SubCode' => '\SimpleSAML\SOAP\XML\env_200305\SubCode',
'SupportedEnvelope' => '\SimpleSAML\SOAP\XML\env_200305\SupportedEnvelope',
'Text' => '\SimpleSAML\SOAP\XML\env_200305\Text',
'Upgrade' => '\SimpleSAML\SOAP\XML\env_200305\Upgrade',
'Value' => '\SimpleSAML\SOAP\XML\env_200305\Value',
],
];
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace SimpleSAML\SOAP11\XML\env;
namespace SimpleSAML\SOAP\XML\env_200106;

use SimpleSAML\SOAP\Constants as C;
use SimpleSAML\XML\AbstractElement;
Expand All @@ -18,5 +18,5 @@ abstract class AbstractSoapElement extends AbstractElement
public const NS = C::NS_SOAP_ENV_11;

/** @var string */
public const NS_PREFIX = 'env';
public const NS_PREFIX = 'SOAP-ENV';
}
25 changes: 5 additions & 20 deletions src/SOAP11/XML/env/Body.php → src/XML/env_200106/Body.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

declare(strict_types=1);

namespace SimpleSAML\SOAP11\XML\env;
namespace SimpleSAML\SOAP\XML\env_200106;

use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\SOAP\Constants as C;
use SimpleSAML\SOAP\Exception\ProtocolViolationException;
use SimpleSAML\XML\Chunk;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\ExtendableAttributesTrait;
use SimpleSAML\XML\ExtendableElementTrait;
Expand Down Expand Up @@ -36,7 +34,7 @@ final class Body extends AbstractSoapElement
public const XS_ANY_ATTR_NAMESPACE = NS::ANY;

/**
* @var \SimpleSAML\SOAP11\XML\env\Fault|null
* @var \SimpleSAML\SOAP\XML\env_200106\Fault|null
*/
protected ?Fault $fault;

Expand Down Expand Up @@ -65,7 +63,7 @@ public function __construct(array $children = [], array $namespacedAttributes =


/**
* @param \SimpleSAML\SOAP11\XML\env\Fault|null $fault
* @param \SimpleSAML\SOAP\XML\env_200106\Fault|null $fault
*/
public function setFault(?Fault $fault): void
{
Expand All @@ -74,7 +72,7 @@ public function setFault(?Fault $fault): void


/**
* @return \SimpleSAML\SOAP11\XML\env\Fault|null
* @return \SimpleSAML\SOAP\XML\env_200106\Fault|null
*/
public function getFault(): ?Fault
{
Expand Down Expand Up @@ -107,21 +105,8 @@ public static function fromXML(DOMElement $xml): static
Assert::same($xml->localName, 'Body', InvalidDOMElementException::class);
Assert::same($xml->namespaceURI, Body::NS, InvalidDOMElementException::class);

$children = [];
foreach ($xml->childNodes as $child) {
if (!($child instanceof DOMElement)) {
continue;
} elseif ($child->namespaceURI === C::NS_SOAP_ENV_11) {
if ($child->localName === 'Fault') {
Fault::fromXML($child);
continue;
}
}
$children[] = new Chunk($child);
}

return new static(
$children,
self::getChildElementsFromXML($xml),
self::getAttributesNSFromXML($xml),
);
}
Expand Down
16 changes: 3 additions & 13 deletions src/SOAP11/XML/env/Detail.php → src/XML/env_200106/Detail.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

declare(strict_types=1);

namespace SimpleSAML\SOAP11\XML\env;
namespace SimpleSAML\SOAP\XML\env_200106;

use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\AbstractElement;
use SimpleSAML\XML\Chunk;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\ExtendableAttributesTrait;
use SimpleSAML\XML\ExtendableElementTrait;
Expand Down Expand Up @@ -42,7 +41,7 @@ final class Detail extends AbstractElement
/**
* Initialize a soap:Detail
*
* @param \SimpleSAML\XML\Chunk[] $children
* @param list<\SimpleSAML\XML\SerializableElementInterface> $children
* @param list<\SimpleSAML\XML\Attribute> $namespacedAttributes
*/
public function __construct(array $children = [], array $namespacedAttributes = [])
Expand Down Expand Up @@ -77,17 +76,8 @@ public static function fromXML(DOMElement $xml): static
Assert::same($xml->localName, 'detail', InvalidDOMElementException::class);
Assert::same($xml->namespaceURI, Detail::NS, InvalidDOMElementException::class);

$children = [];
foreach ($xml->childNodes as $child) {
if (!($child instanceof DOMElement)) {
continue;
}

$children[] = new Chunk($child);
}

return new static(
$children,
self::getChildElementsFromXML($xml),
self::getAttributesNSFromXML($xml),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

declare(strict_types=1);

namespace SimpleSAML\SOAP11\XML\env;
namespace SimpleSAML\SOAP\XML\env_200106;

use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\SOAP\Constants as C;
use SimpleSAML\XML\Chunk;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Exception\MissingElementException;
use SimpleSAML\XML\Exception\TooManyElementsException;
Expand Down Expand Up @@ -35,8 +33,8 @@ final class Envelope extends AbstractSoapElement
/**
* Initialize a env:Envelope
*
* @param \SimpleSAML\SOAP11\XML\env\Body $body
* @param \SimpleSAML\SOAP11\XML\env\Header|null $header
* @param \SimpleSAML\SOAP\XML\env_200106\Body $body
* @param \SimpleSAML\SOAP\XML\env_200106\Header|null $header
* @param list<\SimpleSAML\XML\SerializableElementInterface> $children
* @param list<\SimpleSAML\XML\Attribute> $namespacedAttributes
*/
Expand All @@ -52,7 +50,7 @@ public function __construct(


/**
* @return \SimpleSAML\SOAP11\XML\env\Body
* @return \SimpleSAML\SOAP\XML\env_200106\Body
*/
public function getBody(): Body
{
Expand All @@ -61,7 +59,7 @@ public function getBody(): Body


/**
* @return \SimpleSAML\SOAP11\XML\env\Header|null
* @return \SimpleSAML\SOAP\XML\env_200106\Header|null
*/
public function getHeader(): ?Header
{
Expand Down Expand Up @@ -89,20 +87,10 @@ public static function fromXML(DOMElement $xml): static
$header = Header::getChildrenOfClass($xml);
Assert::maxCount($header, 1, 'Cannot process more than one Header element.', TooManyElementsException::class);

$children = [];
foreach ($xml->childNodes as $child) {
if (!($child instanceof DOMElement)) {
continue;
} elseif ($child->namespaceURI === C::NS_SOAP_ENV_11) {
continue;
}
$children[] = new Chunk($child);
}

return new static(
array_pop($body),
empty($header) ? null : array_pop($header),
$children,
self::getChildElementsFromXML($xml),
self::getAttributesNSFromXML($xml),
);
}
Expand Down
18 changes: 9 additions & 9 deletions src/SOAP11/XML/env/Fault.php → src/XML/env_200106/Fault.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace SimpleSAML\SOAP11\XML\env;
namespace SimpleSAML\SOAP\XML\env_200106;

use DOMElement;
use SimpleSAML\Assert\Assert;
Expand All @@ -20,10 +20,10 @@ final class Fault extends AbstractSoapElement
/**
* Initialize a env:Fault
*
* @param \SimpleSAML\SOAP11\XML\env\FaultCode $faultCode
* @param \SimpleSAML\SOAP11\XML\env\FaultString $faultString
* @param \SimpleSAML\SOAP11\XML\env\FaultActor|null $faultActor
* @param \SimpleSAML\SOAP11\XML\env\Detail|null $detail
* @param \SimpleSAML\SOAP\XML\env_200106\FaultCode $faultCode
* @param \SimpleSAML\SOAP\XML\env_200106\FaultString $faultString
* @param \SimpleSAML\SOAP\XML\env_200106\FaultActor|null $faultActor
* @param \SimpleSAML\SOAP\XML\env_200106\Detail|null $detail
*/
public function __construct(
protected FaultCode $faultCode,
Expand All @@ -35,7 +35,7 @@ public function __construct(


/**
* @return \SimpleSAML\SOAP11\XML\env\FaultCode
* @return \SimpleSAML\SOAP\XML\env_200106\FaultCode
*/
public function getFaultCode(): FaultCode
{
Expand All @@ -44,7 +44,7 @@ public function getFaultCode(): FaultCode


/**
* @return \SimpleSAML\SOAP11\XML\env\FaultString
* @return \SimpleSAML\SOAP\XML\env_200106\FaultString
*/
public function getFaultString(): FaultString
{
Expand All @@ -53,7 +53,7 @@ public function getFaultString(): FaultString


/**
* @return \SimpleSAML\SOAP11\XML\env\FaultActor|null
* @return \SimpleSAML\SOAP\XML\env_200106\FaultActor|null
*/
public function getFaultActor(): ?FaultActor
{
Expand All @@ -62,7 +62,7 @@ public function getFaultActor(): ?FaultActor


/**
* @return \SimpleSAML\SOAP11\XML\env\Detail|null
* @return \SimpleSAML\SOAP\XML\env_200106\Detail|null
*/
public function getDetail(): ?Detail
{
Expand Down
Loading

0 comments on commit 6d9219f

Please sign in to comment.