}
}
private void tryToConnect(String uri, String driver, String host, Integer port, String user, String password, boolean secure) throws DeploymentException {
DeploymentFactoryManager mgr = DeploymentFactoryManager.getInstance();
if (driver != null) {
loadDriver(driver, mgr);
}
if (host != null || port != null || uri == null) {
uri = DeployUtils.getConnectionURI(host, port, secure);
}
if (user == null && password == null) {
try {
SavedAuthentication savedAuthentication = DeployUtils.readSavedCredentials(uri);
if (savedAuthentication != null) {
user = savedAuthentication.getUser();
password = new String(savedAuthentication.getPassword());
}
} catch (IOException e) {
System.out.println("Warning: " + e.getMessage());
}
}
if (secure) {
DeployUtils.setSecurityProperties();
}
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(uri, user, password);
auth = new SavedAuthentication(uri, 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) {