Skip to content

Commit

Permalink
Refactor SP
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Sep 4, 2024
1 parent a07f9de commit bc4a197
Show file tree
Hide file tree
Showing 449 changed files with 2,573 additions and 1,068 deletions.
979 changes: 979 additions & 0 deletions resources/schemas/ws-securitypolicy-1.1.xsd

Large diffs are not rendered by default.

10 changes: 3 additions & 7 deletions src/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ class Constants extends \SimpleSAML\SAML2\Constants
public const NS_SEC_EXT = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd';

/**
* The namespace for WS Security Policy.
* The namespace for the Web Service Security Policy protocol.
*/
public const NS_SEC_POLICY = 'http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702';
public const NS_SEC_POLICY_11 = 'http://schemas.microsoft.com/ws/2005/07/securitypolicy';
public const NS_SEC_POLICY_12 = 'http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702';

/**
* The namespace for WS-Security utilities protocol.
Expand All @@ -67,11 +68,6 @@ class Constants extends \SimpleSAML\SAML2\Constants
*/
public const NS_WSDL_ADDR = 'http://www.w3.org/2006/05/addressing/wsdl';

/**
* The namespace for the Web Service Security Policy protocol.
*/
public const NS_WS_SEC = 'http://schemas.microsoft.com/ws/2005/07/securitypolicy';

/**
* The schema-defined wsa fault codes
*/
Expand Down
3 changes: 2 additions & 1 deletion src/Utils/XPath.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ public static function getXPath(DOMNode $node): DOMXPath
$xp->registerNamespace('fed', C::NS_FED);
$xp->registerNamespace('trust', C::NS_TRUST);
$xp->registerNamespace('policy', C::NS_POLICY);
$xp->registerNamespace('sp', C::NS_SEC_POLICY);
$xp->registerNamespace('sp11', C::NS_SEC_POLICY_11);
$xp->registerNamespace('sp12', C::NS_SEC_POLICY_12);
$xp->registerNamespace('wsdl', C::NS_WS_DESCRIPTION_LANGUAGE);
$xp->registerNamespace('wsse', C::NS_SEC_EXT);
$xp->registerNamespace('wsu', C::NS_SEC_UTIL);
Expand Down
2 changes: 1 addition & 1 deletion src/XML/fed/AuthenticationToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace SimpleSAML\WSSecurity\XML\fed;

use SimpleSAML\WSSecurity\XML\sp\AbstractNestedPolicyType;
use SimpleSAML\WSSecurity\XML\sp_200702\AbstractNestedPolicyType;

/**
* An AuthenticationToken element
Expand Down
2 changes: 1 addition & 1 deletion src/XML/fed/RequireReferenceToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace SimpleSAML\WSSecurity\XML\fed;

use SimpleSAML\WSSecurity\XML\sp\AbstractTokenAssertionType;
use SimpleSAML\WSSecurity\XML\sp_200702\AbstractTokenAssertionType;

/**
* An RequireReferenceToken element
Expand Down
2 changes: 1 addition & 1 deletion src/XML/fed/WebBinding.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace SimpleSAML\WSSecurity\XML\fed;

use SimpleSAML\WSSecurity\XML\sp\AbstractNestedPolicyType;
use SimpleSAML\WSSecurity\XML\sp_200702\AbstractNestedPolicyType;

/**
* A WebBinding element
Expand Down
6 changes: 1 addition & 5 deletions src/XML/mssp/MustNotSendCancel.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

namespace SimpleSAML\WSSecurity\XML\mssp;

use SimpleSAML\WSSecurity\Constants as C;
use SimpleSAML\WSSecurity\XML\sp\AbstractQNameAssertionType;
use SimpleSAML\WSSecurity\XML\sp_200507\AbstractQNameAssertionType;

/**
* An MustNotSendCancel element
Expand All @@ -14,9 +13,6 @@
*/
final class MustNotSendCancel extends AbstractQNameAssertionType
{
/** @var string */
public const NS = C::NS_WS_SEC;

/** @var string */
public const NS_PREFIX = 'mssp';
}
6 changes: 1 addition & 5 deletions src/XML/mssp/RequireClientCertificate.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

namespace SimpleSAML\WSSecurity\XML\mssp;

use SimpleSAML\WSSecurity\Constants as C;
use SimpleSAML\WSSecurity\XML\sp\AbstractQNameAssertionType;
use SimpleSAML\WSSecurity\XML\sp_200507\AbstractQNameAssertionType;

/**
* An RequireClientCertificate element
Expand All @@ -14,9 +13,6 @@
*/
final class RequireClientCertificate extends AbstractQNameAssertionType
{
/** @var string */
public const NS = C::NS_WS_SEC;

/** @var string */
public const NS_PREFIX = 'mssp';
}
6 changes: 1 addition & 5 deletions src/XML/mssp/RsaToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

namespace SimpleSAML\WSSecurity\XML\mssp;

use SimpleSAML\WSSecurity\Constants as C;
use SimpleSAML\WSSecurity\XML\sp\AbstractTokenAssertionType;
use SimpleSAML\WSSecurity\XML\sp_200507\AbstractTokenAssertionType;

/**
* An RsaToken element
Expand All @@ -14,9 +13,6 @@
*/
final class RsaToken extends AbstractTokenAssertionType
{
/** @var string */
public const NS = C::NS_WS_SEC;

/** @var string */
public const NS_PREFIX = 'mssp';
}
6 changes: 1 addition & 5 deletions src/XML/mssp/SslContextToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

namespace SimpleSAML\WSSecurity\XML\mssp;

