// FIXME EXPORT CONTROL
Provider.Service service;
for (Iterator it1 = Services.getProvidersList().iterator(); it1
.hasNext();) {
service = Engine.door.getService((Provider) it1.next(),
"SSLContext");
if (service != null) {
try {
SSLContext con = new ContextImpl(
(SSLContextSpi) service.newInstance(null),
service.getProvider(),
service.getAlgorithm());
//TODO javax.net.ssl.keyStoreProvider, javax.net.ssl.trustStoreProvider system property
// find KeyStore, KeyManagers
KeyManager[] keyManagers = null;
KeyStore ks = KeyStore.getInstance(KeyStore
.getDefaultType());
String keystore = System
.getProperty("javax.net.ssl.keyStore");
String keystorepwd = System
.getProperty("javax.net.ssl.keyStorePassword");
char[] pwd = null;
if (keystorepwd != null) {
pwd = keystorepwd.toCharArray();
}
if (keystore != null) {
FileInputStream fis = new java.io.FileInputStream(
keystore);
ks.load(fis, pwd);
fis.close();
KeyManagerFactory kmf;
String kmfAlg = Security
.getProperty("ssl.KeyManagerFactory.algorithm");
if (kmfAlg == null) {
kmfAlg = "SunX509";
}
kmf = KeyManagerFactory.getInstance(kmfAlg);
kmf.init(ks, pwd);
keyManagers = kmf.getKeyManagers();
}
// find TrustStore, TrustManagers
TrustManager[] trustManagers = null;
keystore = System.getProperty("javax.net.ssl.trustStore");
keystorepwd = System
.getProperty("javax.net.ssl.trustStorePassword");
pwd = null;
if (keystorepwd != null) {
pwd = keystorepwd.toCharArray();
}
//TODO Defaults: jssecacerts; cacerts
if (keystore != null) {
FileInputStream fis = new java.io.FileInputStream(
keystore);
ks.load(fis, pwd);
fis.close();
TrustManagerFactory tmf;
String tmfAlg = Security
.getProperty("ssl.TrustManagerFactory.algorithm");
if (tmfAlg == null) {
tmfAlg = "PKIX";
}
tmf = TrustManagerFactory.getInstance(tmfAlg);
tmf.init(ks);
trustManagers = tmf.getTrustManagers();
}
con.init(keyManagers, trustManagers, null);
return con;
} catch (Exception e) {
// e.printStackTrace();
// ignore and try another
}
}
}
return null;