String getServerURI() {
return auth.uri;
}
private void tryToConnect(String argURI, String driver, String user, String password, boolean authPrompt) throws DeploymentException {
DeploymentFactoryManager mgr = DeploymentFactoryManager.getInstance();
if(driver != null) {
loadDriver(driver, mgr);
} else {
mgr.registerDeploymentFactory(new DeploymentFactoryImpl());
}
String useURI = argURI == null ? DEFAULT_URI : argURI;
if(authPrompt && user == null && password == null) {
File authFile = new File(System.getProperty("user.home"), ".geronimo-deployer");
if(authFile.exists() && authFile.canRead()) {
try {
Properties props = new Properties();
InputStream in = new BufferedInputStream(new FileInputStream(authFile));
props.load(in);
in.close();
String encryped = props.getProperty("login."+useURI);
if(encryped != null) {
if(encryped.startsWith("{Standard}")) {
SavedAuthentication auth = (SavedAuthentication) SimpleEncryption.decrypt(encryped.substring(10));
if(auth.uri.equals(useURI)) {
user = auth.user;
password = new String(auth.password);
}
} else if(encryped.startsWith("{Plain}")) {
int pos = encryped.indexOf("/");
user = encryped.substring(7, pos);
password = encryped.substring(pos+1);
} else {
System.out.println(DeployUtils.reformat("Unknown encryption used in saved login file", 4, 72));
}
}
} catch (IOException e) {
System.out.println(DeployUtils.reformat("Unable to read authentication from saved login file: "+e.getMessage(), 4, 72));
}
}
}
if(authPrompt && !useURI.equals(DEFAULT_URI) && user == null && password == null) {
// Non-standard URI, but no authentication information
doAuthPromptAndRetry(useURI, user, password);
return;
} else { // Standard URI with no auth, Non-standard URI with auth, or else this is the 2nd try already
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
if(authPrompt) {
doAuthPromptAndRetry(useURI, user, password);
return;