Skip to content

Commit e6bf793

Browse files
authored
Merge pull request #6 from simplesamlphp/feature/xsd-types
Feature/xsd types
2 parents 765b414 + 33246c4 commit e6bf793

148 files changed

Lines changed: 2873 additions & 2212 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717

1818
"psr/clock": "~1.0.0",
1919
"psr/log": "~2.3.1 | ~3.0.0",
20-
"simplesamlphp/assert": "~1.8.1",
21-
"simplesamlphp/xml-common": "~1.24.2",
22-
"simplesamlphp/xml-security": "~1.13.0"
20+
"simplesamlphp/assert": "~1.8.2",
21+
"simplesamlphp/xml-common": "~2.0.1",
22+
"simplesamlphp/xml-security": "~2.0.0"
2323
},
2424
"require-dev": {
2525
"beste/clock": "~3.0.0",
26-
"simplesamlphp/simplesamlphp-test-framework": "~1.9.2"
26+
"simplesamlphp/simplesamlphp-test-framework": "~1.9.3"
2727
},
2828
"autoload": {
2929
"psr-4": {

phpstan-baseline.neon

Lines changed: 0 additions & 76 deletions
This file was deleted.

phpstan.neon

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,3 @@ parameters:
22
level: 1
33
paths:
44
- src
5-
includes:
6-
- phpstan-baseline.neon

src/SAML11/Assert/Assert.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,19 @@
1111
*
1212
* @package simplesamlphp/saml11
1313
*
14-
* @method static void validDateTime(mixed $value, string $message = '', string $exception = '')
15-
* @method static void validURI(mixed $value, string $message = '', string $exception = '')
16-
* @method static void validEntityID(mixed $value, string $message = '', string $exception = '')
17-
* @method static void nullOrValidDateTime(mixed $value, string $message = '', string $exception = '')
18-
* @method static void nullOrValidURI(mixed $value, string $message = '', string $exception = '')
19-
* @method static void nullOrValidEntityID(mixed $value, string $message = '', string $exception = '')
20-
* @method static void allValidDateTime(mixed $value, string $message = '', string $exception = '')
21-
* @method static void allValidURI(mixed $value, string $message = '', string $exception = '')
22-
* @method static void allValidEntityID(mixed $value, string $message = '', string $exception = '')
14+
* @method static void validSAMLAnyURI(mixed $value, string $message = '', string $exception = '')
15+
* @method static void validSAMLDateTime(mixed $value, string $message = '', string $exception = '')
16+
* @method static void validSAMLString(mixed $value, string $message = '', string $exception = '')
17+
* @method static void nullOrValidSAMLAnyURI(mixed $value, string $message = '', string $exception = '')
18+
* @method static void nullOrValidSAMLDateTime(mixed $value, string $message = '', string $exception = '')
19+
* @method static void nullOrValidSAMLString(mixed $value, string $message = '', string $exception = '')
20+
* @method static void allValidSAMLAnyURI(mixed $value, string $message = '', string $exception = '')
21+
* @method static void allValidSAMLDateTime(mixed $value, string $message = '', string $exception = '')
22+
* @method static void allValidSAMLString(mixed $value, string $message = '', string $exception = '')
2323
*/
2424
class Assert extends BaseAssert
2525
{
26-
use CustomAssertionTrait;
26+
use SAMLAnyURITrait;
27+
use SAMLDateTimeTrait;
28+
use SAMLStringTrait;
2729
}

src/SAML11/Assert/CustomAssertionTrait.php

Lines changed: 0 additions & 63 deletions
This file was deleted.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SimpleSAML\SAML11\Assert;
6+
7+
use SimpleSAML\Assert\AssertionFailedException;
8+
use SimpleSAML\SAML11\Exception\ProtocolViolationException;
9+
10+
/**
11+
* @package simplesamlphp/saml11
12+
*/
13+
trait SAMLAnyURITrait
14+
{
15+
/**
16+
* @param string $value
17+
* @param string $message
18+
*/
19+
protected static function validSAMLAnyURI(string $value, string $message = ''): void
20+
{
21+
parent::validAnyURI($value, $message);
22+
23+
try {
24+
/**
25+
* 1.2.1 String and URI Values
26+
*
27+
* Unless otherwise indicated in this specification, all URI reference values MUST consist
28+
* of at least one non-whitespace character
29+
*/
30+
static::notWhitespaceOnly(
31+
$value,
32+
$message ?: '%s is not a SAML1.1-compliant URI',
33+
ProtocolViolationException::class,
34+
);
35+
} catch (AssertionFailedException $e) {
36+
throw new ProtocolViolationException($e->getMessage());
37+
}
38+
}
39+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SimpleSAML\SAML11\Assert;
6+
7+
use SimpleSAML\Assert\AssertionFailedException;
8+
use SimpleSAML\SAML11\Exception\ProtocolViolationException;
9+
10+
/**
11+
* @package simplesamlphp/saml11
12+
*/
13+
trait SAMLDateTimeTrait
14+
{
15+
/**
16+
* @param string $value
17+
* @param string $message
18+
*/
19+
protected static function validSAMLDateTime(string $value, string $message = ''): void
20+
{
21+
parent::validDateTime($value, $message);
22+
23+
try {
24+
/**
25+
* 1.2.2 Time Values
26+
*
27+
* All SAML time values have the type xsd:dateTime, which is built in to the W3C XML Schema Datatypes
28+
* specification [Schema2], and MUST be expressed in UTC form
29+
*/
30+
static::endsWith(
31+
$value,
32+
'Z',
33+
$message ?: '%s is not a DateTime expressed in the UTC timezone using the \'Z\' timezone identifier.',
34+
);
35+
} catch (AssertionFailedException $e) {
36+
throw new ProtocolViolationException($e->getMessage());
37+
}
38+
}
39+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SimpleSAML\SAML11\Assert;
6+
7+
use SimpleSAML\Assert\AssertionFailedException;
8+
use SimpleSAML\SAML11\Exception\ProtocolViolationException;
9+
use SimpleSAML\XMLSchema\Exception\SchemaViolationException;
10+
11+
/**
12+
* @package simplesamlphp/saml11
13+
*/
14+
trait SAMLStringTrait
15+
{
16+
/**
17+
* @param string $value
18+
* @param string $message
19+
*/
20+
protected static function validSAMLString(string $value, string $message = ''): void
21+
{
22+
parent::validString($value, $message, SchemaViolationException::class);
23+
24+
try {
25+
/**
26+
* 1.2.1 String and URI Values
27+
*
28+
* All strings in SAML messages MUST consist of at least one non-whitespace character
29+
* (whitespace is defined in the XML Recommendation [XML] §2.3).
30+
* Empty and whitespace-only values are disallowed.
31+
*/
32+
static::notWhitespaceOnly($value, $message ?: '%s is not a SAML1.1-compliant string');
33+
} catch (AssertionFailedException $e) {
34+
throw new ProtocolViolationException($e->getMessage());
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)