Keyple Card Calypso C++ Library 2.1.0
Reference Terminal Reader API for C++
CalypsoSamResourceProfileExtensionAdapter.cpp
Go to the documentation of this file.
1/**************************************************************************************************
2 * Copyright (c) 2021 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
14
15namespace keyple {
16namespace card {
17namespace calypso {
18
20 const std::shared_ptr<CalypsoSamSelection> calypsoSamSelection)
21: mCalypsoSamSelection(calypsoSamSelection) {}
22
24 std::shared_ptr<CardReader> reader,
25 std::shared_ptr<CardSelectionManager> samCardSelectionManager)
26{
27
28 if (!reader->isCardPresent()) {
29 return nullptr;
30 }
31
32 samCardSelectionManager->prepareSelection(mCalypsoSamSelection);
33 std::shared_ptr<CardSelectionResult> samCardSelectionResult = nullptr;
34
35 try {
36 samCardSelectionResult = samCardSelectionManager->processCardSelectionScenario(reader);
37 } catch (const Exception& e) {
38 mLogger->warn("An exception occurred while selecting the SAM: '%'\n", e.getMessage(), e);
39 }
40
41 if (samCardSelectionResult != nullptr) {
42 return samCardSelectionResult->getActiveSmartCard();
43 }
44
45 return nullptr;
46}
47
48}
49}
50}
std::shared_ptr< SmartCard > matches(std::shared_ptr< CardReader > reader, std::shared_ptr< CardSelectionManager > samCardSelectionManager) override
CalypsoSamResourceProfileExtensionAdapter(const std::shared_ptr< CalypsoSamSelection > calypsoSamSelection)