scmApi.h
Go to the documentation of this file.
1 
3 #pragma once
4 
5 #include <boost/function.hpp>
6 #include <boost/system/error_code.hpp>
7 #include <boost/shared_ptr.hpp>
8 #include "scmTypes.h"
9 #include <list>
10 #include <map>
11 
12 class SCMClientService;
13 
14 //To avoid redefinition in client and app
15 #ifndef SCM_TYPES
16 #define SCM_TYPES
17 
23 namespace dpySCM {
24 
29 typedef boost::function<void(const bool &available)> service_availability_handler;
30 
39 typedef boost::function<void(boost::system::error_code& ec, const dpySCM::Device& rDevice)> get_devices_handler_function;
40 typedef boost::function<void(boost::system::error_code& ec, const dpySCM::DeviceReaderList& rReader)> get_readers_handler_function;
41 typedef boost::function<void(boost::system::error_code& ec, const std::string& deviceId, dpySCM::CardEvent cardEvent)> handler_cardEvent_function;
42 typedef boost::function<void(boost::system::error_code& ec, dpySCM::DeviceChargeResult deviceChargeResult)> handler_device_charge_result_function;
43 typedef boost::function<void(boost::system::error_code& ec, const std::string& deviceId, dpySCM::Event deviceEvent)> handler_deviceListEvent_function;
44 typedef boost::function<void(boost::system::error_code& ec)> confirmation_handler_function;
45 typedef boost::function<void(boost::system::error_code& ec, dpySCM::DeviceKeys deviceKeys)> get_keys_handler_function;
46 typedef boost::function<void(boost::system::error_code& ec, dpySCM::TransactionDevice TransactionDevice)> card_operation_handler_function;
47 typedef boost::function<void(boost::system::error_code& ec, dpySCM::DevicePassThrough devicePassThrough)> pass_through_operation_handler_function;
48 typedef boost::function<void(boost::system::error_code& ec, dpySCM::DeviceVersion& deviceVersion)> device_version_handler_function;
49 typedef boost::function<void(boost::system::error_code& ec, dpySCM::DevicePaymentAppInfo& devicePaymentAppInfo)> device_payment_app_info_function;
50 typedef boost::function<void(boost::system::error_code& ec, dpySCM::DeviceMediaProfiles& deviceMediaProfiles)> device_media_profiles_function;
51 typedef boost::function<void(boost::system::error_code& ec, dpySCM::DeviceUpgradeStatus& deviceUpgradeStatus)> upgrade_status_events_function;
52 typedef boost::function<void(boost::system::error_code& ec, const std::string& deviceId)> force_device_upgrade_function;
53 typedef boost::function<void(boost::system::error_code& ec, dpySCM::DevicePciRebootTime& devicePciRebootTime)> reboot_time_handler_function;
54 typedef boost::function<void(boost::system::error_code& ec, dpySCM::UltraLightCounter& ulCounter)> ultralight_counter_handler_function;
55 typedef boost::function<void(boost::system::error_code& ec, dpySCM::DeviceNetworkConfiguration& deviceNetworkConfiguration)> device_network_configuration_handler_function;
56 typedef boost::function<void(boost::system::error_code& ec, dpySCM::DevicePaymentAppConfiguration& devicePaymentAppConf)> device_payment_app_conf_function;
57 typedef boost::function<void(boost::system::error_code& ec, dpySCM::DevicePollingParameter& devicePollingParameter)> device_polling_parameter_function;
58 typedef boost::function<void(boost::system::error_code& ec, dpySCM::DeviceDateTime& dateTime)> device_date_time_handler_function;
59 typedef boost::function<void(boost::system::error_code& ec, dpySCM::DeviceNetworkStatus& deviceNetworkStatus)> network_status_handler_function;
60 typedef boost::function<void(boost::system::error_code& ec, const std::string& deviceId, dpySCM::LoggingConfiguration& loggingConfiguration)> get_logging_configuration_handler_function;
61 typedef boost::function<void(boost::system::error_code& ec, dpySCM::DeviceArtifacts& deviceArtifacts)> get_artifacts_handler_function;
62 typedef boost::function<void(boost::system::error_code& ec, dpySCM::DevicePluginData& devicePluginData)> execute_plugin_handler_function;
63 typedef boost::function<void(boost::system::error_code& ec, const dpySCM::DevicePluginData& devicePluginData)> plugin_event_handler_function;
64 
65 } //dpySCM
66 
67 #endif
68 
73 {
74 public:
81  virtual void newSmartCard(boost::system::error_code& ec, const std::string& deviceId, dpySCM::CardEvent cardEvent) = 0;
87  virtual void chargeResult(boost::system::error_code& ec, dpySCM::DeviceChargeResult deviceChargeResult) = 0;
91  virtual ~IsmartCardReaderObserver() = default;
92 };
93 
98 {
99 public:
100 
106  virtual void notifyPciReboot(boost::system::error_code& ec, dpySCM::DevicePciRebootTime& devicePciRebootTime) = 0;
107 
113  virtual void newUpgradeStatus(boost::system::error_code& ec, dpySCM::DeviceUpgradeStatus& deviceUpgradeStatus) = 0;
114 
118  virtual ~IsmartCardDeviceObserver() = default;
119 
120 };
121 
126 {
127 public:
134  virtual void deviceListEvent(boost::system::error_code& ec, const std::string& deviceId, dpySCM::Event deviceEvent) = 0;
138  virtual ~IsmartCardDeviceListObserver() = default;
139 };
140 
145 {
146 public:
152  virtual void pluginEvent(boost::system::error_code& ec, const dpySCM::DevicePluginData& devicePluginData) = 0;
153 
154  virtual ~IPluginObserver() = default;
155 };
156 
157 
163 class SCM
164 {
165 private:
166 
170  boost::shared_ptr<SCMClientService> mClient;
171  std::map<std::string, std::string> mDevices;
172 
173  template<typename Func>
174  void sendToDeviceOrService(const std::string& deviceId, Func func);
175 
176  std::vector<IsmartCardDeviceListObserver*> observersDeviceListObserver;
177  std::vector<IsmartCardDeviceObserver*> observersDeviceObserver;
178  std::vector<IsmartCardReaderObserver*> observersReaderObserver;
179  std::vector<IPluginObserver*> pluginObservers;
180  boost::system::error_code operateData(dpySCM::OperationType opType, std::string deviceId, std::string uid, std::list<dpySCM::Data> &contents);
181  boost::system::error_code operateDataBlock(dpySCM::OperationType opType, std::string deviceId, std::string uid, std::list<dpySCM::DataBlock> contents);
182  void asyncAddArtifact(std::string deviceId, dpySCM::ArtifactInfo artifactInfo, dpySCM::confirmation_handler_function handler);
183 
184 public:
185 
186  explicit SCM(std::string ip = "127.0.0.1");
187  ~SCM();
188  bool isAlive();
189  void monitorServiceAvailability_S(dpySCM::service_availability_handler handler);
190  void monitorServiceAvailability_U();
191 
194  void asyncGetDevices(dpySCM::get_devices_handler_function handler);
196  boost::system::error_code getDevices(dpySCM::Device& rDevice);
197  void deviceListEvent_S(dpySCM::handler_deviceListEvent_function handler);
198  void deviceListEvent_U();
199  void asyncGetReaders(std::string deviceId,dpySCM::get_readers_handler_function handler);
200  void asyncGetVersion(std::string deviceId, dpySCM::device_version_handler_function handler);
201  void newCardEvent_S(dpySCM::handler_cardEvent_function handler);
202  void newCardEvent_U();
203  void asyncAddKeys(dpySCM::DeviceKeys keyGroup, dpySCM::confirmation_handler_function handler);
204  void asyncAddKeys(std::string deviceId, std::string json, dpySCM::confirmation_handler_function handler);
205  void asyncGetKeys(std::string deviceId, dpySCM::get_keys_handler_function handler);
206  void asyncRemoveKeys(std::string deviceId, dpySCM::confirmation_handler_function handler);
207  void upgradeStatus_S(dpySCM::upgrade_status_events_function handler);
208  void upgradeStatus_U();
209  void asyncForceDeviceUpgrade(std::string deviceId,dpySCM::force_device_upgrade_function handler);
211 
212  // Device list observer
213  boost::system::error_code subscribeDeviceListEvent(IsmartCardDeviceListObserver *observer);
214  boost::system::error_code unsubscribeDeviceListEvent(IsmartCardDeviceListObserver *observer);
215  // Device observer
216  boost::system::error_code subscribeDeviceEvent(IsmartCardDeviceObserver *observer);
217  boost::system::error_code unsubscribeDeviceEvent(IsmartCardDeviceObserver *observer);
218  // Reader observer
219  boost::system::error_code subscribeReaderEvent(IsmartCardReaderObserver *observer);
220  boost::system::error_code unsubscribeReaderEvent(IsmartCardReaderObserver *observer);
221  // Plugin observer
222  boost::system::error_code subscribePluginEvent(IPluginObserver *observer);
223  boost::system::error_code unsubscribePluginEvent(IPluginObserver *observer);
224 
228  void asyncCardOperation(dpySCM::TransactionDevice operationDevice, dpySCM::card_operation_handler_function handler);
230  void asyncPassThrough(dpySCM::DevicePassThrough devicePassThrough, dpySCM::pass_through_operation_handler_function handler);
231  void asyncGetULCounter(std::string deviceId, dpySCM::UltraLightCounter& ulCounter, dpySCM::ultralight_counter_handler_function handler);
232  void asyncIncrementULCounter(std::string deviceId, dpySCM::UltraLightCounter& ulCounter, dpySCM::confirmation_handler_function handler);
233  void asyncResetSamSlot(std::string deviceId, dpySCM::SamSlot slotNumber, dpySCM::confirmation_handler_function handler);
234 
236 
240  boost::system::error_code auth(std::string deviceId, std::string uid, std::list<dpySCM::Data>& contents);
242  boost::system::error_code read(std::string deviceId, std::string uid, std::list<dpySCM::Data>& contents);
243  boost::system::error_code write(std::string deviceId, std::string uid, std::list<dpySCM::Data>& contents);
244  boost::system::error_code apduExchange(std::string deviceId, std::string uid, std::list<dpySCM::ApduTxData>& apduTx, std::list<dpySCM::ApduRxData>& apduRx);
245  boost::system::error_code passThrough(std::string deviceId, dpySCM::PassThrough& passThrough);
246  boost::system::error_code getULCounter(std::string deviceId, dpySCM::UltraLightCounter& ulCounter);
247  boost::system::error_code incrementULCounter(std::string deviceId, dpySCM::UltraLightCounter& ulCounter);
248  boost::system::error_code transferBlock(std::string deviceId, std::string uid, std::list<dpySCM::DataBlock> contents);
249  boost::system::error_code restoreBlock(std::string deviceId, std::string uid, std::list<dpySCM::DataBlock> contents);
250  boost::system::error_code incrementOnlyBlock(std::string deviceId, std::string uid, std::list<dpySCM::DataBlock> contents);
251  boost::system::error_code decrementOnlyBlock(std::string deviceId, std::string uid, std::list<dpySCM::DataBlock> contents);
252  boost::system::error_code incrementBlock(std::string deviceId, std::string uid, std::list<dpySCM::DataBlock> contents);
253  boost::system::error_code decrementBlock(std::string deviceId, std::string uid, std::list<dpySCM::DataBlock> contents);
255 
259  void chargeResultEMV_S(dpySCM::handler_device_charge_result_function handler);
261  void chargeResultEMV_U();
262  void asyncRequestChargeEMV(dpySCM::DeviceRequestCharge requestChargeDevice, dpySCM::confirmation_handler_function handler);
263  void asyncChargeConfirmationEMV(dpySCM::DeviceChargeConfirmation requestChargeConfirmation, dpySCM::confirmation_handler_function handler);
264  void asyncSetPaymentAppStatus(dpySCM::DevicePaymentAppStatus devicePaymentAppStatus, dpySCM::confirmation_handler_function handler);
265  void asyncGetPaymentAppInfo(std::string deviceId, dpySCM::device_payment_app_info_function handler);
266  void asyncGetPaymentAppConf(dpySCM::DevicePaymentAppConfiguration devicePaymentAppConf, dpySCM::device_payment_app_conf_function handler);
267  void asyncSetPaymentAppConf(dpySCM::DevicePaymentAppConfiguration devicePaymentAppConf, dpySCM::confirmation_handler_function handler);
268  void asyncForcePaymentAppComm(std::string deviceId, dpySCM::confirmation_handler_function handler);
270 
274 
276  void asyncPlayProfile(std::string deviceId, std::string profileId, dpySCM::confirmation_handler_function handler);
277  void asyncAddMediaProfiles(std::string deviceId,std::string json, dpySCM::confirmation_handler_function handler);
278  void asyncAddMediaProfiles(dpySCM::DeviceMediaProfiles deviceMediaProfiles, dpySCM::confirmation_handler_function handler);
279  void asyncGetMediaProfiles(std::string deviceId, dpySCM::device_media_profiles_function handler);
280  void asyncRemoveMediaProfiles(std::string deviceId, dpySCM::confirmation_handler_function handler);
282 
285  void pciRebootEvent_S(dpySCM::reboot_time_handler_function handler);
287  void pciRebootEvent_U();
288  void asyncGetPciRebootTime(std::string deviceId, dpySCM::reboot_time_handler_function handler);
289  void asyncSetPciRebootTime(dpySCM::DevicePciRebootTime deviceRebootTime, dpySCM::confirmation_handler_function handler);
290  boost::system::error_code getPciRebootTime(std::string deviceId, dpySCM::DevicePciRebootTime& rebootTime);
291  boost::system::error_code setPciRebootTime(dpySCM::DevicePciRebootTime deviceRebootTime);
293 
297  void asyncGetNetworkConfiguration(std::string deviceId, dpySCM::device_network_configuration_handler_function handler);
299  void asyncSetNetworkConfiguration(dpySCM::DeviceNetworkConfiguration deviceNetworkConfiguration, dpySCM::confirmation_handler_function handler);
301 
305  void asyncGetPollingParameter(dpySCM::DevicePollingParameter devicePollingParameter, dpySCM::device_polling_parameter_function handler);
307  void asyncSetPollingParameter(dpySCM::DevicePollingParameter devicePollingParameter, dpySCM::confirmation_handler_function handler);
309  void asyncGetDateTime(std::string deviceId, dpySCM::device_date_time_handler_function handler);
310  void asyncRebootDevice(std::string deviceId, dpySCM::RebootType rebootType, dpySCM::confirmation_handler_function handler);
311  void asyncTestNetworkConnectivity(dpySCM::DeviceNetworkConnectivity deviceNetworkConnectivity, dpySCM::network_status_handler_function handler);
312  void asyncSetLoggingConfiguration(std::string deviceId, dpySCM::LoggingConfiguration loggingConfiguration, dpySCM::confirmation_handler_function handler);
313  void asyncGetLoggingConfiguration(std::string deviceId, dpySCM::get_logging_configuration_handler_function handler);
314 
318  boost::system::error_code asyncAddArtifact(std::string deviceId, std::string name, std::string fileName, dpySCM::ArtifactType type, dpySCM::ArtifactInstallationType installType, dpySCM::confirmation_handler_function handler);
320  boost::system::error_code asyncAddArtifact(std::string deviceId, std::string name, std::string fileName, dpySCM::ArtifactType type, dpySCM::ArtifactInstallationType installType, std::string version, dpySCM::confirmation_handler_function handler);
321  void asyncGetArtifacts(std::string deviceId, dpySCM::get_artifacts_handler_function handler);
322  void asyncRemoveArtifact(std::string deviceId, std::string name, dpySCM::confirmation_handler_function handler);
323  void asyncExecutePlugin(std::string deviceId, std::string name, std::map<std::string,std::string> inputData, dpySCM::execute_plugin_handler_function handler);
324  void pluginEvent_S(dpySCM::plugin_event_handler_function handler);
325  void pluginEvent_U();
327 };
List of readers.
Definition: scmTypes.h:207
Device upgrade status.
Definition: scmTypes.h:562
boost::function< void(boost::system::error_code &ec, const std::string &deviceId, dpySCM::CardEvent cardEvent)> handler_cardEvent_function
Result of new card event.
Definition: scmApi.h:41
boost::function< void(boost::system::error_code &ec, const dpySCM::DevicePluginData &devicePluginData)> plugin_event_handler_function
Plugin event.
Definition: scmApi.h:63
boost::function< void(boost::system::error_code &ec, const std::string &deviceId, dpySCM::LoggingConfiguration &loggingConfiguration)> get_logging_configuration_handler_function
Result of getting logging configuration.
Definition: scmApi.h:60
Contains the network address to be tested on that device.
Definition: scmTypes.h:686
boost::function< void(boost::system::error_code &ec, dpySCM::DeviceKeys deviceKeys)> get_keys_handler_function
Result of getting keys information.
Definition: scmApi.h:45
boost::function< void(boost::system::error_code &ec, dpySCM::DeviceMediaProfiles &deviceMediaProfiles)> device_media_profiles_function
Result of get media profiles.
Definition: scmApi.h:50
Structure containing information needed to execute a pass through.
Definition: scmTypes.h:644
The kind of event and the card information.
Definition: scmTypes.h:161
Device media profiles.
Definition: scmTypes.h:629
virtual ~IsmartCardDeviceObserver()=default
Destructor.
ArtifactType
Definition: scmTypes.h:743
boost::function< void(boost::system::error_code &ec, dpySCM::DeviceChargeResult deviceChargeResult)> handler_device_charge_result_function
Result of device charge EMV result.
Definition: scmApi.h:42
Device payment application information.
Definition: scmTypes.h:323
RebootType
Reboot type, it defines different reboot types.
Definition: scmTypes.h:679
Event
The type of event related to the smart card.
Definition: scmTypes.h:141
The status of the network connectivity.
Definition: scmTypes.h:693
boost::function< void(boost::system::error_code &ec, dpySCM::DevicePaymentAppConfiguration &devicePaymentAppConf)> device_payment_app_conf_function
Result of get device payment application configuration.
Definition: scmApi.h:56
boost::function< void(boost::system::error_code &ec, dpySCM::DevicePciRebootTime &devicePciRebootTime)> reboot_time_handler_function
Result of getting PCI Data Security Standard reboot time.
Definition: scmApi.h:53
virtual void newUpgradeStatus(boost::system::error_code &ec, dpySCM::DeviceUpgradeStatus &deviceUpgradeStatus)=0
boost::function< void(boost::system::error_code &ec, dpySCM::DevicePollingParameter &devicePollingParameter)> device_polling_parameter_function
Result of get device polling parameter.
Definition: scmApi.h:57
The Logging Configuration to be applied or being applied.
Definition: scmTypes.h:724
boost::function< void(boost::system::error_code &ec, dpySCM::DeviceDateTime &dateTime)> device_date_time_handler_function
Result of get network configuration.
Definition: scmApi.h:58
boost::function< void(boost::system::error_code &ec, dpySCM::TransactionDevice TransactionDevice)> card_operation_handler_function
Result of card operation.
Definition: scmApi.h:46
SamSlot
Logging Level values indicating severity of the logs.
Definition: scmTypes.h:734
virtual void newSmartCard(boost::system::error_code &ec, const std::string &deviceId, dpySCM::CardEvent cardEvent)=0
boost::function< void(boost::system::error_code &ec, dpySCM::UltraLightCounter &ulCounter)> ultralight_counter_handler_function
Result of getting a ultralight counter value.
Definition: scmApi.h:54
virtual ~IsmartCardDeviceListObserver()=default
Destructor.
All the date related to the device information.
Definition: scmTypes.h:176
boost::function< void(boost::system::error_code &ec, dpySCM::DevicePluginData &devicePluginData)> execute_plugin_handler_function
Result of executing plugin.
Definition: scmApi.h:62
Device request of charging.
Definition: scmTypes.h:414
boost::function< void(boost::system::error_code &ec, dpySCM::DeviceNetworkConfiguration &deviceNetworkConfiguration)> device_network_configuration_handler_function
Result of get network configuration.
Definition: scmApi.h:55
virtual ~IsmartCardReaderObserver()=default
Destructor.
virtual void deviceListEvent(boost::system::error_code &ec, const std::string &deviceId, dpySCM::Event deviceEvent)=0
NewEvent. This function will be called on new position received event.
Definition: scmTypes.h:770
OperationType
Different types of operation.
Definition: scmTypes.h:87
Device payment terminal configuration.
Definition: scmTypes.h:376
boost::function< void(boost::system::error_code &ec, dpySCM::DeviceVersion &deviceVersion)> device_version_handler_function
Result of get version.
Definition: scmApi.h:48
The device network configuration.
Definition: scmTypes.h:263
Add Keys.
Definition: scmTypes.h:215
Structure containing information of an artifact.
Definition: scmTypes.h:758
Device payment application information.
Definition: scmTypes.h:294
Device PCI Reboot Time.
Definition: scmTypes.h:528
Definition: scmApi.h:125
Deepsy SCM namespace that includes the different enums, structs or method signatures that should be u...
Structure for UltraLight counter requests.
Definition: scmTypes.h:659
ArtifactInstallationType
Type of artifact installation.
Definition: scmTypes.h:751
Device charge result.
Definition: scmTypes.h:487
Definition: scmTypes.h:777
boost::function< void(boost::system::error_code &ec, const std::string &deviceId)> force_device_upgrade_function
Result of force device upgrade request.
Definition: scmApi.h:52
Definition: scmApi.h:72
boost::function< void(boost::system::error_code &ec, const std::string &deviceId, dpySCM::Event deviceEvent)> handler_deviceListEvent_function
Result of added/removed device event.
Definition: scmApi.h:43
virtual void notifyPciReboot(boost::system::error_code &ec, dpySCM::DevicePciRebootTime &devicePciRebootTime)=0
Device pass through.
Definition: scmTypes.h:652
Transaction operation device.
Definition: scmTypes.h:200
boost::function< void(const bool &available)> service_availability_handler
Prototype of the handler function used to monitor service availability.
Definition: scmApi.h:29
virtual void pluginEvent(boost::system::error_code &ec, const dpySCM::DevicePluginData &devicePluginData)=0
virtual void chargeResult(boost::system::error_code &ec, dpySCM::DeviceChargeResult deviceChargeResult)=0
Device polling parameter.
Definition: scmTypes.h:390
boost::function< void(boost::system::error_code &ec)> confirmation_handler_function
Result of confirmation operation.
Definition: scmApi.h:44
boost::function< void(boost::system::error_code &ec, dpySCM::DevicePaymentAppInfo &devicePaymentAppInfo)> device_payment_app_info_function
Result of get device payment application info.
Definition: scmApi.h:49
DateTime struct which contains the response received from the service.
Definition: scmTypes.h:667
Allows to interact with a platform manager.
Definition: scmApi.h:163
Device full version.
Definition: scmTypes.h:245
boost::function< void(boost::system::error_code &ec, dpySCM::DeviceUpgradeStatus &deviceUpgradeStatus)> upgrade_status_events_function
Result of every upgrade status event.
Definition: scmApi.h:51
boost::function< void(boost::system::error_code &ec, const dpySCM::Device &rDevice)> get_devices_handler_function
Handler for status function callback.
Definition: scmApi.h:39
Definition: scmApi.h:97
boost::function< void(boost::system::error_code &ec, const dpySCM::DeviceReaderList &rReader)> get_readers_handler_function
Result of getting readers information.
Definition: scmApi.h:40
boost::function< void(boost::system::error_code &ec, dpySCM::DeviceArtifacts &deviceArtifacts)> get_artifacts_handler_function
Result of getting artifacts informations.
Definition: scmApi.h:61
Interacts with platform manager service.
Definition: scmClientService.h:14
Definition: scmApi.h:144
boost::function< void(boost::system::error_code &ec, dpySCM::DevicePassThrough devicePassThrough)> pass_through_operation_handler_function
Result of pass through operation.
Definition: scmApi.h:47
boost::function< void(boost::system::error_code &ec, dpySCM::DeviceNetworkStatus &deviceNetworkStatus)> network_status_handler_function
Result of testing network connectivity.
Definition: scmApi.h:59
Device confirmation charge.
Definition: scmTypes.h:507