Keyple C++  0.9.0
Keyple, an Open Source SDK for Ticketing
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
keyple::plugin::stub::StubReaderImpl Class Reference

#include <StubReaderImpl.h>

Inherits keyple::core::seproxy::plugin::AbstractObservableLocalReader, keyple::plugin::stub::StubReader, keyple::core::seproxy::plugin::SmartInsertionReader, and keyple::core::seproxy::plugin::SmartRemovalReader.

Public Member Functions

 StubReaderImpl (const std::string &pluginName, const std::string &readerName)
 
 StubReaderImpl (const std::string &pluginName, const std::string &name, TransmissionMode transmissionMode)
 
 ~StubReaderImpl ()
 
void closePhysicalChannel () override
 
std::vector< uint8_t > transmitApdu (const std::vector< uint8_t > &apduIn) override
 
void setParameter (const std::string &name, const std::string &value) override
 
const std::map< const std::string, const std::string > & getParameters () const override
 
const TransmissionModegetTransmissionMode () const override
 
void insertSe (std::shared_ptr< StubSecureElement > _se) override
 
void removeSe () override
 
std::shared_ptr< StubSecureElementgetSe () override
 
bool waitForCardPresent () override
 
void stopWaitForCard () override
 
bool waitForCardAbsentNative () override
 
void stopWaitForCardRemoval () override
 
bool checkSePresence () override
 
- Public Member Functions inherited from keyple::core::seproxy::plugin::AbstractObservableLocalReader
 AbstractObservableLocalReader (const std::string &pluginName, const std::string &readerName)
 
virtual ~AbstractObservableLocalReader ()=default
 
bool isSePresent () override
 
void startSeDetection (const ObservableReader::PollingMode pollingMode) final
 
void stopSeDetection () final
 
void setDefaultSelectionRequest (std::shared_ptr< AbstractDefaultSelectionsRequest > defaultSelectionsRequest, const ObservableReader::NotificationMode &notificationMode) final
 
void setDefaultSelectionRequest (std::shared_ptr< AbstractDefaultSelectionsRequest > defaultSelectionsRequest, const ObservableReader::NotificationMode &notificationMode, const ObservableReader::PollingMode pollingMode) final
 
virtual std::shared_ptr< ReaderEventprocessSeInserted ()
 
bool isSePresentPing ()
 
void processSeRemoved ()
 
const ObservableReader::PollingModegetPollingMode () const
 
const MonitoringStategetCurrentMonitoringState () const
 
void switchState (const MonitoringState stateId)
 
void addObserver (const std::shared_ptr< ObservableReader::ReaderObserver > observer) final
 
void removeObserver (const std::shared_ptr< ObservableReader::ReaderObserver > observer) final
 
void notifyObservers (const std::shared_ptr< ReaderEvent > event) final
 
int countObservers () const final
 
void clearObservers () final
 
void terminateSeCommunication () override
 
void finalizeSeProcessing () override
 
void onEvent (const InternalEvent event)
 
- Public Member Functions inherited from keyple::core::seproxy::plugin::AbstractLocalReader
 AbstractLocalReader (const std::string &pluginName, const std::string &readerName)
 
virtual ~AbstractLocalReader ()=default
 
virtual bool isLogicalChannelOpen () const final
 
void addSeProtocolSetting (std::shared_ptr< SeProtocol > seProtocol, const std::string &protocolRule) override
 
virtual void setSeProtocolSetting (const std::map< std::shared_ptr< SeProtocol >, std::string > &protocolSetting) override
 
virtual std::shared_ptr< SelectionStatusopenLogicalChannel (std::shared_ptr< SeSelector > seSelector)
 
std::shared_ptr< SelectionStatusopenLogicalChannelAndSelect (std::shared_ptr< SeSelector > seSelector)
 
virtual std::vector< std::shared_ptr< SeResponse > > processSeRequests (const std::vector< std::shared_ptr< SeRequest >> &seRequests, const MultiSeRequestProcessing &multiSeRequestProcessing, const ChannelControl &channelControl) override
 
virtual std::shared_ptr< SeResponseprocessSeRequest (const std::shared_ptr< SeRequest > seRequest, const ChannelControl &channelControl) override
 
