public class IAIKPkcs11
extends java.security.Provider
IAIKPkcs11 smartCardProvider = new IAIKPkcs11();
Security.addProvider(smartCardProvider);
or use static installation.
Despite its standard functionality of a JCE provider, this implementation offers some additional
features.
The methods
getGlobalProperties()
getProperties()
provide access to the provider's global and the provider's instance configuration. The
application can use the handler for creating delegate objects using
getGlobalDelegateProvider()
getDelegateProvider()
setGlobalDelegateProvider(DelegateProvider)
setDelegateProvider(DelegateProvider)
With the
getLoginManager()
setLoginManager(LoginManager)
methods, the application can provide its own handler for login operations.
Further details can be found on the product's page on our website or in the JCA specification.
Provider
,
Security
,
Serialized FormModifier and Type | Field and Description |
---|---|
static java.io.PrintStream |
debugStream_
The output stream for debug messages.
|
protected static java.util.Properties |
defaultInstanceProperties_
The global (for all instances) default configuration of provider instances.
|
protected java.util.Properties |
defaultProperties_
The default configuration of this provider (this instance).
|
protected DelegateProvider |
delegateProvider_
The manager that provides the delegation implementations.
|
protected java.util.Hashtable |
engineObjectsCache_
This is a cache of objects of engine classes.
|
static java.io.PrintStream |
errorStream_
The output stream for error messages.
|
protected static DelegateProvider |
globalDelegateProvider_
Provides the global delegation implementations.
|
protected static java.util.Properties |
globalProperties_
The properties for multiple instances of this provider.
|
protected java.lang.String |
info_
This provider's info string.
|
protected java.lang.String |
initializationParameters_
The module initialization parameters if present.
|
protected static int |
instanceCounter_
The number of instances of this provider already created.
|
protected static KeyHandler |
keyHandler_
The engine classes call the methods of this handler before they perform the actual crypto
operation.
|
protected LoginManager |
loginManager_
The object handling the login of the user, the change of the user PIN and logout.
|
protected java.util.Properties |
properties_
The configuration of this provider.
|
static java.lang.String |
PROVIDER_BASE_NAME
The name the provider is registered to Java.
|
static java.lang.String |
PROVIDER_INFO_BASE
The info for this provider that is registered to Java.
|
static double |
PROVIDER_VERSION
The version of this implementation.
|
protected static java.util.Map |
providerInstances_
The list of all instances of this provider.
|
protected TokenManager |
tokenManager_
The configuration of this provider.
|
protected char[] |
userPIN_
The user PIN that has been set directly, if present.
|
protected double |
version_
This provider's version.
|
Constructor and Description |
---|
IAIKPkcs11()
Default constructor.
|
IAIKPkcs11(java.util.Properties configuration)
Constructor for the provider that takes its configuration as a argument.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addAlgorithms()
Read the algorithms from the configuration and enter them into the provider hash table.
|
protected static void |
checkAccessPermission(java.lang.String accessTarget)
Check, if the given target access is allowed.
|
void |
disableCleanerThread()
removes the cleanerThread_ from the shutdown hook
|
static void |
discardProviderInstance(IAIKPkcs11 provider)
Discards the given provider instance.
|
boolean |
equals(java.lang.Object other)
We override this method to check for reference equality, because we use several instances of
the same class, which may be considered equal otherwise.
|
static IAIKPkcs11 |
getCurrentProviderInstance()
Gets the current provider instance.
|
protected static java.util.Properties |
getDefaultInstanceProperties()
Get the default (configured via properties file) properties for the next provider instance.
|
DelegateProvider |
getDelegateProvider()
Get the current delegate provider.
|
static DelegateProvider |
getGlobalDelegateProvider()
Get the current delegate provider.
|
static KeyHandler |
getGlobalKeyHandler()
Get the current global key handler.
|
static java.util.Properties |
getGlobalProperties()
Get the global configuration of provider class.
|
java.lang.String |
getInfo()
Returns a human-readable description of the provider and its services.
|
java.lang.String |
getKeystoreSupportProvider()
Get the keystore support provider.
|
LoginManager |
getLoginManager()
Get the login manager used by this provider to login the user, to change the user PIN and to
logout.
|
static iaik.pkcs.pkcs11.Module |
getModule()
Get the PKCS#11 module of the static configuration.
|
static iaik.pkcs.pkcs11.Module |
getModule(java.util.Properties configuration)
Get the PKCS#11 module of the given configuration properties.
|
java.lang.String |
getModuleAlreadyInitialized()
Get the behavior in case of a CKR_CRYPTOKI_ALREADY_INITIALIZED error upon module
initialization.
|
java.lang.String |
getModuleInitializationParameters()
Get the current delegate provider.
|
static IAIKPkcs11 |
getNewProviderInstance()
Gets a new provider instance.
|
static IAIKPkcs11 |
getNewProviderInstance(java.util.Properties properties)
Gets a new provider instance.
|
java.util.Properties |
getProperties()
Get the configuration of this provider.
|
java.lang.String |
getProperty(java.lang.String key)
We override this method to check if the requested algorithm is supported by the current token.
|
java.lang.String |
getProperty(java.lang.String key,
java.lang.String defaultValue)
Overridden to ensure thread-safety, because we also synchronized
getProperty(String) . |
static IAIKPkcs11 |
getProviderInstance(int instanceNumber)
Get a reference to the already instantiated provider with the given number.
|
static int |
getProviderInstanceCount()
Get the number of instances that have already been created.
|
static int |
getProviderInstanceNumber(java.lang.String providerName)
Get the instance number of the IAIKPkcs11 provider with the given name.
|
int |
getSessionPoolMaxSize()
Get the maximum number of sessions to keep in the session pool of the token manager.
|
TokenManager |
getTokenManager()
Get the token manager of this provider.
|
char[] |
getUserPIN()
Get the user PIN, which has been set for this provider.
|
double |
getVersion()
Returns the version number for this provider.
|
int |
hashCode()
Override to ensure consistency with
equals(Object) . |
void |
initialize()
Initializes this provider based on its current configuration.
|
static void |
insertProviderAtForJDK14(java.security.Provider provider,
int position)
Adds the give JCE provider to the Security class of JCA/JCE using a workaround that enables the
provider to be added in the first position in JDK 1.4 and later.
|
boolean |
isCheckMechanismSupported()
Get if the provider checks, if a requested algorithm is supported by the underlying PKCS#11
token.
|
boolean |
isCheckSessionIntegrity()
Determines, if the a session should be checked i.e.
|
static boolean |
isEnableSoftwareDelegation()
Check, if the software delegation feature of the PKCS#11 provider is enabled.
|
protected boolean |
isEngineClassKey(java.lang.String key)
Check, if the given property key for this provider denotes a key for an engine class.
|
static boolean |
isIAIKPkcs11Provider(java.security.Provider provider)
Check, if the given provider is a IAIKPkcs11 provider.
|
boolean |
isLoginKeystoreOnDemand()
Enable or disable login on demand for the keystore.
|
boolean |
isMultiThreadInit()
Check, if the provider initializes the underlying PKCS#11 module for multi-threaded operation
or not.
|
void |
setCheckMechanismSupported(boolean checkMechanismSupported)
Set if the provider should check, if a requested algorithm is supported by the underlying
PKCS#11 token.
|
void |
setDelegateProvider(DelegateProvider delegateProvider)
Set the delegate provider.
|
static void |
setEnableSoftwareDelegation(boolean enableSoftwareDelegation)
Enable or disable the software delegation feature of the PKCS#11 provider.
|
static void |
setGlobalDelegateProvider(DelegateProvider globalDelegateProvider)
Set the global delegate provider.
|
static void |
setGlobalKeyHandler(KeyHandler keyHandler)
Set the key handler.
|
protected void |
setInfo()
Sets the information string of this provider using information of the properties of this
provider.
|
void |
setKeystoreSupportProvider(java.lang.String providerName)
Set the keystore support provider.
|
void |
setLoginKeystoreOnDemand(boolean loginOnDemand)
Enable or disable login on demand for the keystore.
|
void |
setLoginManager(LoginManager loginManager)
Set the login manager used by this provider to login the user, to change the user PIN and to
logout.
|
void |
setModuleAlreadyInitialized(java.lang.String value)
Set the behavior in case of a CKR_CRYPTOKI_ALREADY_INITIALIZED error upon module
initialization.
|
void |
setModuleInitializationParameters(java.lang.String initializationParameters)
Set an initialization parameter string to be passed to the underlying PKCS#11 module during
initialization.
|
void |
setMultiThreadInit(boolean multiThread)
Set, if the provider initializes the underlying PKCS#11 module for multi-threaded operation or
not.
|
void |
setSessionPoolMaxSize(int sessionPoolMaxSize)
Set the maximum number of sessions to keep in the session pool of the token manager.
|
void |
setUserPIN(char[] userPIN)
Set the user PIN this provider shall use.
|
protected void |
setVersion()
Sets the version of this provider.
|
java.lang.String |
toString()
Returns a string with the name and the version number of this provider.
|
clear, compute, computeIfAbsent, computeIfPresent, elements, entrySet, forEach, get, getName, getOrDefault, getService, getServices, keys, keySet, load, merge, put, putAll, putIfAbsent, putService, remove, remove, removeService, replace, replace, replaceAll, values
list, list, load, loadFromXML, propertyNames, save, setProperty, store, store, storeToXML, storeToXML, stringPropertyNames
public static final java.lang.String PROVIDER_BASE_NAME
public static final double PROVIDER_VERSION
public static final java.lang.String PROVIDER_INFO_BASE
public static java.io.PrintStream debugStream_
public static java.io.PrintStream errorStream_
protected static java.util.Properties globalProperties_
protected static java.util.Properties defaultInstanceProperties_
protected static int instanceCounter_
protected static java.util.Map providerInstances_
protected static DelegateProvider globalDelegateProvider_
protected static KeyHandler keyHandler_
protected java.util.Properties defaultProperties_
protected java.util.Properties properties_
protected java.lang.String initializationParameters_
protected TokenManager tokenManager_
protected LoginManager loginManager_
protected double version_
protected java.lang.String info_
protected java.util.Hashtable engineObjectsCache_
protected DelegateProvider delegateProvider_
protected char[] userPIN_
public IAIKPkcs11() throws IAIKPkcs11Exception
IAIKPkcs11Exception
- If the provider is not appropriately configured.public IAIKPkcs11(java.util.Properties configuration) throws IAIKPkcs11Exception
configuration
- The configuration properties to use for this provider instance.IAIKPkcs11Exception
- If the initialization fails.protected static void checkAccessPermission(java.lang.String accessTarget)
accessTarget
- The action to be checked.java.lang.SecurityException
- If the calling thread does not have permission for the requested access.SecurityManager.checkSecurityAccess(String)
public static boolean isIAIKPkcs11Provider(java.security.Provider provider)
provider
- The provider to check.protected static java.util.Properties getDefaultInstanceProperties()
public static IAIKPkcs11 getNewProviderInstance()
new IAIKPkcs11()
.public static IAIKPkcs11 getNewProviderInstance(java.util.Properties properties)
new IAIKPkcs11(properties)
.properties
- the propertiespublic static void discardProviderInstance(IAIKPkcs11 provider)
provider
- the providerpublic static IAIKPkcs11 getProviderInstance(int instanceNumber)
instanceNumber
- The number (index) of the provider to get (Starting at index 1).public static IAIKPkcs11 getCurrentProviderInstance()
public static int getProviderInstanceNumber(java.lang.String providerName)
providerName
- The name of the IAIKPkcs11 provider instance.public static int getProviderInstanceCount()
public static void insertProviderAtForJDK14(java.security.Provider provider, int position)
provider
- The provider to add.position
- The position where to install the provider. 1 to become the first provider.Security.insertProviderAt(Provider, int)
public static boolean isEnableSoftwareDelegation()
public static void setEnableSoftwareDelegation(boolean enableSoftwareDelegation)
enableSoftwareDelegation
- True, to enable software delegation, false to disable it.public static DelegateProvider getGlobalDelegateProvider()
public static void setGlobalDelegateProvider(DelegateProvider globalDelegateProvider)
globalDelegateProvider
- The new delegate provider. If this is null, the default delegate provider is used.public static java.util.Properties getGlobalProperties()
public static KeyHandler getGlobalKeyHandler()
public static void setGlobalKeyHandler(KeyHandler keyHandler)
keyHandler
- The new key handler. If this is null, the default key handler is used.public static iaik.pkcs.pkcs11.Module getModule()
PKCS11_NATIVE_MODULE
property.null
if no module has been configured.public static iaik.pkcs.pkcs11.Module getModule(java.util.Properties configuration) throws IAIKPkcs11Exception
PKCS11_NATIVE_MODULE
property. If the given properties do not contain this
property, the property of the configure properties file is used.configuration
- The configuration properties.null
if no module has been configured.IAIKPkcs11Exception
- If the configuration is incorrect.public DelegateProvider getDelegateProvider()
public void setDelegateProvider(DelegateProvider delegateProvider)
delegateProvider
- The new delegate provider. If this is null, the default delegate provider is used.public void setModuleInitializationParameters(java.lang.String initializationParameters)
configdir='/user/home/dummy/.mozilla' certPrefix='' keyPrefix='' secmod='secmod.db'
initializationParameters
- The parameter string for the PKCS#11 module.public java.lang.String getModuleInitializationParameters()
public LoginManager getLoginManager()
public void setLoginManager(LoginManager loginManager)
loginManager
- The login manager to use or null to use the configured default.public char[] getUserPIN()
LoginManager.loginUser(TokenManager, Session, char[])
method.
However, it is then up to the concrete login manager, if it uses this PIN. The default login
manager will use it.public void setUserPIN(char[] userPIN)
LoginManager.loginUser(TokenManager, Session, char[])
method. However, it is then
up to the concrete login manager, if it uses this PIN. The default login manager will use it.userPIN
- The user PIN to pass to the login manager.public java.util.Properties getProperties()
public java.lang.String getProperty(java.lang.String key)
getProperty
in class java.security.Provider
key
- The name of the requested algorithm.public java.lang.String getProperty(java.lang.String key, java.lang.String defaultValue)
getProperty(String)
.getProperty
in class java.util.Properties
key
- The properties key.defaultValue
- The default value.public java.lang.String getKeystoreSupportProvider()
public void setKeystoreSupportProvider(java.lang.String providerName)
providerName
- The name of the keystore support provider or null to use the default provider order.public boolean isLoginKeystoreOnDemand()
public void setLoginKeystoreOnDemand(boolean loginOnDemand)
loginOnDemand
- True, to enable login on demand, false to disable it.public boolean isCheckMechanismSupported()
public void setCheckMechanismSupported(boolean checkMechanismSupported)
checkMechanismSupported
- True, to check if an algorithm is supported by the token, false to not check it.public boolean isMultiThreadInit()
CKF_OS_LOCKING_OK
set to true. If set to false, the provider will initialize the
module without any argument (NULL_PTR
). To safely use a PKCS#11 module with
multiple threads concurrently, this must be set to true
.true
, if the provider initializes the underlying PKCS#11 module for
multi-threaded operation; false
, otherwise.public void setMultiThreadInit(boolean multiThread)
CKF_OS_LOCKING_OK
set to true. If set to false, the provider will initialize the
module without any argument (NULL_PTR
). To safely use a PKCS#11 module with
multiple threads concurrently, this must be set to true
.multiThread
- true
, if the provider initializes the underlying PKCS#11 module for
multi-threaded operation; false
, otherwise.public java.lang.String getModuleAlreadyInitialized()
ignore
or exception
.public void setModuleAlreadyInitialized(java.lang.String value)
value
- The property value; e.g. ignore
or exception
.public int getSessionPoolMaxSize()
public boolean isCheckSessionIntegrity()
#getSessionInfo
after
borrowing from the pool.public void setSessionPoolMaxSize(int sessionPoolMaxSize)
sessionPoolMaxSize
- Set the maximum number of sessions to keep in the pool.public TokenManager getTokenManager()
public double getVersion()
getVersion
in class java.security.Provider
public java.lang.String getInfo()
getInfo
in class java.security.Provider
public java.lang.String toString()
toString
in class java.security.Provider
protected void addAlgorithms()
public void initialize() throws IAIKPkcs11Exception
IAIKPkcs11Exception
- If the provider is not appropriately configured.public void disableCleanerThread()
protected boolean isEngineClassKey(java.lang.String key)
key
- The property key to check.protected void setVersion()
protected void setInfo()
public boolean equals(java.lang.Object other)
equals
in interface java.util.Map<java.lang.Object,java.lang.Object>
equals
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
other
- The other provider to compare to.true
if this object refers to the same object instance than the
other
object.public int hashCode()
equals(Object)
.hashCode
in interface java.util.Map<java.lang.Object,java.lang.Object>
hashCode
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
IAIK JavaSecurity Website https://jce.iaik.tugraz.at/
IAIK at Graz University of Technology, Austria, Europe
Copyright 2001-2023 IAIK, Graz University of Technology, Inffeldgasse 16a, 8010 Graz, Austria. All Rights Reserved. Version 1.9.4