org.hardtokenmgmt.core.token
Class TokenManager

java.lang.Object
  extended by org.hardtokenmgmt.core.token.TokenManager

public class TokenManager
extends java.lang.Object

This is the main class for token management. It manages available slots (card readers) and returns the right IToken interface for inserted cards depending on card type.

Version:
$Id$
Author:
Philip Vendil 2006-aug-29

Field Summary
static int SLOTTYPE_ADMIN
          Constants indicating that all slots containing certificates belonging to an administrator.
static int SLOTTYPE_ALL
          Constants indicating that all available slots (With or without any cards inserted) should be returned.
static int SLOTTYPE_PRESENT
          Constants indicating that all available slots (With any cards inserted) should be returned.
static int SLOTTYPE_PROCESSABLECARDS
          Constants indicating that all slots with a processable card inserted should be returned.
 
Constructor Summary
TokenManager()
           
 
Method Summary
 void flushTokenCache()
          Method that should be called every time one of the tokens is removed from it's reader.
 ILogonCertificateSelector getLogonCertificateSelector()
          Method returning the logon certificate selector defined in the global properties file.
 java.util.Collection getSlots(int type)
          Method returning a Collection of iaik.pkcs.pkcs11.Slot.
 IToken getToken(iaik.pkcs.pkcs11.Slot slot)
          Method that returns the the IToken implementation for the token inserted in the selected slot.
 void stopAllThreads()
          Method that should be called by the main application when terminating, signaling that all the current threads should stop.
 void stopNonAdminCardWaitingThreads()
          Methods that waits for all card waiting threads to stop before proceeding.
 void switchToAdminCardRemovalRunnable(java.util.Observer observer)
          Method used in the logon controller to switch waiting for any card to be removed to just wait for the administration card to be removed.
 void waitForAdminCardRemoval(java.util.Observer observer)
          Special Method checking that the admin card is still inserted
 void waitForCardInsertion(java.util.Observer observer)
          Method waiting for a card to be inserted in a slot not containing the administrator related certificates.
 void waitForCardRemoval(java.util.Observer observer)
          Method waiting for the card to be removed from selected slot.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SLOTTYPE_ALL

public static final int SLOTTYPE_ALL
Constants indicating that all available slots (With or without any cards inserted) should be returned.

See Also:
Constant Field Values

SLOTTYPE_PRESENT

public static final int SLOTTYPE_PRESENT
Constants indicating that all available slots (With any cards inserted) should be returned.

See Also:
Constant Field Values

SLOTTYPE_ADMIN

public static final int SLOTTYPE_ADMIN
Constants indicating that all slots containing certificates belonging to an administrator.

See Also:
Constant Field Values

SLOTTYPE_PROCESSABLECARDS

public static final int SLOTTYPE_PROCESSABLECARDS
Constants indicating that all slots with a processable card inserted should be returned.

See Also:
Constant Field Values
Constructor Detail

TokenManager

public TokenManager()
Method Detail

getSlots

public java.util.Collection getSlots(int type)
                              throws iaik.pkcs.pkcs11.TokenException
Method returning a Collection of iaik.pkcs.pkcs11.Slot. *

Parameters:
type - one of the SLOTTYPE constants of slots to return
Returns:
Collection of iaik.pkcs.pkcs11.Slot is never null.
Throws:
iaik.pkcs.pkcs11.TokenException
OperationNotSupportedException

waitForCardInsertion

public void waitForCardInsertion(java.util.Observer observer)
Method waiting for a card to be inserted in a slot not containing the administrator related certificates.

Parameters:
observer - class the Observer interface that waits for the card insertion. The observer will get slot as argument Or the exception that occurred during the process.
Throws:
OperationNotSupportedException

waitForCardRemoval

public void waitForCardRemoval(java.util.Observer observer)
Method waiting for the card to be removed from selected slot.

Parameters:
observer - observer class the Observer interface that waits for the card removal for the given slot. The observer will get a null value if the operation was successful or the exception if something went wrong.
Throws:
OperationNotSupportedException

waitForAdminCardRemoval

public void waitForAdminCardRemoval(java.util.Observer observer)
Special Method checking that the admin card is still inserted

Parameters:
observer - observer class the Observer interface that waits for the card removal for the given slot. The observer will get a null value if the operation was successful or the exception if something went wrong.
Throws:
OperationNotSupportedException

switchToAdminCardRemovalRunnable

public void switchToAdminCardRemovalRunnable(java.util.Observer observer)
Method used in the logon controller to switch waiting for any card to be removed to just wait for the administration card to be removed.


stopNonAdminCardWaitingThreads

public void stopNonAdminCardWaitingThreads()
Methods that waits for all card waiting threads to stop before proceeding.


getToken

public IToken getToken(iaik.pkcs.pkcs11.Slot slot)
Method that returns the the IToken implementation for the token inserted in the selected slot.

Parameters:
slot - with token in it
Returns:
null if token isn't supported or when the slot is empty.

flushTokenCache

public void flushTokenCache()
Method that should be called every time one of the tokens is removed from it's reader.


stopAllThreads

public void stopAllThreads()
Method that should be called by the main application when terminating, signaling that all the current threads should stop. Used especially in applet environments.


getLogonCertificateSelector

public ILogonCertificateSelector getLogonCertificateSelector()
Method returning the logon certificate selector defined in the global properties file.