Skip to content

Commit 1e26f36

Browse files
committed
Use new & more generic XMLStringElementTrait
1 parent 757de55 commit 1e26f36

7 files changed

Lines changed: 0 additions & 198 deletions

File tree

src/XML/ds/DigestValue.php

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
namespace SimpleSAML\XMLSecurity\XML\ds;
66

7-
use DOMElement;
8-
use SimpleSAML\Assert\Assert;
9-
use SimpleSAML\XML\Exception\InvalidDOMElementException;
107
use SimpleSAML\XML\XMLBase64ElementTrait;
118

129
/**
@@ -17,36 +14,4 @@
1714
final class DigestValue extends AbstractDsElement
1815
{
1916
use XMLBase64ElementTrait;
20-
21-
22-
/**
23-
* Validate the content of the element.
24-
*
25-
* @param string $content The value to go in the XML textContent
26-
* @throws \Exception on failure
27-
* @return void
28-
*/
29-
protected function validateContent(string $content): void
30-
{
31-
Assert::notEmpty($content, 'DigestValue cannot be empty');
32-
Assert::stringPlausibleBase64($content, 'ds:DigestValue is not a valid Base64 encoded string');
33-
}
34-
35-
36-
/**
37-
* Convert XML into a DigestValue
38-
*
39-
* @param \DOMElement $xml The XML element we should load
40-
* @return self
41-
*
42-
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
43-
* If the qualified name of the supplied element is wrong
44-
*/
45-
public static function fromXML(DOMElement $xml): object
46-
{
47-
Assert::same($xml->localName, 'DigestValue', InvalidDOMElementException::class);
48-
Assert::same($xml->namespaceURI, DigestValue::NS, InvalidDOMElementException::class);
49-
50-
return new self($xml->textContent);
51-
}
5217
}

src/XML/ds/KeyName.php

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
namespace SimpleSAML\XMLSecurity\XML\ds;
66

7-
use DOMElement;
8-
use SimpleSAML\Assert\Assert;
9-
use SimpleSAML\XML\Exception\InvalidDOMElementException;
107
use SimpleSAML\XML\XMLStringElementTrait;
118

129
/**
@@ -17,38 +14,4 @@
1714
final class KeyName extends AbstractDsElement
1815
{
1916
use XMLStringElementTrait;
20-
21-
22-
/**
23-
* Validate the content of the element.
24-
*
25-
* @param string $content The value to go in the XML textContent
26-
* @throws \Exception on failure
27-
* @return void
28-
*/
29-
protected function validateContent(string $content): void
30-
{
31-
/**
32-
* Perform no validation by default.
33-
* Override this method on the implementing class to perform content validation.
34-
*/
35-
}
36-
37-
38-
/**
39-
* Convert XML into a KeyName
40-
*
41-
* @param \DOMElement $xml The XML element we should load
42-
* @return self
43-
*
44-
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
45-
* If the qualified name of the supplied element is wrong
46-
*/
47-
public static function fromXML(DOMElement $xml): object
48-
{
49-
Assert::same($xml->localName, 'KeyName', InvalidDOMElementException::class);
50-
Assert::same($xml->namespaceURI, KeyName::NS, InvalidDOMElementException::class);
51-
52-
return new self($xml->textContent);
53-
}
5417
}

src/XML/ds/SignatureValue.php

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
namespace SimpleSAML\XMLSecurity\XML\ds;
66

7-
use DOMElement;
8-
use SimpleSAML\Assert\Assert;
9-
use SimpleSAML\XML\Exception\InvalidDOMElementException;
107
use SimpleSAML\XML\XMLBase64ElementTrait;
118

129
/**
@@ -17,36 +14,4 @@
1714
final class SignatureValue extends AbstractDsElement
1815
{
1916
use XMLBase64ElementTrait;
20-
21-
22-
/**
23-
* Validate the content of the element.
24-
*
25-
* @param string $content The value to go in the XML textContent
26-
* @throws \Exception on failure
27-
* @return void
28-
*/
29-
protected function validateContent(string $content): void
30-
{
31-
Assert::notEmpty($content, 'SignatureValue cannot be empty');
32-
Assert::stringPlausibleBase64($content, 'SignatureValue is not a valid Base64 encoded string');
33-
}
34-
35-
36-
/**
37-
* Convert XML into a SignatureValue
38-
*
39-
* @param \DOMElement $xml The XML element we should load
40-
* @return self
41-
*
42-
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException If the qualified name of the supplied element is
43-
* wrong.
44-
*/
45-
public static function fromXML(DOMElement $xml): object
46-
{
47-
Assert::same($xml->localName, 'SignatureValue', InvalidDOMElementException::class);
48-
Assert::same($xml->namespaceURI, SignatureValue::NS, InvalidDOMElementException::class);
49-
50-
return new self($xml->textContent);
51-
}
5217
}

