java.lang.AutoCloseable
public class Module extends NativeObject implements java.lang.AutoCloseable
The PKCS#11 driver module (middleware) manages the cryptographic devices of a particular type.
Note: The PKCS#11 interface requires special handling of the driver modules:
Module
instance for each driver.
Since this object is fully thread-safe, it might be used by multiple threads though.
Modifier and Type | Method | Description |
---|---|---|
void |
close() |
Close all open sessions and unload the module
|
DeviceList |
getDevices() |
The list of devices managed by this module (Getter)
|
boolean |
getEnableFullParallelization() |
Enable full parallelization (Getter)
|
static Module |
load(java.lang.String library) |
Load a PKCS#11 driver module
|
void |
setEnableFullParallelization(boolean value) |
Enable full parallelization (Setter)
|
equals, hashCode
public static Module load(java.lang.String library) throws NotFoundException, ExistsException
library
- The name or path to the driver module (middleware). This can be found in the documentation of your cryptographic device.
Examples:
primusP11.dll
on Windows and libprimusP11.so
on Linux.libkmsp11.so
and Session.createSignatureFromKeyLabel(java.lang.String, com.pdftools.sys.Stream)
cryptoki.dll
on Windows or libCryptoki2_64.so
on Linux/UNIX.siecap11.dll
cryptoki.dll
etpkcs11.dll
NotFoundException
- The library cannot be found.ExistsException
- The module has been loaded already by this application.java.lang.IllegalArgumentException
- The given library
is not a PKCS#11 driver module.java.lang.IllegalArgumentException
- if library
is null
public boolean getEnableFullParallelization()
The PKCS#11 standard specifies that "an application can specify that it will be accessing the library concurrently from multiple
threads, and the library must [...] ensure proper thread-safe behavior."
However, some PKCS#11 modules (middleware) implementations are not thread-safe.
For this reason, the SDK synchronizes all access to the module.
If the middleware is thread-safe, full parallel usage of the cryptographic device can be enabled by setting this property to true
and thereby improving the performance.
Default: false
public void setEnableFullParallelization(boolean value)
The PKCS#11 standard specifies that "an application can specify that it will be accessing the library concurrently from multiple
threads, and the library must [...] ensure proper thread-safe behavior."
However, some PKCS#11 modules (middleware) implementations are not thread-safe.
For this reason, the SDK synchronizes all access to the module.
If the middleware is thread-safe, full parallel usage of the cryptographic device can be enabled by setting this property to true
and thereby improving the performance.
Default: false
public DeviceList getDevices()
DeviceList.getSingle()
can be used.public void close() throws PdfToolsException, java.io.IOException
After unloading, the module cannot be loaded again in the same process. Proper unloading is crucial. Otherwise, the application might crash and/or the HSM, USB token, or smart card might not be unlocked.
When using the C interface, this method must not be called from the context of the destructor of a global or static object,
nor an atexit()
handler, nor the DllMain()
entry point.
close
in interface java.lang.AutoCloseable
PdfToolsException
- only explicitly stated in a superclassjava.io.IOException