use of org.apache.cxf.configuration.jsse.TLSServerParameters in project cxf by apache.
the class NettyHttpServerEngineTest method testHttps.
@Test
public void testHttps() throws Exception {
Map<String, TLSServerParameters> tlsParamsMap = new HashMap<>();
tlsParamsMap.put(Integer.toString(PORT2), new TLSServerParameters());
factory.setTlsServerParameters(tlsParamsMap);
factory.createNettyHttpServerEngine(PORT2, "https");
NettyHttpServerEngineFactory.destroyForPort(PORT2);
}
use of org.apache.cxf.configuration.jsse.TLSServerParameters in project cxf by apache.
the class UndertowHTTPServerEngineTest method testHttpAndHttps.
@Test
public void testHttpAndHttps() throws Exception {
UndertowHTTPServerEngine engine = factory.createUndertowHTTPServerEngine(PORT1, "http");
assertTrue("Protocol must be http", "http".equals(engine.getProtocol()));
engine = new UndertowHTTPServerEngine();
engine.setPort(PORT2);
engine.setMaxIdleTime(30000);
engine.setTlsServerParameters(new TLSServerParameters());
engine.finalizeConfig();
List<UndertowHTTPServerEngine> list = new ArrayList<>();
list.add(engine);
factory.setEnginesList(list);
engine = factory.createUndertowHTTPServerEngine(PORT2, "https");
UndertowHTTPTestHandler handler1 = new UndertowHTTPTestHandler("string1", true);
engine.addServant(new URL("https://localhost:" + PORT2 + "/test"), handler1);
assertTrue("Protocol must be https", "https".equals(engine.getProtocol()));
assertEquals("Get the wrong maxIdleTime.", 30000, engine.getMaxIdleTime());
factory.setTLSServerParametersForPort(PORT1, new TLSServerParameters());
engine = factory.createUndertowHTTPServerEngine(PORT1, "https");
assertTrue("Protocol must be https", "https".equals(engine.getProtocol()));
factory.setTLSServerParametersForPort(PORT3, new TLSServerParameters());
engine = factory.createUndertowHTTPServerEngine(PORT3, "https");
assertTrue("Protocol must be https", "https".equals(engine.getProtocol()));
UndertowHTTPServerEngineFactory.destroyForPort(PORT1);
UndertowHTTPServerEngineFactory.destroyForPort(PORT2);
UndertowHTTPServerEngineFactory.destroyForPort(PORT3);
}
use of org.apache.cxf.configuration.jsse.TLSServerParameters in project cxf by apache.
the class HTTPUndertowTransportActivator method updated.
public void updated(String pid, Dictionary<String, ?> properties) throws ConfigurationException {
if (pid == null) {
return;
}
int port = Integer.parseInt((String) properties.get("port"));
String host = (String) properties.get("host");
try {
TLSServerParameters tls = createTlsServerParameters(properties);
if (tls != null) {
factory.setTLSServerParametersForPort(host, port, tls);
} else {
factory.createUndertowHTTPServerEngine(host, port, "http");
}
UndertowHTTPServerEngine e = factory.retrieveUndertowHTTPServerEngine(port);
configure(e, properties);
} catch (GeneralSecurityException e) {
throw new ConfigurationException(null, null, e);
} catch (IOException e) {
throw new ConfigurationException(null, null, e);
}
}
use of org.apache.cxf.configuration.jsse.TLSServerParameters 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;
}
use of org.apache.cxf.configuration.jsse.TLSServerParameters in project cxf by apache.
the class TrustServerNoSpring method run.
protected void run() {
Bus busLocal = BusFactory.getDefaultBus(true);
setBus(busLocal);
String address = "https://localhost:" + TrustManagerTest.PORT3 + "/SoapContext/HttpsPort";
try {
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
keyStore.load(ClassLoaderUtils.getResourceAsStream("keys/Bethal.jks", this.getClass()), "password".toCharArray());
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
kmf.init(keyStore, "password".toCharArray());
TLSServerParameters tlsParams = new TLSServerParameters();
tlsParams.setKeyManagers(kmf.getKeyManagers());
ClientAuthentication clientAuthentication = new ClientAuthentication();
clientAuthentication.setRequired(false);
clientAuthentication.setWant(true);
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(TrustManagerTest.PORT3), "https", "tlsId");
factory.initComplete();
} catch (Exception ex) {
ex.printStackTrace();
}
Endpoint.publish(address, new GreeterImpl());
}
Aggregations