We are really excited to see the Nexpose community coming up with all sorts of cool and useful ways to automate Nexpose via our APIs. Since we have published our Ruby and .Net API client libraries, we have had some requests for a Java library as well. And now we have open sourced a Java based library for accessing the Nexpose API.  This library is BSD licensed so feel free to use it in any project.

We have also included examples on how you would use this library.

Using this library is extremely simple, there are 3 basic steps needed to perform an operation with this API:

1. Login:

URL url = new URL("https://<nexpose_netaddress>:<nexpose_port>");
APISession session = new APISession(url, "xml", APISupportedVersion.V1_2, <username>, <password>));
session.login(null);  

2. Perform an action:

Example: Starting a site scan

try
{
   APIResponse response = session.siteScanRequest(sessionID, null, siteID);
   String scanID = response.grab("/SiteScanResponse/Scan/@scan-id");
   System.out.println("Started site scan with scan-id: " + scanID);
}
catch (Exception e)
{
   System.out.println("Could not start scan for site with ID: " + siteID);
}

3. Logout:

session.logout(session.getSessionID(), null);

As this is an open source project we look forward to contributions from the community.

Please post here on the community site if you have any questions.