beautypg.com

Api authentication, Pattern acl api – Google Search Appliance Policy ACL API Developers Guide User Manual

Page 6

background image

Google Search Appliance: Policy ACL API Developer’s Guide

Policy ACL API Developer’s Guide

6

gdata-client-meta-1.0.jar

gdata-gsa-meta-1.0.jar

You can then use the JAR files in your application.

API Authentication

Before making API calls with the Java client library, you must construct a new GsaService object or a
GsaClient object. The GsaClient object provides a simplified interface to the functionality in
GsaService object. Please note that for the Group and Member API (see “Group and Member API” on
page 9)
, the GsaClient object cannot be used.

In the constructor that follows, replace myUserId and myPassword with your Admin Console
authentication information:

// Creates GsaService object
GsaService service = new GsaService("google-adminfeed-1", "http", gsaAddr,
gsaPort);
service.setUserCredentials("myUserId", "myPassword");
// Or creates GsaClient object
GsaClient myClient = new GsaClient(gsaAddr, gsaPort, "myUserId", "myPassword"));

Pattern ACL API

The code in the sections that follow specifies the URL pattern for a rule.

Creating an ACL Rule

To create an ACL rule:

GsaEntry entry = new GsaEntry();
entry.addGsaContent("urlPattern", "http://example.com");
entry.addGsaContent("acl", "group:testGroup user:john");
myClient.insertEntry("policyAcls", entry);