| @@ 672-696 (lines=25) @@ | ||
| 669 | * |
|
| 670 | * @param XMLSecurityKey $key The encryption key. |
|
| 671 | */ |
|
| 672 | public function encryptNameId(XMLSecurityKey $key) |
|
| 673 | { |
|
| 674 | /* First create a XML representation of the NameID. */ |
|
| 675 | $doc = DOMDocumentFactory::create(); |
|
| 676 | $root = $doc->createElement('root'); |
|
| 677 | $doc->appendChild($root); |
|
| 678 | Utils::addNameId($root, $this->nameId); |
|
| 679 | $nameId = $root->firstChild; |
|
| 680 | ||
| 681 | Utils::getContainer()->debugMessage($nameId, 'encrypt'); |
|
| 682 | ||
| 683 | /* Encrypt the NameID. */ |
|
| 684 | $enc = new XMLSecEnc(); |
|
| 685 | $enc->setNode($nameId); |
|
| 686 | // @codingStandardsIgnoreStart |
|
| 687 | $enc->type = XMLSecEnc::Element; |
|
| 688 | // @codingStandardsIgnoreEnd |
|
| 689 | ||
| 690 | $symmetricKey = new XMLSecurityKey(XMLSecurityKey::AES128_CBC); |
|
| 691 | $symmetricKey->generateSessionKey(); |
|
| 692 | $enc->encryptKey($key, $symmetricKey); |
|
| 693 | ||
| 694 | $this->encryptedNameId = $enc->encryptNode($symmetricKey); |
|
| 695 | $this->nameId = null; |
|
| 696 | } |
|
| 697 | ||
| 698 | /** |
|
| 699 | * Decrypt the NameId of the subject in the assertion. |
|
| @@ 605-629 (lines=25) @@ | ||
| 602 | * |
|
| 603 | * @param XMLSecurityKey $key The encryption key. |
|
| 604 | */ |
|
| 605 | public function encryptNameId(XMLSecurityKey $key) |
|
| 606 | { |
|
| 607 | /* First create a XML representation of the NameID. */ |
|
| 608 | $doc = new \DOMDocument(); |
|
| 609 | $root = $doc->createElement('root'); |
|
| 610 | $doc->appendChild($root); |
|
| 611 | Utils::addNameId($root, $this->nameId); |
|
| 612 | $nameId = $root->firstChild; |
|
| 613 | ||
| 614 | Utils::getContainer()->debugMessage($nameId, 'encrypt'); |
|
| 615 | ||
| 616 | /* Encrypt the NameID. */ |
|
| 617 | $enc = new XMLSecEnc(); |
|
| 618 | $enc->setNode($nameId); |
|
| 619 | // @codingStandardsIgnoreStart |
|
| 620 | $enc->type = XMLSecEnc::Element; |
|
| 621 | // @codingStandardsIgnoreEnd |
|
| 622 | ||
| 623 | $symmetricKey = new XMLSecurityKey(XMLSecurityKey::AES128_CBC); |
|
| 624 | $symmetricKey->generateSessionKey(); |
|
| 625 | $enc->encryptKey($key, $symmetricKey); |
|
| 626 | ||
| 627 | $this->encryptedNameId = $enc->encryptNode($symmetricKey); |
|
| 628 | $this->nameId = null; |
|
| 629 | } |
|
| 630 | ||
| 631 | /** |
|
| 632 | * Decrypt the NameId of the subject in the assertion. |
|
| @@ 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. |
|