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

EncryptedID   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 1
dl 0
loc 26
rs 10
c 3
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getBlacklistedAlgorithms() 0 2 1
A decrypt() 0 2 1
A getEncryptionBackend() 0 2 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2\XML\saml;
6
7
use InvalidArgumentException;
8
use SimpleSAML\SAML2\Compat\ContainerSingleton;
9
use SimpleSAML\SAML2\Constants;
10
use SimpleSAML\XML\XMLElementInterface;
11
use SimpleSAML\XMLSecurity\Alg\Encryption\EncryptionAlgorithmInterface;
12
use SimpleSAML\XMLSecurity\Utils\Security;
13
use SimpleSAML\XMLSecurity\XML\EncryptedElementInterface;
14
use SimpleSAML\XMLSecurity\XML\EncryptedElementTrait;
15
16
use function implode;
17
18
/**
19
 * Class representing an encrypted identifier.
20
 *
21
 * @package simplesamlphp/saml2
22
 */
23
class EncryptedID extends AbstractSamlElement implements EncryptedElementInterface, IdentifierInterface
24
{
25
    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\EncryptedID: $localName, $namespaceURI
Loading history...
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\XML\XMLElementInterface
45
     * @throws \InvalidArgumentException
46
     */
47
    public function decrypt(EncryptionAlgorithmInterface $decryptor): XMLElementInterface
48
    {
49
//        $xml = Security::decryptElement($this->encryptedData->toXML(), $key, $blacklist);
50
//        $id = implode(':', [$xml->namespaceURI, $xml->localName]);
51
//        switch ($id) {
52
//            case NameID::NS . ':NameID':
53
//                return NameID::fromXML($xml);
54
//            case Issuer::NS . ':Issuer':
55
//                return Issuer::fromXML($xml);
56
//            case BaseID::NS . ':BaseID':
57
//                $xsiType = $xml->getAttributeNS(Constants::NS_XSI, 'type');
58
//                $container = ContainerSingleton::getInstance();
59
//                $handler = $container->getIdentifierHandler($xsiType);
60
//                if ($handler !== null) {
61
//                    return $handler::fromXML($xml);
62
//                }
63
//                return BaseID::fromXML($xml);
64
//            default:
65
                // Fall thru
66
//        }
67
//        throw new InvalidArgumentException('Unknown or unsupported encrypted identifier.');
68
    }
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\XML\XMLElementInterface. 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...
69
}
70