/
MockContainer.php
114 lines (94 loc) · 2.35 KB
/
MockContainer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
declare(strict_types=1);
namespace SimpleSAML\SAML2\Compat;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use function chmod;
use function file_put_contents;
use function sys_get_temp_dir;
/**
* Class \SimpleSAML\SAML2\Compat\MockContainer
*/
class MockContainer extends AbstractContainer
{
/**
* @var string
*/
private string $id = 's2a0da3504aff978b0f8c80f6a62c713c4a2f64c5b';
/**
* @var array
*/
private array $debugMessages = [];
/**
* Get a PSR-3 compatible logger.
* @return \Psr\Log\LoggerInterface
*/
public function getLogger(): LoggerInterface
{
return new NullLogger();
}
/**
* Generate a random identifier for identifying SAML2 documents.
* @return string
*/
public function generateId(): string
{
return $this->id;
}
/**
* Log an incoming message to the debug log.
*
* Type can be either:
* - **in** XML received from third party
* - **out** XML that will be sent to third party
* - **encrypt** XML that is about to be encrypted
* - **decrypt** XML that was just decrypted
*
* @param \DOMElement|string $message
* @param string $type
*/
public function debugMessage($message, string $type): void
{
$this->debugMessages[$type] = $message;
}
/**
* Trigger the user to perform a POST to the given URL with the given data.
*
* @param string|null $url
* @param array $data
* @return string
*/
public function getPOSTRedirectURL(
/** @scrutinizer ignore-unused */string $url = null,
/** @scrutinizer ignore-unused */array $data = []
): string {
return $url;
}
/**
* @return string
*/
public function getTempDir(): string
{
return sys_get_temp_dir();
}
/**
* @param string $filename
* @param string $data
* @param int|null $mode
*/
public function writeFile(string $filename, string $data, int $mode = null): void
{
if ($mode === null) {
$mode = 0600;
}
file_put_contents($filename, $data);
chmod($filename, $mode);
}
/**
* @inheritDoc
*/
public function setBlacklistedAlgorithms(?array $algos): void
{
$this->blacklistedEncryptionAlgorithms = [];
}
}