public Subject execute(ClientMain client, String username, String password, String host, int port, String transport)
throws Exception {
//add call to different subsystem if it exists
RemoteClient remoteClient;
if ((subsystem != null) && (subsystem.trim().equalsIgnoreCase("WSREMOTEAPI"))) {
remoteClient = new RemoteClient(transport, host, port, subsystem);
} else {
remoteClient = new RemoteClient(transport, host, port);
}
// in case transport was null, let the client tell us what it'll use
client.setTransport(remoteClient.getTransport());
client.setHost(host);
client.setPort(port);
client.setUser(username);
client.setPass(password);
Subject subject = remoteClient.login(username, password);
String versionUpdate = remoteClient.getServerVersionUpdate();
String version;
//Conditionally check for and apply update/patch version details
if ((versionUpdate != null) && (!versionUpdate.trim().isEmpty())) {
version = remoteClient.getServerVersion() + " " + versionUpdate + " ("
+ remoteClient.getServerBuildNumber() + ")";
} else {
version = remoteClient.getServerVersion() + " (" + remoteClient.getServerBuildNumber() + ")";
}
client.getPrintWriter().println("Remote server version is: " + version);
// this call has the side effect of setting bindings for the new remote client and its subject