use of org.mozilla.jss.ssl.SSLSocket in project OpenAM by OpenRock.
the class HttpsClient method doConnect.
/**
* Overrides HTTP protocol handler method so that we return an SSL
* socket, not a TCP socket. This establishes a secure tunnel if
* appropriate.
*
* @param host the host to connect to
* @param port the port on that host.
* @exception IOException on errors including a host doesn't
* authenicate corectly.
* @exception UnknownHostException if "host" is unknown
*/
protected Socket doConnect(String host, int port) throws IOException {
String hostname = null;
try {
hostname = InetAddress.getByName(host).getHostName();
} catch (UnknownHostException e) {
if (debug.messageEnabled()) {
debug.message("Error : HttpsClient.doConnect ", e);
}
hostname = host;
}
if (secureTunnelHost == null || isNonProxyHost()) {
if (debug.messageEnabled()) {
debug.message("HttpsClient: doConnect(" + hostname + ", " + port + ")");
}
sslSocket = new SSLSocket(InetAddress.getByName(hostname), port, null, 0, new ApprovalCallback(hostname), this);
} else {
if (debug.messageEnabled()) {
debug.message("HttpsClient: doConnect through proxy " + secureTunnelHost + ":" + secureTunnelPort);
}
if (debug.messageEnabled()) {
debug.message("HttpsClient: doConnect(" + hostname + ", " + port + ")");
}
sslSocket = new SSLSocket(InetAddress.getByName("localhost"), JSSProxy.serverPort, null, 0, new ApprovalCallback(hostname), this);
Integer localport = new Integer(sslSocket.getLocalPort());
String info = secureTunnelHost + " " + secureTunnelPort + " " + host + " " + port;
JSSProxy.connectHashMap.put(localport, info);
}
return sslSocket;
}
Aggregations