Search in sources :

Example 1 with TLSServerParametersConfig

use of org.apache.cxf.configuration.jsse.TLSServerParametersConfig in project cxf by apache.

the class JettyHTTPServerEngineFactoryHolder method init.

public void init() {
    try {
        Element element = StaxUtils.read(new StringReader(parsedElement)).getDocumentElement();
        JettyHTTPServerEngineFactoryConfigType config = getJaxbObject(element, JettyHTTPServerEngineFactoryConfigType.class);
        Bus defaultBus = BusFactory.getDefaultBus();
        factory = new JettyHTTPServerEngineFactory(defaultBus);
        Map<String, ThreadingParameters> threadingParametersMap = new TreeMap<String, ThreadingParameters>();
        if (config.getIdentifiedThreadingParameters() != null) {
            for (ThreadingParametersIdentifiedType threads : config.getIdentifiedThreadingParameters()) {
                ThreadingParameters rThreads = new ThreadingParameters();
                String id = threads.getId();
                rThreads.setMaxThreads(threads.getThreadingParameters().getMaxThreads());
                rThreads.setMinThreads(threads.getThreadingParameters().getMinThreads());
                rThreads.setThreadNamePrefix(threads.getThreadingParameters().getThreadNamePrefix());
                threadingParametersMap.put(id, rThreads);
            }
            factory.setThreadingParametersMap(threadingParametersMap);
        }
        // SSL
        Map<String, TLSServerParameters> sslMap = new TreeMap<String, TLSServerParameters>();
        if (config.getIdentifiedTLSServerParameters() != null) {
            for (TLSServerParametersIdentifiedType t : config.getIdentifiedTLSServerParameters()) {
                try {
                    TLSServerParameters parameter = new TLSServerParametersConfig(t.getTlsServerParameters());
                    sslMap.put(t.getId(), parameter);
                } catch (Exception e) {
                    throw new RuntimeException("Could not configure TLS for id " + t.getId(), e);
                }
            }
            factory.setTlsServerParametersMap(sslMap);
        }
        // Engines
        List<JettyHTTPServerEngine> engineList = new ArrayList<>();
        for (JettyHTTPServerEngineConfigType engine : config.getEngine()) {
            JettyHTTPServerEngine eng = new JettyHTTPServerEngine(factory.getMBeanContainer(), engine.getHost(), engine.getPort());
            if (engine.getConnector() != null && connectorMap != null) {
                // we need to setup the Connector from the connectorMap
                Connector connector = connectorMap.get(engine.getPort().toString());
                if (connector != null) {
                    eng.setConnector(connector);
                } else {
                    throw new RuntimeException("Could not find the connector instance for engine with port" + engine.getPort().toString());
                }
            }
            if (engine.getHandlers() != null && handlersMap != null) {
                List<Handler> handlers = handlersMap.get(engine.getPort().toString());
                if (handlers != null) {
                    eng.setHandlers(handlers);
                } else {
                    throw new RuntimeException("Could not find the handlers instance for engine with port" + engine.getPort().toString());
                }
            }
            if (engine.isContinuationsEnabled() != null) {
                eng.setContinuationsEnabled(engine.isContinuationsEnabled());
            }
            if (engine.getHost() != null && !StringUtils.isEmpty(engine.getHost())) {
                eng.setHost(engine.getHost());
            }
            if (engine.getMaxIdleTime() != null) {
                eng.setMaxIdleTime(engine.getMaxIdleTime());
            }
            if (engine.getPort() != null) {
                eng.setPort(engine.getPort());
            }
            if (engine.isReuseAddress() != null) {
                eng.setReuseAddress(engine.isReuseAddress());
            }
            if (engine.isSessionSupport() != null) {
                eng.setSessionSupport(engine.isSessionSupport());
            }
            if (engine.getThreadingParameters() != null) {
                ThreadingParametersType threads = engine.getThreadingParameters();
                ThreadingParameters rThreads = new ThreadingParameters();
                rThreads.setMaxThreads(threads.getMaxThreads());
                rThreads.setMinThreads(threads.getMinThreads());
                eng.setThreadingParameters(rThreads);
            }
            // eng.setServer(engine.getTlsServerParameters());
            if (engine.getTlsServerParameters() != null) {
                TLSServerParameters parameter = null;
                try {
                    parameter = new TLSServerParametersConfig(engine.getTlsServerParameters());
                    eng.setTlsServerParameters(parameter);
                } catch (Exception e) {
                    throw new RuntimeException("Could not configure TLS for engine on  " + eng.getHost() + ":" + eng.getPort(), e);
                }
            }
            eng.finalizeConfig();
            engineList.add(eng);
        }
        factory.setEnginesList(engineList);
        // Unravel this completely.
        factory.initComplete();
    } catch (Exception e) {
        throw new RuntimeException("Could not process configuration.", e);
    }
}
Also used : Bus(org.apache.cxf.Bus) ThreadingParameters(org.apache.cxf.transport.http_jetty.ThreadingParameters) JettyHTTPServerEngineConfigType(org.apache.cxf.transports.http_jetty.configuration.JettyHTTPServerEngineConfigType) Connector(org.eclipse.jetty.server.Connector) ThreadingParametersType(org.apache.cxf.transports.http_jetty.configuration.ThreadingParametersType) JAXBElement(javax.xml.bind.JAXBElement) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) Handler(org.eclipse.jetty.server.Handler) JettyHTTPServerEngineFactoryConfigType(org.apache.cxf.transports.http_jetty.configuration.JettyHTTPServerEngineFactoryConfigType) TreeMap(java.util.TreeMap) TLSServerParameters(org.apache.cxf.configuration.jsse.TLSServerParameters) TLSServerParametersConfig(org.apache.cxf.configuration.jsse.TLSServerParametersConfig) JAXBException(javax.xml.bind.JAXBException) ThreadingParametersIdentifiedType(org.apache.cxf.transports.http_jetty.configuration.ThreadingParametersIdentifiedType) StringReader(java.io.StringReader) JettyHTTPServerEngine(org.apache.cxf.transport.http_jetty.JettyHTTPServerEngine) JettyHTTPServerEngineFactory(org.apache.cxf.transport.http_jetty.JettyHTTPServerEngineFactory) TLSServerParametersIdentifiedType(org.apache.cxf.transports.http_jetty.configuration.TLSServerParametersIdentifiedType)

