logger.info( "Using a common session. Connection information is obtained from client preferences" );
session = ip.getCommonSession();
}
// Test the connection to the MKS Integrity Server
Command ping = new Command( Command.SI, "connect" );
CmdRunner cmdRunner = session.createCmdRunner();
// Initialize the command runner with valid connection information
if ( null != host && host.length() > 0 )
{
cmdRunner.setDefaultHostname( host );
}
if ( portNum > 0 )
{
cmdRunner.setDefaultPort( portNum );
}
if ( null != user && user.length() > 0 )
{
cmdRunner.setDefaultUsername( user );
}
if ( null != paswd && paswd.length() > 0 )
{
cmdRunner.setDefaultPassword( paswd );
}
// Execute the connection
Response res = cmdRunner.execute( ping );
logger.debug( res.getCommandString() + " returned exit code " + res.getExitCode() );
// Initialize class variables based on the connection information
hostName = res.getConnectionHostname();
port = res.getConnectionPort();
userName = res.getConnectionUsername();
password = paswd;
cmdRunner.release();
logger.info( "Successfully established connection " + userName + "@" + hostName + ":" + port );
return res;
}