This chapter explains how each interceptor works, then shows how to build and run them with the PersonQuery sample application.

InterceptorDataClient Interceptor

The InterceptorDataClient interceptor intercepts and logs each client application request and reply parameters. This interceptor also allows certain operations on the PersonQuery server application to be invoked by users of the client application who meet specific criteria. The InterceptorDataClient interceptor implements the InterceptorDataClient interface, which inherits from the ClientRequestInterceptor class.

The InterceptorDataClient class implements the methods as follows:

id()

This method returns the string InterceptorDataClient.

shutdown()

This method removes the request from the tracker object.

exception_occurred()

When invoked by the ORB, this method removes the request from the tracker object.

client_invoke()

This method determines if the interface and operation are "of interest." If the client request is "of interest," this method parses the request parameters and outputs the parameters to the log file. If the client request is not "of interest," this method simply returns.

client_response()

This method determines if the interface and operation in the request are "of interest." If the interface and operation are "of interest," this method walks through the CORBA DataInputStream parameter to obtain the reply parameters and write them to the log file. If the interface and operation in the request are not "of interest," this method simply returns.

In addition, the data interceptor provides the InterceptorDataClientInit method to initialize the client interceptor class.

InterceptorDataTarget Interceptor

The InterceptorDataTarget interceptor intercepts and logs request and reply data parameters. This interceptor also removes sensitive data from specific reply parameters by masking the data with x characters. The InterceptorDataTarget interceptor implements the InterceptorDataTarget interface, which inherits from the TargetRequestInterceptor class.

The InterceptorDataTarget class implements the methods as follows:

id()

This method returns the string InterceptorDataTarget.

shutdown()

This method simply returns.

exception_occurred()

This method removes the request from the tracker object.

target_invoke()

This method determines if the interface and operation are "of interest." If so, this method parses the request parameters and outputs that data to the log file. If the interface and operation in the request are not "of interest," this method simply returns. If the operation in the request is exit, this method returns the status value INVOKE_NO_EXCEPTION.

target_response()

This method determines if the interface and operation are "of interest." If so, this method walks through the DataInputStream parameter to obtain the response parameters and output to the log file. Sensitive data items are substituted in the log. For example, a person's social security number will not be output to the log. If the interface and operation in the request are not "of interest," this method simply returns.

In addition, the data interceptor provides the InterceptorDataTargetInit method to initialize the target interceptor class.

Registering and Running the InterceptorData Interceptors

When you run the makefile that builds the PersonQuery sample application in PersonQuery Sample Application, the entire set of sample interceptors are built as well, including the InterceptorData interceptors. This section describes how to register the InterceptorData interceptor so that it works with PersonQuery application at run time.

To register and run the InterceptorData client and server interceptors:

Change directory to the InterceptorData sample directory, where workdirectory represents the name of the directory into which you copied the interceptor sample applications in Chapter , "PersonQuery Sample Application:"

Examining the Interceptor Output

The InterceptorData client and target interceptors log each invocation. For each PersonQuery application session, the client interceptor creates a log file named InterceptorDataClientxxx.out, and the target interceptor creates a log file named InterceptorDataTargetxxx.out. This section shows sample log file data for each interceptor.

Sample Client Interceptor Log Output

InterceptorDataClientInit calledClientInterceptorData::id called

ClientInterceptorData::client_invoke calledClientInterceptorData::client_response called Request Id: 1 unable to find request for this reply (must not be one we care about)

Unregistering the Interceptors

After you have run the PersonQuery sample application with the InterceptorData sample interceptors, you can unregister those interceptors using the following steps:

Shut down all running CORBA applications by entering the following command:

> tmshutdown -y

Change directory to the InterceptorData sample directory, where workdirectory represents the name of the directory into which you copied the interceptor sample applications in Chapter , "PersonQuery Sample Application:"