-
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
220 changed files
with
3,373 additions
and
2,349 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,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\XMLSecurity\Assert; | ||
|
||
use InvalidArgumentException; | ||
|
||
/** | ||
* @package simplesamlphp/xml-security | ||
*/ | ||
trait DigestValueTrait | ||
{ | ||
/** | ||
* @param string $value | ||
* @param string $message | ||
*/ | ||
protected static function validDigestValue(string $value, string $message = ''): void | ||
{ | ||
parent::validBase64Binary( | ||
$value, | ||
$message ?: '%s is not a valid xs:DigestValue', | ||
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,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\XMLSecurity\Assert; | ||
|
||
use InvalidArgumentException; | ||
|
||
/** | ||
* @package simplesamlphp/xml-security | ||
*/ | ||
trait ECPointTrait | ||
{ | ||
/** | ||
* @param string $value | ||
* @param string $message | ||
*/ | ||
protected static function validECPoint(string $value, string $message = ''): void | ||
{ | ||
Assert::validCryptoBinary( | ||
$value, | ||
$message ?: '%s is not a valid dsig11:ECPointType', | ||
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,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\XMLSecurity\Assert; | ||
|
||
use InvalidArgumentException; | ||
|
||
/** | ||
* @package simplesamlphp/xml-security | ||
*/ | ||
trait HMACOutputLengthTrait | ||
{ | ||
/** | ||
* The HMAC algorithm (RFC2104 [HMAC]) takes the output (truncation) length in bits as a parameter; | ||
* this specification REQUIRES that the truncation length be a multiple of 8 (i.e. fall on a byte boundary) | ||
* because Base64 encoding operates on full bytes | ||
* | ||
* @var string | ||
*/ | ||
private static string $HMACOutputLength_regex = '/^([1-9]\d*)$/D'; | ||
|
||
|
||
/** | ||
* @param string $value | ||
* @param string $message | ||
*/ | ||
protected static function validHMACOutputLength(string $value, string $message = ''): void | ||
{ | ||
parent::regex( | ||
$value, | ||
self::$HMACOutputLength_regex, | ||
$message ?: '%s is not a valid ds:HMACOutputLengthType', | ||
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); | ||
} | ||
} |
Oops, something went wrong.