Passed
Push — master ( a470ba...be54de )
by Tim
02:20
created

EncryptedAssertion   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 43
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getBlacklistedAlgorithms() 0 2 1
A wasSignedAtConstruction() 0 3 1
A getEncryptionBackend() 0 2 1
A decrypt() 0 2 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2\XML\saml;
6
7
use SimpleSAML\SAML2\Utils;
8
use SimpleSAML\XML\AbstractXMLElement;
9
use SimpleSAML\XMLSecurity\Alg\Encryption\EncryptionAlgorithmInterface;
10
use SimpleSAML\XMLSecurity\Utils\Security;
11
use SimpleSAML\XMLSecurity\XML\EncryptedElementInterface;
12
use SimpleSAML\XMLSecurity\XML\EncryptedElementTrait;
13
use SimpleSAML\XMLSecurity\XMLSecurityKey;
14
15
/**
16
 * Class handling encrypted assertions.
17
 *
18
 * @package simplesamlphp/saml2
19
 */
20
class EncryptedAssertion extends AbstractSamlElement implements EncryptedElementInterface
21
{
22
    use EncryptedElementTrait;
1 ignored issue
show
introduced by
The trait SimpleSAML\XMLSecurity\XML\EncryptedElementTrait requires some properties which are not provided by SimpleSAML\SAML2\XML\saml\EncryptedAssertion: $localName, $namespaceURI
Loading history...
23
24
    /** @var bool */
25
    protected bool $wasSignedAtConstruction = false;
26
27
28
    public function getBlacklistedAlgorithms(): ?array
29
    {
30
        // return an array with the algorithms you don't want to allow to be used
31
    }
32
33
34
    public function getEncryptionBackend(): ?EncryptionBackend
0 ignored issues
show
Bug introduced by
The type SimpleSAML\SAML2\XML\saml\EncryptionBackend was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
35
    {
36
        // return the encryption backend you want to use,
37
        // or null if you are fine with the default
38
    }
39
40
41
    /**
42
     * @inheritDoc
43
     *
44
     * @return \SimpleSAML\SAML2\XML\saml\Assertion
45
     * @throws \Exception
46
     */
47
    public function decrypt(EncryptionAlgorithmInterface $decryptor): Assertion
48
    {
49
//        $assertionXML = Security::decryptElement($this->encryptedData->toXML(), $key, $blacklist);
50
51
//        Utils::getContainer()->debugMessage($assertionXML, 'decrypt');
52
53
//        return Assertion::fromXML($assertionXML);
54
    }
0 ignored issues
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return SimpleSAML\SAML2\XML\saml\Assertion. Consider adding a return statement or allowing null as return value.

For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example:

interface ReturnsInt {
    public function returnsIntHinted(): int;
}

class MyClass implements ReturnsInt {
    public function returnsIntHinted(): int
    {
        if (foo()) {
            return 123;
        }
        // here: null is implicitly returned
    }
}
Loading history...
55
56
57
    /**
58
     * @return bool
59
     */
60
    public function wasSignedAtConstruction(): bool
61
    {
62
        return $this->wasSignedAtConstruction;
63
    }
64
}
65