1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\Module\monitor\TestSuite\AuthSource; |
6
|
|
|
|
7
|
|
|
use KRB5NegotiateAuth; |
8
|
|
|
use SimpleSAML\Assert\Assert; |
9
|
|
|
use SimpleSAML\Module\monitor\TestConfiguration; |
10
|
|
|
use SimpleSAML\Module\monitor\TestCase; |
11
|
|
|
use SimpleSAML\Module\monitor\TestData; |
12
|
|
|
|
13
|
|
|
use function is_array; |
14
|
|
|
|
15
|
|
|
final class Negotiate extends \SimpleSAML\Module\monitor\TestSuiteFactory |
16
|
|
|
{ |
17
|
|
|
/** @var string|null */ |
18
|
|
|
private ?string $authorization; |
19
|
|
|
|
20
|
|
|
/** @var \KRB5NegotiateAuth */ |
21
|
|
|
private KRB5NegotiateAuth $handle; |
22
|
|
|
|
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @param \SimpleSAML\Module\monitor\TestConfiguration $configuration |
26
|
|
|
* @param \SimpleSAML\Module\monitor\TestData $testData |
27
|
|
|
*/ |
28
|
|
|
public function __construct(TestConfiguration $configuration, TestData $testData) |
29
|
|
|
{ |
30
|
|
|
$authSourceData = $testData->getInputItem('authSourceData'); |
31
|
|
|
$serverVars = $configuration->getServerVars(); |
32
|
|
|
|
33
|
|
|
Assert::isArray($authSourceData); |
34
|
|
|
|
35
|
|
|
$keytab = isset($authSourceData['keytab']) ? $authSourceData['keytab'] : null; |
36
|
|
|
$this->handle = new KRB5NegotiateAuth($keytab); |
37
|
|
|
$this->authorization = $serverVars->get('HTTP_AUTHORIZATION'); |
38
|
|
|
$this->setCategory('SPNEGO authentication source'); |
39
|
|
|
|
40
|
|
|
parent::__construct($configuration); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @return void |
46
|
|
|
*/ |
47
|
|
|
public function invokeTest(): void |
48
|
|
|
{ |
49
|
|
|
$input = [ |
50
|
|
|
'handle' => $this->handle, |
51
|
|
|
'authorization' => $this->authorization |
52
|
|
|
]; |
53
|
|
|
$testData = new TestData($input); |
54
|
|
|
|
55
|
|
|
$test = new TestCase\AuthSource\Negotiate($testData); |
56
|
|
|
$this->addTestResult($test->getTestResult()); |
57
|
|
|
$this->setTestResult($test->getTestResult()); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|