de.cardcontact.opencard.terminal.jcwdpsim
Class JCWDPSimCardTerminal

java.lang.Object
  extended by opencard.core.terminal.CardTerminal
      extended by de.cardcontact.opencard.terminal.jcwdpsim.JCWDPSimCardTerminal
All Implemented Interfaces:
Pollable

public class JCWDPSimCardTerminal
extends CardTerminal
implements Pollable

Class implementing a SUN JCWDE simulation card terminal using T=1 protocol This class is based on the Gemplus ApduIO reference implementation. There were some necessary modifications to adapt that terminal to the new JC 2.2.2 reference implementation.

Author:
Frank Thater (info@cardcontact.de)

Field Summary
 
Fields inherited from class opencard.core.terminal.CardTerminal
address, name, slots, type
 
Constructor Summary
JCWDPSimCardTerminal(java.lang.String name, java.lang.String type, java.lang.String address, java.lang.String host, int port)
          Constructor for JCWDPSimCardTerminal
 
Method Summary
 void close()
          Disable the terminal Removes the terminal from the polling registry, powers down the client interface and closes the socket
 CardID getCardID(int slotID)
          Return the ATR of the card inserted in the specified slot.
protected  CardID internalReset(int slotID, int ms)
          Re-power up the card and retreives the ATR.
protected  ResponseAPDU internalSendAPDU(int slotID, CommandAPDU capdu, int ms)
          Exchange APDU commands
 boolean isCardPresent(int slotID)
          Check whether a smart card is present in a particular slot.
 void open()
          Open the terminal - just adds the terminal to the OCF polling registry.
 void poll()
          Updates the card inserted/removed state.
 
Methods inherited from class opencard.core.terminal.CardTerminal
addSlots, cardInserted, cardRemoved, closeSlotChannel, enumerateSlots, features, getAddress, getCardID, getName, getSlot, getSlots, getType, internalCloseSlotChannel, internalFeatures, internalOpenSlotChannel, internalOpenSlotChannel, internalReset, isCardPresent, isSlotChannelAvailable, isSlotChannelAvailable, openSlotChannel, openSlotChannel, openSlotChannel, reset, 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

JCWDPSimCardTerminal

public JCWDPSimCardTerminal(java.lang.String name,
                            java.lang.String type,
                            java.lang.String address,
                            java.lang.String host,
                            int port)
                     throws CardTerminalException
Constructor for JCWDPSimCardTerminal

Parameters:
name - Friendly name of the terminal
type - Type of the card terminal
address - Identifier for the driver to locate the terminal
host - Host of the remote terminal simulation
port - Port number of the remote terminal simulation
timeout -
Throws:
CardTerminalException
Method Detail

open

public void open()
Open the terminal - just adds the terminal to the OCF polling registry.

Specified by:
open in class CardTerminal
Throws:
CardTerminalException - if there are problems adding the terminal to the registry

close

public void close()
           throws CardTerminalException
Disable the terminal Removes the terminal from the polling registry, powers down the client interface and closes the socket

Specified by:
close in class CardTerminal
Throws:
CardTerminalException - Thrown in case of errors during close process

isCardPresent

public boolean isCardPresent(int slotID)
                      throws CardTerminalException
Check whether a smart card is present in a particular slot.

Specified by:
isCardPresent in class CardTerminal
Parameters:
slotID - slot to check for a card.
Returns:
true if connected to a simulator
Throws:
java.lang.IndexOutOfBoundsException - when the slotID is different from 0
CardTerminalException - thrown in case of problems getting the status from CardTerminal (or other serious problems in the terminal).

getCardID

public CardID getCardID(int slotID)
                 throws CardTerminalException
Return the ATR of the card inserted in the specified slot.

Specified by:
getCardID in class CardTerminal
Parameters:
slotID - slot id.
Returns:
The CardID containing the ATR.
Throws:
CardTerminalException - in case of communication problems.
java.lang.IndexOutOfBoundsException - when the slotID is different from 0

poll

public void poll()
Updates the card inserted/removed state.

Specified by:
poll in interface Pollable

internalReset

protected CardID internalReset(int slotID,
                               int ms)
                        throws CardTerminalException
Re-power up the card and retreives the ATR.

Specified by:
internalReset in class CardTerminal
Parameters:
slotID - the slot number of the slot used.
ms - A timeout in milliseconds. (ignored)
Returns:
The CardID containing the ATR.
Throws:
CardTerminalException - if there is a problem during reset.

internalSendAPDU

protected ResponseAPDU internalSendAPDU(int slotID,
                                        CommandAPDU capdu,
                                        int ms)
                                 throws CardTerminalException
Exchange APDU commands

Specified by:
internalSendAPDU in class CardTerminal
Parameters:
slotID - The slot number of the slot used.
capdu - The CommandAPDU to send.
ms - A timeout in milliseconds. (ignored)
Returns:
the response to this APDU
Throws:
CardTerminalException - if there is an error in apdu exchange