use of javax.net.ssl.SSLParameters in project rest.li by linkedin.
the class TestHttpNettyClient method testClientPipelineFactory3Fail.
// Test that cannot set protocols in SSLParameters that don't have any match in
// SSLContext.
// This in fact tests HttpClientPipelineFactory constructor through HttpNettyClient
// constructor.
@Test
public void testClientPipelineFactory3Fail() throws NoSuchAlgorithmException {
String[] requestedProtocols = { "Unsupported" };
SSLParameters sslParameters = new SSLParameters();
sslParameters.setProtocols(requestedProtocols);
try {
new HttpClientBuilder(_eventLoop, _scheduler).setSSLContext(SSLContext.getDefault()).setSSLParameters(sslParameters).buildRest();
} catch (IllegalArgumentException e) {
// Check exception message to make sure it's the expected one.
Assert.assertEquals(e.getMessage(), "None of the requested protocols: [Unsupported] are found in SSLContext");
}
}
use of javax.net.ssl.SSLParameters in project rest.li by linkedin.
the class TestHttpNettyClient method testClientPipelineFactory3Pass.
// Test that can set protocols in SSLParameters that have at least one match in
// SSLContext.
// This in fact tests HttpClientPipelineFactory constructor through HttpNettyClient
// constructor.
@Test
public void testClientPipelineFactory3Pass() throws NoSuchAlgorithmException {
String[] requestedProtocols = { "Unsupported", "TLSv1" };
SSLParameters sslParameters = new SSLParameters();
sslParameters.setProtocols(requestedProtocols);
new HttpClientBuilder(_eventLoop, _scheduler).setSSLContext(SSLContext.getDefault()).setSSLParameters(sslParameters).buildRest();
}
use of javax.net.ssl.SSLParameters in project rest.li by linkedin.
the class SimpleLoadBalancerStateTest method reset.
public void reset(boolean useSSL) {
_executorService = new SynchronousExecutorService();
_uriRegistry = new MockStore<UriProperties>();
_clusterRegistry = new MockStore<ClusterProperties>();
_serviceRegistry = new MockStore<ServiceProperties>();
_clientFactories = new HashMap<String, TransportClientFactory>();
_loadBalancerStrategyFactories = new HashMap<String, LoadBalancerStrategyFactory<? extends LoadBalancerStrategy>>();
_loadBalancerStrategyFactories.put("random", new RandomLoadBalancerStrategyFactory());
_loadBalancerStrategyFactories.put("degraderV3", new DegraderLoadBalancerStrategyFactoryV3());
try {
_sslContext = SSLContext.getDefault();
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
_sslParameters = new SSLParameters();
if (useSSL) {
_clientFactories.put("https", new SimpleLoadBalancerTest.DoNothingClientFactory());
_state = new SimpleLoadBalancerState(_executorService, _uriRegistry, _clusterRegistry, _serviceRegistry, _clientFactories, _loadBalancerStrategyFactories, _sslContext, _sslParameters, true);
} else {
_clientFactories.put("http", new SimpleLoadBalancerTest.DoNothingClientFactory());
_state = new SimpleLoadBalancerState(_executorService, _uriRegistry, _clusterRegistry, _serviceRegistry, _clientFactories, _loadBalancerStrategyFactories);
}
FutureCallback<None> callback = new FutureCallback<None>();
_state.start(callback);
try {
callback.get();
} catch (Exception e) {
Assert.fail("State start failed", e);
}
}
use of javax.net.ssl.SSLParameters in project undertow by undertow-io.
the class JDK9AlpnProvider method setProtocols.
@Override
public SSLEngine setProtocols(SSLEngine engine, String[] protocols) {
SSLParameters sslParameters = engine.getSSLParameters();
try {
JDK_9_ALPN_METHODS.setApplicationProtocols().invoke(sslParameters, (Object) protocols);
} catch (IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException(e);
}
engine.setSSLParameters(sslParameters);
return engine;
}
use of javax.net.ssl.SSLParameters in project keywhiz by square.
the class EndpointIdentificationSocketFactory method prepareSocket.
private Socket prepareSocket(Socket socket) {
SSLSocket sslSocket = (SSLSocket) socket;
SSLParameters parameters = sslSocket.getSSLParameters();
parameters.setEndpointIdentificationAlgorithm("LDAPS");
sslSocket.setSSLParameters(parameters);
return sslSocket;
}
Aggregations