1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\SAML2\Compat; |
6
|
|
|
|
7
|
|
|
use Psr\Log\LoggerInterface; |
8
|
|
|
use SimpleSAML\Assert\Assert; |
9
|
|
|
use SimpleSAML\XML\AbstractXMLElement; |
10
|
|
|
use SimpleSAML\XML\Exception\SchemaViolationException; |
11
|
|
|
use SimpleSAML\SAML2\XML\ExtensionPointInterface; |
12
|
|
|
|
13
|
|
|
use function array_key_exists; |
14
|
|
|
use function explode; |
15
|
|
|
use function is_subclass_of; |
16
|
|
|
use function join; |
17
|
|
|
|
18
|
|
|
abstract class AbstractContainer |
19
|
|
|
{ |
20
|
|
|
/** @var array */ |
21
|
|
|
public array $registry = []; |
22
|
|
|
|
23
|
|
|
/** @var array|null */ |
24
|
|
|
protected ?array $blacklistedEncryptionAlgorithms; |
25
|
|
|
|
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Set the list of algorithms that are blacklisted for any encryption operation. |
29
|
|
|
* |
30
|
|
|
* @param string[]|null $algos An array with all algorithm identifiers that are blacklisted, |
31
|
|
|
* or null if we want to use the defaults. |
32
|
|
|
*/ |
33
|
|
|
abstract public function setBlacklistedAlgorithms(?array $algos): void; |
34
|
|
|
|
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Get the list of algorithms that are blacklisted for any encryption operation. |
38
|
|
|
* |
39
|
|
|
* @return string[]|null An array with all algorithm identifiers that are blacklisted, or null if we want to use the |
40
|
|
|
* defaults. |
41
|
|
|
*/ |
42
|
|
|
public function getBlacklistedEncryptionAlgorithms(): ?array |
43
|
|
|
{ |
44
|
|
|
return $this->blacklistedEncryptionAlgorithms; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Get a PSR-3 compatible logger. |
50
|
|
|
* @return \Psr\Log\LoggerInterface |
51
|
|
|
*/ |
52
|
|
|
abstract public function getLogger(): LoggerInterface; |
53
|
|
|
|
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Generate a random identifier for identifying SAML2 documents. |
57
|
|
|
* @return string |
58
|
|
|
*/ |
59
|
|
|
abstract public function generateId(): string; |
60
|
|
|
|
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Log an incoming message to the debug log. |
64
|
|
|
* |
65
|
|
|
* Type can be either: |
66
|
|
|
* - **in** XML received from third party |
67
|
|
|
* - **out** XML that will be sent to third party |
68
|
|
|
* - **encrypt** XML that is about to be encrypted |
69
|
|
|
* - **decrypt** XML that was just decrypted |
70
|
|
|
* |
71
|
|
|
* @param \DOMElement|string $message |
72
|
|
|
* @param string $type |
73
|
|
|
*/ |
74
|
|
|
abstract public function debugMessage($message, string $type): void; |
75
|
|
|
|
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Trigger the user to perform a GET to the given URL with the given data. |
79
|
|
|
* |
80
|
|
|
* @param string $url |
81
|
|
|
* @param array $data |
82
|
|
|
*/ |
83
|
|
|
abstract public function redirect(string $url, array $data = []): void; |
84
|
|
|
|
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Trigger the user to perform a POST to the given URL with the given data. |
88
|
|
|
* |
89
|
|
|
* @param string $url |
90
|
|
|
* @param array $data |
91
|
|
|
*/ |
92
|
|
|
abstract public function postRedirect(string $url, array $data = []): void; |
93
|
|
|
|
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* This function retrieves the path to a directory where temporary files can be saved. |
97
|
|
|
* |
98
|
|
|
* @throws \Exception If the temporary directory cannot be created or it exists and does not belong |
99
|
|
|
* to the current user. |
100
|
|
|
* @return string Path to a temporary directory, without a trailing directory separator. |
101
|
|
|
*/ |
102
|
|
|
abstract public function getTempDir(): string; |
103
|
|
|
|
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* Atomically write a file. |
107
|
|
|
* |
108
|
|
|
* This is a helper function for writing data atomically to a file. It does this by writing the file data to a |
109
|
|
|
* temporary file, then renaming it to the required file name. |
110
|
|
|
* |
111
|
|
|
* @param string $filename The path to the file we want to write to. |
112
|
|
|
* @param string $data The data we should write to the file. |
113
|
|
|
* @param int $mode The permissions to apply to the file. Defaults to 0600. |
114
|
|
|
*/ |
115
|
|
|
abstract public function writeFile(string $filename, string $data, int $mode = null): void; |
116
|
|
|
|
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* Register a class that can handle given extension points of the standard. |
120
|
|
|
* |
121
|
|
|
* @param string $class The class name of a class extending AbstractXMLElement or implementing ExtensionPointInterface. |
122
|
|
|
* @psalm-param class-string $class |
123
|
|
|
*/ |
124
|
|
|
public function registerExtensionHandler(string $class): void |
125
|
|
|
{ |
126
|
|
|
Assert::subclassOf($class, AbstractXMLElement::class); |
127
|
|
|
if (is_subclass_of($class, ExtensionPointInterface::class)) { |
128
|
|
|
$key = join(':', [$class::getXsiTypeNamespaceURI(), $class::getXsiTypeName()]); |
129
|
|
|
} else { |
130
|
|
|
$className = AbstractXMLElementName::getClassName($class); |
|
|
|
|
131
|
|
|
$key = ($class::NS === null) ? $className : join(':', [$class::NS, $className]); |
132
|
|
|
} |
133
|
|
|
$this->registry[$key] = $class; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* Search for a class that implements an $element in the given $namespace. |
139
|
|
|
* |
140
|
|
|
* Such classes must have been registered previously by calling registerExtensionHandler(), and they must |
141
|
|
|
* extend \SimpleSAML\XML\AbstractXMLElement. |
142
|
|
|
* |
143
|
|
|
* @param string|null $namespace The namespace URI for the given element. |
144
|
|
|
* @param string $element The local name of the element. |
145
|
|
|
* |
146
|
|
|
* @return string|null The fully-qualified name of a class extending \SimpleSAML\XML\AbstractXMLElement and |
147
|
|
|
* implementing support for the given element, or null if no such class has been registered before. |
148
|
|
|
* @psalm-return class-string|null |
149
|
|
|
*/ |
150
|
|
|
public function getElementHandler(?string $namespace, string $elementOrType): ?string |
151
|
|
|
{ |
152
|
|
|
Assert::nullOrValidURI($namespace, SchemaViolationException::class); |
153
|
|
|
Assert::validNCName($elementOrType, SchemaViolationException::class); |
154
|
|
|
|
155
|
|
|
$key = ($namespace === null) ? $elementOrType : join(':', [$namespace, $elementOrType]); |
156
|
|
|
if (array_key_exists($key, $this->registry) === true) { |
157
|
|
|
return $this->registry[$key]; |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
return null; |
161
|
|
|
} |
162
|
|
|
} |
163
|
|
|
|
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