|
From: <bob...@us...> - 2003-09-09 04:06:28
|
Update of /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/transport
In directory sc8-pr-cvs1:/tmp/cvs-serv13696/src/hk/hku/cecid/phoenix/message/transport
Modified Files:
Http.java
Log Message:
add settings for SSL Server authentication.
However, the SSL Server authentication is not implemented yet.
Index: Http.java
===================================================================
RCS file: /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/transport/Http.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Http.java 21 Jun 2003 03:08:25 -0000 1.4
--- Http.java 9 Sep 2003 04:06:18 -0000 1.5
***************
*** 79,82 ****
--- 79,83 ----
import java.io.IOException;
import java.io.InputStream;
+ import java.io.File;
import java.io.OutputStream;
import java.net.HttpURLConnection;
***************
*** 88,91 ****
--- 89,96 ----
// import java.util.Map.Entry;
import java.util.StringTokenizer;
+ import javax.net.ssl.KeyManager;
+ import javax.net.ssl.TrustManager;
+ import javax.net.ssl.HostnameVerifier;
+ import javax.net.ssl.HttpsURLConnection;
import javax.xml.soap.MessageFactory;
// import javax.xml.soap.MimeHeader;
***************
*** 128,131 ****
--- 133,188 ----
encoding = s;
}
+ /*
+ HTTPS Connection settings
+ */
+ /*
+ Set the custom HostnameVerifier if it is set on the properties.
+ The HostnameVerifier is used for the case that the URL's hostname
+ and the server's identification hostname mismatch
+ */
+ logger.debug("Configure HTTPS");
+ String hostnameVerifierClassname = prop.get(
+ Constants.PROPERTY_SSL_HOSTNAME_VERIFIER);
+ if (hostnameVerifierClassname != null
+ && !hostnameVerifierClassname.equals("")) {
+ logger.debug("Use custom Hostname Verifier on SSL : "
+ + hostnameVerifierClassname);
+ HostnameVerifier hostnameVerifier = null;
+ try {
+ hostnameVerifier = (HostnameVerifier)
+ Class.forName(hostnameVerifierClassname).newInstance();
+ } catch (Exception e) {
+ String err = ErrorMessages.getMessage
+ (ErrorMessages.ERR_HERMES_INIT_ERROR, e.getMessage());
+ logger.error(err, e);
+ throw new InitializationException(err);
+ }
+ HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier);
+ }
+ /*
+ Get the trust certificates on SSL if it is set on the properties.
+ */
+ String trustedStorePath = prop.get
+ (Constants.PROPERTY_SSL_TRUST_KEY_STORE_PATH, "");
+ String trustedStoreFile = prop.get
+ (Constants.PROPERTY_SSL_TRUST_KEY_STORE_FILE);
+ String trustedStorePassword = prop.get
+ (Constants.PROPERTY_SSL_TRUST_KEY_STORE_PASSWORD, "");
+ if (trustedStorePath.equals("")) {
+ trustedStorePath = System.getProperty
+ (Constants.PROPERTY_USER_HOME);
+ }
+ String realTrustedStorePath = trustedStorePath + File.separator
+ + trustedStoreFile;
+ File realTrustStoreFile = new File(trustedStorePath + File.separator
+ + trustedStoreFile);
+ if (realTrustStoreFile.exists() && realTrustStoreFile.isFile()) {
+ logger.debug("Use SSL trusted keystore : " + realTrustStoreFile);
+ }
+ }
+
+ private static void configureHTTPS(KeyManager[] keyManagers,
+ TrustManager[] trustManagers) throws InitializationException {
+
}
|