setReadTimeout(con, timeout);
con.connect();
System.out.println(MessageFormat.format(Messages.getString("VPNLauncher.sysout.connectedTo"), new Object[] { url } )); //$NON-NLS-1$
XMLElement result = new XMLElement();
result.parseFromReader(new InputStreamReader(con.getInputStream()));
if (result.getName().equalsIgnoreCase("success")) { //$NON-NLS-1$
System.out.println(Messages.getString("VPNLauncher.sysout.syncOk")); //$NON-NLS-1$
/*
* TODO A nasty hack - If the returnTo points back to
* the VPN Client, then make sure the port is correct
* (the server would not have known the port for the
* client at the point the returnTO link was created).
*/
URL returnToUrl = returnTo.equals("") ? getDocumentBase() : new URL(getDocumentBase(), returnTo); //$NON-NLS-1$
if (returnToUrl.getProtocol().equals("http") && returnToUrl.getHost().equals("localhost") //$NON-NLS-1$ //$NON-NLS-2$
&& returnToUrl.getPort() == -1) {
returnToUrl = new URL(returnToUrl.getProtocol(), returnToUrl.getHost(), Integer.parseInt(result
.getAttribute("clientPort").toString()), returnToUrl.getFile()); //$NON-NLS-1$
}
returnToUrl = new URL(addRedirectParameter(returnToUrl.toExternalForm(),
"vpnMessage", appName + " launched.")); //$NON-NLS-1$ //$NON-NLS-2$
System.out.println(MessageFormat.format(Messages.getString("VPNLauncher.sysout.redirecting"), new Object[] { returnToUrl.toExternalForm() })); //$NON-NLS-1$
getAppletContext().showDocument(returnToUrl);
setMessage(Messages.getString("VPNLauncher.complete")); //$NON-NLS-1$
} else {
// Show an error message and kill the process
System.out.println(Messages.getString("VPNLauncher.sysout.failedSync")); //$NON-NLS-1$
System.out.println(result.getContent());
ProcessMonitor monitor = launcher.getApplicationType().getProcessMonitor();
if (monitor != null) {
// We cant kill the process as there may be error
// dialogs
// monitor.kill();