Logging in

The logging in example shows how to establish an API session using the APIFactory class.

The logging in example shows how to call the getSession method that is defined by the APIFactory class. The getSession method takes the user credentials (username and password) and the server name and port.

String username;
String password;
String server;
int port;
.
.
.
ApiSession session = null;
try {
//it is assumed that the argument values have been set
session = ApiFactory.getSession(username, password, server, port);
} catch (IcosException ie) {
ie.printStackTrace();
System.err.println(ie.getNestedExceptionStackTrace());
} catch (Exception e) {
e.printStackTrace();
}
if (
session == null) {
System.out.println("Login failed!");
System.exit(1);
}