Example 2 with TLSServerParametersConfig

use of org.apache.cxf.configuration.jsse.TLSServerParametersConfig in project cxf by apache.

the class JettySpringTypesFactory method toTLSServerParamenters.

private static Map<String, TLSServerParameters> toTLSServerParamenters(List<TLSServerParametersIdentifiedType> list) {
    Map<String, TLSServerParameters> map = new TreeMap<String, TLSServerParameters>();
    for (TLSServerParametersIdentifiedType t : list) {
        try {
            TLSServerParameters parameter = new TLSServerParametersConfig(t.getTlsServerParameters());
            map.put(t.getId(), parameter);
        } catch (Exception e) {
            throw new RuntimeException("Could not configure TLS for id " + t.getId(), e);
        }
    }
    return map;
}
Also used : TreeMap(java.util.TreeMap) TLSServerParameters(org.apache.cxf.configuration.jsse.TLSServerParameters) TLSServerParametersConfig(org.apache.cxf.configuration.jsse.TLSServerParametersConfig) JAXBException(javax.xml.bind.JAXBException) TLSServerParametersIdentifiedType(org.apache.cxf.transports.http_jetty.configuration.TLSServerParametersIdentifiedType)

Example 3 with TLSServerParametersConfig

use of org.apache.cxf.configuration.jsse.TLSServerParametersConfig in project cxf by apache.

the class NettyHttpServerEngineFactoryHolder method init.

