use of org.apache.cxf.transport.http_jetty.JettyHTTPServerEngineFactory in project camel by apache.
the class CxfCustomerStartStopTest method startAndStopService.
@Test
public void startAndStopService() throws Exception {
CamelContext context = new DefaultCamelContext();
// start a server
context.addRoutes(new RouteBuilder() {
public void configure() {
from("cxf:http://localhost:" + PORT1 + "/test?serviceClass=org.apache.camel.component.cxf.HelloService").to("log:endpoint");
}
});
context.start();
Thread.sleep(300);
context.stop();
Bus bus = BusFactory.getDefaultBus();
JettyHTTPServerEngineFactory factory = bus.getExtension(JettyHTTPServerEngineFactory.class);
JettyHTTPServerEngine engine = factory.retrieveJettyHTTPServerEngine(PORT1);
assertNotNull("Jetty engine should be found there", engine);
// Need to call the bus shutdown ourselves.
String orig = System.setProperty("org.apache.cxf.transports.http_jetty.DontClosePort", "false");
bus.shutdown(true);
System.setProperty("org.apache.cxf.transports.http_jetty.DontClosePort", orig == null ? "true" : "false");
engine = factory.retrieveJettyHTTPServerEngine(PORT1);
assertNull("Jetty engine should be removed", engine);
}
use of org.apache.cxf.transport.http_jetty.JettyHTTPServerEngineFactory in project camel by apache.
the class CxfProducerSessionTest method startServer.
@BeforeClass
public static void startServer() throws Exception {
// start a simple front service
JaxWsServiceFactoryBean svrFBean = new JaxWsServiceFactoryBean();
svrFBean.setServiceClass(EchoService.class);
JaxWsServerFactoryBean svrBean = new JaxWsServerFactoryBean(svrFBean);
svrBean.setAddress(SIMPLE_SERVER_ADDRESS);
svrBean.setServiceClass(EchoService.class);
svrBean.setServiceBean(new EchoServiceSessionImpl());
// make the Jetty server support sessions
Bus bus = BusFactory.newInstance().createBus();
JettyHTTPServerEngineFactory jettyFactory = bus.getExtension(JettyHTTPServerEngineFactory.class);
jettyFactory.createJettyHTTPServerEngine(PORT, "http").setSessionSupport(true);
svrBean.setBus(bus);
svrBean.create();
}
use of org.apache.cxf.transport.http_jetty.JettyHTTPServerEngineFactory in project testcases by coheigea.
the class ClientAuthServer method run.
protected void run() {
Bus busLocal = BusFactory.getDefaultBus(true);
setBus(busLocal);
String address = "https://localhost:" + TLSOCSPClientAuthTest.PORT + "/doubleit/services/doubleittlsocspclientauth";
try {
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
keyStore.load(ClassLoaderUtils.getResourceAsStream("servicestore.jks", this.getClass()), "sspass".toCharArray());
PKIXBuilderParameters param = new PKIXBuilderParameters(keyStore, new X509CertSelector());
param.setRevocationEnabled(true);
tmf.init(new CertPathTrustManagerParameters(param));
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
kmf.init(keyStore, "skpass".toCharArray());
ClientAuthentication clientAuthentication = new ClientAuthentication();
clientAuthentication.setRequired(true);
clientAuthentication.setWant(true);
TLSServerParameters tlsParams = new TLSServerParameters();
tlsParams.setTrustManagers(tmf.getTrustManagers());
tlsParams.setKeyManagers(kmf.getKeyManagers());
tlsParams.setClientAuthentication(clientAuthentication);
Map<String, TLSServerParameters> map = new HashMap<>();
map.put("tlsId", tlsParams);
JettyHTTPServerEngineFactory factory = busLocal.getExtension(JettyHTTPServerEngineFactory.class);
factory.setTlsServerParametersMap(map);
factory.createJettyHTTPServerEngine("localhost", Integer.parseInt(TLSOCSPClientAuthTest.PORT), "https", "tlsId");
factory.initComplete();
} catch (Exception ex) {
ex.printStackTrace();
}
Endpoint.publish(address, new DoubleItPortTypeImpl());
}
use of org.apache.cxf.transport.http_jetty.JettyHTTPServerEngineFactory in project chuidiang-ejemplos by chuidiang.
the class Main method coinfigureJettyTLs.
public static void coinfigureJettyTLs() throws Exception {
/*
* create a JettyHTTPServerEngineFactory to handle the configuration of
* network port numbers for use with "HTTPS"
*/
JettyHTTPServerEngineFactory jettyHTTPServerEngineFactory = new JettyHTTPServerEngineFactory();
// load the key store containing the server certificate
File keyStoreFile = new File(KEY_STORE_PATH_NAME);
KeyStore keyStore = KeyStore.getInstance("PKCS12");
keyStore.load(new FileInputStream(keyStoreFile), KEY_STORE_PASSWORD.toCharArray());
// create a key manager to handle the server private/public key pair
KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
keyManagerFactory.init(keyStore, PRIVATE_KEY_PASSWORD.toCharArray());
KeyManager[] keyManager = keyManagerFactory.getKeyManagers();
// set the TLSServerParameters on theJettyHTTPServerEngineFactory
TLSServerParameters tLSServerParameters = new TLSServerParameters();
tLSServerParameters.setKeyManagers(keyManager);
jettyHTTPServerEngineFactory.setTLSServerParametersForPort(9443, tLSServerParameters);
}
use of org.apache.cxf.transport.http_jetty.JettyHTTPServerEngineFactory in project cxf by apache.
the class EJBEndpoint method setWorkManagerThreadPoolToJetty.
protected void setWorkManagerThreadPoolToJetty(Bus bus, String baseAddress) {
JettyHTTPServerEngineFactory engineFactory = bus.getExtension(JettyHTTPServerEngineFactory.class);
int port = getAddressPort(baseAddress);
if (engineFactory.retrieveJettyHTTPServerEngine(port) != null) {
return;
}
JettyHTTPServerEngine engine = new JettyHTTPServerEngine();
engine.setThreadPool(new WorkManagerThreadPool(getWorkManager()));
engine.setPort(port);
List<JettyHTTPServerEngine> engineList = new ArrayList<>();
engineList.add(engine);
engineFactory.setEnginesList(engineList);
}
Aggregations