Direct Method

This method is documented here for completeness. The IBMPKCS11Impl provider has two constructors. One takes the configuration file's full pathname as argument. The usage is described in Using Configuration File section. The other one has no arguments. You can call it to construct an IBMPKCS11Impl provider instance. It is initially empty, and you must initialize it to make it functional.

Here are the code snippets:
com.ibm.crypto.pkcs11impl.provider.IBMPKCS11Impl p1 = new com.ibm.crypto.pkcs11impl.provider.IBMPKCS11Impl();
p1.Init("c:\\program files\\LunaSA\\cryptoki.dll:0", "password".toCharArray());
Security.addProvider(p1);
The format of the string supplied to the Init methods is:
<hardware device PKCS #11 library name>:<slot #>
or
<configuration file name>
Note: Problems will occur when two IBMPKCS11Impl providers in the provider list share the same provider name. This can happen if two IBMPKCS11Impl providers are initialized with the same configuration file or if the two providers are initialized using the 1.4.2 initializations. If you could get a PKCS11Exception the exception message is like this-com.ibm.pkcs11.PKCS11Exception: Invalid dll name : c:\program files\LunaSA\cryptoki. If you use Login Module mechanism, you could get a LoginException with such messages- javax.security.auth.login.LoginException: com.ibm.pkcs11.PKCS11Exception: Cryptoki is already initialized. This is not a problem with using configuration file. That is, if the configuration file is specified with the provider name in the provider list, you still can programmatically initialize a new provider using the same configuration file.