Write a Policy Management Application
Contents
casso10
Contents
To write a Policy Management application
- Establish a Connection to the Policy Server
- Obtain a Session Object
- Pass in the Session Object
- Make Policy Management API Requests
- Terminate the Administrator Session
The
CA Single Sign-On
SDK contains a sample of how to use the classes and methods in the Java Policy Management API.Establish a Connection to the Policy Server
To establish a connection to the Policy Server, use the SmApiConnection class of the Utilities package. This class holds the Agent API handle through which Java API requests are sent.
There are two types of connection handles in this class:
- Adefaultconnection handle. A default connection handle:
- Represents a single instance of an Agent API object.
- Is static across the process.
- Allows connections to the Agent API object from both Policy Management and DMS clients.
You can establish multiple connections to the Policy Server through the single Agent API object instance. - Auser-definedconnection handle. You can create multiple user-defined connection objects; each one can support multiple connections to the Policy Server.
Obtain a Session Object
A session object is obtained when a user or administrator successfully logs in. In this case, an administrator login is required, since only administrators can perform policy management.
To log in a
CA Single Sign-On
administrator and establish an administrator session, call the login() method in the SmApiSession class of the Utilities package.Once login is successful, the session object will hold a valid administrator session specification.
Pass in the Session Object
After obtaining a valid session, create a Policy Management API object by passing the session to the constructor of the SmPolicyApiImpl class—forexample:
SmPolicyApi policyApi = new SmPolicyApiImpl (apiSession);
In the example, policyApi is the new Policy Management API object and
apiSession
is the session obtained when the administrator successfully logged in.Make Policy Management API Requests
After you obtain a session object and create a Policy Management API object, you are ready to make Policy Management requests. Most of the methods in the Policy Management API are categorized according to the
CA Single Sign-On
object that a given method acts upon—for example, agents, policies, and rules.There is also a Utilities category for methods that perform services, such as cache and encryption key management. Use these categories to help you find a particular Policy Management API method to use in your custom policy management applications.
The methods in the policyapi package can only be called from a Siteminder administrator session.
Terminate the Administrator Session
When you are finished making Policy Management API requests, log out the administrator by calling the logout() method in the SmApiSession class of the Utilities package.
After you have called the logout() method, the connection handle becomes invalid. Do not reference it again.