org.opensc.pkcs11
Class PKCS11LoadStoreParameter

java.lang.Object
  extended by org.opensc.pkcs11.PKCS11LoadStoreParameter
All Implemented Interfaces:
KeyStore.LoadStoreParameter

public class PKCS11LoadStoreParameter
extends Object
implements KeyStore.LoadStoreParameter

An instance of this class should be passed to the function KeyStore.load() in order to configure PKCS11 store loading with parameters appropriate for cyrptographic tokens.

Author:
wglas
See Also:
KeyStore.load(java.security.KeyStore.LoadStoreParameter)

Constructor Summary
PKCS11LoadStoreParameter()
          Constructs a PKCS11LoadStoreParameter instance using default settings.
 
Method Summary
 CallbackHandler getEventHandler()
           
 KeyStore.ProtectionParameter getProtectionParameter()
           
 Long getSlotId()
           
 KeyStore.ProtectionParameter getSOProtectionParameter()
           
 boolean isWaitForSlot()
           
 boolean isWriteEnabled()
           
 void setEventHandler(CallbackHandler eventHandler)
          Sets the CallbackHandler, which receives callbacks of type PKCS11EventCallback.
 void setProtectionCallback(CallbackHandler handler)
          This is a convenience function for setting a callback protection to the protection parameter.
 void setProtectionParameter(KeyStore.ProtectionParameter protectionParameter)
           
 void setProtectionPIN(char[] pin)
          This is a convenience function for setting a password protection to the protection parameter.
 void setSlotId(Long slotId)
           
 void setSOProtectionCallback(CallbackHandler handler)
          This is a convenience function for setting a callback protection to the SO protection parameter.
 void setSOProtectionParameter(KeyStore.ProtectionParameter protectionParameter)
           
 void setSOProtectionPIN(char[] pin)
          This is a convenience function for setting a password protection to the SO protection parameter.
 void setWaitForSlot(boolean waitForSlot)
           
 void setWriteEnabled(boolean writeEnabled)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PKCS11LoadStoreParameter

public PKCS11LoadStoreParameter()
Constructs a PKCS11LoadStoreParameter instance using default settings. No protection parameters are set, the slot ID ist set to null and KeyStore.load() does not not wait for a token insertion, if no token is present.

Method Detail

getProtectionParameter

public KeyStore.ProtectionParameter getProtectionParameter()
Specified by:
getProtectionParameter in interface KeyStore.LoadStoreParameter

setProtectionParameter

public void setProtectionParameter(KeyStore.ProtectionParameter protectionParameter)
Parameters:
protectionParameter - The protectionParameter for the normal user to set A protection parameter for a normal user is needed for signing as well as for listing private keys on the token.
See Also:
KeyStore.PasswordProtection, KeyStore.CallbackHandlerProtection, PasswordCallback

setProtectionPIN

public void setProtectionPIN(char[] pin)
This is a convenience function for setting a password protection to the protection parameter. Equivalent to calling this.setProtectionParameter(new PasswordProtection(pin)).

Parameters:
pin - The pin to present to the token.
See Also:
PKCS11LoadStoreParameter#setProtectionParameter(ProtectionParameter)

setProtectionCallback

public void setProtectionCallback(CallbackHandler handler)
This is a convenience function for setting a callback protection to the protection parameter. The callback handler will receive callbacks of type PasswordCallback. Equivalent to calling this.setProtectionParameter(new CallbackHandlerProtection(handler)).

Parameters:
handler - The callback handler for querying the PIN from the user by means of a PasswordCallback.
See Also:
PKCS11LoadStoreParameter#setProtectionParameter(ProtectionParameter), PasswordCallback, KeyStore.CallbackHandlerProtection

getSOProtectionParameter

public KeyStore.ProtectionParameter getSOProtectionParameter()
Returns:
The protection parameter of the security officer, which might be used in order to store a certificate on the token.

setSOProtectionParameter

public void setSOProtectionParameter(KeyStore.ProtectionParameter protectionParameter)
Parameters:
protectionParameter - The security officer protection parameter to be used. A SO protection parameter is used, when the token is opened in read/write mode.
See Also:
KeyStore.PasswordProtection, KeyStore.CallbackHandlerProtection, PasswordCallback

setSOProtectionPIN

public void setSOProtectionPIN(char[] pin)
This is a convenience function for setting a password protection to the SO protection parameter. Equivalent to calling this.setSOProtectionParameter(new PasswordProtection(pin)).

Parameters:
pin - The SO pin to present to the token.
See Also:
PKCS11LoadStoreParameter#setSOProtectionParameter(ProtectionParameter)

setSOProtectionCallback

public void setSOProtectionCallback(CallbackHandler handler)
This is a convenience function for setting a callback protection to the SO protection parameter. The callback handler will receive callbacks of type PasswordCallback. Equivalent to calling this.setSOProtectionParameter(new CallbackHandlerProtection(handler)).

Parameters:
handler - The callback handler for querying the SO PIN from the user by means of a PasswordCallback.
See Also:
PKCS11LoadStoreParameter#setSOProtectionParameter(ProtectionParameter), PasswordCallback, KeyStore.CallbackHandlerProtection

getEventHandler

public CallbackHandler getEventHandler()
Returns:
Returns the CallbackHandler, which receives callbacks of type PKCS11EventCallback. This handler my be used in order to display some helpful information to the user while the KeyStore is performing the authentication against the token.
See Also:
PKCS11EventCallback

setEventHandler

public void setEventHandler(CallbackHandler eventHandler)
Sets the CallbackHandler, which receives callbacks of type PKCS11EventCallback.

Parameters:
eventHandler - The CallbackHandler to set.
See Also:
getEventHandler(), PKCS11EventCallback

getSlotId

public Long getSlotId()
Returns:
Returns the ID of the slot to be opened.

setSlotId

public void setSlotId(Long slotId)
Parameters:
slotId - Set the ID of the slot to be opened. If set to null, the KeyStore opens the first slot with a present token.

isWaitForSlot

public boolean isWaitForSlot()
Returns:
Returns, whether the KeyStore should wait for a token to be inserted if no token is found.

setWaitForSlot

public void setWaitForSlot(boolean waitForSlot)
Parameters:
waitForSlot - Set, whether the KeyStore should wait for a token to be inserted if no token is found.

isWriteEnabled

public boolean isWriteEnabled()
Returns:
Returns, whether the token should be opened in read/write mode instead of read-only mode.

setWriteEnabled

public void setWriteEnabled(boolean writeEnabled)
Parameters:
writeEnabled - Set, whether the token should be opened in read/write mode instead of read-only mode.