KeyChain::keychainPrivateXmlSecurityKey()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
nc 1
cc 1
nop 0
1
<?php
2
3
4
namespace flipbox\saml\core\records\traits;
5
6
use flipbox\keychain\records\KeyChainRecord;
7
use flipbox\saml\core\records\AbstractProvider;
8
use RobRichards\XMLSecLibs\XMLSecurityKey;
9
10
/**
11
 * Trait KeyPair
12
 * @package flipbox\saml\core\records\traits
13
 * @property KeyChainRecord $keychain
14
 * @mixin AbstractProvider
15
 */
16
trait KeyChain
17
{
18
    /**
19
     * @return string
20
     */
21
    public function defaultCipherType()
22
    {
23
        return XMLSecurityKey::RSA_SHA256;
24
    }
25
26
    /**
27
     * @return XMLSecurityKey
28
     * @throws \Exception
29
     */
30
    public function keychainPrivateXmlSecurityKey()
31
    {
32
        $xmlSecurityKey = new XMLSecurityKey($this->defaultCipherType(), [
33
            'type' => 'private',
34
        ]);
35
36
        $xmlSecurityKey->loadKey($this->keychain->getDecryptedKey());
37
38
        return $xmlSecurityKey;
39
    }
40
}
41