ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
PrivateKey.php
Go to the documentation of this file.
1<?php
2
3namespace SAML2\Certificate;
4
6
7class PrivateKey extends Key
8{
9 public static function create($keyContents, $passphrase = null)
10 {
11 if (!is_string($keyContents)) {
12 throw InvalidArgumentException::invalidType('string', $keyContents);
13 }
14
15 if ($passphrase && !is_string($passphrase)) {
16 throw InvalidArgumentException::invalidType('string', $passphrase);
17 }
18
19 $keyData = array('PEM' => $keyContents, self::USAGE_ENCRYPTION => true);
20 if ($passphrase) {
21 $keyData['passphrase'] = $passphrase;
22 }
23
24 return new self($keyData);
25 }
26
27 public function getKeyAsString()
28 {
29 return $this->keyData['PEM'];
30 }
31
32 public function getPassphrase()
33 {
34 return isset($this->keyData['passphrase']) ? $this->keyData['passphrase'] : null;
35 }
36}
An exception for terminatinating execution or to throw for unit testing.
Simple DTO wrapper for (X509) keys.
Definition: Key.php:13
static create($keyContents, $passphrase=null)
Definition: PrivateKey.php:9