public void init() {
    try {
        Element element = StaxUtils.read(new StringReader(parsedElement)).getDocumentElement();
        NettyHttpServerEngineFactoryConfigType config = (NettyHttpServerEngineFactoryConfigType) getJaxbObject(element, NettyHttpServerEngineFactoryConfigType.class);
        factory = new NettyHttpServerEngineFactory();
        Map<String, ThreadingParameters> threadingParametersMap = new TreeMap<String, ThreadingParameters>();
        if (config.getIdentifiedThreadingParameters() != null) {
            for (ThreadingParametersIdentifiedType threads : config.getIdentifiedThreadingParameters()) {
                ThreadingParameters rThreads = new ThreadingParameters();
                String id = threads.getId();
                rThreads.setThreadPoolSize(threads.getThreadingParameters().getThreadPoolSize());
                threadingParametersMap.put(id, rThreads);
            }
            factory.setThreadingParametersMap(threadingParametersMap);
        }
        // SSL
        Map<String, TLSServerParameters> sslMap = new TreeMap<String, TLSServerParameters>();
        if (config.getIdentifiedTLSServerParameters() != null) {
            for (TLSServerParametersIdentifiedType t : config.getIdentifiedTLSServerParameters()) {
                try {
                    TLSServerParameters parameter = new TLSServerParametersConfig(t.getTlsServerParameters());
                    sslMap.put(t.getId(), parameter);
                } catch (Exception e) {
                    throw new RuntimeException("Could not configure TLS for id " + t.getId(), e);
                }
            }
            factory.setTlsServerParameters(sslMap);
        }
        // Engines
        List<NettyHttpServerEngine> engineList = new ArrayList<>();
        for (NettyHttpServerEngineConfigType engine : config.getEngine()) {
            NettyHttpServerEngine eng = new NettyHttpServerEngine();
            if (engine.getHost() != null && !StringUtils.isEmpty(engine.getHost())) {
                eng.setHost(engine.getHost());
            }
            if (engine.getReadIdleTime() != null) {
                eng.setReadIdleTime(engine.getReadIdleTime());
            }
            if (engine.getWriteIdleTime() != null) {
                eng.setWriteIdleTime(engine.getWriteIdleTime());
            }
            if (engine.getMaxChunkContentSize() != null) {
                eng.setMaxChunkContentSize(engine.getMaxChunkContentSize());
            }
            if (engine.getPort() != null) {
                eng.setPort(engine.getPort());
            }
            if (engine.isSessionSupport() != null) {
                eng.setSessionSupport(engine.isSessionSupport());
            }
            if (engine.getThreadingParameters() != null) {
                ThreadingParametersType threads = engine.getThreadingParameters();
                ThreadingParameters rThreads = new ThreadingParameters();
                rThreads.setThreadPoolSize(threads.getThreadPoolSize());
                eng.setThreadingParameters(rThreads);
            }
            // eng.setServer(engine.getTlsServerParameters());
            if (engine.getTlsServerParameters() != null) {
                TLSServerParameters parameter = null;
                try {
                    parameter = new TLSServerParametersConfig(engine.getTlsServerParameters());
                    eng.setTlsServerParameters(parameter);
                } catch (Exception e) {
                    throw new RuntimeException("Could not configure TLS for engine on  " + eng.getHost() + ":" + eng.getPort(), e);
                }
            }
            eng.finalizeConfig();
            engineList.add(eng);
        }
        factory.setEnginesList(engineList);
        // Unravel this completely.
        factory.initComplete();
    } catch (Exception e) {
        throw new RuntimeException("Could not process configuration.", e);
    }
}
Also used : NettyHttpServerEngineFactory(org.apache.cxf.transport.http.netty.server.NettyHttpServerEngineFactory) ThreadingParameters(org.apache.cxf.transport.http.netty.server.ThreadingParameters) ThreadingParametersType(org.apache.cxf.transports.http_netty_server.configuration.ThreadingParametersType) NettyHttpServerEngineFactoryConfigType(org.apache.cxf.transports.http_netty_server.configuration.NettyHttpServerEngineFactoryConfigType) JAXBElement(javax.xml.bind.JAXBElement) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) TreeMap(java.util.TreeMap) TLSServerParameters(org.apache.cxf.configuration.jsse.TLSServerParameters) TLSServerParametersConfig(org.apache.cxf.configuration.jsse.TLSServerParametersConfig) JAXBException(javax.xml.bind.JAXBException) NettyHttpServerEngine(org.apache.cxf.transport.http.netty.server.NettyHttpServerEngine) NettyHttpServerEngineConfigType(org.apache.cxf.transports.http_netty_server.configuration.NettyHttpServerEngineConfigType) ThreadingParametersIdentifiedType(org.apache.cxf.transports.http_netty_server.configuration.ThreadingParametersIdentifiedType) StringReader(java.io.StringReader) TLSServerParametersIdentifiedType(org.apache.cxf.transports.http_netty_server.configuration.TLSServerParametersIdentifiedType)

Example 4 with TLSServerParametersConfig