src/XML/ds/X509Certificate.php

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
namespace SimpleSAML\XMLSecurity\XML\ds;
66

7-
use DOMElement;
8-
use SimpleSAML\Assert\Assert;
9-
use SimpleSAML\XML\Exception\InvalidDOMElementException;
107
use SimpleSAML\XML\XMLBase64ElementTrait;
118

129
/**
@@ -17,36 +14,4 @@
1714
final class X509Certificate extends AbstractDsElement
1815
{
1916
use XMLBase64ElementTrait;
20-
21-
22-
/**
23-
* Validate the content of the element.
24-
*
25-
* @param string $content The value to go in the XML textContent
26-
* @throws \Exception on failure
27-
* @return void
28-
*/
29-
protected function validateContent(string $content): void
30-
{
31-
Assert::notEmpty($content, 'ds:X509Certificate cannot be empty');
32-
Assert::stringPlausibleBase64($content, 'ds:X509Certificate is not a valid Base64 encoded string');
33-
}
34-
35-
36-
/**
37-
* Convert XML into a X509Certificate
38-
*
39-
* @param \DOMElement $xml The XML element we should load
40-
* @return self
41-
*
42-
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
43-
* If the qualified name of the supplied element is wrong
44-
*/
45-
public static function fromXML(DOMElement $xml): object
46-
{
47-
Assert::same($xml->localName, 'X509Certificate', InvalidDOMElementException::class);
48-
Assert::same($xml->namespaceURI, X509Certificate::NS, InvalidDOMElementException::class);
49-
50-
return new self($xml->textContent);
51-
}
5217
}

src/XML/ds/X509Digest.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -77,20 +77,6 @@ private function setAlgorithm(string $algorithm): void
7777
}
7878

7979

80-
/**
81-
* Validate the content of the element.
82-
*
83-
* @param string $content The value to go in the XML textContent
84-
* @throws \Exception on failure
85-
* @return void
86-
*/
87-
protected function validateContent(string $content): void
88-
{
89-
Assert::notEmpty($content, 'X509Digest cannot be empty');
90-
Assert::stringPlausibleBase64($content, 'ds:X509Digest is not a valid Base64 encoded string');
91-
}
92-
93-
9480
/**
9581
* Convert XML into a X509Digest
9682
*

src/XML/ds/X509IssuerName.php

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
namespace SimpleSAML\XMLSecurity\XML\ds;
66

7-
use DOMElement;
8-
use SimpleSAML\Assert\Assert;
9-
use SimpleSAML\XML\Exception\InvalidDOMElementException;
107
use SimpleSAML\XML\XMLStringElementTrait;
118

129
/**
@@ -17,22 +14,4 @@
1714
final class X509IssuerName extends AbstractDsElement
1815
{
1916
use XMLStringElementTrait;
20-
21-
22-
/**
23-
* Convert XML into a X509IssuerName
24-
*
25-
* @param \DOMElement $xml The XML element we should load
26-
* @return self
27-
*
28-
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
29-
* If the qualified name of the supplied element is wrong
30-
*/
31-
public static function fromXML(DOMElement $xml): object
32-
{
33-
Assert::same($xml->localName, 'X509IssuerName', InvalidDOMElementException::class);
34-
Assert::same($xml->namespaceURI, X509IssuerName::NS, InvalidDOMElementException::class);
35-
36-
return new self($xml->textContent);
37-
}
3817
}

src/XML/ds/X509SubjectName.php

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
namespace SimpleSAML\XMLSecurity\XML\ds;
66

7-
use DOMElement;
8-
use SimpleSAML\Assert\Assert;
9-
use SimpleSAML\XML\Exception\InvalidDOMElementException;
107
use SimpleSAML\XML\XMLStringElementTrait;
118

129
/**
@@ -17,22 +14,4 @@
1714
final class X509SubjectName extends AbstractDsElement
1815
{
1916
use XMLStringElementTrait;
20-
21-
22-
/**
23-
* Convert XML into a X509SubjectName
24-
*
25-
* @param \DOMElement $xml The XML element we should load
26-
* @return self
27-
*
28-
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
29-
* If the qualified name of the supplied element is wrong
30-
*/
31-
public static function fromXML(DOMElement $xml): object
32-
{
33-
Assert::same($xml->localName, 'X509SubjectName', InvalidDOMElementException::class);
34-
Assert::same($xml->namespaceURI, X509SubjectName::NS, InvalidDOMElementException::class);
35-
36-
return new self($xml->textContent);
37-
}
3817
}

0 commit comments

Comments
 (0)