Total Complexity | 5 |
Total Lines | 34 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
7 | class PrivateKey extends Key |
||
8 | { |
||
9 | /** |
||
10 | * @param string $keyContents |
||
11 | * @param string|null $passphrase |
||
12 | * @throws \SimpleSAML\SAML2\Exception\InvalidArgumentException |
||
13 | * @return \SimpleSAML\SAML2\Certificate\PrivateKey |
||
14 | */ |
||
15 | public static function create(string $keyContents, ?string $passphrase = null): PrivateKey |
||
16 | { |
||
17 | $keyData = ['PEM' => $keyContents, self::USAGE_ENCRYPTION => true]; |
||
18 | if ($passphrase) { |
||
19 | $keyData['passphrase'] = $passphrase; |
||
20 | } |
||
21 | |||
22 | return new self($keyData); |
||
23 | } |
||
24 | |||
25 | |||
26 | /** |
||
27 | * @return string |
||
28 | */ |
||
29 | public function getKeyAsString(): string |
||
30 | { |
||
31 | return $this->keyData['PEM']; |
||
32 | } |
||
33 | |||
34 | |||
35 | /** |
||
36 | * @return string|null |
||
37 | */ |
||
38 | public function getPassphrase(): ?string |
||
41 | } |
||
42 | } |
||
43 |