-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
185 changed files
with
8,152 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\WSSecurity\XML\fed; | ||
|
||
use DateTimeImmutable; | ||
use DOMElement; | ||
use SimpleSAML\Assert\Assert; | ||
use SimpleSAML\SAML2\XML\md\Extensions; | ||
use SimpleSAML\SAML2\XML\md\Organization; | ||
use SimpleSAML\XML\Exception\MissingElementException; | ||
use SimpleSAML\XML\Exception\SchemaViolationException; | ||
|
||
/** | ||
* A ApplicationServiceType | ||
* | ||
* @package tvdijen/ws-security | ||
*/ | ||
abstract class AbstractApplicationServiceType extends AbstractWebServiceDescriptorType | ||
{ | ||
/** | ||
* ApplicationServiceType constructor. | ||
* | ||
* @param string[] $protocolSupportEnumeration A set of URI specifying the protocols supported. | ||
* @param string|null $ID The ID for this document. Defaults to null. | ||
* @param \DateTimeImmutable|null $validUntil Unix time of validity for this document. Defaults to null. | ||
* @param string|null $cacheDuration Maximum time this document can be cached. Defaults to null. | ||
* @param \SimpleSAML\SAML2\XML\md\Extensions|null $extensions An array of extensions. Defaults to an empty array. | ||
* @param string|null $errorURL An URI where to redirect users for support. Defaults to null. | ||
* @param \SimpleSAML\SAML2\XML\md\KeyDescriptor[] $keyDescriptors An array of KeyDescriptor elements. | ||
* Defaults to an empty array. | ||
* @param \SimpleSAML\SAML2\XML\md\Organization|null $organization | ||
* The organization running this entity. Defaults to null. | ||
* @param \SimpleSAML\SAML2\XML\md\ContactPerson[] $contacts An array of contacts for this entity. | ||
* Defaults to an empty array. | ||
* @param list<\SimpleSAML\XML\Attribute> $namespacedAttributes | ||
* @param \SimpleSAML\WSSecurity\XML\fed\LogicalServiceNamesOffered|null $logicalServiceNamesOffered | ||
* @param \SimpleSAML\WSSecurity\XML\fed\TokenTypesOffered|null $tokenTypesOffered | ||
* @param \SimpleSAML\WSSecurity\XML\fed\ClaimDialectsOffered|null $claimDialectsOffered | ||
* @param \SimpleSAML\WSSecurity\XML\fed\ClaimTypesOffered|null $claimTypesOffered | ||
* @param \SimpleSAML\WSSecurity\XML\fed\ClaimTypesRequested|null $claimTypesRequested | ||
* @param \SimpleSAML\WSSecurity\XML\fed\AutomaticPseudonyms|null $automaticPseudonyms | ||
* @param \SimpleSAML\WSSecurity\XML\fed\TargetScopes|null $targetScopes | ||
* @param string|null $serviceDisplayName | ||
* @param string|null $serviceDescription | ||
* @param \SimpleSAML\WSSecurity\XML\fed\ApplicationServiceEndpoint[] $applicationServiceEndpoint | ||
* @param \SimpleSAML\WSSecurity\XML\fed\SingleSignOutNotificationEndpoint[] $singleSignOutNotificationEndpoint | ||
*/ | ||
final public function __construct( | ||
array $protocolSupportEnumeration, | ||
?string $ID = null, | ||
?DateTimeImmutable $validUntil = null, | ||
?string $cacheDuration = null, | ||
?Extensions $extensions = null, | ||
?string $errorURL = null, | ||
array $keyDescriptors = [], | ||
?Organization $organization = null, | ||
array $contacts = [], | ||
array $namespacedAttributes = [], | ||
?LogicalServiceNamesOffered $logicalServiceNamesOffered = null, | ||
?TokenTypesOffered $tokenTypesOffered = null, | ||
?ClaimDialectsOffered $claimDialectsOffered = null, | ||
?ClaimTypesOffered $claimTypesOffered = null, | ||
?ClaimTypesRequested $claimTypesRequested = null, | ||
?AutomaticPseudonyms $automaticPseudonyms = null, | ||
?TargetScopes $targetScopes = null, | ||
?string $serviceDisplayName = null, | ||
?string $serviceDescription = null, | ||
protected array $applicationServiceEndpoint = [], | ||
protected array $singleSignOutNotificationEndpoint = [], | ||
protected array $passiveRequestorEndpoint = [], | ||
) { | ||
Assert::minCount($applicationServiceEndpoint, 1, MissingElementException::class); | ||
Assert::allIsInstanceOf( | ||
$applicationServiceEndpoint, | ||
ApplicationServiceEndpoint::class, | ||
SchemaViolationException::class, | ||
); | ||
Assert::allIsInstanceOf( | ||
$singleSignOutNotificationEndpoint, | ||
SingleSignOutNotificationEndpoint::class, | ||
SchemaViolationException::class, | ||
); | ||
Assert::allIsInstanceOf( | ||
$passiveRequestorEndpoint, | ||
PassiveRequestorEndpoint::class, | ||
SchemaViolationException::class, | ||
); | ||
|
||
parent::__construct( | ||
$protocolSupportEnumeration, | ||
$ID, | ||
$validUntil, | ||
$cacheDuration, | ||
$extensions, | ||
$errorURL, | ||
$keyDescriptor, | ||
$organization, | ||
$contact, | ||
$namespacedAttributes, | ||
$logicalServiceNamesOffered, | ||
$tokenTypesOffered, | ||
$claimDialectsOffered, | ||
$claimTypesOffered, | ||
$claimTypesRequested, | ||
$automaticPseudonyms, | ||
$targetedScopes, | ||
$serviceDisplayName, | ||
$serviceDescription, | ||
); | ||
} | ||
|
||
|
||
/** | ||
* Collect the value of the applicationServicEndpoint-property | ||
* | ||
* @return \SimpleSAML\WSSecurity\XML\fed\ApplicationServiceEndpoint[] | ||
*/ | ||
public function getApplicationServiceEndpoint(): array | ||
{ | ||
return $this->applicationServiceEndpoint; | ||
} | ||
|
||
|
||
/** | ||
* Collect the value of the singleSignOutNotificationtionEndpoint-property | ||
* | ||
* @return \SimpleSAML\WSSecurity\XML\fed\SingleSignOutNotificationEndpoint[] | ||
*/ | ||
public function getSingleSignOutNotificationEndpoint(): array | ||
{ | ||
return $this->singleSignOutNotificationEndpoint; | ||
} | ||
|
||
|
||
/** | ||
* Collect the value of the passiveRequestorEndpoint-property | ||
* | ||
* @return \SimpleSAML\WSSecurity\XML\fed\PassiveRequestorEndpoint[] | ||
*/ | ||
public function getPassiveRequestorEndpoint(): array | ||
{ | ||
return $this->passiveRequestorEndpoint; | ||
} | ||
|
||
|
||
/** | ||
* Convert this element to XML. | ||
* | ||
* @param \DOMElement|null $parent The element we should append this element to. | ||
* @return \DOMElement | ||
*/ | ||
public function toUnsignedXML(?DOMElement $parent = null): DOMElement | ||
{ | ||
$e = parent::toXML($parent); | ||
|
||
foreach ($this->getApplicationServiceEndpoint() as $ase) { | ||
$ase->toXML($e); | ||
} | ||
|
||
foreach ($this->getSingleSignOutNotificationEndpoint() as $ssone) { | ||
$ssone->toXML($e); | ||
} | ||
|
||
foreach ($this->getPassiveRequestorEndpoint() as $pre) { | ||
$pre->toXML($e); | ||
} | ||
|
||
return $e; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\WSSecurity\XML\fed; | ||
|
||
use DOMElement; | ||
use SimpleSAML\Assert\Assert; | ||
use SimpleSAML\XML\Chunk; | ||
use SimpleSAML\XML\ExtendableAttributesTrait; | ||
use SimpleSAML\XML\ExtendableElementTrait; | ||
use SimpleSAML\XML\Exception\InvalidDOMElementException; | ||
use SimpleSAML\XML\XsNamespace as NS; | ||
|
||
/** | ||
* Class defining the AssertionType element | ||
* | ||
* @package tvdijen/ws-security | ||
*/ | ||
abstract class AbstractAssertionType extends AbstractFedElement | ||
{ | ||
use ExtendableAttributesTrait; | ||
use ExtendableElementTrait; | ||
|
||
/** The namespace-attribute for the xs:anyAttribute element */ | ||
public const XS_ANY_ATTR_NAMESPACE = NS::OTHER; | ||
|
||
/** The namespace-attribute for the xs:any element */ | ||
public const XS_ANY_ELT_NAMESPACE = NS::ANY; | ||
|
||
|
||
/** | ||
* AbstractAssertionType constructor | ||
* | ||
* @param \SimpleSAML\XML\SerializableElementInterface[] $children | ||
* @param array $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); | ||
|
||
$children = []; | ||
foreach ($xml->childNodes as $child) { | ||
if (!($child instanceof DOMElement)) { | ||
continue; | ||
} | ||
|
||
$children[] = new Chunk($child); | ||
} | ||
|
||
return new static( | ||
$children, | ||
self::getAttributesNSFromXML($xml), | ||
); | ||
} | ||
|
||
|
||
/** | ||
* Add this AssertionType 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->getAttributesNS() as $attr) { | ||
$attr->toXML($e); | ||
} | ||
|
||
/** @psalm-var \SimpleSAML\XML\SerializableElementInterface $child */ | ||
foreach ($this->getElements() as $child) { | ||
if (!$child->isEmptyElement()) { | ||
$child->toXML($e); | ||
} | ||
} | ||
|
||
return $e; | ||
} | ||
} |
Oops, something went wrong.