if (ks != null) {
keyStore = ks;
if (password != null) {
pwd = (char[]) password.clone();
} else {
pwd = new char[0];
}
} else {
keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
String keyStoreName = AccessController
.doPrivileged(new java.security.PrivilegedAction<String>() {
public String run() {
return System.getProperty("javax.net.ssl.keyStore");
}
});
String keyStorePwd = null;
if (keyStoreName == null || keyStoreName.equalsIgnoreCase("NONE")
|| keyStoreName.length() == 0) {
try {
keyStore.load(null, null);
} catch (IOException e) {
throw new KeyStoreException(e);
} catch (CertificateException e) {
throw new KeyStoreException(e);
}
} else {
keyStorePwd = AccessController
.doPrivileged(new java.security.PrivilegedAction<String>() {
public String run() {
return System
.getProperty("javax.net.ssl.keyStorePassword");
}
});
if (keyStorePwd == null) {
pwd = new char[0];
} else {
pwd = keyStorePwd.toCharArray();
}
try {
keyStore.load(new FileInputStream(new File(keyStoreName)),
pwd);
} catch (FileNotFoundException e) {
throw new KeyStoreException(e);
} catch (IOException e) {
throw new KeyStoreException(e);
} catch (CertificateException e) {
throw new KeyStoreException(e);
}
}
}