Package eu.europa.esig.dss.token
Class Pkcs11SignatureToken
java.lang.Object
eu.europa.esig.dss.token.AbstractSignatureTokenConnection
eu.europa.esig.dss.token.AbstractKeyStoreTokenConnection
eu.europa.esig.dss.token.Pkcs11SignatureToken
- All Implemented Interfaces:
SignatureTokenConnection
,AutoCloseable
PKCS11 token with callback
-
Constructor Summary
ConstructorDescriptionPkcs11SignatureToken
(String pkcs11Path) Create the SignatureTokenConnection, using the provided path for the library.Pkcs11SignatureToken
(String pkcs11Path, PasswordInputCallback callback) Create the SignatureTokenConnection, using the provided path for the library and a way of retrieving the password from the user.Pkcs11SignatureToken
(String pkcs11Path, PasswordInputCallback callback, int slotId) Sometimes, multiple SmartCard reader is connected.Pkcs11SignatureToken
(String pkcs11Path, PasswordInputCallback callback, int slotId, int slotListIndex, String extraPkcs11Config) Sometimes, multiple SmartCard reader is connected.Pkcs11SignatureToken
(String pkcs11Path, PasswordInputCallback callback, int slotId, String extraPkcs11Config) Sometimes, multiple SmartCard reader is connected.Pkcs11SignatureToken
(String pkcs11Path, PasswordInputCallback callback, String extraPkcs11Config) Create the SignatureTokenConnection, using the provided path for the library and a way of retrieving the password from the user.Pkcs11SignatureToken
(String pkcs11Path, String extraPkcs11Config) Create the SignatureTokenConnection, using the provided path for the library.Pkcs11SignatureToken
(String pkcs11Path, KeyStore.PasswordProtection password) Sometimes, the password is known in advance.Pkcs11SignatureToken
(String pkcs11Path, KeyStore.PasswordProtection password, int slotId) Sometimes, multiple SmartCard reader is connected.Pkcs11SignatureToken
(String pkcs11Path, KeyStore.PasswordProtection password, int slotId, String extraPkcs11Config) Sometimes, multiple SmartCard reader is connected.Pkcs11SignatureToken
(String pkcs11Path, KeyStore.PasswordProtection password, String extraPkcs11Config) Sometimes, the password is known in advance. -
Method Summary
Modifier and TypeMethodDescriptionprotected String
Builds the PKCS11 configvoid
close()
protected String
escapePath
(String pathToEscape) Replaces the path like ('\' to '\\')protected KeyStore.PasswordProtection
Gets the password protectionprotected KeyStore
Gets the key storeprotected String
Gets the path to PKCS libraryprotected Provider
Gets the Provider to useprotected Signature
getSignatureInstance
(String javaSignatureAlgorithm) Returns thejava.security.Signature
instance for the givenjavaSignatureAlgorithm
Methods inherited from class eu.europa.esig.dss.token.AbstractKeyStoreTokenConnection
getKey, getKey, getKeys, setKeyEntryPredicate
Methods inherited from class eu.europa.esig.dss.token.AbstractSignatureTokenConnection
createPSSParam, sign, sign, sign, signDigest, signDigest, signDigest
-
Constructor Details
-
Pkcs11SignatureToken
Create the SignatureTokenConnection, using the provided path for the library.- Parameters:
pkcs11Path
- the path for the library (.dll, .so)
-
Pkcs11SignatureToken
Create the SignatureTokenConnection, using the provided path for the library.- Parameters:
pkcs11Path
- the path for the library (.dll, .so)extraPkcs11Config
- extra configuration for pkcs11 library
-
Pkcs11SignatureToken
Sometimes, the password is known in advance. This create a SignatureTokenConnection and the keys will be accessed using the provided password. The default constructor for CallbackPkcs11SignatureToken.- Parameters:
pkcs11Path
- the path for the library (.dll, .so)password
- the pin code / password to use
-
Pkcs11SignatureToken
public Pkcs11SignatureToken(String pkcs11Path, KeyStore.PasswordProtection password, String extraPkcs11Config) Sometimes, the password is known in advance. This create a SignatureTokenConnection and the keys will be accessed using the provided password. The default constructor for CallbackPkcs11SignatureToken.- Parameters:
pkcs11Path
- the path for the library (.dll, .so)password
- the pin code / password to useextraPkcs11Config
- extra configuration for pkcs11 library
-
Pkcs11SignatureToken
Create the SignatureTokenConnection, using the provided path for the library and a way of retrieving the password from the user. The default constructor for CallbackPkcs11SignatureToken.- Parameters:
pkcs11Path
- the path for the library (.dll, .so)callback
- the callback to enter the pin code / password
-
Pkcs11SignatureToken
public Pkcs11SignatureToken(String pkcs11Path, PasswordInputCallback callback, String extraPkcs11Config) Create the SignatureTokenConnection, using the provided path for the library and a way of retrieving the password from the user. The default constructor for CallbackPkcs11SignatureToken.- Parameters:
pkcs11Path
- the path for the library (.dll, .so)callback
- the callback to enter the pin code / passwordextraPkcs11Config
- extra configuration for pkcs11 library
-
Pkcs11SignatureToken
Sometimes, multiple SmartCard reader is connected. To create a connection on a specific one, slotIndex is used. This Create the SignatureTokenConnection, using the provided path for the library and a way of retrieving the password from the user.- Parameters:
pkcs11Path
- the path for the library (.dll, .so)password
- the pin code / password to useslotId
- the slotId to use
-
Pkcs11SignatureToken
public Pkcs11SignatureToken(String pkcs11Path, KeyStore.PasswordProtection password, int slotId, String extraPkcs11Config) Sometimes, multiple SmartCard reader is connected. To create a connection on a specific one, slotIndex is used. This Create the SignatureTokenConnection, using the provided path for the library and a way of retrieving the password from the user.- Parameters:
pkcs11Path
- the path for the library (.dll, .so)password
- the pin code / password to useslotId
- the slotId to useextraPkcs11Config
- extra configuration for pkcs11 library
-
Pkcs11SignatureToken
Sometimes, multiple SmartCard reader is connected. To create a connection on a specific one, slotIndex is used. This create a SignatureTokenConnection and the keys will be accessed using the provided password.- Parameters:
pkcs11Path
- the path for the library (.dll, .so)callback
- the callback to enter the pin code / passwordslotId
- the slotId to use
-
Pkcs11SignatureToken
public Pkcs11SignatureToken(String pkcs11Path, PasswordInputCallback callback, int slotId, String extraPkcs11Config) Sometimes, multiple SmartCard reader is connected. To create a connection on a specific one, slotIndex is used. This create a SignatureTokenConnection and the keys will be accessed using the provided password.- Parameters:
pkcs11Path
- the path for the library (.dll, .so)callback
- the callback to enter the pin code / passwordslotId
- the slotId to useextraPkcs11Config
- extra configuration for pkcs11 library
-
Pkcs11SignatureToken
public Pkcs11SignatureToken(String pkcs11Path, PasswordInputCallback callback, int slotId, int slotListIndex, String extraPkcs11Config) Sometimes, multiple SmartCard reader is connected. To create a connection on a specific one, slotListIndex is used. This create a SignatureTokenConnection and the keys will be accessed using the provided password.- Parameters:
pkcs11Path
- the path for the library (.dll, .so)callback
- the callback to enter the pin code / passwordslotId
- the slotId to use (if negative, the parameter is not used)slotListIndex
- the slotListIndex to use (if negative, the parameter is not used)extraPkcs11Config
- extra configuration for pkcs11 library
-
-
Method Details
-
getProvider
Gets the Provider to use- Returns:
Provider
-
buildConfig
Builds the PKCS11 config- Returns:
String
-
escapePath
Replaces the path like ('\' to '\\') -
getKeyStore
Description copied from class:AbstractKeyStoreTokenConnection
Gets the key store- Specified by:
getKeyStore
in classAbstractKeyStoreTokenConnection
- Returns:
KeyStore
- Throws:
DSSException
-
getPkcs11Path
Gets the path to PKCS library- Returns:
String
-
getKeyProtectionParameter
Description copied from class:AbstractKeyStoreTokenConnection
Gets the password protection- Specified by:
getKeyProtectionParameter
in classAbstractKeyStoreTokenConnection
- Returns:
KeyStore.PasswordProtection
-
getSignatureInstance
protected Signature getSignatureInstance(String javaSignatureAlgorithm) throws NoSuchAlgorithmException Description copied from class:AbstractSignatureTokenConnection
Returns thejava.security.Signature
instance for the givenjavaSignatureAlgorithm
- Overrides:
getSignatureInstance
in classAbstractSignatureTokenConnection
- Parameters:
javaSignatureAlgorithm
-String
representing the Java name of a signature algorithm- Returns:
Signature
- Throws:
NoSuchAlgorithmException
- if the algorithm is not found
-
close
public void close()
-