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[]cardIdTableprotected byte[]cardStatusprotected CTAPICTprotected charctnstatic byte[]getStatusprotected charpnstatic byte[]requestICCprotected booleantermopened-
Fields inherited from class opencard.core.terminal.CardTerminal
address, name, slots, type
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedCTAPICardTerminal(CTAPITerminal ctterm, java.lang.String type)Create CTAPICardTerminal objectprotectedCTAPICardTerminal(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 voidclose()Close used resourcesCardIDgetCardID(int slot)Return ATR for card in slotbyte[]getStatus()Issue STATUS command to query status of card reader slotsprotected CardIDinternalReset(int slot, int ms)Reset card in slot and return ATRprotected ResponseAPDUinternalSendAPDU(int slot, CommandAPDU capdu, int ms)Send APDU to card in slotbooleanisCardPresent(int slot)Return true is slot contains a cardvoidopen()Open card terminal connection Called from OCF during startupvoidpoll()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 CardTerminalExceptionCreate 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 CardTerminalExceptionOpen card terminal connection Called from OCF during startup- Specified by:
openin 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 CardTerminalExceptionClose used resources- Specified by:
closein 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 CardTerminalExceptionReturn true is slot contains a card- Specified by:
isCardPresentin 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:
getCardIDin 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:
internalResetin 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:
internalSendAPDUin 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 CardTerminalExceptionPoll for status change This is called from OCF every second- Specified by:
pollin interfacePollable- Throws:
CardTerminalException- Thrown when error occurred in poll-mechanism.
-
sendTerminalCommand
public byte[] sendTerminalCommand(byte[] com) throws CardTerminalExceptionSend a control command to the terminal- Specified by:
sendTerminalCommandin 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 CardTerminalExceptionIssue STATUS command to query status of card reader slots- Returns:
- Byte array of slot status as returned by STATUS command
- Throws:
CardTerminalException
-
-