com.ibm.opencard.terminal.pcsc10
Class Pcsc10LockableTerminal

java.lang.Object
  |
  +--opencard.core.terminal.CardTerminal
        |
        +--opencard.opt.terminal.AbstractLockableTerminal
              |
              +--com.ibm.opencard.terminal.pcsc10.Pcsc10LockableTerminal

public final class Pcsc10LockableTerminal
extends opencard.opt.terminal.AbstractLockableTerminal
implements opencard.opt.terminal.TerminalCommand, opencard.core.terminal.Pollable

Implementation of a lockable OpenCard CardTerminal for PCSC.

See Also:
AbstractLockableTerminal

Fields inherited from class opencard.core.terminal.CardTerminal
address, name, slots, type
 
Constructor Summary
protected Pcsc10LockableTerminal(java.lang.String name, java.lang.String type, java.lang.String address)
          Instantiate an Pcsc10Terminal.
 
Method Summary
protected  void cardRemoved(int slotID)
          Signal to observers that an inserted card was removed.
 void close()
          Close the connection to the card terminal.
 opencard.core.terminal.CardID getCardID(int slot)
          Return the CardID of the presently inserted card.
 opencard.core.terminal.CardID getCardID(int slot, int timeout)
          Deprecated.  
protected  void internalCloseSlotChannel(opencard.core.terminal.SlotChannel sc)
          The internal closeSlotChannel method.
protected  java.util.Properties internalFeatures(java.util.Properties features)
          Query the card terminal about its features.
protected  void internalLock()
           
protected  void internalLockSlot(int slotNr)
           
protected  opencard.core.terminal.CardID internalReset(int slot, int ms)
          Implementation of CardTerminal.internalReset().
protected  opencard.core.terminal.ResponseAPDU internalSendAPDU(int slot, opencard.core.terminal.CommandAPDU capdu, int ms)
          The implementation of CardTerminal.internalSendAPDU().
protected  void internalUnlock()
           
protected  void internalUnlockSlot(int slotNr)
           
 boolean isCardPresent(int slot)
          Check whether there is a smart card present.
protected  void lockableOpenSlotChannel(int slotID)
          The internal openSlotChannel method.
 void open()
          Open the card terminal: We register with the CardTerminalRegistry as a Pollable card terminal.
 void poll()
          This method is normally used by the CardTerminalRegistry to generate the OpenCard events if the Slot implementation does not support events itself.
 byte[] sendTerminalCommand(byte[] cmd)
          Send control command to terminal.
 byte[] sendTerminalCommand(byte[] cmd, java.lang.Object lockHandle)
          Send control command to terminal.
protected  opencard.core.terminal.CardTerminalException translatePcscException(PcscException e)
          translate the PcscException into CardTerminalException.
 
Methods inherited from class opencard.opt.terminal.AbstractLockableTerminal
getSlotLockHandle, getTerminalLockHandle, internalOpenSlotChannel, internalOpenSlotChannel, lock, lockSlot, unlock, unlockSlot
 
Methods inherited from class opencard.core.terminal.CardTerminal
addSlots, cardInserted, closeSlotChannel, enumerateSlots, features, getAddress, getName, getSlot, getSlots, getType, isCardPresent, isSlotChannelAvailable, isSlotChannelAvailable, openSlotChannel, openSlotChannel, openSlotChannel, reset, reset, sendAPDU, sendAPDU, sendVerifiedCommandAPDU, slots, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Pcsc10LockableTerminal

protected Pcsc10LockableTerminal(java.lang.String name,
                                 java.lang.String type,
                                 java.lang.String address)
                          throws opencard.core.terminal.CardTerminalException
Instantiate an Pcsc10Terminal.
Parameters:
name - The user friendly name.
type - The terminal type (here "PCSC")
address - not used
Throws:
opencard.core.terminal.CardTerminalException - Thrown when a problem occured.
Method Detail

open

public void open()
          throws opencard.core.terminal.CardTerminalException
Open the card terminal: We register with the CardTerminalRegistry as a Pollable card terminal.
Overrides:
open in class opencard.core.terminal.CardTerminal

close

public void close()
           throws opencard.core.terminal.CardTerminalException
Close the connection to the card terminal. Could be used by unregister to free up the resources used by the terminal.
Throws:
opencard.core.terminal.CardTerminalException - Thrown if there are problems with closing the connection
Overrides:
close in class opencard.core.terminal.CardTerminal

internalReset

protected opencard.core.terminal.CardID internalReset(int slot,
                                                      int ms)
                                               throws opencard.core.terminal.CardTerminalException
Implementation of CardTerminal.internalReset().
Overrides:
internalReset in class opencard.core.terminal.CardTerminal

internalFeatures

protected java.util.Properties internalFeatures(java.util.Properties features)
Query the card terminal about its features.

Returns:
features
Overrides:
internalFeatures in class opencard.core.terminal.CardTerminal

isCardPresent

