public final class

Secmod

extends Object
java.lang.Object
   ↳ sun.security.pkcs11.Secmod

Class Overview

The Secmod class defines the interface to the native NSS library and the configuration information it stores in its secmod.db file.

Example code:

   Secmod secmod = Secmod.getInstance();
   if (secmod.isInitialized() == false) {
       secmod.initialize("/home/myself/.mozilla", "/usr/sfw/lib/mozilla");
   }

   Provider p = secmod.getModule(ModuleType.KEYSTORE).getProvider();
   KeyStore ks = KeyStore.getInstance("PKCS11", p);
   ks.load(null, password);
 

Summary

Nested Classes
enum Secmod.DbMode  
class Secmod.KeyStoreLoadParameter A LoadStoreParameter for use with the NSS Softtoken or NSS TrustAnchor KeyStores. 
class Secmod.Module A representation of one PKCS#11 slot in a PKCS#11 module. 
enum Secmod.ModuleType Constants describing the different types of NSS modules. 
enum Secmod.TrustType Constants representing NSS trust categories. 
Public Methods
static Secmod getInstance()
Return the singleton Secmod instance.
Secmod.Module getModule(Secmod.ModuleType type)
Returns the first module of the specified type.
synchronized List<Secmod.Module> getModules()
Return an immutable list of all available modules.
synchronized void initialize(Secmod.DbMode dbMode, String configDir, String nssLibDir)
void initialize(String configDir, String nssLibDir)
Initialize this Secmod.
synchronized boolean isInitialized()
Test whether this Secmod has been initialized.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static Secmod getInstance ()

Return the singleton Secmod instance.

public Secmod.Module getModule (Secmod.ModuleType type)

Returns the first module of the specified type. If no such module exists, this method returns null.

Throws
IllegalStateException if this Secmod is misconfigured or not initialized

public synchronized List<Secmod.Module> getModules ()

Return an immutable list of all available modules.

Throws
IllegalStateException if this Secmod is misconfigured or not initialized

public synchronized void initialize (Secmod.DbMode dbMode, String configDir, String nssLibDir)

Throws
IOException

public void initialize (String configDir, String nssLibDir)

Initialize this Secmod.

Parameters
configDir the directory containing the NSS configuration files such as secmod.db
nssLibDir the directory containing the NSS libraries (libnss3.so or nss3.dll) or null if the library is on the system default shared library path
Throws
IOException if NSS has already been initialized, the specified directories are invalid, or initialization fails for any other reason

public synchronized boolean isInitialized ()

Test whether this Secmod has been initialized. Returns true if NSS has been initialized using either the initialize() method or by directly calling the native NSS APIs. The latter may be the case if the current process contains components that use NSS directly.

Throws
IOException if an incompatible version of NSS has been loaded