Skip to content

Commit

Permalink
Modified HTTPConnection so it can be instanciated on Java 1.3 even th…
Browse files Browse the repository at this point in the history
…ough https is not supported.
  • Loading branch information
Pierre-Luc Paour committed Jun 13, 2003
1 parent 7ea24e8 commit 9258856
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
2 changes: 2 additions & 0 deletions ChangeLog
Expand Up @@ -11,6 +11,8 @@
* Fixed losing caption when selecting more than one picture.
* Fixed drag-n-dropping folders.
* Unhacked list selection.
* Modified HTTPConnection so it can be instanciated on Java 1.3
even though https is not supported.

2003-06-12 Pierre-Luc Paour <gallery@paour.com> (1.1-b3)

Expand Down
21 changes: 13 additions & 8 deletions HTTPClient/HTTPConnection.java
Expand Up @@ -320,11 +320,10 @@ public class HTTPConnection implements GlobalConstants, HTTPClientModuleConstant
private boolean allowUI;

/** JSSE's default socket factory */
private static SSLSocketFactory defaultSSLFactory =
(SSLSocketFactory) SSLSocketFactory.getDefault();
private static Object defaultSSLFactory = null;

/** JSSE's socket factory */
private SSLSocketFactory sslFactory;
private Object sslFactory = null;


static
Expand Down Expand Up @@ -519,6 +518,12 @@ public class HTTPConnection implements GlobalConstants, HTTPClientModuleConstant
}
catch (Exception e)
{ }

try {
defaultSSLFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
} catch (Throwable t) {
// probably class not found exception, for example on Java 1.3
}
}


Expand Down Expand Up @@ -1445,7 +1450,7 @@ public static void setDefaultSSLSocketFactory(SSLSocketFactory sslFactory)
*/
public static SSLSocketFactory getDefaultSSLSocketFactory()
{
return defaultSSLFactory;
return (SSLSocketFactory) defaultSSLFactory;
}

/**
Expand All @@ -1466,7 +1471,7 @@ public void setSSLSocketFactory(SSLSocketFactory sslFactory)
*/
public SSLSocketFactory getSSLSocketFactory()
{
return sslFactory;
return (SSLSocketFactory) sslFactory;
}

/**
Expand Down Expand Up @@ -1911,7 +1916,7 @@ private static final boolean addModule(Vector list, Class module, int pos)

// check if module implements HTTPClientModule
try
{ HTTPClientModule tmp = (HTTPClientModule) module.newInstance(); }
{ module.newInstance(); }
catch (RuntimeException re)
{ throw re; }
catch (Exception e)
Expand Down Expand Up @@ -2945,7 +2950,7 @@ Response sendRequest(Request req, int con_timeout)
}

sock.setSoTimeout(con_timeout);
sock = sslFactory.createSocket(sock, Host, Port, true);
sock = ((SSLSocketFactory) sslFactory).createSocket(sock, Host, Port, true);
checkCert(((SSLSocket) sock).getSession().
getPeerCertificateChain()[0], Host);
}
Expand Down Expand Up @@ -3306,7 +3311,7 @@ private static void checkCert(X509Certificate cert, String host)
if (Util.wildcardMatch(name, host))
return;

throw new SSLException("Name in certificate `" + name + "' does not " +
throw new IOException("Name in certificate `" + name + "' does not " +
"match host name `" + host + "'");
}

Expand Down

0 comments on commit 9258856

Please sign in to comment.