Previous Topic: Java API OverviewNext Topic: Agent API


Utilities Package

This section contains the following topics:

Purpose of the Utilities Package

Classes for Internal Use

Connection Class

Session Class

Result Class

Exception Class

Property Class

Purpose of the Utilities Package

If you plan to call functions in the Policy Management API or the DMS API, you must use the functions in the Utilities package to build your Java application.

The SmApiConnection, SmApiResult, SmApiSession, SmApiException, and SmProperty classes in the Utilities package provide services such as:

Classes for Internal Use

The Utilities package provides these classes for SiteMinder internal use only:

These classes are used internally to define methods in the Policy Management API and the DMS API.

Connection Class

Use the SmApiConnection class to create an API connection object and establish a connection between the Agent API and Policy Server. Depending upon the constructor you use, you can establish either a default connection or a user-defined connection.

The core methods of the SmApiConnection class are as follows:

Method

Description

getAgentApiConnection()

Retrieves the Agent API handle for the current connection. Use this handle when issuing subsequent Java API requests to the Policy Server.

isValidApiConnection()

Verifies whether a valid Agent API connection is available.

setAgentApiConnection()

Establishes a user-defined connection through the handle passed into the method. If null is passed, a static connection is established.

Note: Do not call the execute() method from your client application. This method is for internal use only.

Session Class

The Session class, SmApiSession, lets you create a session object by passing in a valid API connection and, depending upon the constructor you use, a session specification. (A session specification is also known as a session ticket).

The core methods of the SmApiSession class are as follows:

Method

Description

getApiConnection()

Retrieves the SmApiConnection object for the current connection.

getSessionSpec()

Retrieves the specification for the current session.

login()

Logs in a SiteMinder administrator. The Policy Server issues a session specification for the session.

logout()

Logs out a SiteMinder administrator.

setApiConnection()

Sets a valid API connection.

setSessionSpec()

Sets an existing session specification.

Note: For login and logout of end users, DMS organization administrators, and DMS super administrators, use the AgentAPI.login() and AgentAPI.logout() methods in the Agent API package.

Result Class

The Result class, SmApiResult, stores the result of a SiteMinder Java API request. A SiteMinder result contains the following elements:

A result might also include a reason code. For example, a password policy result might include a reason code of 1001, meaning that the password does not contain the required minimum number of characters. To find a reason code for a result, call getReason().

All server-side errors are returned as results, not as exceptions. However, when a client-side exception is thrown, an SmApiResult object is embedded in the exception.

Interpret a Result Object

Each result object and its Facility/Severity/Status combination are represented by a unique value. These unique values are associated with predefined constants defined in the SmApiResult class—for example, SERVER_CONFIGURATION_FAILURE.

To determine the Facility/Severity/Status information for a result, you can call the equals() method to compare the returned SmApiResult object with the result constants.

You can output a result object as a string—for example, you can generate a result string by calling toString() on the SmApiResult object.

A result string has five space-separated name/value pairs in the following format:

[facility=facility severity=severity reason=reason
status=statusCode message=message]

For example, suppose you call toString() for an SmApiResult object that occurs because a user attempted to create a password with fewer than the minimum number of alphabetic characters. The method might return a result string that looks like this:

[facility=4 severity=3 reason=1008 status=13 message=nArg=1,Arg1=3]

The fields in the result have the following meanings:

Core Methods in the Result Class

The core methods of the SmApiResult class include:

Method

Description

equals()

Indicates whether the current object is equal to the object passed to the method.

getError()

Retrieves a unique error code.

getFacility()

Retrieves the facility code associated with the error.

getMessage()

Retrieves the message associated with the error.

getReason()

Retrieves the reason code of the error.

getSeverity()

Retrieves the severity code associated with the error.

getStatus()

Retrieves the status code in the current facility. This method can take as a parameter the result code from the server.

isSuccess()

Reports whether the request was successful.

toString()

Returns a string representation of the SmApiResult object.

Exception Class

The Exception class, SmApiException, contains the result class SmApiResult. The following packages use SmApiException:

Method

Description

getFacility()

Retrieves the facility code of the exception.

getReason()

Retrieves the reason code of the exception.

getSeverity()

Retrieves the severity code of the exception.

getStatus()

Retrieves the status code of the exception.

toString()

Returns a string representation of the SmApiResult object.

The Exception class extends java.lang.Exception. By calling the inherited getMessage() method, you can retrieve the message associated with the exception.

Property Class

The Property class, SmProperty, holds the following information about a property:

Method

Description

getName()

Retrieves the name of the property.

getType()

Retrieves the type of the property (that is, 0 if plain text, 1 if encrypted).

getValue()

Retrieves the value of the property.

setName()

Sets the name of the property.

setType()

Sets the type of the property, 0 if plain text & 1 if encrypted.

setValue()

Sets the value of the property.