|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace SimpleSAML\SAML2\XML\samlp; |
|
6
|
|
|
|
|
7
|
|
|
use DOMElement; |
|
8
|
|
|
use SimpleSAML\SAML2\Assert\Assert; |
|
9
|
|
|
use SimpleSAML\SAML2\Exception\Protocol\RequestVersionTooHighException; |
|
|
|
|
|
|
10
|
|
|
use SimpleSAML\SAML2\Exception\Protocol\RequestVersionTooLowException; |
|
|
|
|
|
|
11
|
|
|
use SimpleSAML\SAML2\Type\SAMLAnyURIValue; |
|
12
|
|
|
use SimpleSAML\SAML2\Type\SAMLDateTimeValue; |
|
|
|
|
|
|
13
|
|
|
use SimpleSAML\SAML2\Type\SAMLStringValue; |
|
14
|
|
|
use SimpleSAML\SAML2\XML\saml\Issuer; |
|
15
|
|
|
use SimpleSAML\SAML2\XML\samlp\NewEncryptedID; |
|
|
|
|
|
|
16
|
|
|
use SimpleSAML\SAML2\XML\samlp\NewID; |
|
|
|
|
|
|
17
|
|
|
use SimpleSAML\SAML2\XML\samlp\Terminate; |
|
18
|
|
|
use SimpleSAML\XML\SchemaValidatableElementInterface; |
|
19
|
|
|
use SimpleSAML\XML\SchemaValidatableElementTrait; |
|
20
|
|
|
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException; |
|
21
|
|
|
use SimpleSAML\XMLSchema\Exception\MissingElementException; |
|
22
|
|
|
use SimpleSAML\XMLSchema\Exception\TooManyElementsException; |
|
23
|
|
|
use SimpleSAML\XMLSchema\Type\IDValue; |
|
|
|
|
|
|
24
|
|
|
use SimpleSAML\XMLSecurity\XML\ds\Signature; |
|
25
|
|
|
|
|
26
|
|
|
use function array_merge; |
|
27
|
|
|
use function array_pop; |
|
28
|
|
|
use function version_compare; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Class for handling SAML2 ManageNameIDRequest. |
|
32
|
|
|
* |
|
33
|
|
|
* @package simplesamlphp/saml2 |
|
34
|
|
|
*/ |
|
35
|
|
|
final class ManageNameIDRequest extends AbstractManageNameIDRequest implements |
|
36
|
|
|
SchemaValidatableElementInterface |
|
37
|
|
|
{ |
|
38
|
|
|
use SchemaValidatableElementTrait; |
|
39
|
|
|
|
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Convert XML into a ManageNameIDRequest |
|
43
|
|
|
* |
|
44
|
|
|
* @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException |
|
45
|
|
|
* if the qualified name of the supplied element is wrong |
|
46
|
|
|
*/ |
|
47
|
|
|
public static function fromXML(DOMElement $xml): static |
|
48
|
|
|
{ |
|
49
|
|
|
Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); |
|
50
|
|
|
Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); |
|
51
|
|
|
|
|
52
|
|
|
$version = self::getAttribute($xml, 'Version', SAMLStringValue::class); |
|
53
|
|
|
Assert::true(version_compare('2.0', strval($version), '<='), RequestVersionTooLowException::class); |
|
54
|
|
|
Assert::true(version_compare('2.0', strval($version), '>='), RequestVersionTooHighException::class); |
|
55
|
|
|
|
|
56
|
|
|
$issuer = Issuer::getChildrenOfClass($xml); |
|
57
|
|
|
Assert::maxCount($issuer, 1, 'Only one <saml:Issuer> element is allowed.', TooManyElementsException::class); |
|
58
|
|
|
|
|
59
|
|
|
$extensions = Extensions::getChildrenOfClass($xml); |
|
|
|
|
|
|
60
|
|
|
Assert::maxCount( |
|
61
|
|
|
$extensions, |
|
62
|
|
|
1, |
|
63
|
|
|
'Only one <samlp:Extensions> element is allowed.', |
|
64
|
|
|
TooManyElementsException::class, |
|
65
|
|
|
); |
|
66
|
|
|
|
|
67
|
|
|
$signature = Signature::getChildrenOfClass($xml); |
|
68
|
|
|
Assert::maxCount( |
|
69
|
|
|
$signature, |
|
70
|
|
|
1, |
|
71
|
|
|
'Only one <ds:Signature> element is allowed.', |
|
72
|
|
|
TooManyElementsException::class, |
|
73
|
|
|
); |
|
74
|
|
|
|
|
75
|
|
|
$newId = NewID::getChildrenOfClass($xml); |
|
76
|
|
|
Assert::maxCount($newId, 1, TooManyElementsException::class); |
|
77
|
|
|
|
|
78
|
|
|
$newEncryptedId = NewEncryptedID::getChildrenOfClass($xml); |
|
79
|
|
|
Assert::maxCount($newEncryptedId, 1, TooManyElementsException::class); |
|
80
|
|
|
|
|
81
|
|
|
$terminate = Terminate::getChildrenOfClass($xml); |
|
82
|
|
|
Assert::maxCount($terminate, 1, TooManyElementsException::class); |
|
83
|
|
|
|
|
84
|
|
|
$newIdentifier = array_merge($newId, $newEncryptedId, $terminate); |
|
85
|
|
|
Assert::minCount($newIdentifier, 1, MissingElementException::class); |
|
86
|
|
|
Assert::maxCount($newIdentifier, 1, TooManyElementsException::class); |
|
87
|
|
|
|
|
88
|
|
|
$request = new static( |
|
89
|
|
|
self::getIdentifierFromXML($xml), |
|
|
|
|
|
|
90
|
|
|
array_pop($newIdentifier), |
|
91
|
|
|
self::getAttribute($xml, 'ID', IDValue::class), |
|
92
|
|
|
array_pop($issuer), |
|
93
|
|
|
self::getAttribute($xml, 'IssueInstant', SAMLDateTimeValue::class), |
|
94
|
|
|
self::getOptionalAttribute($xml, 'Destination', SAMLAnyURIValue::class, null), |
|
95
|
|
|
self::getOptionalAttribute($xml, 'Consent', SAMLAnyURIValue::class, null), |
|
96
|
|
|
array_pop($extensions), |
|
97
|
|
|
); |
|
98
|
|
|
|
|
99
|
|
|
if (!empty($signature)) { |
|
100
|
|
|
$request->setSignature($signature[0]); |
|
101
|
|
|
$request->messageContainedSignatureUponConstruction = true; |
|
102
|
|
|
$request->setXML($xml); |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
return $request; |
|
106
|
|
|
} |
|
107
|
|
|
} |
|
108
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths