34 $data = Utils::xpQuery(
$xml,
'./xenc:EncryptedData');
35 if (count(
$data) === 0) {
36 throw new \Exception(
'Missing encrypted data in <saml:EncryptedAssertion>.');
37 } elseif (count(
$data) > 1) {
38 throw new \Exception(
'More than one encrypted data element in <saml:EncryptedAssertion>.');
40 $this->encryptedData =
$data[0];
54 Utils::getContainer()->debugMessage(
$xml,
'encrypt');
58 $enc->type = XMLSecEnc::Element;
61 case XMLSecurityKey::TRIPLEDES_CBC:
62 case XMLSecurityKey::AES128_CBC:
63 case XMLSecurityKey::AES192_CBC:
64 case XMLSecurityKey::AES256_CBC:
68 case XMLSecurityKey::RSA_1_5:
69 case XMLSecurityKey::RSA_OAEP_MGF1P:
71 $symmetricKey->generateSessionKey();
73 $enc->encryptKey($key, $symmetricKey);
78 throw new \Exception(
'Unknown key type for encryption: ' . $key->type);
81 $this->encryptedData = $enc->encryptNode($symmetricKey);
93 $assertionXML = Utils::decryptElement($this->encryptedData, $inputKey, $blacklist);
95 Utils::getContainer()->debugMessage($assertionXML,
'decrypt');
108 if ($parentElement === null) {
109 $document = DOMDocumentFactory::create();
110 $parentElement = $document;
112 $document = $parentElement->ownerDocument;
115 $root = $document->createElementNS(Constants::NS_SAML,
'saml:' .
'EncryptedAssertion');
116 $parentElement->appendChild(
$root);
118 $root->appendChild($document->importNode($this->encryptedData,
true));
__construct(\DOMElement $xml=null)
Constructor for SAML 2 encrypted assertions.
toXML(\DOMNode $parentElement=null)
Convert this encrypted assertion to an XML element.
getAssertion(XMLSecurityKey $inputKey, array $blacklist=array())
Retrieve the assertion.
toXML(\DOMNode $parentElement=null)
Convert this assertion to an XML element.
setAssertion(Assertion $assertion, XMLSecurityKey $key)
Set the assertion.