Class CTAPICardTerminal
- java.lang.Object
-
- opencard.core.terminal.CardTerminal
-
- de.cardcontact.opencard.terminal.ctapi4ocf.CTAPICardTerminal
-
- All Implemented Interfaces:
Pollable
,TerminalCommand
- Direct Known Subclasses:
CTAPIWithKeyboardCardTerminal
public class CTAPICardTerminal extends CardTerminal implements Pollable, TerminalCommand
Implements a CT-API card terminal for OCF.
-
-
Field Summary
Fields Modifier and Type Field Description protected CardID[]
cardIdTable
protected byte[]
cardStatus
protected CTAPI
CT
protected char
ctn
static byte[]
getStatus
protected char
pn
static byte[]
requestICC
protected boolean
termopened
-
Fields inherited from class opencard.core.terminal.CardTerminal
address, name, slots, type
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
CTAPICardTerminal(CTAPITerminal ctterm, java.lang.String type)
Create CTAPICardTerminal objectprotected
CTAPICardTerminal(java.lang.String name, java.lang.String type, java.lang.String device, java.lang.String libname)
Create CTAPICardTerminal object
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close used resourcesCardID
getCardID(int slot)
Return ATR for card in slotbyte[]
getStatus()
Issue STATUS command to query status of card reader slotsprotected CardID
internalReset(int slot, int ms)
Reset card in slot and return ATRprotected ResponseAPDU
internalSendAPDU(int slot, CommandAPDU capdu, int ms)
Send APDU to card in slotboolean
isCardPresent(int slot)
Return true is slot contains a cardvoid
open()
Open card terminal connection Called from OCF during startupvoid
poll()
Poll for status change This is called from OCF every secondbyte[]
sendTerminalCommand(byte[] com)
Send a control command to the terminal-
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
-
-
-
-
Constructor Detail
-
CTAPICardTerminal
protected CTAPICardTerminal(java.lang.String name, java.lang.String type, java.lang.String device, java.lang.String libname) throws CardTerminalException
Create CTAPICardTerminal object- Parameters:
name
-type
-device
-libname
-- Throws:
CardTerminalException
-
CTAPICardTerminal
protected CTAPICardTerminal(CTAPITerminal ctterm, java.lang.String type) throws CardTerminalException
Create CTAPICardTerminal object- Parameters:
name
-type
-device
-libname
-- Throws:
CardTerminalException
-
-
Method Detail
-
open
public void open() throws CardTerminalException
Open card terminal connection Called from OCF during startup- Specified by:
open
in classCardTerminal
- Throws:
CardTerminalException
- thrown in case of initialization-errors (e.g. couldn't setup transfer protocol between CardTerminal and reader).
-
close
public void close() throws CardTerminalException
Close used resources- Specified by:
close
in classCardTerminal
- Throws:
CardTerminalException
- thrown in case of initialization-errors (e.g. couldn't setup transfer protocol between CardTerminal and reader).
-
isCardPresent
public boolean isCardPresent(int slot) throws CardTerminalException
Return true is slot contains a card- Specified by:
isCardPresent
in classCardTerminal
- Parameters:
slot
- Slot number starting at 0- Returns:
- True if there is a smart card inserted in the slot.
- Throws:
CardTerminalException
- thrown in case of problems getting the status from CardTerminal (or other serious problems in the terminal).
-
getCardID
public CardID getCardID(int slot) throws CardTerminalException
Return ATR for card in slot- Specified by:
getCardID
in classCardTerminal
- Parameters:
slot
- slot id.- Returns:
- The ATR response in form of a CardID object or null if no card is present.
- Throws:
CardTerminalException
- Thrown in case of problems in the card terminal.
-
internalReset
protected CardID internalReset(int slot, int ms) throws CardTerminalException
Reset card in slot and return ATR- Specified by:
internalReset
in classCardTerminal
- Parameters:
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.- Returns:
- The CardID of the card.
- Throws:
CardTerminalException
- thrown in case of errors during reset
-
internalSendAPDU
protected ResponseAPDU internalSendAPDU(int slot, CommandAPDU capdu, int ms) throws CardTerminalException
Send APDU to card in slot- Specified by:
internalSendAPDU
in classCardTerminal
- Parameters:
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.- Returns:
- A ResponseAPDU.
- Throws:
CardTerminalException
- thrown in case of errors in the CardTerminal (e.g. errors during data exchange)
-
poll
public void poll() throws CardTerminalException
Poll for status change This is called from OCF every second- Specified by:
poll
in interfacePollable
- Throws:
CardTerminalException
- Thrown when error occurred in poll-mechanism.
-
sendTerminalCommand
public byte[] sendTerminalCommand(byte[] com) throws CardTerminalException
Send a control command to the terminal- Specified by:
sendTerminalCommand
in interfaceTerminalCommand
- Parameters:
com
- A byte[] containing the command to be send to the card terminal.- Returns:
- A byte[] with the result (null if no result is available).
- Throws:
CardTerminalException
- ;
-
getStatus
public byte[] getStatus() throws CardTerminalException
Issue STATUS command to query status of card reader slots- Returns:
- Byte array of slot status as returned by STATUS command
- Throws:
CardTerminalException
-
-