|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace SimpleSAML\XMLSecurity\XML\xenc; |
|
6
|
|
|
|
|
7
|
|
|
use DOMElement; |
|
8
|
|
|
use SimpleSAML\Assert\Assert; |
|
9
|
|
|
use SimpleSAML\XML\Exception\InvalidDOMElementException; |
|
10
|
|
|
use SimpleSAML\XML\Exception\MissingElementException; |
|
11
|
|
|
use SimpleSAML\XML\Exception\TooManyElementsException; |
|
12
|
|
|
use SimpleSAML\XMLSecurity\XML\ds\KeyInfo; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Class containing encrypted data. |
|
16
|
|
|
* |
|
17
|
|
|
* Note: <xenc:EncryptionProperties> elements are not supported. |
|
18
|
|
|
* |
|
19
|
|
|
* @package simplesamlphp/xml-security |
|
20
|
|
|
*/ |
|
21
|
|
|
class EncryptedData extends AbstractEncryptedType |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* EncryptedData constructor. |
|
25
|
|
|
* |
|
26
|
|
|
* @param \SimpleSAML\XMLSecurity\XML\xenc\CipherData $cipherData The CipherData object of this EncryptedData. |
|
27
|
|
|
* @param string|null $id The Id attribute of this object. Optional. |
|
28
|
|
|
* @param string|null $type The Type attribute of this object. Optional. |
|
29
|
|
|
* @param string|null $mimeType The MimeType attribute of this object. Optional. |
|
30
|
|
|
* @param string|null $encoding The Encoding attribute of this object. Optional. |
|
31
|
|
|
* @param \SimpleSAML\XMLSecurity\XML\xenc\EncryptionMethod|null $encryptionMethod |
|
32
|
|
|
* The EncryptionMethod object of this EncryptedData. Optional. |
|
33
|
|
|
* @param \SimpleSAML\XMLSecurity\XML\ds\KeyInfo|null $keyInfo The KeyInfo object of this EncryptedData. Optional. |
|
34
|
|
|
*/ |
|
35
|
|
|
public function __construct( |
|
36
|
|
|
CipherData $cipherData, |
|
37
|
|
|
?string $id = null, |
|
38
|
|
|
?string $type = null, |
|
39
|
|
|
?string $mimeType = null, |
|
40
|
|
|
?string $encoding = null, |
|
41
|
|
|
?EncryptionMethod $encryptionMethod = null, |
|
42
|
|
|
?KeyInfo $keyInfo = null |
|
43
|
|
|
) { |
|
44
|
|
|
parent::__construct($cipherData, $id, $type, $mimeType, $encoding, $encryptionMethod, $keyInfo); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @inheritDoc |
|
50
|
|
|
*/ |
|
51
|
|
|
public function toXML(DOMElement $parent = null): DOMElement |
|
52
|
|
|
{ |
|
53
|
|
|
$e = $this->instantiateParentElement($parent); |
|
54
|
|
|
|
|
55
|
|
|
if ($this->id !== null) { |
|
56
|
|
|
$e->setAttribute('Id', $this->id); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
if ($this->type !== null) { |
|
60
|
|
|
$e->setAttribute('Type', $this->type); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
if ($this->mimeType !== null) { |
|
64
|
|
|
$e->setAttribute('MimeType', $this->mimeType); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
if ($this->encoding !== null) { |
|
68
|
|
|
$e->setAttribute('Encoding', $this->encoding); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
if ($this->encryptionMethod !== null) { |
|
72
|
|
|
$this->encryptionMethod->toXML($e); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
if ($this->keyInfo !== null) { |
|
76
|
|
|
$this->keyInfo->toXML($e); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
$this->cipherData->toXML($e); |
|
80
|
|
|
|
|
81
|
|
|
return $e; |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|