Installing Providers

There are two parts to installing a provider:

  • Installing the provider package classes,
  • Configuring the provider.

Installing the Provider Classes

There are two possible ways to install the provider classes:

  1. Place a zip or JAR file containing the classes anywhere in your classpath.
  2. Supply your provider JAR file as an installed or bundled extension. For more information on how to deploy an extension, see How is an extension deployed?.

Configuring the Provider

The next step is to add the provider to your list of approved providers. This step can be done statically by editing the java.security file in the lib/security directory of the SDK; therefore, if the SDK is installed in a directory called j2sdk1.2, the file would be j2sdk1.2/lib/security/java.security. One of the types of properties you can set in java.security has the following form:

security.provider.n=className

This property declares a provider, and specifies its preference order n. The preference order is the order in which providers are searched for requested algorithms (when no specific provider is requested). The order is 1-based: 1 is the most preferred, followed by 2, and so on.

The className must specify the provider's class. The provider's documentation will specify its class. This class is always a subclass of the Provider class. The subclass constructor sets the values of various properties that are required for the Java™ Cryptography API to look up the algorithms or other facilities that the provider implements.

Suppose that the class is COM.acme.provider.Acme, and that you would like to configure Acme as your third preferred provider. To do so, you would add the following line to the java.security file:

security.provider.3=COM.acme.provider.Acme
Providers can also be registered dynamically. To do so, call either the addProvider or insertProviderAt method in the Security class. This type of registration is not persistent and can be done only by "trusted" programs. See Security.