-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
206 changed files
with
2,857 additions
and
2,323 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\XMLSecurity\Assert; | ||
|
||
use InvalidArgumentException; | ||
|
||
/** | ||
* @package simplesamlphp/xml-security | ||
*/ | ||
trait CryptoBinaryTrait | ||
{ | ||
/** | ||
* @param string $value | ||
* @param string $message | ||
*/ | ||
protected static function validCryptoBinary(string $value, string $message = ''): void | ||
{ | ||
parent::validBase64Binary( | ||
$value, | ||
$message ?: '%s is not a valid xs:cryptoBinary', | ||
InvalidArgumentException::class, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\XMLSecurity\Assert; | ||
|
||
use InvalidArgumentException; | ||
|
||
/** | ||
* @package simplesamlphp/xml-security | ||
*/ | ||
trait KeySizeTrait | ||
{ | ||
/** | ||
* The size in bits of the key to be derived from the shared secret as the UTF-8 string for the corresponding | ||
* decimal integer with only digits in the string and no leading zeros. | ||
* | ||
* @var string | ||
*/ | ||
private static string $keySize_regex = '/^([1-9]\d+)$/D'; | ||
|
||
|
||
/** | ||
* @param string $value | ||
* @param string $message | ||
*/ | ||
protected static function validKeySize(string $value, string $message = ''): void | ||
{ | ||
parent::regex( | ||
$value, | ||
self::$keySize_regex, | ||
$message ?: '%s is not a valid xenc:keySizeType', | ||
InvalidArgumentException::class, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\XMLSecurity\Exception; | ||
|
||
/** | ||
* This exception may be raised when a violation of the xmldsig specification is detected | ||
* | ||
* @package simplesamlphp/xml-security | ||
*/ | ||
class ProtocolViolationException extends RuntimeException | ||
{ | ||
/** | ||
* @param string|null $message | ||
*/ | ||
public function __construct(?string $message = null) | ||
{ | ||
if ($message === null) { | ||
if (defined('static::DEFAULT_MESSAGE')) { | ||
$message = static::DEFAULT_MESSAGE; | ||
} else { | ||
$message = 'A violation of the XML Signature Syntax and Processing specification occurred.'; | ||
} | ||
} | ||
|
||
parent::__construct($message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\XMLSecurity\Type; | ||
|
||
use SimpleSAML\XML\Exception\SchemaViolationException; | ||
use SimpleSAML\XML\Type\Base64BinaryValue; | ||
use SimpleSAML\XMLSecurity\Assert\Assert; | ||
|
||
/** | ||
* @package simplesaml/xml-security | ||
*/ | ||
class CryptoBinaryValue extends Base64BinaryValue | ||
{ | ||
/** | ||
* Validate the value. | ||
* | ||
* @param string $value | ||
* @throws \SimpleSAML\XML\Exception\SchemaViolationException on failure | ||
* @return void | ||
*/ | ||
protected function validateValue(string $value): void | ||
{ | ||
// Note: value must already be sanitized before validating | ||
Assert::validCryptoBinary($this->sanitizeValue($value), SchemaViolationException::class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\XMLSecurity\Type; | ||
|
||
use SimpleSAML\XML\Exception\SchemaViolationException; | ||
use SimpleSAML\XML\Type\IntegerValue; | ||
use SimpleSAML\XMLSecurity\Assert\Assert; | ||
|
||
/** | ||
* @package simplesaml/xml-security | ||
*/ | ||
class KeySizeValue extends IntegerValue | ||
{ | ||
/** | ||
* Validate the value. | ||
* | ||
* @param string $value | ||
* @throws \SimpleSAML\XML\Exception\SchemaViolationException on failure | ||
* @return void | ||
*/ | ||
protected function validateValue(string $value): void | ||
{ | ||
// Note: value must already be sanitized before validating | ||
Assert::validKeySize($this->sanitizeValue($value), SchemaViolationException::class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.