public abstract class AbstractReader extends java.lang.Object implements ProxyReader
AbstractReader
defines the minimum required functionality for a local or remote
reader.
It provides logging facilities.
Modifier and Type | Field and Description |
---|---|
protected boolean |
isRegistered
Registeration status of the reader
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractReader(java.lang.String pluginName,
java.lang.String name)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getName()
Gets the name of the reader.
|
java.lang.String |
getPluginName()
Gets the name of plugin provided in the constructor.
|
protected abstract CardResponse |
processCardRequest(CardRequest cardRequest,
ChannelControl channelControl)
This method is the actual implementation of the process of a
CardRequest as defined by
ProxyReader.transmitCardRequest(CardRequest, ChannelControl) |
protected abstract java.util.List<CardSelectionResponse> |
processCardSelectionRequests(java.util.List<CardSelectionRequest> cardSelectionRequests,
MultiSelectionProcessing multiSelectionProcessing,
ChannelControl channelControl)
This method is the actual implementation of the process of transmitting a list of
CardSelectionRequest as defined by ProxyReader.transmitCardSelectionRequests(List,
MultiSelectionProcessing, ChannelControl) . |
CardResponse |
transmitCardRequest(CardRequest cardRequest,
ChannelControl channelControl)
Transmits a single
CardRequest passed as an argument and returns a CardResponse . |
java.util.List<CardSelectionResponse> |
transmitCardSelectionRequests(java.util.List<CardSelectionRequest> cardSelectionRequests,
MultiSelectionProcessing multiSelectionProcessing,
ChannelControl channelControl)
Transmits the list of
CardSelectionRequest and gets in return a list of CardSelectionResponse . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
releaseChannel
activateProtocol, deactivateProtocol, isCardPresent, isContactless
protected AbstractReader(java.lang.String pluginName, java.lang.String name)
Plugin and reader names helps to identify the object in a multireader context.
The reader is marked as registered as soon as it is created.
Initializes the time measurement log at CardRequest
level. The first measurement
gives the time elapsed since the plugin was loaded.
pluginName
- A not empty string.name
- A not empty string.public final java.lang.String getName()
public final java.lang.String getPluginName()
public final java.util.List<CardSelectionResponse> transmitCardSelectionRequests(java.util.List<CardSelectionRequest> cardSelectionRequests, MultiSelectionProcessing multiSelectionProcessing, ChannelControl channelControl)
CardSelectionRequest
and gets in return a list of CardSelectionResponse
.
The actual processing of each CardSelectionRequest
is similar to that performed by
ProxyReader.transmitCardRequest(CardRequest, ChannelControl)
(see this method for further
explanation of how the process works).
If the multiSelectionProcessing parameter equals to MultiSelectionProcessing.FIRST_MATCH
, the iteration over the CardSelectionRequest
list
is interrupted at the first processing that leads to an open logical channel state. In this
case, the list of CardSelectionResponse
may be shorter than the list of CardSelectionRequest
provided as input.
If it equals to MultiSelectionProcessing.PROCESS_ALL
, all the CardSelectionRequest
are processed and the logical channel is closed after each process.
The physical channel is managed by the ChannelControl parameter as in ProxyReader.transmitCardRequest(CardRequest, ChannelControl)
.
In the case of a selection specifying a card protocol, it is imperative to activate it
previously with the method Reader.activateProtocol(String, String)
. An
IllegalStateException exception will be thrown in case of inconsistency.
This implementation of ProxyReader.transmitCardSelectionRequests(List,
MultiSelectionProcessing, ChannelControl)
is based on processCardSelectionRequests(List, MultiSelectionProcessing, ChannelControl)
.
It adds a logging of exchanges including a measure of execution time, available at the debug
level.
transmitCardSelectionRequests
in interface ProxyReader
cardSelectionRequests
- A not empty list of 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).protected abstract java.util.List<CardSelectionResponse> processCardSelectionRequests(java.util.List<CardSelectionRequest> cardSelectionRequests, MultiSelectionProcessing multiSelectionProcessing, ChannelControl channelControl)
CardSelectionRequest
as defined by ProxyReader.transmitCardSelectionRequests(List,
MultiSelectionProcessing, ChannelControl)
.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).KeypleReaderIOException
- if the communication with the reader or the card has failedjava.lang.IllegalArgumentException
- if one of the arguments is null.java.lang.IllegalStateException
- in case of configuration inconsistency.ProxyReader.transmitCardSelectionRequests(List, MultiSelectionProcessing, ChannelControl)
public final CardResponse transmitCardRequest(CardRequest cardRequest, ChannelControl channelControl)
CardRequest
passed as an argument and returns a CardResponse
.
The process includes the following steps:
CardRequest
contains a non null CardSelector
. The 3 following
operations are performed in this order:
CardRequest
contains a list of APDUs to send (ApduRequest
) then
each APDU is sent to the card and its response (ApduResponse
is added to a new
list.
ChannelControl
is ChannelControl.CLOSE_AFTER
.
CardResponse
containing:
CardSelector
not null) a SelectionStatus
object containing the elements resulting from the selection.
KeypleReaderIOException
exception is thrown. Responses to previous APDUs are attached to this exception.CardRequest
.
This implementation of ProxyReader.transmitCardRequest(CardRequest, ChannelControl)
is based on processCardRequest(CardRequest, ChannelControl)
.
It adds a logging of exchanges including a measure of execution time, available at the debug
level.
transmitCardRequest
in interface ProxyReader
cardRequest
- The CardRequest
to be processed (must be not null).channelControl
- indicates if the physical channel has to be closed at the end of the
processing (must be not null).CardResponse
.protected abstract CardResponse processCardRequest(CardRequest cardRequest, ChannelControl channelControl)
CardRequest
as defined by
ProxyReader.transmitCardRequest(CardRequest, ChannelControl)
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
.KeypleReaderIOException
- if the communication with the reader or the card has failedjava.lang.IllegalArgumentException
- if one of the arguments is null.ProxyReader.transmitCardRequest(CardRequest, ChannelControl)