Java Preferences

This provider will check user preferences for class:
com.ibm.crypto.pkcs11impl.provider.IBMPKCS11Impl

If the preferences "IBMPKCSImpl DLL" and "IBMPKCSImpl password" exist, the values from these will be used to initialize the connection between the provider and the hardware device. This initialization is done before the provider is created and added to the Java™ Provider list.

This example shows how to use preferences and then add the provider to the Java Provider List:
// Get class associated with the preferences
Class cls = null;
cls = Class.forName("com.ibm.crypto.pkcs11impl.provider.IBMPKCS11Impl");

// Get user preferences associated with this class.
Preferences prefs = Preferences.userNodeForPackage(cls);

// prefs.put("IBMPKCSImpl DLL","{hardware device PKCS #11 library name}:{slot #}
");
// A DLL name of cryptoki.dll and a slot of 0:
prefs.put("IBMPKCSImpl DLL","cryptoki.dll:0");

// prefs.put("IBMPKCSImpl password", "{hardware device PIN}");
// A PIN of PASSWORD:
prefs.put("IBMPKCSImpl password", "PASSWORD");

// Create provider using the previous preferences.
Provider p1 = new com.ibm.crypto.pkcs11impl.provider.IBMPKCS11Impl();

// Since the PIN is sensitive data you probably want to remove it as soon as
// possible.
prefs.remove("IBMPKCSImpl DLL");
prefs.remove("IBMPKCSImpl password");

//Add the provider to the Java Provider List after the IBMJCE provider. Note
//that the IBMJCE provider should be in the provider list for JCE framework
verification.
Security.addProvider(p1);