| @@ 126-148 (lines=23) @@ | ||
| 123 | * |
|
| 124 | * @param XMLSecurityKey $key The encryption key. |
|
| 125 | */ |
|
| 126 | public function encryptNameId(XMLSecurityKey $key) |
|
| 127 | { |
|
| 128 | /* First create a XML representation of the NameID. */ |
|
| 129 | $doc = DOMDocumentFactory::create(); |
|
| 130 | $root = $doc->createElement('root'); |
|
| 131 | $doc->appendChild($root); |
|
| 132 | Utils::addNameId($root, $this->nameId); |
|
| 133 | $nameId = $root->firstChild; |
|
| 134 | ||
| 135 | Utils::getContainer()->debugMessage($nameId, 'encrypt'); |
|
| 136 | ||
| 137 | /* Encrypt the NameID. */ |
|
| 138 | $enc = new XMLSecEnc(); |
|
| 139 | $enc->setNode($nameId); |
|
| 140 | $enc->type = XMLSecEnc::Element; |
|
| 141 | ||
| 142 | $symmetricKey = new XMLSecurityKey(XMLSecurityKey::AES128_CBC); |
|
| 143 | $symmetricKey->generateSessionKey(); |
|
| 144 | $enc->encryptKey($key, $symmetricKey); |
|
| 145 | ||
| 146 | $this->encryptedNameId = $enc->encryptNode($symmetricKey); |
|
| 147 | $this->nameId = null; |
|
| 148 | } |
|
| 149 | ||
| 150 | /** |
|
| 151 | * Decrypt the NameID in the LogoutRequest. |
|
| @@ 746-770 (lines=25) @@ | ||
| 743 | * |
|
| 744 | * @param XMLSecurityKey $key The encryption key. |
|
| 745 | */ |
|
| 746 | public function encryptNameId(XMLSecurityKey $key) |
|
| 747 | { |
|
| 748 | /* First create a XML representation of the NameID. */ |
|
| 749 | $doc = DOMDocumentFactory::create(); |
|
| 750 | $root = $doc->createElement('root'); |
|
| 751 | $doc->appendChild($root); |
|
| 752 | Utils::addNameId($root, $this->nameId); |
|
| 753 | $nameId = $root->firstChild; |
|
| 754 | ||
| 755 | Utils::getContainer()->debugMessage($nameId, 'encrypt'); |
|
| 756 | ||
| 757 | /* Encrypt the NameID. */ |
|
| 758 | $enc = new XMLSecEnc(); |
|
| 759 | $enc->setNode($nameId); |
|
| 760 | // @codingStandardsIgnoreStart |
|
| 761 | $enc->type = XMLSecEnc::Element; |
|
| 762 | // @codingStandardsIgnoreEnd |
|
| 763 | ||
| 764 | $symmetricKey = new XMLSecurityKey(XMLSecurityKey::AES128_CBC); |
|
| 765 | $symmetricKey->generateSessionKey(); |
|
| 766 | $enc->encryptKey($key, $symmetricKey); |
|
| 767 | ||
| 768 | $this->encryptedNameId = $enc->encryptNode($symmetricKey); |
|
| 769 | $this->nameId = null; |
|
| 770 | } |
|
| 771 | ||
| 772 | /** |
|
| 773 | * Decrypt the NameId of the subject in the assertion. |
|
| @@ 620-644 (lines=25) @@ | ||
| 617 | * |
|
| 618 | * @param XMLSecurityKey $key The encryption key. |
|
| 619 | */ |
|
| 620 | public function encryptNameId(XMLSecurityKey $key) |
|
| 621 | { |
|
| 622 | /* First create a XML representation of the NameID. */ |
|
| 623 | $doc = new \DOMDocument(); |
|
| 624 | $root = $doc->createElement('root'); |
|
| 625 | $doc->appendChild($root); |
|
| 626 | Utils::addNameId($root, $this->nameId); |
|
| 627 | $nameId = $root->firstChild; |
|
| 628 | ||
| 629 | Utils::getContainer()->debugMessage($nameId, 'encrypt'); |
|
| 630 | ||
| 631 | /* Encrypt the NameID. */ |
|
| 632 | $enc = new XMLSecEnc(); |
|
| 633 | $enc->setNode($nameId); |
|
| 634 | // @codingStandardsIgnoreStart |
|
| 635 | $enc->type = XMLSecEnc::Element; |
|
| 636 | // @codingStandardsIgnoreEnd |
|
| 637 | ||
| 638 | $symmetricKey = new XMLSecurityKey(XMLSecurityKey::AES128_CBC); |
|
| 639 | $symmetricKey->generateSessionKey(); |
|
| 640 | $enc->encryptKey($key, $symmetricKey); |
|
| 641 | ||
| 642 | $this->encryptedNameId = $enc->encryptNode($symmetricKey); |
|
| 643 | $this->nameId = null; |
|
| 644 | } |
|
| 645 | ||
| 646 | /** |
|
| 647 | * Decrypt the NameId of the subject in the assertion. |
|