public abstract class AbstractLocalReader extends AbstractReader
ProxyReader
interface for a local reader.
It also defines a set of abstract methods to be implemented by the reader plugins in order to manage the specific needs of the related reader platform.
isRegistered
Modifier | Constructor and Description |
---|---|
protected |
AbstractLocalReader(java.lang.String pluginName,
java.lang.String readerName)
(protected)
Constructor. |
Modifier and Type | Method and Description |
---|---|
void |
activateProtocol(java.lang.String readerProtocolName,
java.lang.String applicationProtocolName)
Activates the provided card protocol and assigns it a name.
|
protected abstract void |
activateReaderProtocol(java.lang.String readerProtocolName)
Activates the protocol provided from the reader's implementation point of view.
|
protected abstract boolean |
checkCardPresence()
Wrapper for the native method of the plugin specific local reader to verify the presence of the
card.
|
protected abstract void |
closePhysicalChannel()
Attempts to close the current physical channel.
|
void |
deactivateProtocol(java.lang.String readerProtocolName)
Deactivates the provided card protocol.
|
protected abstract void |
deactivateReaderProtocol(java.lang.String readerProtocolName)
Deactivates the protocol provided from the reader's implementation point of view.
|
protected abstract byte[] |
getATR()
This abstract method must be implemented by the derived class in order to provide the
information retrieved when powering up the card.
|
boolean |
isCardPresent()
Check the presence of a card
|
protected abstract boolean |
isCurrentProtocol(java.lang.String readerProtocolName)
Tells if the current card communicates with the protocol provided as an argument.
|
protected abstract boolean |
isPhysicalChannelOpen()
Tells if the physical channel is open or not.
|
protected abstract void |
openPhysicalChannel()
Attempts to open the physical channel.
|
protected CardResponse |
processCardRequest(CardRequest cardRequest,
ChannelControl channelControl)
Local implementation of
AbstractReader.processCardSelectionRequests(List,
MultiSelectionProcessing, ChannelControl) |
protected java.util.List<CardSelectionResponse> |
processCardSelectionRequests(java.util.List<CardSelectionRequest> cardSelectionRequests,
MultiSelectionProcessing multiSelectionProcessing,
ChannelControl channelControl)
Local implementation of
AbstractReader.processCardSelectionRequests(List,
MultiSelectionProcessing, ChannelControl) |
void |
releaseChannel()
Release the communication channel previously established with the card.
|
protected abstract byte[] |
transmitApdu(byte[] apduIn)
Transmits a single APDU and receives its response.
|
getName, getPluginName, transmitCardRequest, transmitCardSelectionRequests
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isContactless
protected AbstractLocalReader(java.lang.String pluginName, java.lang.String readerName)
Defines the plugin and reader names.
Initializes the time measurement log at ApduRequest
level. The first measurement
gives the time elapsed since the plugin was loaded.
pluginName
- the name of the plugin that instantiated the readerreaderName
- the name of the readerpublic boolean isCardPresent()
This method is recommended for non-observable readers.
When the card is not present the logical and physical channels status may be refreshed through a call to the processCardRemoved method.
KeypleReaderIOException
- if the communication with the reader or the card has failedjava.lang.IllegalStateException
- is called when reader is no longer registeredprotected abstract boolean checkCardPresence()
This method must be implemented by the ProxyReader plugin (e.g. Pcsc reader plugin).
This method is invoked by isCardPresent.
KeypleReaderIOException
- if the communication with the reader or the card has failedprotected abstract byte[] getATR()
In contact mode, ATR data is the data returned by the card.
In contactless mode, as the ATR is not provided by the secured element, it can vary from one plugin to another
protected abstract void openPhysicalChannel()
This method must not return normally if the physical channel could not be opened.
KeypleReaderIOException
- if the communication with the reader or the card has failed and
the physical channel could not be open.protected abstract void closePhysicalChannel()
This method must not return normally if the physical channel could not be closed.
KeypleReaderIOException
- if the communication with the reader or the card has failedprotected abstract boolean isPhysicalChannelOpen()
protected abstract boolean isCurrentProtocol(java.lang.String readerProtocolName)
The protocol identification string must match one of the protocols supported by this reader.
This method must be implemented by the plugin's reader, which is the only one able to determine if the provided protocol matches the current protocol.
It returns true if the current protocol is the protocol provided as an argument, false if it is not.
readerProtocolName
- A not empty string.KeypleReaderProtocolNotFoundException
- if it is not possible to determine the protocol.public final void releaseChannel()
If the ProxyReader is not observable the logical and physical channels must be closed
instantly.
If the ProxyReader is observable, the closure of both channels must be the result of the
completion of a removal sequence.
TODO check how to make this conditional on the WAIT_FOR_SE_PROCESSING state.
protected final java.util.List<CardSelectionResponse> processCardSelectionRequests(java.util.List<CardSelectionRequest> cardSelectionRequests, MultiSelectionProcessing multiSelectionProcessing, ChannelControl channelControl)
AbstractReader.processCardSelectionRequests(List,
MultiSelectionProcessing, ChannelControl)
This method is the actual implementation of the process of transmitting a list of CardSelectionRequest
as defined by ProxyReader.transmitCardSelectionRequests(List,
MultiSelectionProcessing, ChannelControl)
.
processCardSelectionRequests
in class AbstractReader
cardSelectionRequests
- A not empty list of not null CardSelectionRequest
.multiSelectionProcessing
- The multi card processing flag (must be not null).channelControl
- indicates if the physical channel has to be closed at the end of the
processing (must be not null).ProxyReader.transmitCardSelectionRequests(List, MultiSelectionProcessing, ChannelControl)
protected final CardResponse processCardRequest(CardRequest cardRequest, ChannelControl channelControl)
AbstractReader.processCardSelectionRequests(List,
MultiSelectionProcessing, ChannelControl)
This method is the actual implementation of the process of a CardRequest
as defined by
ProxyReader.transmitCardRequest(CardRequest, ChannelControl)
processCardRequest
in class AbstractReader
cardRequest
- The CardRequest
to be processed (can be null).channelControl
- indicates if the physical channel has to be closed at the end of the
processing (must be not null).CardResponse
.ProxyReader.transmitCardRequest(CardRequest, ChannelControl)
protected abstract byte[] transmitApdu(byte[] apduIn)
This abstract method must be implemented by the ProxyReader plugin (e.g. Pcsc, Nfc).
Caution: the implementation must handle the case where the card response is 61xy and execute the appropriate get response command.
apduIn
- byte buffer containing the ingoing data (should be not null).KeypleReaderIOException
- if the communication with the reader or the card has failedprotected abstract void activateReaderProtocol(java.lang.String readerProtocolName)
The argument is a reader specific String identifying the protocol.
Must implemented by the plugin.
readerProtocolName
- A not empty String.KeypleReaderProtocolNotSupportedException
- if the protocol is not supported.public final void activateProtocol(java.lang.String readerProtocolName, java.lang.String applicationProtocolName)
readerProtocolName
- A not empty String.applicationProtocolName
- A not empty String.protected abstract void deactivateReaderProtocol(java.lang.String readerProtocolName)
The argument is a reader specific String identifying the protocol.
readerProtocolName
- A not empty String.KeypleReaderProtocolNotSupportedException
- if the protocol is not supported.public final void deactivateProtocol(java.lang.String readerProtocolName)
readerProtocolName
- A not empty String.