@Override
    public void marshal(Exchange exchange, Object graph, OutputStream stream) throws Exception {
        // Retrieve the message body as input stream
        InputStream is = exchange.getContext().getTypeConverter().mandatoryConvertTo(InputStream.class, graph);
        // and covert that to XML
        Document document = exchange.getContext().getTypeConverter().convertTo(Document.class, exchange, is);

        if (null != keyCipherAlgorithm
                && (keyCipherAlgorithm.equals(XMLCipher.RSA_v1dot5) || keyCipherAlgorithm.equals(XMLCipher.RSA_OAEP)
                        || keyCipherAlgorithm.equals(XMLCipher.RSA_OAEP_11))) {
            encryptAsymmetric(exchange, document, stream);
        } else if (null != recipientKeyAlias) {
            encryptAsymmetric(exchange, document, stream);
        } else {
            encryptSymmetric(exchange, document, stream);
        }
    }
@Test
    public void testPartialPayloadXMLElementEncryptionWithByteKeyAndAlgorithm() throws Exception {
        final byte[] bits192 = {
                (byte) 0x24, (byte) 0xf2, (byte) 0xd3, (byte) 0x45,
                (byte) 0xc0, (byte) 0x75, (byte) 0xb1, (byte) 0x00,
                (byte) 0x30, (byte) 0xd4, (byte) 0x3d, (byte) 0xf5,
                (byte) 0x6d, (byte) 0xaa, (byte) 0x7d, (byte) 0xc2,
                (byte) 0x85, (byte) 0x32, (byte) 0x2a, (byte) 0xb6,
                (byte) 0xfe, (byte) 0xed, (byte) 0xbe, (byte) 0xef };

        final Charset passCodeCharset = StandardCharsets.UTF_8;
        final String passCode = new String(bits192, passCodeCharset);
        byte[] bytes = passCode.getBytes(passCodeCharset);
        assertNotEquals(bits192.length, bytes.length);
        context.addRoutes(new RouteBuilder() {
            public void configure() {
                from("direct:start")
                        .marshal().xmlSecurity("//cheesesites/netherlands", false, bits192, XMLCipher.AES_192)
                        .to("mock:encrypted");
            }
        });
        xmlsecTestHelper.testEncryption(context);
    }