Skip to content

Commit

Permalink
Implement DOM schema validation
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Dec 18, 2024
1 parent 92e2831 commit 3adb6d4
Show file tree
Hide file tree
Showing 88 changed files with 232 additions and 130 deletions.
6 changes: 5 additions & 1 deletion src/XML/ds/AbstractDSAKeyValueType.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Exception\SchemaViolationException;
use SimpleSAML\XML\Exception\TooManyElementsException;
use SimpleSAML\XML\SchemaValidatableElementInterface;
use SimpleSAML\XML\SchemaValidatableElementTrait;

use function array_pop;

Expand All @@ -17,8 +19,10 @@
*
* @package simplesamlphp/xml-security
*/
abstract class AbstractDSAKeyValueType extends AbstractDsElement
abstract class AbstractDSAKeyValueType extends AbstractDsElement implements SchemaValidatableElementInterface
{
use SchemaValidatableElementTrait;

/**
* DSAKeyValueType constructor.
*
Expand Down
3 changes: 3 additions & 0 deletions src/XML/ds/AbstractDsElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ abstract class AbstractDsElement extends AbstractElement

/** @var string */
public const NS_PREFIX = 'ds';

/** @var string */
public const SCHEMA = 'resources/schemas/xmldsig-core-schema.xsd';
}
5 changes: 4 additions & 1 deletion src/XML/ds/AbstractPGPDataType.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
use SimpleSAML\XML\Exception\SchemaViolationException;
use SimpleSAML\XML\Exception\TooManyElementsException;
use SimpleSAML\XML\ExtendableElementTrait;
use SimpleSAML\XML\SchemaValidatableElementInterface;
use SimpleSAML\XML\SchemaValidatableElementTrait;
use SimpleSAML\XML\XsNamespace as NS;
use SimpleSAML\XMLSecurity\XML\ds\AbstractDsElement;

