ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
X509.php
Go to the documentation of this file.
1<?php
2
3namespace SAML2\Certificate;
4
8class 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}
An exception for terminatinating execution or to throw for unit testing.
Simple representation of the fingerprint of a certificate.
Definition: Fingerprint.php:13
Simple DTO wrapper for (X509) keys.
Definition: Key.php:13
Specific Certificate Key.
Definition: X509.php:9
getCertificate()
Get the certificate representation.
Definition: X509.php:44
offsetSet($offset, $value)
{} Best place to ensure the logic is encapsulated in a single place
Definition: X509.php:30
static createFromCertificateData($certificateContents)
Definition: X509.php:15