- Public Member Functions inherited from keyple::core::seproxy::plugin::AbstractReader
std::vector< std::shared_ptr< SeResponse > > transmitSeRequests (const std::vector< std::shared_ptr< SeRequest >> &seRequests, const MultiSeRequestProcessing &multiSeRequestProcessing, const ChannelControl &channelControl) override
 
std::shared_ptr< SeResponsetransmitSeRequest (std::shared_ptr< SeRequest > seRequest, const ChannelControl &channelControl) override
 
const std::string & getPluginName () const
 
const std::string & getName () const override
 
- Public Member Functions inherited from keyple::core::seproxy::plugin::AbstractSeProxyComponent
 AbstractSeProxyComponent (const std::string &name)
 
virtual ~AbstractSeProxyComponent ()=default
 
const std::string & getName () const
 
void setParameters (const std::map< const std::string, const std::string > &parameters)
 
- Public Member Functions inherited from keyple::core::seproxy::message::ProxyReader
virtual ~ProxyReader ()
 
- Public Member Functions inherited from keyple::core::seproxy::SeReader
virtual ~SeReader ()
 
virtual bool operator== (const SeReader &o) const
 
- Public Member Functions inherited from keyple::core::seproxy::ProxyElement
virtual ~ProxyElement ()=default
 
virtual void setParameters (const std::map< const std::string, const std::string > &parameters)
 
- Public Member Functions inherited from keyple::core::seproxy::plugin::ObservableReaderNotifier
 ObservableReaderNotifier ()
 
virtual ~ObservableReaderNotifier ()
 
- Public Member Functions inherited from keyple::core::seproxy::event::ObservableReader
virtual ~ObservableReader ()=default
 
virtual void addObserver (const std::shared_ptr< ReaderObserver > observer)=0
 
virtual void removeObserver (const std::shared_ptr< ReaderObserver > observer)=0
 
- Public Member Functions inherited from keyple::plugin::stub::StubReader
virtual ~StubReader ()=default
 
- Public Member Functions inherited from keyple::core::seproxy::plugin::SmartInsertionReader
virtual ~SmartInsertionReader ()
 
- Public Member Functions inherited from keyple::core::seproxy::plugin::SmartRemovalReader
virtual ~SmartRemovalReader ()
 

Protected Member Functions

const std::vector< uint8_t > & getATR () override
 
bool isPhysicalChannelOpen () override
 
void openPhysicalChannel () override
 
bool protocolFlagMatches (const std::shared_ptr< SeProtocol > protocolFlag) override
 
std::shared_ptr< ObservableReaderStateServiceinitStateService () override
 
- Protected Member Functions inherited from keyple::core::seproxy::plugin::AbstractLocalReader
void closeLogicalAndPhysicalChannels ()
 
virtual void setForceGetDataFlag (bool forceGetDataFlag)
 
void closeLogicalChannel ()
 
std::shared_ptr< ApduResponseprocessApduRequest (std::shared_ptr< ApduRequest > apduRequest)
 
const std::map< std::shared_ptr< SeProtocol >, std::string > & getProtocolsMap () const
 
- Protected Member Functions inherited from keyple::core::seproxy::plugin::AbstractReader
 AbstractReader (const std::string &pluginName, const std::string &name)
 
virtual ~AbstractReader ()=default
 

Protected Attributes

std::shared_ptr< ExecutorServicemExecutorService
 
- Protected Attributes inherited from keyple::core::seproxy::plugin::AbstractObservableLocalReader
std::shared_ptr< ObservableReaderStateServicemStateService
 
- Protected Attributes inherited from keyple::core::seproxy::plugin::AbstractReader
std::shared_ptr< DefaultSelectionsRequestmDefaultSelectionsRequest
 
ObservableReader::NotificationMode mNotificationMode
 

Additional Inherited Members

- Public Types inherited from keyple::core::seproxy::event::ObservableReader
enum  PollingMode { PollingMode::REPEATING, PollingMode::SINGLESHOT }
 
- Public Attributes inherited from keyple::core::seproxy::plugin::ObservableReaderNotifier
std::atomic< bool > mShuttingDown
 
- Static Protected Member Functions inherited from keyple::core::seproxy::plugin::AbstractLocalReader
static bool startsWith (const std::vector< uint8_t > &source, const std::vector< uint8_t > &match)
 

