return (auth == null) ? null : auth.getURI();
}
private void tryToConnect(String argURI, String driver, String user, String password, boolean secure)
throws DeploymentException {
DeploymentFactoryManager mgr = DeploymentFactoryManager.getInstance();
if (driver != null) {
loadDriver(driver, mgr);
} else {
mgr.registerDeploymentFactory(geronimoDeploymentFactory);
}
String useURI = argURI == null ? DeployUtils.getConnectionURI(null, null, secure) : argURI;
if (user == null && password == null) {
try {
SavedAuthentication savedAuthentication = DeployUtils.readSavedCredentials(useURI);
if (savedAuthentication != null) {
user = savedAuthentication.getUser();
password = new String(savedAuthentication.getPassword());
}
} catch (IOException e) {
System.out.println("Warning: " + e.getMessage());
}
}
if (secure) {
try {
Properties props = new Properties();
String keyStorePassword = null;
String trustStorePassword = null;
FileInputStream fstream = new FileInputStream(System.getProperty(KEYSTORE_TRUSTSTORE_PASSWORD_FILE,
DEFAULT_KEYSTORE_TRUSTSTORE_PASSWORD_FILE));
props.load(fstream);
keyStorePassword = (String) EncryptionManager.decrypt(props.getProperty("keyStorePassword"));
trustStorePassword = (String) EncryptionManager.decrypt(props.getProperty("trustStorePassword"));
fstream.close();
String value = System.getProperty("javax.net.ssl.keyStore", System.getProperty(GERONIMO_HOME)
+ DEFAULT_TRUSTSTORE_KEYSTORE_LOCATION);
String value1 = System.getProperty("javax.net.ssl.trustStore", System.getProperty(GERONIMO_HOME)
+ DEFAULT_TRUSTSTORE_KEYSTORE_LOCATION);
System.setProperty("javax.net.ssl.keyStore", value);
System.setProperty("javax.net.ssl.trustStore", value1);
System.setProperty("javax.net.ssl.keyStorePassword", keyStorePassword);
System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword);
} catch (IOException e) {
throw new DeploymentException("Unable to set KeyStorePassword and TrustStorePassword.", e);
}
}
if (user == null || password == null) {
try {
if (user == null) {
user = handler.getUsername();
}
if (password == null) {
password = handler.getPassword();
}
} catch (IOException e) {
throw new DeploymentException("Unable to prompt for login", e);
}
}
try {
manager = mgr.getDeploymentManager(useURI, user, password);
auth = new SavedAuthentication(useURI, user, password == null ? null : password.toCharArray());
} catch (AuthenticationFailedException e) {
// server's there, you just can't talk to it
throw new DeploymentException("Login Failed");
} catch (DeploymentManagerCreationException e) {