Class SmartCardIOTerminal
- java.lang.Object
-
- opencard.core.terminal.CardTerminal
-
- de.cardcontact.opencard.terminal.smartcardio.SmartCardIOTerminal
-
- All Implemented Interfaces:
ExtendedVerifiedAPDUInterface
,Pollable
,VerifiedAPDUInterface
,TerminalCommand
public class SmartCardIOTerminal extends CardTerminal implements TerminalCommand, Pollable, ExtendedVerifiedAPDUInterface
Implements a wrapper card terminal for access to smart card with the javax.smartcardio interface.
-
-
Field Summary
-
Fields inherited from class opencard.core.terminal.CardTerminal
address, name, slots, type
-
-
Constructor Summary
Constructors Constructor Description SmartCardIOTerminal(java.lang.String name, java.lang.String type, java.lang.String address, javax.smartcardio.CardTerminal ct)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the CardTerminal.CardID
getCardID(int slotID)
Return the answer-to-reset (ATR) response of the card inserted in slot slotID as a CardID.boolean
hasSendVerifiedCommandAPDU()
protected java.util.Properties
internalFeatures(java.util.Properties features)
The CardTerminal internal features() method to be provided by the concrete implementation.protected CardID
internalReset(int slot, boolean warm)
The internal reset method may be overwritten by the actual implementation to support warm resets.protected CardID
internalReset(int slot, int ms)
The internal reset method to be provided by the concrete implementation.protected ResponseAPDU
internalSendAPDU(int slot, CommandAPDU capdu, int ms)
The internalSendAPDU method to be provided by the concrete implementation.boolean
isCardPresent(int slotID)
Check whether there is a smart card present in a particular slot.void
open()
Initializes the CardTerminal.void
poll()
Checks the status of the underlying terminal device.ResponseAPDU
sendModifyPINCommandAPDU(SlotChannel chann, CommandAPDU capdu, CHVControl vc)
Send a modify PIN command to the card.byte[]
sendTerminalCommand(byte[] cmd)
Send control command to terminal.ResponseAPDU
sendVerifiedCommandAPDU(SlotChannel chann, CommandAPDU capdu, CHVControl vc)
Send a verified command APDU to the card.-
Methods inherited from class opencard.core.terminal.CardTerminal
addSlots, cardInserted, cardRemoved, closeSlotChannel, enumerateSlots, features, getAddress, getCardID, getName, getSlot, getSlots, getType, internalCloseSlotChannel, internalOpenSlotChannel, internalOpenSlotChannel, 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
-
Methods inherited from interface opencard.core.terminal.VerifiedAPDUInterface
sendVerifiedCommandAPDU
-
-
-
-
Constructor Detail
-
SmartCardIOTerminal
public SmartCardIOTerminal(java.lang.String name, java.lang.String type, java.lang.String address, javax.smartcardio.CardTerminal ct) throws CardTerminalException
- Throws:
CardTerminalException
-
-
Method Detail
-
internalFeatures
protected java.util.Properties internalFeatures(java.util.Properties features)
Description copied from class:CardTerminal
The CardTerminal internal features() method to be provided by the concrete implementation. This default implementation just returns the parameter provided. Concrete implementations should override this method.- Overrides:
internalFeatures
in classCardTerminal
- Parameters:
features
- A Properties object that needs to be enhanced with the card terminal specific features.- Returns:
- The enriched Properties object.
-
open
public void open() throws CardTerminalException
Description copied from class:CardTerminal
Initializes the CardTerminal. Implementations of this method must carry out all steps required to set the concrete terminal into a proper state. After invoking this method it should be possible to communicate with the terminal properly.- 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
Description copied from class:CardTerminal
Closes the CardTerminal. Implementations of this method must carry out all steps required to close the concrete terminal and free resources held by it.- Specified by:
close
in classCardTerminal
- Throws:
CardTerminalException
- thrown in case of initialization-errors (e.g. couldn't setup transfer protocol between CardTerminal and reader).
-
getCardID
public CardID getCardID(int slotID) throws CardTerminalException
Description copied from class:CardTerminal
Return the answer-to-reset (ATR) response of the card inserted in slot slotID as a CardID. Before calling this method the caller should make sure that a card is present, otherwise null may be returned.This call should NOT block if no card is present.
- Specified by:
getCardID
in classCardTerminal
- Parameters:
slotID
- 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
Description copied from class:CardTerminal
The internal reset method to be provided by the concrete implementation.- 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
-
internalReset
protected CardID internalReset(int slot, boolean warm) throws CardTerminalException
Description copied from class:CardTerminal
The internal reset method may be overwritten by the actual implementation to support warm resets.- Overrides:
internalReset
in classCardTerminal
- Parameters:
slot
- The slot number of the slot to be resetted.- 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
Description copied from class:CardTerminal
The internalSendAPDU method to be provided by the concrete implementation.- 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)
-
isCardPresent
public boolean isCardPresent(int slotID) throws CardTerminalException
Description copied from class:CardTerminal
Check whether there is a smart card present in a particular slot.- Specified by:
isCardPresent
in classCardTerminal
- Parameters:
slotID
- slot to check for a card.- 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).
-
sendTerminalCommand
public byte[] sendTerminalCommand(byte[] cmd) throws CardTerminalException
Send control command to terminal. The first four byte encode the PC/SC Control Code.- Specified by:
sendTerminalCommand
in interfaceTerminalCommand
- Parameters:
cmd
- the command data- Returns:
- the response data
- Throws:
CardTerminalException
- ;
-
poll
public void poll() throws CardTerminalException
Description copied from interface:Pollable
Checks the status of the underlying terminal device. Must generate a CardTerminalEvent if a card is being inserted or removed by calling CardTerminal.cardInserted() or CardTerminal.cardRemoved(). Alternatively the terminal could perform status checks itsself, e.g. by handling interrupts. Implementation Note: the CardTerminalRegistry calls this method of all registered Pollable terminals periodically. So the implementation of this method should not carry out lengthy operations but return as quickly as possible.- Specified by:
poll
in interfacePollable
- Throws:
CardTerminalException
- Thrown when error occurred in poll-mechanism.
-
sendModifyPINCommandAPDU
public ResponseAPDU sendModifyPINCommandAPDU(SlotChannel chann, CommandAPDU capdu, CHVControl vc) throws CardTerminalException
Send a modify PIN command to the card. A class 3 card terminal is requested for PIN modification.- Parameters:
capdu
- the command APDUvc
- PIN control information- Returns:
- The response APDU or null if no class 3 card terminal was found.
- Throws:
CardTerminalException
-
sendVerifiedCommandAPDU
public ResponseAPDU sendVerifiedCommandAPDU(SlotChannel chann, CommandAPDU capdu, CHVControl vc) throws CardTerminalException
Send a verified command APDU to the card. The verification will be performed with a class 3 card reader. The PIN has to be entered on the PIN pad. If the password encoding is of type CHVEncoder.PACE, then a PACE channel will be established- Specified by:
sendVerifiedCommandAPDU
in interfaceVerifiedAPDUInterface
- Parameters:
chann
- the SlotChannelcapdu
- the CommandAPDUvc
- the CHVControl- Returns:
- The ResponseAPDU as received from the smart card.
- Throws:
CardTerminalException
- Thrown when an error condition occured.
-
hasSendVerifiedCommandAPDU
public boolean hasSendVerifiedCommandAPDU()
- Specified by:
hasSendVerifiedCommandAPDU
in interfaceExtendedVerifiedAPDUInterface
-
-