@@ -0,0 +1,2920 @@
+package org.apache.camel.component.restlet;%0A%0Aimport org.apache.camel.Exchange;%0Aimport org.apache.camel.Processor;%0Aimport org.apache.camel.builder.RouteBuilder;%0Aimport org.apache.camel.impl.JndiRegistry;%0Aimport org.apache.camel.util.jsse.KeyManagersParameters;%0Aimport org.apache.camel.util.jsse.KeyStoreParameters;%0Aimport org.apache.camel.util.jsse.SSLContextParameters;%0A%0Aimport org.junit.Test;%0A%0Aimport java.io.File;%0A%0A/**%0A * Licensed to the Apache Software Foundation (ASF) under one or more%0A * contributor license agreements.  See the NOTICE file distributed with%0A * this work for additional information regarding copyright ownership.%0A * The ASF licenses this file to You under the Apache License, Version 2.0%0A * (the %22License%22); you may not use this file except in compliance with%0A * the License.  You may obtain a copy of the License at%0A * %3Cp%3E%0A * http://www.apache.org/licenses/LICENSE-2.0%0A * %3Cp%3E%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apublic class RestletProducerSSLTest extends RestletTestSupport %7B%0A%0A%09public static final String BODY = %22some body%22;%0A%0A%09@Override%0A%09protected JndiRegistry createRegistry() throws Exception %7B%0A%0A%09%09SSLContextParameters sslContextParameters = createSSLContext();%0A%0A%09%09JndiRegistry registry = super.createRegistry();%0A%09%09registry.bind(%22mySSLContextParameters%22, sslContextParameters);%0A%0A%09%09return registry;%0A%09%7D%0A%0A%09@Test%0A%09public void testRestletProducerComponentSSL() throws Exception %7B%0A%09%09String out = template.requestBody(%22direct:startWithEndpointSSL%22, %22neco%22, String.class);%0A%09%09assertEquals(BODY, out);%0A%09%7D%0A%0A%09@Override%0A%09protected RouteBuilder createRouteBuilder() throws Exception %7B%0A%09%09return new RouteBuilder() %7B%0A%09%09%09@Override%0A%09%09%09public void configure() throws Exception %7B%0A%09%09%09%09from(%22direct:startWithEndpointSSL%22).to(%22restlet:https://localhost:%22 + portNum + %22/?restletMethod=post&sslContextParameters=#mySSLContextParameters%22);%0A%0A%09%09%09%09from(%22restlet:https://localhost:%22 + portNum + %22/?restletMethods=post&sslContextParameters=#mySSLContextParameters%22)%0A%09%09%09%09%09%09.process(new Processor() %7B%0A%09%09%09%09%09%09%09public void process(Exchange exchange) throws Exception %7B%0A%09%09%09%09%09%09%09%09exchange.getOut().setBody(BODY);%0A%09%09%09%09%09%09%09%7D%0A%09%09%09%09%09%09%7D);%0A%09%09%09%7D%0A%09%09%7D;%0A%09%7D%0A%0A%09protected SSLContextParameters createSSLContext() %7B%0A%09%09KeyStoreParameters ksp = new KeyStoreParameters();%0A%09%09ksp.setResource(new File(%22src/test/resources/jsse/localhost.ks%22).getAbsolutePath());%0A%09%09ksp.setPassword(%22changeit%22);%0A%0A%09%09KeyManagersParameters kmp = new KeyManagersParameters();%0A%09%09kmp.setKeyPassword(%22changeit%22);%0A%09%09kmp.setKeyStore(ksp);%0A%0A%09%09SSLContextParameters sslContextParameters = new SSLContextParameters();%0A%09%09sslContextParameters.setKeyManagers(kmp);%0A%0A%09%09return sslContextParameters;%0A%09%7D%0A%7D%0A

Test SSL communication on Restlet producer