List of usage examples for org.apache.http.impl.nio.reactor SSLIOSessionHandler SSLIOSessionHandler
SSLIOSessionHandler
From source file:org.apache.axis2.transport.nhttp.HttpCoreNIOSSLSender.java
protected SSLIOSessionHandler getSSLIOSessionHandler(TransportOutDescription transportOut) throws AxisFault { final Parameter hostnameVerifier = transportOut.getParameter("HostnameVerifier"); return new SSLIOSessionHandler() { public void initalize(SSLEngine sslengine, HttpParams params) { }/*w w w.j av a 2s .c o m*/ public void verify(SocketAddress remoteAddress, SSLSession session) throws SSLException { String address = null; if (remoteAddress instanceof InetSocketAddress) { address = ((InetSocketAddress) remoteAddress).getHostName(); } else { address = remoteAddress.toString(); } boolean valid = false; if (hostnameVerifier != null) { if ("Strict".equals(hostnameVerifier.getValue())) { valid = HostnameVerifier.STRICT.verify(address, session); } else if ("AllowAll".equals(hostnameVerifier.getValue())) { valid = HostnameVerifier.ALLOW_ALL.verify(address, session); } else if ("DefaultAndLocalhost".equals(hostnameVerifier.getValue())) { valid = HostnameVerifier.DEFAULT_AND_LOCALHOST.verify(address, session); } } else { valid = HostnameVerifier.DEFAULT.verify(address, session); } if (!valid) { throw new SSLException("Host name verification failed for host : " + address); } } }; }
From source file:org.apache.axis2.transport.nhttp.HttpCoreNIOSSLListener.java
/** * Create the SSLIOSessionHandler to initialize the SSL session / engine, and request for * client authentication at the following levels, through an Axis2 transport configuration * parameter as follows://from ww w.java 2 s .co m * SSLVerifyClient - none, optional, require * * @param transportIn the Axis2 transport configuration * @return the SSLIOSessionHandler to be used * @throws AxisFault if a configuration error occurs */ protected SSLIOSessionHandler getSSLIOSessionHandler(TransportInDescription transportIn) throws AxisFault { final Parameter clientAuth = transportIn.getParameter("SSLVerifyClient"); return new SSLIOSessionHandler() { public void initalize(SSLEngine sslengine, HttpParams params) { if (clientAuth != null) { if ("optional".equals(clientAuth.getValue())) { sslengine.setWantClientAuth(true); } else if ("require".equals(clientAuth.getValue())) { sslengine.setNeedClientAuth(true); } } } public void verify(SocketAddress removeAddress, SSLSession session) throws SSLException { } }; }