Search in sources :

Example 1 with JettyHTTPServerEngineFactory

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);
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Bus(org.apache.cxf.Bus) RouteBuilder(org.apache.camel.builder.RouteBuilder) JettyHTTPServerEngine(org.apache.cxf.transport.http_jetty.JettyHTTPServerEngine) JettyHTTPServerEngineFactory(org.apache.cxf.transport.http_jetty.JettyHTTPServerEngineFactory) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Example 2 with JettyHTTPServerEngineFactory

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();
}
Also used : Bus(org.apache.cxf.Bus) JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) JettyHTTPServerEngineFactory(org.apache.cxf.transport.http_jetty.JettyHTTPServerEngineFactory) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean) BeforeClass(org.junit.BeforeClass)

Example 3 with JettyHTTPServerEngineFactory

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());
}
Also used : Bus(org.apache.cxf.Bus) HashMap(java.util.HashMap) DoubleItPortTypeImpl(org.apache.coheigea.cxf.ocsp.common.DoubleItPortTypeImpl) PKIXBuilderParameters(java.security.cert.PKIXBuilderParameters) CertPathTrustManagerParameters(javax.net.ssl.CertPathTrustManagerParameters) X509CertSelector(java.security.cert.X509CertSelector) KeyStore(java.security.KeyStore) TLSServerParameters(org.apache.cxf.configuration.jsse.TLSServerParameters) KeyManagerFactory(javax.net.ssl.KeyManagerFactory) TrustManagerFactory(javax.net.ssl.TrustManagerFactory) JettyHTTPServerEngineFactory(org.apache.cxf.transport.http_jetty.JettyHTTPServerEngineFactory) ClientAuthentication(org.apache.cxf.configuration.security.ClientAuthentication)

Example 4 with JettyHTTPServerEngineFactory

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);
}
Also used : JettyHTTPServerEngineFactory(org.apache.cxf.transport.http_jetty.JettyHTTPServerEngineFactory) File(java.io.File) KeyStore(java.security.KeyStore) KeyManager(javax.net.ssl.KeyManager) FileInputStream(java.io.FileInputStream) TLSServerParameters(org.apache.cxf.configuration.jsse.TLSServerParameters) KeyManagerFactory(javax.net.ssl.KeyManagerFactory)

Example 5 with JettyHTTPServerEngineFactory

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);
}
Also used : WorkManagerThreadPool(org.apache.cxf.jca.cxf.WorkManagerThreadPool) JettyHTTPServerEngine(org.apache.cxf.transport.http_jetty.JettyHTTPServerEngine) ArrayList(java.util.ArrayList) JettyHTTPServerEngineFactory(org.apache.cxf.transport.http_jetty.JettyHTTPServerEngineFactory)

Aggregations

JettyHTTPServerEngineFactory (org.apache.cxf.transport.http_jetty.JettyHTTPServerEngineFactory)8 Bus (org.apache.cxf.Bus)6 TLSServerParameters (org.apache.cxf.configuration.jsse.TLSServerParameters)4 JettyHTTPServerEngine (org.apache.cxf.transport.http_jetty.JettyHTTPServerEngine)4 KeyStore (java.security.KeyStore)3 KeyManagerFactory (javax.net.ssl.KeyManagerFactory)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 ClientAuthentication (org.apache.cxf.configuration.security.ClientAuthentication)2 Test (org.junit.Test)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 StringReader (java.io.StringReader)1 PKIXBuilderParameters (java.security.cert.PKIXBuilderParameters)1 X509CertSelector (java.security.cert.X509CertSelector)1 TreeMap (java.util.TreeMap)1 CertPathTrustManagerParameters (javax.net.ssl.CertPathTrustManagerParameters)1 KeyManager (javax.net.ssl.KeyManager)1 TrustManagerFactory (javax.net.ssl.TrustManagerFactory)1 JAXBElement (javax.xml.bind.JAXBElement)1