|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Copyright 2019 SURFnet B.V. |
|
4
|
|
|
* |
|
5
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
6
|
|
|
* you may not use this file except in compliance with the License. |
|
7
|
|
|
* You may obtain a copy of the License at |
|
8
|
|
|
* |
|
9
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
|
10
|
|
|
* |
|
11
|
|
|
* Unless required by applicable law or agreed to in writing, software |
|
12
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
|
13
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
14
|
|
|
* See the License for the specific language governing permissions and |
|
15
|
|
|
* limitations under the License. |
|
16
|
|
|
*/ |
|
17
|
|
|
|
|
18
|
|
|
namespace Surfnet\StepupSelfService\SelfServiceBundle\Mock\RemoteVetting; |
|
19
|
|
|
|
|
20
|
|
|
use InvalidArgumentException; |
|
21
|
|
|
|
|
22
|
|
|
final class MockConfiguration |
|
23
|
|
|
{ |
|
24
|
|
|
private $identityProviderEntityId; |
|
25
|
|
|
private $serviceProviderEntityId; |
|
26
|
|
|
private $publicKeyCertData; |
|
27
|
|
|
private $privateKeyPem; |
|
28
|
|
|
private $publicKeyCertDataFile; |
|
29
|
|
|
private $privateKeyPemFile; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @param string $identityProviderEntityId |
|
33
|
|
|
* @param string $serviceProviderEntityId |
|
34
|
|
|
* @param string $privateKeyPath |
|
35
|
|
|
* @param string $publicCertPath |
|
36
|
|
|
*/ |
|
37
|
|
|
public function __construct( |
|
38
|
|
|
$identityProviderEntityId, |
|
39
|
|
|
$serviceProviderEntityId, |
|
40
|
|
|
$privateKeyPath, |
|
41
|
|
|
$publicCertPath |
|
42
|
|
|
) { |
|
43
|
|
|
|
|
44
|
|
|
if (!is_file($privateKeyPath)) { |
|
45
|
|
|
throw new InvalidArgumentException('Unable to find private key: '. $privateKeyPath); |
|
46
|
|
|
} |
|
47
|
|
|
if (!is_file($publicCertPath)) { |
|
48
|
|
|
throw new InvalidArgumentException('Unable to find private key: '. $publicCertPath); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
$this->identityProviderEntityId = $identityProviderEntityId; |
|
52
|
|
|
$this->serviceProviderEntityId = $serviceProviderEntityId; |
|
53
|
|
|
$this->privateKeyPemFile = $privateKeyPath; |
|
54
|
|
|
$this->publicKeyCertDataFile = $publicCertPath; |
|
55
|
|
|
$this->privateKeyPem = file_get_contents($privateKeyPath); |
|
56
|
|
|
$this->publicKeyCertData = file_get_contents($publicCertPath); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @return string |
|
61
|
|
|
*/ |
|
62
|
|
|
public function getIdentityProviderEntityId() |
|
63
|
|
|
{ |
|
64
|
|
|
return $this->identityProviderEntityId; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @return string |
|
69
|
|
|
*/ |
|
70
|
|
|
public function getIdentityProviderPublicKeyCertData() |
|
71
|
|
|
{ |
|
72
|
|
|
return $this->publicKeyCertData; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @return string |
|
77
|
|
|
*/ |
|
78
|
|
|
public function getIdentityProviderGetPrivateKeyPem() |
|
79
|
|
|
{ |
|
80
|
|
|
return $this->privateKeyPem; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @return string |
|
85
|
|
|
*/ |
|
86
|
|
|
public function getServiceProviderEntityId() |
|
87
|
|
|
{ |
|
88
|
|
|
return $this->serviceProviderEntityId; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* @return string |
|
93
|
|
|
*/ |
|
94
|
|
|
public function getPublicKeyCertDataFile() |
|
95
|
|
|
{ |
|
96
|
|
|
return $this->publicKeyCertDataFile; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* @return string |
|
101
|
|
|
*/ |
|
102
|
|
|
public function getPrivateKeyPemFile() |
|
103
|
|
|
{ |
|
104
|
|
|
return $this->privateKeyPemFile; |
|
105
|
|
|
} |
|
106
|
|
|
} |
|
107
|
|
|
|