if (!conn.isOpen()) {
throw new IllegalArgumentException
("Connection must be open.");
}
final Scheme schm = schemeRegistry.getScheme(target.getSchemeName());
if (schm == null) {
throw new IllegalArgumentException
("Unknown scheme '" + target.getSchemeName() +
"' in target host.");
}
if (!(schm.getSocketFactory() instanceof SecureSocketFactory)) {
throw new IllegalArgumentException
("Target scheme (" + schm.getName() +
") must have secure socket factory.");
}
final SecureSocketFactory ssf =
(SecureSocketFactory)schm.getSocketFactory();
final Socket sock = ssf.createSocket
(conn.getSocket(), target.getHostName(), target.getPort(), true);
prepareSocket(sock, context, params);
final boolean secure = ssf.isSecure(sock);