Keyple Card Calypso C++ Library 2.1.0
Reference Terminal Reader API for C++
CmdCardGetDataFcp.cpp
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#include "CmdCardGetDataFcp.h"
14
15/* Keyple Card Calypso */
17
18/* Keyple Core Util */
19#include "ApduUtil.h"
20#include "BerTlvUtil.h"
21#include "IllegalStateException.h"
22#include "KeypleAssert.h"
23
24namespace keyple {
25namespace card {
26namespace calypso {
27
28using namespace keyple::core::util;
29using namespace keyple::core::util::cpp::exception;
30
31const CalypsoCardCommand CmdCardGetDataFcp::mCommand = CalypsoCardCommand::GET_DATA;
32const int CmdCardGetDataFcp::TAG_PROPRIETARY_INFORMATION = 0x85;
33const std::map<const int, const std::shared_ptr<StatusProperties>>
34 CmdCardGetDataFcp::STATUS_TABLE = initStatusTable();
35
37: AbstractCardCommand(mCommand)
38{
40 std::make_shared<ApduRequestAdapter>(
41 ApduUtil::build(calypsoCardClass.getValue(),
42 mCommand.getInstructionByte(),
43 0x00,
44 0x62,
45 0x00)));
46}
47
49{
50 return false;
51}
52
54{
55 if (mProprietaryInformation.empty()) {
56 const std::map<const int, const std::vector<uint8_t>> tags =
57 BerTlvUtil::parseSimple(getApduResponse()->getDataOut(), true);
58
59 const auto it = tags.find(TAG_PROPRIETARY_INFORMATION);
60 if (it == tags.end()) {
61 throw IllegalStateException("Proprietary information: tag not found.");
62 }
63
64 mProprietaryInformation = it->second;
65 Assert::getInstance().isEqual(mProprietaryInformation.size(), 23, "proprietaryInformation");
66 }
67
68 return mProprietaryInformation;
69}
70
71const std::map<const int, const std::shared_ptr<StatusProperties>>
72 CmdCardGetDataFcp::initStatusTable()
73{
74 std::map<const int, const std::shared_ptr<StatusProperties>> m =
76
77 m.insert({0x6A88,
78 std::make_shared<StatusProperties>("Data object not found (optional mode not " \
79 "available).",
80 typeid(CardDataAccessException))});
81 m.insert({0x6A82,
82 std::make_shared<StatusProperties>("File not found.",
83 typeid(CardDataAccessException))});
84 m.insert({0x6B00,
85 std::make_shared<StatusProperties>("P1 or P2 value not supported.",
86 typeid(CardDataAccessException))});
87
88 return m;
89}
90
91const std::map<const int, const std::shared_ptr<StatusProperties>>&
93{
94 return STATUS_TABLE;
95}
96
97}
98}
99}
static const std::map< const int, const std::shared_ptr< StatusProperties > > STATUS_TABLE
virtual const std::shared_ptr< ApduResponseApi > getApduResponse() const final
virtual void setApduRequest(const std::shared_ptr< ApduRequestAdapter > apduRequest) final
static const CalypsoCardCommand GET_DATA
CmdCardGetDataFcp(const CalypsoCardClass calypsoCardClass)
const std::vector< uint8_t > & getProprietaryInformation()
const std::map< const int, const std::shared_ptr< StatusProperties > > & getStatusTable() const override