Skip to content

Commit

Permalink
Refactor assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Jan 8, 2025
1 parent 1f9c5af commit ae601fb
Show file tree
Hide file tree
Showing 17 changed files with 33 additions and 17 deletions.
16 changes: 16 additions & 0 deletions src/Assert/Assert.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

namespace SimpleSAML\XMLSecurity\Assert;

use SimpleSAML\XML\Assert\Assert as BaseAssert;

/**
* SimpleSAML\XMLSecurity\Assert\Assert wrapper class
*
* @package simplesamlphp/xml-security
*/
class Assert extends BaseAssert
{
}
4 changes: 2 additions & 2 deletions src/CryptoEncoding/PEMBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Countable;
use IteratorAggregate;
use LogicException;
use SimpleSAML\Assert\Assert;
use SimpleSAML\XMLSecurity\Assert\Assert;
use SimpleSAML\XMLSecurity\Exception\IOException;
use UnexpectedValueException;

Expand Down Expand Up @@ -77,7 +77,7 @@ public static function fromString(string $str): self
$pems = array_map(
function ($match) {
$payload = preg_replace('/\s+/', '', $match[2]);
Assert::stringPlausibleBase64($payload);
Assert::validBase64($payload);

$data = base64_decode($payload, true);
if (empty($data)) {
Expand Down
2 changes: 1 addition & 1 deletion src/XML/ds/AbstractKeyInfoType.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
namespace SimpleSAML\XMLSecurity\XML\ds;

use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\Exception\SchemaViolationException;
use SimpleSAML\XML\ExtendableElementTrait;
use SimpleSAML\XML\SerializableElementInterface;
use SimpleSAML\XML\XsNamespace as NS;
use SimpleSAML\XMLSecurity\Assert\Assert;
use SimpleSAML\XMLSecurity\Constants as C;
use SimpleSAML\XMLSecurity\Exception\InvalidArgumentException;
use SimpleSAML\XMLSecurity\XML\ds\AbstractDsElement;
Expand Down
2 changes: 1 addition & 1 deletion src/XML/ds/DsObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
namespace SimpleSAML\XMLSecurity\XML\ds;

use DOMElement;
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;
use SimpleSAML\XMLSecurity\Assert\Assert;

/**
* Class representing a ds:Object element.
Expand Down
2 changes: 1 addition & 1 deletion src/XML/ds/Manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
namespace SimpleSAML\XMLSecurity\XML\ds;

use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\Constants as C;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Exception\MissingElementException;
use SimpleSAML\XML\SchemaValidatableElementInterface;
use SimpleSAML\XML\SchemaValidatableElementTrait;
use SimpleSAML\XMLSecurity\Assert\Assert;

/**
* Class representing a ds:Manifest element.
Expand Down
2 changes: 1 addition & 1 deletion src/XML/ds/Reference.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
namespace SimpleSAML\XMLSecurity\XML\ds;

use DOMElement;
use SimpleSAML\Assert\Assert;
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\Assert\Assert;

use function array_pop;

Expand Down
2 changes: 1 addition & 1 deletion src/XML/ds/Signature.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
namespace SimpleSAML\XMLSecurity\XML\ds;

use DOMElement;
use SimpleSAML\Assert\Assert;
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\Assert\Assert;
use SimpleSAML\XMLSecurity\Constants as C;

use function array_pop;
Expand Down
2 changes: 1 addition & 1 deletion src/XML/ds/SignatureProperties.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
namespace SimpleSAML\XMLSecurity\XML\ds;

use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\Constants as C;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Exception\MissingElementException;
use SimpleSAML\XML\Exception\SchemaViolationException;
use SimpleSAML\XML\SchemaValidatableElementInterface;
use SimpleSAML\XML\SchemaValidatableElementTrait;
use SimpleSAML\XMLSecurity\Assert\Assert;

/**
* Class representing a ds:SignatureProperties element.
Expand Down
2 changes: 1 addition & 1 deletion src/XML/ds/SignatureProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
namespace SimpleSAML\XMLSecurity\XML\ds;

use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Exception\MissingElementException;
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\Assert\Assert;

/**
* Class representing a ds:SignatureProperty element.
Expand Down
2 changes: 1 addition & 1 deletion src/XML/ds/SignatureValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
namespace SimpleSAML\XMLSecurity\XML\ds;

use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\Base64ElementTrait;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\SchemaValidatableElementInterface;
use SimpleSAML\XML\SchemaValidatableElementTrait;
use SimpleSAML\XMLSecurity\Assert\Assert;

/**
* Class representing a ds:SignatureValue element.
Expand Down
2 changes: 1 addition & 1 deletion src/XML/ds/SignedInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
namespace SimpleSAML\XMLSecurity\XML\ds;

use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\Constants as C;
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\Assert\Assert;
use SimpleSAML\XMLSecurity\Exception\InvalidArgumentException;
use SimpleSAML\XMLSecurity\XML\CanonicalizableElementInterface;
use SimpleSAML\XMLSecurity\XML\CanonicalizableElementTrait;
Expand Down
2 changes: 1 addition & 1 deletion src/XML/dsig11/KeyInfoReference.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
namespace SimpleSAML\XMLSecurity\XML\dsig11;

use DOMElement;
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\Assert\Assert;

/**
* Class representing a dsig11:KeyInfoReference element.
Expand Down
2 changes: 1 addition & 1 deletion src/XML/xenc/AbstractEncryptedType.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
namespace SimpleSAML\XMLSecurity\XML\xenc;

use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\Exception\SchemaViolationException;
use SimpleSAML\XMLSecurity\Assert\Assert;
use SimpleSAML\XMLSecurity\XML\ds\KeyInfo;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/XML/xenc/AbstractEncryptionPropertiesType.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
namespace SimpleSAML\XMLSecurity\XML\xenc;

use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Exception\MissingElementException;
use SimpleSAML\XML\Exception\SchemaViolationException;
use SimpleSAML\XML\SchemaValidatableElementInterface;
use SimpleSAML\XML\SchemaValidatableElementTrait;
use SimpleSAML\XMLSecurity\Assert\Assert;

/**
* Class representing <xenc:EncryptionPropertiesType>.
Expand Down
2 changes: 1 addition & 1 deletion src/XML/xenc/AbstractEncryptionPropertyType.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace SimpleSAML\XMLSecurity\XML\xenc;

use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\Constants as C;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Exception\MissingElementException;
Expand All @@ -15,6 +14,7 @@
use SimpleSAML\XML\SchemaValidatableElementInterface;
use SimpleSAML\XML\SchemaValidatableElementTrait;
use SimpleSAML\XML\XsNamespace as NS;
use SimpleSAML\XMLSecurity\Assert\Assert;

/**
* Class representing <xenc:EncryptionPropertyType>.
Expand Down
2 changes: 1 addition & 1 deletion src/XML/xenc11/AbstractConcatKDFParamsType.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
namespace SimpleSAML\XMLSecurity\XML\xenc11;

use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Exception\MissingElementException;
use SimpleSAML\XML\Exception\SchemaViolationException;
use SimpleSAML\XML\Exception\TooManyElementsException;
use SimpleSAML\XML\SchemaValidatableElementInterface;
use SimpleSAML\XML\SchemaValidatableElementTrait;
use SimpleSAML\XMLSecurity\Assert\Assert;
use SimpleSAML\XMLSecurity\XML\ds\DigestMethod;

use function array_pop;
Expand Down
2 changes: 1 addition & 1 deletion src/XML/xenc11/AbstractDerivedKeyType.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
namespace SimpleSAML\XMLSecurity\XML\xenc11;

use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Exception\SchemaViolationException;
use SimpleSAML\XML\Exception\TooManyElementsException;
use SimpleSAML\XML\SchemaValidatableElementInterface;
use SimpleSAML\XML\SchemaValidatableElementTrait;
use SimpleSAML\XMLSecurity\Assert\Assert;
use SimpleSAML\XMLSecurity\XML\xenc\ReferenceList;

use function array_pop;
Expand Down

0 comments on commit ae601fb

Please sign in to comment.