ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
PrivateKey.php
Go to the documentation of this file.
1 <?php
2 
3 namespace SAML2\Certificate;
4 
6 
7 class 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 }
Simple DTO wrapper for (X509) keys.
Definition: Key.php:12
static create($keyContents, $passphrase=null)
Definition: PrivateKey.php:9