use SimpleSAML\WSSecurity\Constants as C;
use SimpleSAML\WSSecurity\XML\sp\AbstractTokenAssertionType;
use SimpleSAML\WSSecurity\XML\sp_200507\AbstractTokenAssertionType;

/**
* An SslContextToken element
Expand All @@ -14,9 +13,6 @@
*/
final class SslContextToken extends AbstractTokenAssertionType
{
/** @var string */
public const NS = C::NS_WS_SEC;

/** @var string */
public const NS_PREFIX = 'mssp';
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace SimpleSAML\WSSecurity\XML\sp;
namespace SimpleSAML\WSSecurity\XML\sp_200507;

use DOMElement;
use SimpleSAML\Assert\Assert;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace SimpleSAML\WSSecurity\XML\sp;
namespace SimpleSAML\WSSecurity\XML\sp_200507;

use SimpleSAML\WSSecurity\Constants as C;
use SimpleSAML\XML\AbstractElement;
Expand All @@ -15,7 +15,7 @@
abstract class AbstractSpElement extends AbstractElement
{
/** @var string */
public const NS = C::NS_SEC_POLICY;
public const NS = C::NS_SEC_POLICY_11;

/** @var string */
public const NS_PREFIX = 'sp';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace SimpleSAML\WSSecurity\XML\sp;
namespace SimpleSAML\WSSecurity\XML\sp_200507;

use DOMElement;
use SimpleSAML\Assert\Assert;
Expand Down
13 changes: 13 additions & 0 deletions src/XML/sp_200507/IncludeToken.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

namespace SimpleSAML\WSSecurity\XML\sp_200507;

enum IncludeToken: string
{
case Always = 'http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Always';
case AlwaysToRecipient = 'http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient';
case Once = 'http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Once';
case Never = 'http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never';
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace SimpleSAML\WSSecurity\XML\sp;
namespace SimpleSAML\WSSecurity\XML\sp_200507;

use SimpleSAML\Assert\Assert;

Expand Down
2 changes: 1 addition & 1 deletion src/XML/sp/AbsXPath.php → src/XML/sp_200702/AbsXPath.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace SimpleSAML\WSSecurity\XML\sp;
namespace SimpleSAML\WSSecurity\XML\sp_200702;

/**
* An AbsXPath element
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace SimpleSAML\WSSecurity\XML\sp;
namespace SimpleSAML\WSSecurity\XML\sp_200702;

use DOMElement;
use SimpleSAML\Assert\Assert;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace SimpleSAML\WSSecurity\XML\sp;
namespace SimpleSAML\WSSecurity\XML\sp_200702;

use DOMElement;
use SimpleSAML\Assert\Assert;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace SimpleSAML\WSSecurity\XML\sp;
namespace SimpleSAML\WSSecurity\XML\sp_200702;

use DOMElement;
use SimpleSAML\Assert\Assert;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace SimpleSAML\WSSecurity\XML\sp;
namespace SimpleSAML\WSSecurity\XML\sp_200702;

use DOMElement;
use SimpleSAML\Assert\Assert;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace SimpleSAML\WSSecurity\XML\sp;
namespace SimpleSAML\WSSecurity\XML\sp_200702;

use DOMElement;
use SimpleSAML\Assert\Assert;
Expand Down
82 changes: 82 additions & 0 deletions src/XML/sp_200702/AbstractQNameAssertionType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?php

declare(strict_types=1);

namespace SimpleSAML\WSSecurity\XML\sp_200702;

use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\ExtendableAttributesTrait;
use SimpleSAML\XML\XsNamespace as NS;

use function sprintf;

/**
* Class representing WS security policy QNameAssertionType.
*
* @package simplesamlphp/ws-security
*/
abstract class AbstractQNameAssertionType extends AbstractSpElement
{
use ExtendableAttributesTrait;

/** The namespace-attribute for the xs:anyAttribute element */
public const XS_ANY_ATTR_NAMESPACE = NS::ANY;


/**
* AbstractQNameAssertionType constructor.
*
* @param list<\SimpleSAML\XML\Attribute> $namespacedAttributes
*/
final public function __construct(
array $namespacedAttributes = [],
) {
$this->setAttributesNS($namespacedAttributes);
}


/**
* Initialize an QNameAssertionType.
*
* Note: this method cannot be used when extending this class, if the constructor has a different signature.
*
* @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
{
$qualifiedName = static::getClassName(static::class);
Assert::eq(
$xml->localName,
$qualifiedName,
sprintf('Unexpected name for QNameAssertion: %s. Expected: %s.', $xml->localName, $qualifiedName),
InvalidDOMElementException::class,
);


return new static(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->getAttributesNS() as $attr) {
$attr->toXML($e);
}

return $e;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace SimpleSAML\WSSecurity\XML\sp;
namespace SimpleSAML\WSSecurity\XML\sp_200702;

use DOMElement;
use SimpleSAML\Assert\Assert;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace SimpleSAML\WSSecurity\XML\sp;
namespace SimpleSAML\WSSecurity\XML\sp_200702;

use DOMElement;
use SimpleSAML\Assert\Assert;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace SimpleSAML\WSSecurity\XML\sp;
namespace SimpleSAML\WSSecurity\XML\sp_200702;

use DOMElement;
use SimpleSAML\Assert\Assert;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace SimpleSAML\WSSecurity\XML\sp;
namespace SimpleSAML\WSSecurity\XML\sp_200702;

use DOMElement;
use SimpleSAML\Assert\Assert;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace SimpleSAML\WSSecurity\XML\sp;
namespace SimpleSAML\WSSecurity\XML\sp_200702;

use DOMElement;
use SimpleSAML\Assert\Assert;
Expand Down
Loading

0 comments on commit bc4a197

Please sign in to comment.