Keyple Card Calypso C++ Library 2.2.2
Reference Terminal Reader API for C++
CalypsoSamSelectionAdapter.h
Go to the documentation of this file.
1/**************************************************************************************************
2 * Copyright (c) 2022 Calypso Networks Association https://calypsonet.org/ *
3 * *
4 * See the NOTICE file(s) distributed with this work for additional information regarding *
5 * copyright ownership. *
6 * *
7 * This program and the accompanying materials are made available under the terms of the Eclipse *
8 * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 *
9 * *
10 * SPDX-License-Identifier: EPL-2.0 *
11 **************************************************************************************************/
12
13#pragma once
14
15#include <memory>
16#include <string>
17#include <vector>
18
19/* Calypsonet Terminal Calypso */
20#include "CalypsoSam.h"
21#include "CalypsoSamSelection.h"
22
23/* Calypsonet Terminal Card */
24#include "CardSelectionSpi.h"
25
26/* Keyple Card Calypso */
27#include "AbstractSamCommand.h"
28#include "CardSelectorAdapter.h"
29#include "CmdSamUnlock.h"
30
31/* Keyple Core Util */
32#include "LoggerFactory.h"
33
34
35namespace keyple {
36namespace card {
37namespace calypso {
38
39using namespace calypsonet::terminal::calypso::sam;
40using namespace calypsonet::terminal::card::spi;
41using namespace keyple::core::util::cpp;
42
51class CalypsoSamSelectionAdapter : public CalypsoSamSelection, public CardSelectionSpi {
52public:
60
66 const std::shared_ptr<CardSelectionRequestSpi> getCardSelectionRequest() override;
67
73 const std::shared_ptr<SmartCardSpi> parse(
74 const std::shared_ptr<CardSelectionResponseApi> cardSelectionResponse) override;
75
81 CalypsoSamSelection& filterByProductType(const CalypsoSam::ProductType productType) override;
82
88 CalypsoSamSelection& filterBySerialNumber(const std::string& serialNumberRegex) override;
89
95 CalypsoSamSelection& setUnlockData(const std::string& unlockData) override;
96
97private:
101 const std::unique_ptr<Logger> mLogger =
102 LoggerFactory::getLogger(typeid(CalypsoSamSelectionAdapter));
103
107 static const int SW_NOT_LOCKED;
108
112 const std::shared_ptr<CardSelectorAdapter> mSamCardSelector;
113
117 CalypsoSam::ProductType mProductType = CalypsoSam::ProductType::UNKNOWN;
118
122 std::string mSerialNumberRegex;
123
127 std::shared_ptr<CmdSamUnlock> mUnlockCommand;
128
138 const std::string buildAtrRegex(const CalypsoSam::ProductType productType,
139 const std::string& samSerialNumberRegex);
140};
141
142}
143}
144}
CalypsoSamSelection & setUnlockData(const std::string &unlockData) override
CalypsoSamSelection & filterByProductType(const CalypsoSam::ProductType productType) override
const std::shared_ptr< SmartCardSpi > parse(const std::shared_ptr< CardSelectionResponseApi > cardSelectionResponse) override
const std::shared_ptr< CardSelectionRequestSpi > getCardSelectionRequest() override
CalypsoSamSelection & filterBySerialNumber(const std::string &serialNumberRegex) override
CalypsoSam::ProductType ProductType