|
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; |
|
|
|
|
|
|
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 |
|
|
|
|
|
|
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
|
|
|
} |
|
|
|
|
|
|
69
|
|
|
} |
|
70
|
|
|
|