public function setAssertion(Assertion $assertion, XMLSecurityKey $key) : void
    {
        $xml = $assertion->toXML();

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

        $enc = new XMLSecEnc();
        $enc->setNode($xml);
        $enc->type = XMLSecEnc::Element;

        switch ($key->type) {
            case XMLSecurityKey::TRIPLEDES_CBC:
            case XMLSecurityKey::AES128_CBC:
            case XMLSecurityKey::AES192_CBC:
            case XMLSecurityKey::AES256_CBC:
                $symmetricKey = $key;
                break;

            case XMLSecurityKey::RSA_1_5:
            case XMLSecurityKey::RSA_OAEP_MGF1P:
                $symmetricKey = new XMLSecurityKey(XMLSecurityKey::AES128_CBC);
                $symmetricKey->generateSessionKey();

                $enc->encryptKey($key, $symmetricKey);

                break;

            default:
                throw new \Exception('Unknown key type for encryption: '.$key->type);
        }

        /**
         * @var \DOMElement encryptedData
         * @psalm-suppress UndefinedClass
         */
        $this->encryptedData = $enc->encryptNode($symmetricKey);
    }
public function setAssertion(Assertion $assertion, XMLSecurityKey $key) : void
    {
        $xml = $assertion->toXML();

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

        $enc = new XMLSecEnc();
        $enc->setNode($xml);
        $enc->type = XMLSecEnc::Element;

        switch ($key->type) {
            case XMLSecurityKey::TRIPLEDES_CBC:
            case XMLSecurityKey::AES128_CBC:
            case XMLSecurityKey::AES192_CBC:
            case XMLSecurityKey::AES256_CBC:
                $symmetricKey = $key;
                break;

            case XMLSecurityKey::RSA_1_5:
            case XMLSecurityKey::RSA_OAEP_MGF1P:
                $symmetricKey = new XMLSecurityKey(XMLSecurityKey::AES128_CBC);
                $symmetricKey->generateSessionKey();

                $enc->encryptKey($key, $symmetricKey);

                break;

            default:
                throw new \Exception('Unknown key type for encryption: '.$key->type);
        }

        /**
         * @var \DOMElement encryptedData
         * @psalm-suppress UndefinedClass
         */
        $this->encryptedData = $enc->encryptNode($symmetricKey);
    }
public function setAssertion ( Assertion $ assertion , XMLSecurityKey $ key ) : void { $ xml = $ assertion -> toXML ( ) ; Utils :: getContainer ( ) -> debugMessage ( $ xml , 'encrypt' ) ; $ enc = new XMLSecEnc ( ) ; $ enc -> setNode ( $ xml ) ; $ enc -> type = XMLSecEnc :: Element ; switch ( $ key -> type ) { case XMLSecurityKey :: TRIPLEDES_CBC : case XMLSecurityKey :: AES128_CBC : case XMLSecurityKey :: AES192_CBC : case XMLSecurityKey :: AES256_CBC : $ symmetricKey = $ key ; break ; case XMLSecurityKey :: RSA_1_5 : case XMLSecurityKey :: RSA_OAEP_MGF1P : $ symmetricKey = new XMLSecurityKey ( XMLSecurityKey :: AES128_CBC ) ; $ symmetricKey -> generateSessionKey ( ) ; $ enc -> encryptKey ( $ key , $ symmetricKey ) ; break ; default : throw new \ Exception ( 'Unknown key type for encryption: ' . $ key -> type ) ; } /**
         * @var \DOMElement encryptedData
         * @psalm-suppress UndefinedClass
         */ $ this -> encryptedData = $ enc -> encryptNode ( $ symmetricKey ) ; }
Set the assertion.

@param \SAML2\Assertion $assertion The assertion.
@param XMLSecurityKey  $key       The key we should use to encrypt the assertion.
@throws \Exception
@return void
Set the assertion .