public boolean isCardPresent(int slot)
                      throws opencard.core.terminal.CardTerminalException
Check whether there is a smart card present.
Parameters:
slot - Number of the slot to check (must be 0 for PCSC)
Returns:
True if there is a smart card inserted in the card terminals slot.
Overrides:
isCardPresent in class opencard.core.terminal.CardTerminal

getCardID

public opencard.core.terminal.CardID getCardID(int slot,
                                               int timeout)
                                        throws opencard.core.terminal.CardTerminalException
Deprecated.  
Overrides:
getCardID in class opencard.core.terminal.CardTerminal

getCardID

public opencard.core.terminal.CardID getCardID(int slot)
                                        throws opencard.core.terminal.CardTerminalException
Return the CardID of the presently inserted card. Will returned the cached card if slot's status has not changed; otherwise it will really retrieve the CardID.

Parameters:
slot - slot number
Returns:
A CardID object representing the inserted smart card.
Throws:
opencard.core.terminal.CardTerminalException - thrown when problem occured getting the ATR of the card
Overrides:
getCardID in class opencard.core.terminal.CardTerminal

lockableOpenSlotChannel

protected void lockableOpenSlotChannel(int slotID)
                                throws opencard.core.terminal.CardTerminalException
The internal openSlotChannel method. lockableOpenSlotChannel is executed at the beginning of openSlotChannel.
Parameters:
slotID - The number of the slot for which a SlotChannel is requested.
Overrides:
lockableOpenSlotChannel in class opencard.opt.terminal.AbstractLockableTerminal

internalCloseSlotChannel

protected void internalCloseSlotChannel(opencard.core.terminal.SlotChannel sc)
                                 throws opencard.core.terminal.CardTerminalException
The internal closeSlotChannel method. internalCloseSlotChannel is executed at the end of closeSlotChannel.
Parameters:
SlotChannel - The SlotChannel to close.
Throws:
opencard.core.terminal.CardTerminalException - thrown in case of errors closing the card (e.g. error disconnecting the card).
Overrides:
internalCloseSlotChannel in class opencard.core.terminal.CardTerminal

sendTerminalCommand

public byte[] sendTerminalCommand(byte[] cmd)
                           throws opencard.core.terminal.CardTerminalException
Send control command to terminal.
Specified by:
sendTerminalCommand in interface opencard.opt.terminal.TerminalCommand
Parameters:
cmd - a byte array containing the command to be sent to the card terminal
Returns:
Response from terminal.
Throws:
opencard.core.terminal.CardTerminalException - Exception thrown by driver.
See Also:
TerminalCommand

sendTerminalCommand

public byte[] sendTerminalCommand(byte[] cmd,
                                  java.lang.Object lockHandle)
                           throws opencard.core.terminal.CardTerminalException
Send control command to terminal.
Parameters:
cmd - a byte array containing the command to be sent to the card terminal
Returns:
Response from terminal.
Throws:
opencard.core.terminal.CardTerminalException - Exception thrown by driver.
See Also:
TerminalCommand

internalSendAPDU

protected opencard.core.terminal.ResponseAPDU internalSendAPDU(int slot,
                                                               opencard.core.terminal.CommandAPDU capdu,
                                                               int ms)
                                                        throws opencard.core.terminal.CardTerminalException
The implementation of CardTerminal.internalSendAPDU().
Parameters:
slot - logical slot number
capdu - C-APDU to send to the card
ms - timeout in ms (not supported, ignored)
Overrides:
internalSendAPDU in class opencard.core.terminal.CardTerminal

cardRemoved

protected void cardRemoved(int slotID)
Signal to observers that an inserted card was removed.

Parameters:
slot - slot number
Overrides:
cardRemoved in class opencard.core.terminal.CardTerminal

poll

public void poll()
          throws opencard.core.terminal.CardTerminalException
This method is normally used by the CardTerminalRegistry to generate the OpenCard events if the Slot implementation does not support events itself.
Specified by:
poll in interface opencard.core.terminal.Pollable

translatePcscException

protected opencard.core.terminal.CardTerminalException translatePcscException(PcscException e)
translate the PcscException into CardTerminalException.


internalLock

protected void internalLock()
                     throws opencard.core.terminal.CardTerminalException
Overrides:
internalLock in class opencard.opt.terminal.AbstractLockableTerminal

internalUnlock

protected void internalUnlock()
                       throws opencard.core.terminal.CardTerminalException
Overrides:
internalUnlock in class opencard.opt.terminal.AbstractLockableTerminal

internalLockSlot

protected void internalLockSlot(int slotNr)
                         throws opencard.core.terminal.CardTerminalException
Overrides:
internalLockSlot in class opencard.opt.terminal.AbstractLockableTerminal

internalUnlockSlot

protected void internalUnlockSlot(int slotNr)
                           throws opencard.core.terminal.CardTerminalException
Overrides:
internalUnlockSlot in class opencard.opt.terminal.AbstractLockableTerminal