Security through the Java ACI API NG

This section contains example code that demonstrates how to use the Java ACI API NG to obtain a securityinfo string for a user and perform queries against IDOL.

The sample code makes the following assumptions:

  • The IDOL components have been deployed in a Kerberos environment.
  • You have configured your JVM to work in a Kerberos environment. For information about how to do this, refer to the Java documentation, for example: http://docs.oracle.com/javase/7/docs/technotes/guides/security/.
  • The sample code requests the details required, for example a user name and the query text, on the command line. You can modify this so that the information is obtained in a suitable way.

 

The sample code first creates an AciService to use for communicating with IDOL components. For more information about creating an ACI service, refer to the ACI API Programming Guide.

    // Create the AciService to use when communicating with IDOL...
    final AciService aciService = new AciServiceImpl(
            new GssAciHttpClientImpl(new HttpClientFactory().createInstance()),
            new GssAciServerDetails(serviceName, host, port)
    );

The sample code then obtains a securityinfo string:

   final Document document = aciService.executeAction(
            new AciParameters(
                  new AciParameter(AciConstants.PARAM_ACTION, "UserRead"),
                  new AciParameter("UserName", userName),
                  new AciParameter("SecurityInfo", true)
            ),
            new DocumentProcessor()
    );

After extracting the securityinfo string from the XML response, the sample code then sends a query to the IDOL Content component:

   final Document results = aciService.executeAction(
          new AciParameters(
                 new AciParameter(AciConstants.PARAM_ACTION, "Query"),
                 new AciParameter("Text", queryText),
                 new AciParameter("combine", "simple"),
                 new AciParameter("maxResults", 10),
                 new AciParameter("totalResults", true),
                 new AciParameter("print", "none"),
                 new AciParameter("summary", "ParagraphConcept"),
                 new AciParameter("characters", 400),
                 new AciParameter("anyLanguage", true),
                 new AciParameter("outputEncoding", "utf8"),
                 new AciParameter("SecurityInfo", securityInfo)
          ),
          new DocumentProcessor()
    );

The sample code prints information about the result documents to the command line. You can modify this to suit your requirements.