Skip to content

Commit d3f4f2d

Browse files
committed
Use ReferenceValidationFailedException
1 parent 587409e commit d3f4f2d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/XML/SignedElementTrait.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use SimpleSAML\XMLSecurity\Constants as C;
1414
use SimpleSAML\XMLSecurity\Exception\InvalidArgumentException;
1515
use SimpleSAML\XMLSecurity\Exception\NoSignatureFoundException;
16+
use SimpleSAML\XMLSecurity\Exception\ReferenceValidationFailedException;
1617
use SimpleSAML\XMLSecurity\Exception\RuntimeException;
1718
use SimpleSAML\XMLSecurity\Exception\SignatureVerificationFailedException;
1819
use SimpleSAML\XMLSecurity\Key\AbstractKey;
@@ -90,7 +91,7 @@ private function validateReferenceUri(Reference $reference, DOMElement $xml): vo
9091
)
9192
&& !$reference->isXPointer()
9293
) { // canonicalization with comments used, but reference wasn't an xpointer!
93-
throw new RuntimeException('Invalid reference for canonicalization algorithm.');
94+
throw new ReferenceValidationFailedException('Invalid reference for canonicalization algorithm.');
9495
}
9596

9697
$id = $this->getId();
@@ -100,13 +101,13 @@ private function validateReferenceUri(Reference $reference, DOMElement $xml): vo
100101
Assert::true(
101102
$xml->isSameNode($xml->ownerDocument->documentElement),
102103
'Cannot use document reference when element is not the root of the document.',
103-
RuntimeException::class,
104+
ReferenceValidationFailedException::class,
104105
);
105106
} else { // short-name or scheme-based xpointer
106107
Assert::notEmpty(
107108
$id,
108109
'Reference points to an element, but given element does not have an ID.',
109-
RuntimeException::class,
110+
ReferenceValidationFailedException::class,
110111
);
111112
Assert::oneOf(
112113
$uri,
@@ -115,7 +116,7 @@ private function validateReferenceUri(Reference $reference, DOMElement $xml): vo
115116
'#xpointer(id(' . $id . '))',
116117
],
117118
'Reference does not point to given element.',
118-
RuntimeException::class,
119+
ReferenceValidationFailedException::class,
119120
);
120121
}
121122
}

0 commit comments

Comments
 (0)