Using Authentication APIs
Access Manager comes with a number of sample programs that demonstrate
how you can use the Authentication APIs to extend the functionality
of the authentication service and authentication modules.
Running the Sample Authentication Programs
The source code and Makefile are provided for all sample programs.
For some sample programs, additional supporting files are also included.
The instructions for compiling and executing the sample programs are
the same for all samples described in this section.
Java API Code Samples and Their Locations
The following tables describe the locations of all the files
you need to implement the sample programs on various platforms, and
the variable names used for default directories in the source code
and Makefiles. Table 5–2 summarizes
file locations and variable names used for Solaris Sparc/x86.l Table 5–3 summarizes default directories
for Linux. Table 5–4 summarizes
default directories for Windows 2000.
Table 5–2 Default directories
for Solaris Sparc/x86
|
Variable
|
Description
|
Location
|
|
Api_sample_dir
|
Directory that contains authentication API sample files
|
<install_root>/SUNWam/
samples/authenitcation/api
|
|
Config_directory
|
Directory that contains configuration files
|
/etc/opt/SUNWam/config
|
|
Product_Directory
|
Directory where Access Manager is installed.
|
install_root>/SUNWam
|
Table 5–3 Default directories
for Linux
|
Variable
|
Description
|
Location
|
|
Api_Sample_Dir
|
Directory that contains authentication API sample files
|
<install_root>/sun/
identity/samples/authentication/api
|
|
Config_Directory
|
Directory that contains configuration files
|
/etc/opt/sun/identity/config
|
|
Product_Directory
|
Directory where Access Manager is installed.
|
<install_root>/sun/identity
|
Table 5–4 Default
directories for Windows 2000
|
Variable
|
Description
|
Location
|
|
Api_Sample_Dir
|
Directory that contains authentication API sample files
|
<install_root>\samples\
authentication\api
|
|
Config_Directory
|
Directory that contains configuration files
|
<install_root>\lib
|
|
Product_Directory
|
Directory where Access Manager is installed.
|
<install_root>
|
These steps are for all platforms.
To Compile and Execute the Java API Samples
-
In the Makefile, modify the following variables as necessary
to suit your Access Manager installation:
BASE_DIR: Enter the path to the directory
where Access Manager is installed.
JAVA_HOME: Enter the path to the directory where the Java compiler
is installed.
DOMAIN: Enter
the name of the organization to login to.
SHARE_LIB: Enter the path to the directory
where Access Manager jar files are stored.
JSS_JAR_PATH: Enter the path to the directory
where JSS jar files are stored.
JSSPATH: Enter the path to the directory where JSS libraries are
located.
-
In the Certificate Sample Makefile only, modify the following
as necessary:
CERTNICKNAME: Enter
the Certificate nickname.
URL: Enter
the Access Manger Server URL.
PASSWORD: Enter the Certificate DB Password.
-
Copy AMConfig.properties from Config_Directory in the Access Manager server installation
to the client machine.
(Note: For SSL check SSL Configuration
Setup, step 2).
-
In the Makefile, update the classpath to include the location
of the newly created AMConfig.properties.
-
In the client machine, create a directory named locale.
C opy all the property files from the locale directory in the Access Manager server installation machine
to the client machine. The locale directory on
the server machine can be found under the Product_Directory.
-
Update the classpath in the Makefile to include the location
of newly created locale files.
-
Include jaas.jar in your classpath
if you are using a JDK version less than JDK1.4
-
Compile the program.
-
Run the sample program.
To Configure SSL for Java API Samples
-
In the Makefile, add this JVM property in the run target:
-D "java.protocol.handler.pkgs=com.iplanet.services.comm"
-
Copy AMConfig.properties from Config_Directory in the Access Manager server installation
to the client machine.
-
Edit the following properties in AMConfig.properties.
com.iplanet.am.admin.cli.certdb.dir: Enter the path to the certificate database directory.
com.iplanet.am.admin.cli.certdb.prefix: Enter
the certificate database prefix.
-
In the LDAP and JCDI Samples only:
com.iplanet.am.server.protocol: Change the
value to HTTPS.
com.iplanet.am.server.port: Enter the appropriate port number from the server machine.
-
Create or copy the certificate database file to the certificate
db directory. Use the directory name in com.iplanet.am.admin.cli.certdb.dir.
-
Rename the file to use the prefix specified in the property com.iplanet.am.admin.cli.certdb.prefix.
For
the details, see the Javadoc for the Remote Client API.
LDAPLogin Example
The LDAPLogin sample is an example of a custom
Java application that uses the authentication remote APIs to authenticate
to the LDAP module. You can modify the sample source code to authenticate
to other existing or customized authentication modules. The sample
source code, Makefile, and Readme.html are located
in the following directory:
AccessManager-base/ SUNWam/samples/authentication/LDAP
To compile and run the sample program, follow the steps in To Compile and Execute the Java API Samples.
CertLogin Example
The CertLogin sample is an example of a custom Java application
that uses digital certificates for authentication. You can modify
the sample source code to authenticate to other existing or customized
authentication modules. The sample source code, Makefile,
and Readme.html are located in the following file:
AccessManager-base/ SUNWam/samples/authentication/Cert
To Run the CertLogin Program
-
Enable SSL.
Follow the instructions in To Configure SSL for Java API Samples.
-
Compile and execute the sample code.
See To Compile and Execute the Java API Samples
Using certutil for Client Certificate Management
Certutil is a command-line utility that can
create and modify cert7.db and key3.db database files. It can also
list, generate, modify, or delete certificates within the cert7.db
file and create or change the password, generate new public and private
key pairs, display the contents of the key database, or delete key
pairs within the key3.db file. The key and certificate management
process usually begins with creating keys in the key database, then
generating and managing certificates in the certificate database.
JCDI Module Example
The JCDI Module Example demonstrates the use of Java Card Digital
ID (JCDI) authentication with Access Manager. The sample has two components:
The remote client component is located in the following directory:
AccessManager-base/samples/authentication/api/jcdi
The server JCDI authentication module is located in the following
directory:
AccessManager-basesamples/authentication/spi/jcdi
The sample illustrates JCDI authentication using the Remote
Authentication API. You can modify the sample source code to authenticate
to other existing or customized authentication modules. The source
code, Makefile, and Readme.html are
located in the following directory:
AccessManager-basesamples/authentication/api/jcdi
To compile and run the sample program, follow the steps in Running the Sample Authentication Programs.