|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectopencard.core.terminal.CardTerminal
public abstract class CardTerminal
The CardTerminal class represents a physical card terminal. It is
assumed that a certain card terminal provides (at least one) slot for a
smart card or a transceiver for a contactless smart card. Please NOTE that
throughout OpenCard Framework inserting or removing a card may
equally well mean that a connection between a contactless card and a transceiver
was established or ended respectively.
Depending on the features of the specific card terminal a concrete
implementation might also implement additional, optional, interfaces (as found in
opencard.opt.terminal.
Similar to the PCSC smart card specification we assume that the card terminal will automatically power up the smart card and retrieve the ATR response (available through cardID() as a CardID object).
CardTerminal objects are created by a CardTerminalFactory and registered in the CardTerminalRegistry. To get an enumeration of the available CardTerminals invoke CardTerminalRegistry.getCardTerminals ().
CardTerminalRegistry
,
CardTerminalFactory
,
CardID
Field Summary | |
---|---|
protected java.lang.String |
address
|
protected java.lang.String |
name
Useful information about this card terminal: the name, the type, and the address (usually meaning the COM port) as registered with the CardTerminalRegistry. |
protected java.util.Vector |
slots
Deprecated. |
protected java.lang.String |
type
|
Constructor Summary | |
---|---|
protected |
CardTerminal(java.lang.String name,
java.lang.String type,
java.lang.String address)
Instantiates a CardTerminal object. |
Method Summary | |
---|---|
protected void |
addSlots(int numberOfSlots)
Add Slots to the CardTerminal. |
protected void |
cardInserted(int slotID)
Notify listeners that a card was inserted into a slot of this terminal. |
protected void |
cardRemoved(int slotID)
Notify listeners that a card was removed from a slot of this terminal. |
abstract void |
close()
Closes the CardTerminal. |
void |
closeSlotChannel(SlotChannel sc)
Closes a SlotChannel. |
java.util.Enumeration |
enumerateSlots()
Deprecated. |
java.util.Properties |
features()
Query the card terminal about its features. |
java.lang.String |
getAddress()
Return the address of this CardTerminal. |
abstract CardID |
getCardID(int slotID)
Return the answer-to-reset (ATR) response of the card inserted in slot slotID as a CardID. |
CardID |
getCardID(int slotID,
int ms)
Deprecated. |
java.lang.String |
getName()
Return the name associated with this CardTerminal. |
Slot |
getSlot(int slotID)
Deprecated. |
int |
getSlots()
Return the number of slots belonging to this CardTerminal object. |
java.lang.String |
getType()
Return the type of this CardTerminal. |
protected void |
internalCloseSlotChannel(SlotChannel sc)
The internal closeSlotChannel method. |
protected java.util.Properties |
internalFeatures(java.util.Properties features)
The CardTerminal internal features() method to be provided by the concrete implementation. |
protected void |
internalOpenSlotChannel(int slotID)
The internal openSlotChannel method. |
protected void |
internalOpenSlotChannel(int slotID,
java.lang.Object lockHandle)
The internal openSlotChannel method for locked terminals (default implementation). |
protected CardID |
internalReset(int slot,
boolean warm)
The internal reset method may be overwritten by the actual implementation to support warm resets. |
protected abstract CardID |
internalReset(int slot,
int ms)
The internal reset method to be provided by the concrete implementation. |
protected abstract ResponseAPDU |
internalSendAPDU(int slot,
CommandAPDU capdu,
int ms)
The internalSendAPDU method to be provided by the concrete implementation. |
abstract boolean |
isCardPresent(int slotID)
Check whether there is a smart card present in a particular slot. |
boolean |
isCardPresent(Slot slot)
Deprecated. use isCardPresent(int) instead |
boolean |
isSlotChannelAvailable(int slotID)
Check whether a SlotChannel is available for a particular slot. |
boolean |
isSlotChannelAvailable(Slot slot)
Deprecated. use isSlotChannelAvailable(int) instead |
abstract void |
open()
Initializes the CardTerminal. |
SlotChannel |
openSlotChannel(int slotID)
Open a SlotChannel on Slot number slotID. |
SlotChannel |
openSlotChannel(int slotID,
java.lang.Object lockHandle)
Open a SlotChannel on Slot number slotID. |
SlotChannel |
openSlotChannel(Slot slot)
Deprecated. use openSlotChannel(int) instead |
CardID |
reset(SlotChannel sc)
Reset a smart card inserted in a slot. |
CardID |
reset(SlotChannel sc,
boolean warm)
Reset a smart card inserted in a slot. |
CardID |
reset(SlotChannel sc,
int ms)
Deprecated. use reset(SlotChannel) |
ResponseAPDU |
sendAPDU(SlotChannel sc,
CommandAPDU capdu)
Send a CommandAPDU on a slot. |
ResponseAPDU |
sendAPDU(SlotChannel sc,
CommandAPDU capdu,
int ms)
Deprecated. |
ResponseAPDU |
sendVerifiedCommandAPDU(SlotChannel chann,
CommandAPDU capdu,
CHVControl vc,
int ms)
default implementation for deprecated method in interface VerifiedAPDUInterface. |
Slot[] |
slots()
Deprecated. use getSlots() instead |
java.lang.String |
toString()
Returns a printable representation of this CardTerminal object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected java.util.Vector slots
protected final java.lang.String name
protected final java.lang.String type
protected final java.lang.String address
Constructor Detail |
---|
protected CardTerminal(java.lang.String name, java.lang.String type, java.lang.String address)
name
- The user friendly name.type
- The terminal type.address
- An identifier for the driver to locate the terminal.Method Detail |
---|
public java.util.Enumeration enumerateSlots()
public final java.util.Properties features()
Each feature is represented by a property. The standard features are
public java.lang.String getAddress()
public abstract CardID getCardID(int slotID) throws CardTerminalException
This call should NOT block if no card is present.
slotID
- slot id.
CardTerminalException
- Thrown in case of problems in the card terminal.public CardID getCardID(int slotID, int ms) throws CardTerminalException
CardTerminalException
public java.lang.String getName()
public Slot getSlot(int slotID) throws java.lang.IndexOutOfBoundsException
java.lang.IndexOutOfBoundsException
public java.lang.String getType()
public Slot[] slots()
public int getSlots()
public abstract boolean isCardPresent(int slotID) throws CardTerminalException
slotID
- slot to check for a card.
CardTerminalException
- thrown in case of problems getting the status from CardTerminal
(or other serious problems in the terminal).public boolean isCardPresent(Slot slot) throws CardTerminalException
CardTerminalException
public boolean isSlotChannelAvailable(int slotID)
slotID
- The slot to check.
public boolean isSlotChannelAvailable(Slot slot)
public abstract void open() throws CardTerminalException
CardTerminalException
- thrown in case of initialization-errors
(e.g. couldn't setup transfer protocol between CardTerminal and reader).public abstract void close() throws CardTerminalException
CardTerminalException
- thrown in case of initialization-errors
(e.g. couldn't setup transfer protocol between CardTerminal and reader).public final SlotChannel openSlotChannel(int slotID) throws InvalidSlotChannelException, java.lang.IndexOutOfBoundsException, CardTerminalException
slotID
- The number of the slot for which a SlotChannel
is requested.
InvalidSlotChannelException
- Thrown when slot channel is already allocated.
java.lang.IndexOutOfBoundsException
- Thrown when slotID is out of bounds.
CardTerminalException
- Thrown when internalOpenSlotChannel failed.public final SlotChannel openSlotChannel(int slotID, java.lang.Object lockHandle) throws InvalidSlotChannelException, java.lang.IndexOutOfBoundsException, CardTerminalException
slotID
- The number of the slot for which a SlotChannel
is requested.lockHandle
- trust ticket obtained from locking the terminal
InvalidSlotChannelException
- Thrown when slot channel is already allocated.
java.lang.IndexOutOfBoundsException
- Thrown when slotID is out of bounds.
CardTerminalException
- Thrown when internalOpenSlotChannel failed.public final SlotChannel openSlotChannel(Slot slot) throws InvalidSlotChannelException, java.lang.IndexOutOfBoundsException, CardTerminalException
InvalidSlotChannelException
java.lang.IndexOutOfBoundsException
CardTerminalException
public final void closeSlotChannel(SlotChannel sc) throws InvalidSlotChannelException, CardTerminalException
sc
- The SlotChannel to close.
InvalidSlotChannelException
- when slot channel of the slot in the passed SlotChannel is not the
same as the one passed
CardTerminalException
- thrown in case of problem in internalCloseSlotChannelpublic final CardID reset(SlotChannel sc, int ms) throws InvalidSlotChannelException, CardTerminalException
InvalidSlotChannelException
CardTerminalException
public final CardID reset(SlotChannel sc) throws InvalidSlotChannelException, CardTerminalException
sc
- The open SlotChannel attached to the slot.
InvalidSlotChannelException
- Thrown when the supplied SlotChannel is not valid.
CardTerminalException
- Thrown when error occurred in internalResetpublic final CardID reset(SlotChannel sc, boolean warm) throws InvalidSlotChannelException, CardTerminalException
sc
- The open SlotChannel attached to the slot.warm
- Perform a warm reset rather than a cold reset
InvalidSlotChannelException
- Thrown when the supplied SlotChannel is not valid.
CardTerminalException
- Thrown when error occurred in internalResetpublic final ResponseAPDU sendAPDU(SlotChannel sc, CommandAPDU capdu) throws InvalidSlotChannelException, CardTerminalException
sc
- The open SlotChannel attached to the slot.capdu
- The CommandAPDU to send.
InvalidSlotChannelException
- Thrown when the supplied SlotChannel is not valid.
CardTerminalException
- thrown in case of problems in the CardTerminal.public final ResponseAPDU sendAPDU(SlotChannel sc, CommandAPDU capdu, int ms) throws InvalidSlotChannelException, CardTerminalException
InvalidSlotChannelException
CardTerminalException
public java.lang.String toString()
toString
in class java.lang.Object
protected void addSlots(int numberOfSlots) throws CardTerminalException
numberOfSlots
- The number of slots to add.
CardTerminalException
- Thrown when instanciating of Slot failed.protected void cardRemoved(int slotID)
slot
- slot number of the slot where a card was removedprotected void cardInserted(int slotID)
slot
- slot number of the slot where a card was insertedprotected java.util.Properties internalFeatures(java.util.Properties features)
features
- A Properties object that needs to be enhanced
with the card terminal specific features.
protected void internalOpenSlotChannel(int slotID) throws CardTerminalException
slotID
- The number of the slot for which a SlotChannel is requested.
CardTerminalException
- thrown in case of errors opening the card (e.g. error powering card).protected void internalOpenSlotChannel(int slotID, java.lang.Object lockHandle) throws CardTerminalException
slotID
- The number of the slot for which a SlotChannel is requested.lockHandle
- the trust ticket that the lock owner obtained when locking the terminal
or slot
CardTerminalException
- thrown in case of errors opening the card (e.g. error powering card).protected void internalCloseSlotChannel(SlotChannel sc) throws CardTerminalException
SlotChannel
- The SlotChannel to close.
CardTerminalException
- thrown in case of errors closing the card (e.g. error disconnecting the card).protected abstract CardID internalReset(int slot, int ms) throws CardTerminalException
slot
- The slot number of the slot to be resetted.ms
- To be ignored. If the card does not respond within the time
specified for the protocol an exception should be thrown.
CardTerminalException
- thrown in case of errors during resetprotected CardID internalReset(int slot, boolean warm) throws CardTerminalException
slot
- The slot number of the slot to be resetted.ms
- To be ignored. If the card does not respond within the time
specified for the protocol an exception should be thrown.
CardTerminalException
- thrown in case of errors during resetprotected abstract ResponseAPDU internalSendAPDU(int slot, CommandAPDU capdu, int ms) throws CardTerminalException
slot
- The slot number of the slot to be resetted.capdu
- The CommandAPDU to send.ms
- To be ignored. If the card does not respond within the time
specified for the protocol an exception should be thrown.
CardTerminalException
- thrown in case of errors in the CardTerminal (e.g. errors during data exchange)public ResponseAPDU sendVerifiedCommandAPDU(SlotChannel chann, CommandAPDU capdu, CHVControl vc, int ms) throws CardTerminalException
CardTerminalException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |