Search in sources :

Example 1 with TLSServerParametersIdentifiedType

use of org.apache.cxf.transports.http_undertow.configuration.TLSServerParametersIdentifiedType in project cxf by apache.

the class UndertowSpringTypesFactory method createTLSServerParametersMap.

public Map<String, TLSServerParameters> createTLSServerParametersMap(String s, JAXBContext ctx) throws Exception {
    Document doc = StaxUtils.read(new StringReader(s));
    List<TLSServerParametersIdentifiedType> tlsServerParameters = UndertowSpringTypesFactory.parseListElement(doc.getDocumentElement(), new QName(UndertowHTTPServerEngineFactoryBeanDefinitionParser.HTTP_UNDERTOW_NS, "identifiedTLSServerParameters"), TLSServerParametersIdentifiedType.class, ctx);
    return toTLSServerParamenters(tlsServerParameters);
}
Also used : QName(javax.xml.namespace.QName) StringReader(java.io.StringReader) Document(org.w3c.dom.Document) TLSServerParametersIdentifiedType(org.apache.cxf.transports.http_undertow.configuration.TLSServerParametersIdentifiedType)

Example 2 with TLSServerParametersIdentifiedType

use of org.apache.cxf.transports.http_undertow.configuration.TLSServerParametersIdentifiedType 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 3 with TLSServerParametersIdentifiedType

use of org.apache.cxf.transports.http_undertow.configuration.TLSServerParametersIdentifiedType in project cxf by apache.

the class UndertowHTTPServerEngineFactoryHolder method init.

public void init() {
    try {
        Element element = StaxUtils.read(new StringReader(parsedElement)).getDocumentElement();
        UndertowHTTPServerEngineFactoryConfigType config = getJaxbObject(element, UndertowHTTPServerEngineFactoryConfigType.class);
        factory = new UndertowHTTPServerEngineFactory();
        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.setWorkerIOThreads(threads.getThreadingParameters().getWorkerIOThreads());
                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<UndertowHTTPServerEngine> engineList = new ArrayList<>();
        for (UndertowHTTPServerEngineConfigType engine : config.getEngine()) {
            UndertowHTTPServerEngine eng = new UndertowHTTPServerEngine();
            if (engine.getHandlers() != null && handlersMap != null) {
                List<CXFUndertowHttpHandler> 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.getThreadingParameters() != null) {
                ThreadingParametersType threads = engine.getThreadingParameters();
                ThreadingParameters rThreads = new ThreadingParameters();
                rThreads.setMaxThreads(threads.getMaxThreads());
                rThreads.setMinThreads(threads.getMinThreads());
                rThreads.setWorkerIOThreads(threads.getWorkerIOThreads());
                eng.setThreadingParameters(rThreads);
            }
            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 : UndertowHTTPServerEngine(org.apache.cxf.transport.http_undertow.UndertowHTTPServerEngine) ThreadingParameters(org.apache.cxf.transport.http_undertow.ThreadingParameters) ThreadingParametersType(org.apache.cxf.transports.http_undertow.configuration.ThreadingParametersType) JAXBElement(javax.xml.bind.JAXBElement) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) UndertowHTTPServerEngineFactoryConfigType(org.apache.cxf.transports.http_undertow.configuration.UndertowHTTPServerEngineFactoryConfigType) TreeMap(java.util.TreeMap) TLSServerParameters(org.apache.cxf.configuration.jsse.TLSServerParameters) TLSServerParametersConfig(org.apache.cxf.configuration.jsse.TLSServerParametersConfig) JAXBException(javax.xml.bind.JAXBException) CXFUndertowHttpHandler(org.apache.cxf.transport.http_undertow.CXFUndertowHttpHandler) UndertowHTTPServerEngineFactory(org.apache.cxf.transport.http_undertow.UndertowHTTPServerEngineFactory) ThreadingParametersIdentifiedType(org.apache.cxf.transports.http_undertow.configuration.ThreadingParametersIdentifiedType) UndertowHTTPServerEngineConfigType(org.apache.cxf.transports.http_undertow.configuration.UndertowHTTPServerEngineConfigType) StringReader(java.io.StringReader) TLSServerParametersIdentifiedType(org.apache.cxf.transports.http_undertow.configuration.TLSServerParametersIdentifiedType)

Aggregations

TLSServerParametersIdentifiedType (org.apache.cxf.transports.http_undertow.configuration.TLSServerParametersIdentifiedType)3 StringReader (java.io.StringReader)2 TreeMap (java.util.TreeMap)2 JAXBException (javax.xml.bind.JAXBException)2 TLSServerParameters (org.apache.cxf.configuration.jsse.TLSServerParameters)2 TLSServerParametersConfig (org.apache.cxf.configuration.jsse.TLSServerParametersConfig)2 ArrayList (java.util.ArrayList)1 JAXBElement (javax.xml.bind.JAXBElement)1 QName (javax.xml.namespace.QName)1 CXFUndertowHttpHandler (org.apache.cxf.transport.http_undertow.CXFUndertowHttpHandler)1 ThreadingParameters (org.apache.cxf.transport.http_undertow.ThreadingParameters)1 UndertowHTTPServerEngine (org.apache.cxf.transport.http_undertow.UndertowHTTPServerEngine)1 UndertowHTTPServerEngineFactory (org.apache.cxf.transport.http_undertow.UndertowHTTPServerEngineFactory)1 ThreadingParametersIdentifiedType (org.apache.cxf.transports.http_undertow.configuration.ThreadingParametersIdentifiedType)1 ThreadingParametersType (org.apache.cxf.transports.http_undertow.configuration.ThreadingParametersType)1 UndertowHTTPServerEngineConfigType (org.apache.cxf.transports.http_undertow.configuration.UndertowHTTPServerEngineConfigType)1 UndertowHTTPServerEngineFactoryConfigType (org.apache.cxf.transports.http_undertow.configuration.UndertowHTTPServerEngineFactoryConfigType)1 Document (org.w3c.dom.Document)1 Element (org.w3c.dom.Element)1