Skip to content

Commit

Permalink
Restore the posibility to omit optional digestAlgorithm on PolicyRefe…
Browse files Browse the repository at this point in the history
…rence
  • Loading branch information
tvdijen committed Oct 8, 2024
1 parent dc4315c commit 1eb764a
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/XML/wsp/PolicyReference.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ final class PolicyReference extends AbstractWspElement
public function __construct(
protected string $URI,
protected ?string $Digest = null,
protected ?string $DigestAlgorithm = null,
protected ?string $DigestAlgorithm = 'http://schemas.xmlsoap.org/ws/2004/09/policy/Sha1Exc',
array $namespacedAttributes = [],
) {
Assert::validURI($URI, SchemaViolationException::class);
Expand Down Expand Up @@ -67,11 +67,11 @@ public function getDigest(): ?string


/**
* @return string
* @return string|null
*/
public function getDigestAlgorithm(): string
public function getDigestAlgorithm(): ?string
{
return $this->DigestAlgorithm ?? 'http://schemas.xmlsoap.org/ws/2004/09/policy/Sha1Exc';
return $this->DigestAlgorithm;
}


Expand Down Expand Up @@ -124,10 +124,14 @@ public function toXML(DOMElement $parent = null): DOMElement
{
$e = $this->instantiateParentElement($parent);
$e->setAttribute('URI', $this->getURI());

if ($this->getDigest() !== null) {
$e->setAttribute('Digest', $this->getDigest());
}
$e->setAttribute('DigestAlgorithm', $this->getDigestAlgorithm());

if ($this->getDigestAlgorithm() !== null) {
$e->setAttribute('DigestAlgorithm', $this->getDigestAlgorithm());
}

foreach ($this->getAttributesNS() as $attr) {
$attr->toXML($e);
Expand Down

0 comments on commit 1eb764a

Please sign in to comment.