Constructor & Destructor Documentation

◆ StubReaderImpl() [1/2]

keyple::plugin::stub::StubReaderImpl::StubReaderImpl ( const std::string &  pluginName,
const std::string &  readerName 
)

Do not use directly

Parameters
pluginName
readerName

◆ StubReaderImpl() [2/2]

keyple::plugin::stub::StubReaderImpl::StubReaderImpl ( const std::string &  pluginName,
const std::string &  name,
TransmissionMode  transmissionMode 
)

Specify

Parameters
pluginName
name
transmissionMode

◆ ~StubReaderImpl()

keyple::plugin::stub::StubReaderImpl::~StubReaderImpl ( )

Member Function Documentation

◆ checkSePresence()

bool keyple::plugin::stub::StubReaderImpl::checkSePresence ( )
overridevirtual

Wrapper for the native method of the plugin specific local reader to verify the presence of the SE.

This method must be implemented by the ProxyReader plugin (e.g. Pcsc reader plugin).

This method is invoked by isSePresent.

Returns
true if the SE is present
Exceptions
KeypleReaderIOExceptionif the communication with the reader or the SE has failed

Implements keyple::core::seproxy::plugin::AbstractLocalReader.

◆ closePhysicalChannel()

void keyple::plugin::stub::StubReaderImpl::closePhysicalChannel ( )
overridevirtual

Closes the current physical channel.

This method must be implemented by the ProxyReader plugin (e.g. Pcsc/Nfc/Omapi Reader).

Exceptions
KeypleReaderIOExceptionif the communication with the reader or the SE has failed

Implements keyple::core::seproxy::plugin::AbstractLocalReader.

◆ getATR()

const std::vector< uint8_t > & keyple::plugin::stub::StubReaderImpl::getATR ( )
overrideprotectedvirtual

This abstract method must be implemented by the derived class in order to provide the SE ATR when available.

Gets the SE Answer to reset

Returns
ATR returned by the SE or reconstructed by the reader (contactless)

Implements keyple::core::seproxy::plugin::AbstractLocalReader.

◆ getParameters()

const std::map< const std::string, const std::string > & keyple::plugin::stub::StubReaderImpl::getParameters ( ) const
overridevirtual

Gets the parameters

Returns
the configuration of the item

Implements keyple::core::seproxy::ProxyElement.

◆ getSe()

std::shared_ptr< StubSecureElement > keyple::plugin::stub::StubReaderImpl::getSe ( )
overridevirtual

Get inserted SE

Returns
se, can be null if no Se inserted

Implements keyple::plugin::stub::StubReader.

◆ getTransmissionMode()

const TransmissionMode & keyple::plugin::stub::StubReaderImpl::getTransmissionMode ( ) const
overridevirtual
Returns
the current transmission mode

Implements keyple::core::seproxy::SeReader.

◆ initStateService()

std::shared_ptr< ObservableReaderStateService > keyple::plugin::stub::StubReaderImpl::initStateService ( )
overrideprotectedvirtual

Initialize the ObservableReaderStateService with the possible states and their implementation. ObservableReaderStateService define the initial state.

Make sure to initialize the stateService in your reader constructor with stateService = initStateService()

Returns
initialized state stateService with possible states and the init state

Implements keyple::core::seproxy::plugin::AbstractObservableLocalReader.

◆ insertSe()

void keyple::plugin::stub::StubReaderImpl::insertSe ( std::shared_ptr< StubSecureElement _se)
overridevirtual

STATE CONTROLLERS FOR INSERTING AND REMOVING SECURE ELEMENT

Implements keyple::plugin::stub::StubReader.

◆ isPhysicalChannelOpen()

bool keyple::plugin::stub::StubReaderImpl::isPhysicalChannelOpen ( )
overrideprotectedvirtual

Tells if the physical channel is open or not

This method must be implemented by the ProxyReader plugin (e.g. Pcsc/Nfc/Omapi Reader).

Returns
true is the channel is open

Implements keyple::core::seproxy::plugin::AbstractLocalReader.

◆ openPhysicalChannel()

void keyple::plugin::stub::StubReaderImpl::openPhysicalChannel ( )
overrideprotectedvirtual

