Completed
Push — master ( 4b394d...0ca4f0 )
by Damien
09:55
created

KeyChain   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 25
rs 10
c 0
b 0
f 0

2 Methods

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