use of org.apache.cxf.configuration.jsse.TLSServerParametersConfig in project cxf by apache.

the class UndertowSpringTypesFactory method toTLSServerParamenters.

private static Map<String, TLSServerParameters> toTLSServerParamenters(List<TLSServerParametersIdentifiedType> list) {
    Map<String, TLSServerParameters> map = new TreeMap<String, TLSServerParameters>();
    for (TLSServerParametersIdentifiedType t : list) {
        try {
            TLSServerParameters parameter = new TLSServerParametersConfig(t.getTlsServerParameters());
            map.put(t.getId(), parameter);
        } catch (Exception e) {
            throw new RuntimeException("Could not configure TLS for id " + t.getId(), e);
        }
    }
    return map;
}
Also used : TreeMap(java.util.TreeMap) TLSServerParameters(org.apache.cxf.configuration.jsse.TLSServerParameters) TLSServerParametersConfig(org.apache.cxf.configuration.jsse.TLSServerParametersConfig) JAXBException(javax.xml.bind.JAXBException) TLSServerParametersIdentifiedType(org.apache.cxf.transports.http_undertow.configuration.TLSServerParametersIdentifiedType)

Example 5 with TLSServerParametersConfig

use of org.apache.cxf.configuration.jsse.TLSServerParametersConfig in project cxf by apache.

the class NettySpringTypesFactory method toTLSServerParamenters.

private static Map<String, TLSServerParameters> toTLSServerParamenters(List<TLSServerParametersIdentifiedType> list) {
    Map<String, TLSServerParameters> map = new TreeMap<String, TLSServerParameters>();
    for (TLSServerParametersIdentifiedType t : list) {
        try {
            TLSServerParameters parameter = new TLSServerParametersConfig(t.getTlsServerParameters());
            map.put(t.getId(), parameter);
        } catch (Exception e) {
            throw new RuntimeException("Could not configure TLS for id " + t.getId(), e);
        }
    }
    return map;
}
Also used : TreeMap(java.util.TreeMap) TLSServerParameters(org.apache.cxf.configuration.jsse.TLSServerParameters) TLSServerParametersConfig(org.apache.cxf.configuration.jsse.TLSServerParametersConfig) JAXBException(javax.xml.bind.JAXBException) TLSServerParametersIdentifiedType(org.apache.cxf.transports.http_netty_server.configuration.TLSServerParametersIdentifiedType)

Aggregations

TreeMap (java.util.TreeMap)6 JAXBException (javax.xml.bind.JAXBException)6 TLSServerParameters (org.apache.cxf.configuration.jsse.TLSServerParameters)6 TLSServerParametersConfig (org.apache.cxf.configuration.jsse.TLSServerParametersConfig)6 StringReader (java.io.StringReader)3 ArrayList (java.util.ArrayList)3 JAXBElement (javax.xml.bind.JAXBElement)3 Element (org.w3c.dom.Element)3 TLSServerParametersIdentifiedType (org.apache.cxf.transports.http_jetty.configuration.TLSServerParametersIdentifiedType)2 TLSServerParametersIdentifiedType (org.apache.cxf.transports.http_netty_server.configuration.TLSServerParametersIdentifiedType)2 TLSServerParametersIdentifiedType (org.apache.cxf.transports.http_undertow.configuration.TLSServerParametersIdentifiedType)2 Bus (org.apache.cxf.Bus)1 NettyHttpServerEngine (org.apache.cxf.transport.http.netty.server.NettyHttpServerEngine)1 NettyHttpServerEngineFactory (org.apache.cxf.transport.http.netty.server.NettyHttpServerEngineFactory)1 ThreadingParameters (org.apache.cxf.transport.http.netty.server.ThreadingParameters)1 JettyHTTPServerEngine (org.apache.cxf.transport.http_jetty.JettyHTTPServerEngine)1 JettyHTTPServerEngineFactory (org.apache.cxf.transport.http_jetty.JettyHTTPServerEngineFactory)1 ThreadingParameters (org.apache.cxf.transport.http_jetty.ThreadingParameters)1 CXFUndertowHttpHandler (org.apache.cxf.transport.http_undertow.CXFUndertowHttpHandler)1 ThreadingParameters (org.apache.cxf.transport.http_undertow.ThreadingParameters)1