Passed
Push — master ( ff3228...e5a9b6 )
by Tim
14:22
created

EncryptedAssertion   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
c 0
b 0
f 0
dl 0
loc 28
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A wasSignedAtConstruction() 0 3 1
A decrypt() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2\XML\saml;
6
7
use DOMElement;
8
use SimpleSAML\SAML2\Compat\ContainerSingleton;
9
use SimpleSAML\SAML2\XML\EncryptedElementTrait;
10
use SimpleSAML\XML\DOMDocumentFactory;
11
use SimpleSAML\XMLSecurity\Alg\Encryption\EncryptionAlgorithmInterface;
12
use SimpleSAML\XMLSecurity\XML\EncryptedElementInterface;
13
14
/**
15
 * Class handling encrypted assertions.
16
 *
17
 * @package simplesamlphp/saml2
18
 */
19
final class EncryptedAssertion extends AbstractSamlElement implements EncryptedElementInterface
20
{
21
    use EncryptedElementTrait;
0 ignored issues
show
introduced by
The trait SimpleSAML\SAML2\XML\EncryptedElementTrait requires some properties which are not provided by SimpleSAML\SAML2\XML\saml\EncryptedAssertion: $localName, $namespaceURI
Loading history...
22
23
    /** @var bool */
24
    protected bool $wasSignedAtConstruction = false;
25
26
27
    /**
28
     * @inheritDoc
29
     *
30
     * @return \SimpleSAML\SAML2\XML\saml\Assertion
31
     * @throws \Exception
32
     */
33
    public function decrypt(EncryptionAlgorithmInterface $decryptor): Assertion
34
    {
35
        return Assertion::fromXML(
36
            DOMDocumentFactory::fromString($this->decryptData($decryptor))->documentElement,
37
        );
38
    }
39
40
41
    /**
42
     * @return bool
43
     */
44
    public function wasSignedAtConstruction(): bool
45
    {
46
        return $this->wasSignedAtConstruction;
47
    }
48
}
49