Product Documentation

System APIs

Jun 14, 2016

The first step towards using NITRO is to establish a session with the NetScaler appliance and then authenticate the session by using the NetScaler administrator's credentials.

You must create an object of the com.citrix.netscaler.nitro.service.nitro_service class by specifying the NetScaler IP (NSIP) address and the protocol to connect to the appliance (HTTP or HTTPS). You then use this object and log on to the appliance by specifying the user name and the password of the NetScaler administrator.

Note: You must have a user account on that appliance. The configuration operations that you perform are limited by the administrative roles assigned to your account.

The following sample code establishes a session with a NetScaler appliance with IP address 10.102.29.60 by using the HTTPS protocol:

//Specify the NetScaler appliance IP address and protocol 
nitro_service ns_session = new nitro_service("10.102.29.60","https"); 
 
//Specify the login credentials 
ns_session.login("admin","verysecret");
Note: When using HTTPS, you must make sure that the root CA is added to the truststore. By default, NITRO validates the SSL certificate and verifies the hostname. To disable this validation, use the following:
ns_session.set_certvalidation(false); 
ns_session.set_hostnameverification(false);
Note: You can modify the timeout period by specifying a new timeout period (in seconds) in the login method. For example, to modify the timeout period to 60 minutes:
ns_session.login("admin","verysecret",3600);
Some points to note with regards to session timeout for NetScaler 10.5 and later versions:
  • When restricted timeout param is enabled, NITRO, by default, uses the timeout value that is configured for the logged in user. You can customize this value but it must be limited to the value specified for the user. If no value is specified for the user, the default timeout value of 15 minutes is used.
  • When restricted timeout param is not enabled, NITRO uses the default value of 30 minutes as session timeout.

You must use the nitro_service object in all further NITRO operations on the appliance. For example to save the configurations on the appliance, you must use the nitro_service object as follows:

ns_session.save_config();

The nitro_service class also provides APIs to perform other system-level operations such as enabling and disabling NetScaler features and modes, saving and clearing NetScaler configurations, setting the session timeout, setting the severity of the exceptions to be handled, setting the behavior of bulk operations, and disconnecting from the appliance.