Utils::getContainer()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2;
6
7
use SimpleSAML\SAML2\Compat\AbstractContainer;
8
use SimpleSAML\SAML2\Compat\ContainerSingleton;
9
use SimpleSAML\SAML2\XML\md\KeyDescriptor;
10
use SimpleSAML\XMLSecurity\XML\ds\KeyInfo;
11
use SimpleSAML\XMLSecurity\XML\ds\X509Certificate;
12
use SimpleSAML\XMLSecurity\XML\ds\X509Data;
13
14
/**
15
 * Helper functions for the SAML2 library.
16
 *
17
 * @package simplesamlphp/saml2
18
 */
19
class Utils
20
{
21
    /**
22
     * Create a KeyDescriptor with the given certificate.
23
     *
24
     * @param string $x509Data The certificate, as a base64-encoded PEM data.
25
     * @return \SimpleSAML\SAML2\XML\md\KeyDescriptor The keydescriptor.
26
     */
27
    public static function createKeyDescriptor(string $x509Data): KeyDescriptor
28
    {
29
        $x509Data = new X509Data([
30
            new X509Certificate($x509Data),
31
        ]);
32
33
        $keyInfo = new KeyInfo([
34
            $x509Data,
35
        ]);
36
37
        return new KeyDescriptor($keyInfo);
38
    }
39
40
41
    /**
42
     * @return \SimpleSAML\SAML2\Compat\AbstractContainer
43
     */
44
    public static function getContainer(): AbstractContainer
45
    {
46
        return ContainerSingleton::getInstance();
47
    }
48
}
49