Expand All @@ -20,9 +22,10 @@
*
* @package simplesamlphp/xml-security
*/
abstract class AbstractPGPDataType extends AbstractDsElement
abstract class AbstractPGPDataType extends AbstractDsElement implements SchemaValidatableElementInterface
{
use ExtendableElementTrait;
use SchemaValidatableElementTrait;

/** @var \SimpleSAML\XML\XsNamespace */
public const XS_ANY_ELT_NAMESPACE = NS::OTHER;
Expand Down
6 changes: 5 additions & 1 deletion src/XML/ds/AbstractSPKIDataType.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Exception\SchemaViolationException;
use SimpleSAML\XML\Registry\ElementRegistry;
use SimpleSAML\XML\SchemaValidatableElementInterface;
use SimpleSAML\XML\SchemaValidatableElementTrait;
use SimpleSAML\XML\SerializableElementInterface;
use SimpleSAML\XMLSecurity\XML\ds\AbstractDsElement;

Expand All @@ -18,8 +20,10 @@
*
* @package simplesamlphp/xml-security
*/
abstract class AbstractSPKIDataType extends AbstractDsElement
abstract class AbstractSPKIDataType extends AbstractDsElement implements SchemaValidatableElementInterface
{
use SchemaValidatableElementTrait;

/**
* Initialize a SPKIData element.
*
Expand Down
6 changes: 5 additions & 1 deletion src/XML/ds/CanonicalizationMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Exception\SchemaViolationException;
use SimpleSAML\XML\SchemaValidatableElementInterface;
use SimpleSAML\XML\SchemaValidatableElementTrait;
use SimpleSAML\XMLSecurity\Constants as C;
use SimpleSAML\XMLSecurity\Exception\InvalidArgumentException;

Expand All @@ -16,8 +18,10 @@
*
* @package simplesamlphp/xml-security
*/
final class CanonicalizationMethod extends AbstractDsElement
final class CanonicalizationMethod extends AbstractDsElement implements SchemaValidatableElementInterface
{
use SchemaValidatableElementTrait;

/**
* Initialize a CanonicalizationMethod element.
*
Expand Down
5 changes: 4 additions & 1 deletion src/XML/ds/DigestMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Exception\SchemaViolationException;
use SimpleSAML\XML\ExtendableElementTrait;
use SimpleSAML\XML\SchemaValidatableElementInterface;
use SimpleSAML\XML\SchemaValidatableElementTrait;
use SimpleSAML\XML\XsNamespace as NS;
use SimpleSAML\XMLSecurity\Constants as C;
use SimpleSAML\XMLSecurity\Exception\InvalidArgumentException;
Expand All @@ -18,9 +20,10 @@
*
* @package simplesamlphp/xml-security
*/
final class DigestMethod extends AbstractDsElement
final class DigestMethod extends AbstractDsElement implements SchemaValidatableElementInterface
{
use ExtendableElementTrait;
use SchemaValidatableElementTrait;

public const XS_ANY_ELT_NAMESPACE = NS::OTHER;

Expand Down
5 changes: 4 additions & 1 deletion src/XML/ds/DigestValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@
namespace SimpleSAML\XMLSecurity\XML\ds;

use SimpleSAML\XML\Base64ElementTrait;
use SimpleSAML\XML\SchemaValidatableElementInterface;
use SimpleSAML\XML\SchemaValidatableElementTrait;

/**
* Class representing a ds:DigestValue element.
*
* @package simplesaml/xml-security
*/
final class DigestValue extends AbstractDsElement
final class DigestValue extends AbstractDsElement implements SchemaValidatableElementInterface
{
use Base64ElementTrait;
use SchemaValidatableElementTrait;


/**
Expand Down
5 changes: 4 additions & 1 deletion src/XML/ds/DsObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,19 @@
use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\ExtendableElementTrait;
use SimpleSAML\XML\SchemaValidatableElementInterface;
use SimpleSAML\XML\SchemaValidatableElementTrait;
use SimpleSAML\XML\XsNamespace as NS;

/**
* Class representing a ds:Object element.
*
* @package simplesamlphp/xml-security
*/
final class DsObject extends AbstractDsElement
final class DsObject extends AbstractDsElement implements SchemaValidatableElementInterface
{
use ExtendableElementTrait;
use SchemaValidatableElementTrait;

/** @var string */
public const LOCALNAME = 'Object';
Expand Down
6 changes: 5 additions & 1 deletion src/XML/ds/KeyInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\SchemaValidatableElementInterface;
use SimpleSAML\XML\SchemaValidatableElementTrait;

use function array_merge;

Expand All @@ -15,8 +17,10 @@
*
* @package simplesamlphp/xml-security
*/
final class KeyInfo extends AbstractKeyInfoType
final class KeyInfo extends AbstractKeyInfoType implements SchemaValidatableElementInterface
{
use SchemaValidatableElementTrait;

/**
* Convert XML into a KeyInfo
*
Expand Down
5 changes: 4 additions & 1 deletion src/XML/ds/KeyName.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@

namespace SimpleSAML\XMLSecurity\XML\ds;

use SimpleSAML\XML\SchemaValidatableElementInterface;
use SimpleSAML\XML\SchemaValidatableElementTrait;
use SimpleSAML\XML\StringElementTrait;

/**
* Class representing a ds:KeyName element.
*
* @package simplesamlphp/xml-security
*/
final class KeyName extends AbstractDsElement
final class KeyName extends AbstractDsElement implements SchemaValidatableElementInterface
{
use SchemaValidatableElementTrait;
use StringElementTrait;


Expand Down
5 changes: 4 additions & 1 deletion src/XML/ds/KeyValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,19 @@
use SimpleSAML\XML\Exception\SchemaViolationException;
use SimpleSAML\XML\Exception\TooManyElementsException;
use SimpleSAML\XML\ExtendableElementTrait;
use SimpleSAML\XML\SchemaValidatableElementInterface;
use SimpleSAML\XML\SchemaValidatableElementTrait;
use SimpleSAML\XML\XsNamespace as NS;

/**
* Class representing a ds:KeyValue element.
*
* @package simplesamlphp/xml-security
*/
final class KeyValue extends AbstractDsElement
final class KeyValue extends AbstractDsElement implements SchemaValidatableElementInterface
{
use ExtendableElementTrait;
use SchemaValidatableElementTrait;


/** The namespace-attribute for the xs:any element */
Expand Down
6 changes: 5 additions & 1 deletion src/XML/ds/Manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@
use SimpleSAML\XML\Constants as C;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Exception\MissingElementException;
use SimpleSAML\XML\SchemaValidatableElementInterface;
use SimpleSAML\XML\SchemaValidatableElementTrait;

/**
* Class representing a ds:Manifest element.
*
* @package simplesamlphp/xml-security
*/
final class Manifest extends AbstractDsElement
final class Manifest extends AbstractDsElement implements SchemaValidatableElementInterface
{
use SchemaValidatableElementTrait;

/**
* Initialize a ds:Manifest
*
Expand Down
5 changes: 4 additions & 1 deletion src/XML/ds/MgmtData.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@

namespace SimpleSAML\XMLSecurity\XML\ds;

use SimpleSAML\XML\SchemaValidatableElementInterface;
use SimpleSAML\XML\SchemaValidatableElementTrait;
use SimpleSAML\XML\StringElementTrait;

/**
* Class representing a ds:MgmtData element.
*
* @package simplesamlphp/xml-security
*/
final class MgmtData extends AbstractDsElement
final class MgmtData extends AbstractDsElement implements SchemaValidatableElementInterface
{
use SchemaValidatableElementTrait;
use StringElementTrait;


Expand Down
6 changes: 5 additions & 1 deletion src/XML/ds/RSAKeyValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Exception\MissingElementException;
use SimpleSAML\XML\Exception\TooManyElementsException;
use SimpleSAML\XML\SchemaValidatableElementInterface;
use SimpleSAML\XML\SchemaValidatableElementTrait;

/**
* Class representing a ds:RSAKeyValue element.
*
* @package simplesamlphp/xml-security
*/
final class RSAKeyValue extends AbstractDsElement
final class RSAKeyValue extends AbstractDsElement implements SchemaValidatableElementInterface
{
use SchemaValidatableElementTrait;

/**
* Initialize an RSAKeyValue.
*
Expand Down
6 changes: 5 additions & 1 deletion src/XML/ds/Reference.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Exception\MissingElementException;
use SimpleSAML\XML\Exception\TooManyElementsException;
use SimpleSAML\XML\SchemaValidatableElementInterface;
use SimpleSAML\XML\SchemaValidatableElementTrait;

use function array_pop;

Expand All @@ -17,8 +19,10 @@
*
* @package simplesamlphp/xml-security
*/
final class Reference extends AbstractDsElement
final class Reference extends AbstractDsElement implements SchemaValidatableElementInterface
{
use SchemaValidatableElementTrait;

/**
* Initialize a ds:Reference
*
Expand Down
6 changes: 5 additions & 1 deletion src/XML/ds/RetrievalMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Exception\SchemaViolationException;
use SimpleSAML\XML\Exception\TooManyElementsException;
use SimpleSAML\XML\SchemaValidatableElementInterface;
use SimpleSAML\XML\SchemaValidatableElementTrait;

/**
* Class representing a ds:RetrievalMethod element.
*
* @package simplesamlphp/xml-security
*/
final class RetrievalMethod extends AbstractDsElement
final class RetrievalMethod extends AbstractDsElement implements SchemaValidatableElementInterface
{
use SchemaValidatableElementTrait;

/**
* Initialize a ds:RetrievalMethod
*
Expand Down
6 changes: 5 additions & 1 deletion src/XML/ds/Signature.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Exception\MissingElementException;
use SimpleSAML\XML\Exception\TooManyElementsException;
use SimpleSAML\XML\SchemaValidatableElementInterface;
use SimpleSAML\XML\SchemaValidatableElementTrait;
use SimpleSAML\XMLSecurity\Constants as C;

use function array_pop;
Expand All @@ -18,8 +20,10 @@
*
* @package simplesamlphp/xml-security
*/
final class Signature extends AbstractDsElement
final class Signature extends AbstractDsElement implements SchemaValidatableElementInterface
{
use SchemaValidatableElementTrait;

/**
* Signature constructor.
*
Expand Down
5 changes: 4 additions & 1 deletion src/XML/ds/SignatureMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
use SimpleSAML\XML\Exception\SchemaViolationException;
use SimpleSAML\XML\Exception\TooManyElementsException;
use SimpleSAML\XML\ExtendableElementTrait;
use SimpleSAML\XML\SchemaValidatableElementInterface;
use SimpleSAML\XML\SchemaValidatableElementTrait;
use SimpleSAML\XML\XsNamespace as NS;
use SimpleSAML\XMLSecurity\Constants as C;
use SimpleSAML\XMLSecurity\Exception\InvalidArgumentException;
Expand All @@ -23,9 +25,10 @@
*
* @package simplesamlphp/xml-security
*/
final class SignatureMethod extends AbstractDsElement
final class SignatureMethod extends AbstractDsElement implements SchemaValidatableElementInterface
{
use ExtendableElementTrait;
use SchemaValidatableElementTrait;

/** The namespace-attribute for the xs:any element */
public const XS_ANY_ELT_NAMESPACE = NS::OTHER;
Expand Down
6 changes: 5 additions & 1 deletion src/XML/ds/SignatureProperties.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Exception\MissingElementException;
use SimpleSAML\XML\Exception\SchemaViolationException;
use SimpleSAML\XML\SchemaValidatableElementInterface;
use SimpleSAML\XML\SchemaValidatableElementTrait;

/**
* Class representing a ds:SignatureProperties element.
*
* @package simplesamlphp/xml-security
*/
final class SignatureProperties extends AbstractDsElement
final class SignatureProperties extends AbstractDsElement implements SchemaValidatableElementInterface
{
use SchemaValidatableElementTrait;

/**
* Initialize a ds:SignatureProperties
*
Expand Down
Loading

0 comments on commit 3adb6d4

Please sign in to comment.