ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
X509.php
Go to the documentation of this file.
1 <?php
2 
3 namespace SAML2\Certificate;
4 
8 class X509 extends Key
9 {
13  private $fingerprint;
14 
15  public static function createFromCertificateData($certificateContents)
16  {
17  $data = array(
18  'encryption' => true,
19  'signing' => true,
20  'type' => 'X509Certificate',
21  'X509Certificate' => $certificateContents
22  );
23 
24  return new self($data);
25  }
26 
30  public function offsetSet($offset, $value)
31  {
32  if ($offset === 'X509Certificate') {
33  $value = preg_replace('~\s+~', '', $value);
34  }
35 
36  parent::offsetSet($offset, $value);
37  }
38 
44  public function getCertificate()
45  {
46  return "-----BEGIN CERTIFICATE-----\n"
47  . chunk_split($this->keyData['X509Certificate'], 64)
48  . "-----END CERTIFICATE-----\n";
49  }
50 
56  public function getFingerprint()
57  {
58  if (isset($this->fingerprint)) {
59  return $this->fingerprint;
60  }
61 
62  $fingerprint = strtolower(sha1(base64_decode($this->keyData['X509Certificate'])));
63 
64  return $this->fingerprint = new Fingerprint($fingerprint);
65  }
66 }
Pure-PHP X.509 Parser.
offsetSet($offset, $value)
{} Best place to ensure the logic is encapsulated in a single place
Definition: X509.php:30
Simple DTO wrapper for (X509) keys.
Definition: Key.php:12
getCertificate()
Get the certificate representation.
Definition: X509.php:44
static createFromCertificateData($certificateContents)
Definition: X509.php:15
$data
Definition: bench.php:6
Simple representation of the fingerprint of a certificate.
Definition: Fingerprint.php:12