This abstract method must be implemented by the derived class in order to provide a selection and ATR filtering mechanism.

The Selector provided in argument holds all the needed data to handle the Application Selection and ATR matching process and build the resulting SelectionStatus.

Parameters
seSelectorthe SE selector
Returns
the SelectionStatus Attempts to open the physical channel
Exceptions
KeypleReaderIOExceptionif the communication with the reader or the SE has failed

Implements keyple::core::seproxy::plugin::AbstractLocalReader.

◆ protocolFlagMatches()

bool keyple::plugin::stub::StubReaderImpl::protocolFlagMatches ( const std::shared_ptr< SeProtocol protocolFlag)
overrideprotectedvirtual

Test if the current protocol matches the provided protocol flag.

The method must be implemented by the ProxyReader plugin.

The protocol flag is used to retrieve from the protocolsMap the String used to differentiate this particular protocol. (e.g. in PC/SC the only way to identify the SE protocol is to analyse the ATR returned by the reader [ISO SE and memory card SE have specific ATR], in Android Nfc the SE protocol can be deduced with the TagTechnology interface).

Parameters
protocolFlagthe protocol flag
Returns
true if the current protocol matches the provided protocol flag
Exceptions
KeypleReaderIOExceptionif the communication with the reader or the SE has failed

Implements keyple::core::seproxy::plugin::AbstractLocalReader.

◆ removeSe()

void keyple::plugin::stub::StubReaderImpl::removeSe ( )
overridevirtual

Remove se from reader if any

Implements keyple::plugin::stub::StubReader.

◆ setParameter()

void keyple::plugin::stub::StubReaderImpl::setParameter ( const std::string &  key,
const std::string &  value 
)
overridevirtual

This method has to be implemented by the reader plugin.
Allows to define a proprietary setting for a reader or a plugin (contactless protocols polling sequence, baud rate, … etc.).

Parameters
keythe parameter key
valuethe parameter value
Exceptions
IllegalArgumentExceptionif the parameter or the value is not supported
KeypleReaderIOExceptionif the communication with the reader or the SE has failed

Implements keyple::core::seproxy::plugin::AbstractSeProxyComponent.

◆ stopWaitForCard()

void keyple::plugin::stub::StubReaderImpl::stopWaitForCard ( )
overridevirtual

Interrupts the waiting of a SE

Reimplemented from keyple::core::seproxy::plugin::SmartInsertionReader.

◆ stopWaitForCardRemoval()

void keyple::plugin::stub::StubReaderImpl::stopWaitForCardRemoval ( )
overridevirtual

Interrupts the waiting of the removal of the SE

Reimplemented from keyple::core::seproxy::plugin::SmartRemovalReader.

◆ transmitApdu()

std::vector< uint8_t > keyple::plugin::stub::StubReaderImpl::transmitApdu ( const std::vector< uint8_t > &  apduIn)
overridevirtual

Transmits a single APDU and receives its response.

This abstract method must be implemented by the ProxyReader plugin (e.g. Pcsc, Nfc). The implementation must handle the case where the SE response is 61xy and execute the appropriate get response command.

Parameters
apduInbyte buffer containing the ingoing data
Returns
apduResponse byte buffer containing the outgoing data.
Exceptions
KeypleReaderIOExceptionif the communication with the reader or the SE has failed

Implements keyple::core::seproxy::plugin::AbstractLocalReader.

◆ waitForCardAbsentNative()

bool keyple::plugin::stub::StubReaderImpl::waitForCardAbsentNative ( )
overridevirtual

Defined in the keyple::core::seproxy::plugin::local::SmartRemovalReader interface, this method is called by the monitoring thread to check SE absence

Returns
true if the SE is absent

Implements keyple::core::seproxy::plugin::SmartRemovalReader.

◆ waitForCardPresent()

bool keyple::plugin::stub::StubReaderImpl::waitForCardPresent ( )
overridevirtual

This method is called by the monitoring thread to check SE presence

Returns
true if the SE is present

Implements keyple::core::seproxy::plugin::SmartInsertionReader.

Member Data Documentation

◆ mExecutorService

std::shared_ptr<ExecutorService> keyple::plugin::stub::StubReaderImpl::mExecutorService
protected

The documentation for this class was generated from the following files: