public function encryptNameId(XMLSecurityKey $key) : void
    {
        if ($this->nameId === null) {
            throw new \Exception('Cannot encrypt NameID, no NameID set.');
        }
        /* First create an XML representation of the NameID. */
        $doc = DOMDocumentFactory::create();
        $root = $doc->createElement('root');
        $doc->appendChild($root);
        $this->nameId->toXML($root);
        /** @var \DOMElement $nameId */
        $nameId = $root->firstChild;

        Utils::getContainer()->debugMessage($nameId, 'encrypt');

        /* Encrypt the NameID. */
        $enc = new XMLSecEnc();
        $enc->setNode($nameId);
        // @codingStandardsIgnoreStart
        $enc->type = XMLSecEnc::Element;
        // @codingStandardsIgnoreEnd

        $symmetricKey = new XMLSecurityKey(XMLSecurityKey::AES128_CBC);
        $symmetricKey->generateSessionKey();
        $enc->encryptKey($key, $symmetricKey);

        /**
         * @var \DOMElement encryptedNameId
         * @psalm-suppress UndefinedClass
         */
        $this->encryptedNameId = $enc->encryptNode($symmetricKey);
        $this->nameId = null;
    }
public function encryptNameId(XMLSecurityKey $key) : void
    {
        if ($this->nameId === null) {
            throw new \Exception('Cannot encrypt NameID, no NameID set.');
        }
        /* First create an XML representation of the NameID. */
        $doc = DOMDocumentFactory::create();
        $root = $doc->createElement('root');
        $doc->appendChild($root);
        $this->nameId->toXML($root);
        /** @var \DOMElement $nameId */
        $nameId = $root->firstChild;

        Utils::getContainer()->debugMessage($nameId, 'encrypt');

        /* Encrypt the NameID. */
        $enc = new XMLSecEnc();
        $enc->setNode($nameId);
        // @codingStandardsIgnoreStart
        $enc->type = XMLSecEnc::Element;
        // @codingStandardsIgnoreEnd

        $symmetricKey = new XMLSecurityKey(XMLSecurityKey::AES128_CBC);
        $symmetricKey->generateSessionKey();
        $enc->encryptKey($key, $symmetricKey);

        /**
         * @var \DOMElement encryptedNameId
         * @psalm-suppress UndefinedClass
         */
        $this->encryptedNameId = $enc->encryptNode($symmetricKey);
        $this->nameId = null;
    }
public function encryptNameId ( XMLSecurityKey $ key ) : void { if ( $ this -> nameId === null ) { throw new \ Exception ( 'Cannot encrypt NameID, no NameID set.' ) ; } /* First create an XML representation of the NameID. */ $ doc = DOMDocumentFactory :: create ( ) ; $ root = $ doc -> createElement ( 'root' ) ; $ doc -> appendChild ( $ root ) ; $ this -> nameId -> toXML ( $ root ) ; /** @var \DOMElement $nameId */ $ nameId = $ root -> firstChild ; Utils :: getContainer ( ) -> debugMessage ( $ nameId , 'encrypt' ) ; /* Encrypt the NameID. */ $ enc = new XMLSecEnc ( ) ; $ enc -> setNode ( $ nameId ) ; // @codingStandardsIgnoreStart $ enc -> type = XMLSecEnc :: Element ; // @codingStandardsIgnoreEnd $ symmetricKey = new XMLSecurityKey ( XMLSecurityKey :: AES128_CBC ) ; $ symmetricKey -> generateSessionKey ( ) ; $ enc -> encryptKey ( $ key , $ symmetricKey ) ; /**
         * @var \DOMElement encryptedNameId
         * @psalm-suppress UndefinedClass
         */ $ this -> encryptedNameId = $ enc -> encryptNode ( $ symmetricKey ) ; $ this -> nameId = null ; }
Encrypt the NameID in the Assertion.

@param XMLSecurityKey $key The encryption key.
@return void
Encrypt the NameID in the Assertion .