Author: jaz
Date: Mon Apr 16 15:49:11 2007
New Revision: 529428
URL:
http://svn.apache.org/viewvc?view=rev&rev=529428Log:
now uses the new hostname verifier code
Modified:
ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/URLConnector.java
Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/URLConnector.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/URLConnector.java?view=diff&rev=529428&r1=529427&r2=529428==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/URLConnector.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/URLConnector.java Mon Apr 16 15:49:11 2007
@@ -38,11 +38,13 @@
private URL url = null;
private String clientCertAlias = null;
private boolean timedOut = false;
+ private int hostCertLevel = 2;
- protected URLConnector() {}
- protected URLConnector(URL url, String clientCertAlias) {
+ protected URLConnector() {}
+ protected URLConnector(URL url, String clientCertAlias, int hostCertLevel) {
this.clientCertAlias = clientCertAlias;
this.url = url;
+ this.hostCertLevel = hostCertLevel;
}
protected synchronized URLConnection openConnection(int timeout) throws IOException {
@@ -73,15 +75,15 @@
}
public static URLConnection openConnection(URL url, int timeout) throws IOException {
- return openConnection(url, timeout, null);
+ return openConnection(url, timeout, null, SSLUtil.HOSTCERT_NORMAL_CHECK);
}
public static URLConnection openConnection(URL url, String clientCertAlias) throws IOException {
- return openConnection(url, 30000, clientCertAlias);
+ return openConnection(url, 30000, clientCertAlias, SSLUtil.HOSTCERT_NORMAL_CHECK);
}
- public static URLConnection openConnection(URL url, int timeout, String clientCertAlias) throws IOException {
- URLConnector uc = new URLConnector(url, clientCertAlias);
+ public static URLConnection openConnection(URL url, int timeout, String clientCertAlias, int hostCertLevel) throws IOException {
+ URLConnector uc = new URLConnector(url, clientCertAlias, hostCertLevel);
return uc.openConnection(timeout);
}
@@ -95,6 +97,10 @@
HttpsURLConnection scon = (HttpsURLConnection) con;
try {
scon.setSSLSocketFactory(SSLUtil.getSSLSocketFactory(clientCertAlias));
+ HostnameVerifier hv = SSLUtil.getHostnameVerifier(hostCertLevel);
+ if (hv != null) {
+ scon.setHostnameVerifier(hv);
+ }
} catch (GeneralSecurityException gse) {
Debug.logError(gse, module);
}