Keyple Card Calypso C++ Library 2.1.0
Reference Terminal Reader API for C++
CmdSamSvPrepareUndebit.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
14
15/* Keyple Card Calypso */
16#include "CalypsoCardAdapter.h"
17#include "CalypsoCardClass.h"
24#include "SamUtilAdapter.h"
25
26/* Keyple Core Util */
27#include "ApduUtil.h"
28#include "IllegalArgumentException.h"
29#include "IllegalStateException.h"
30#include "System.h"
31
32namespace keyple {
33namespace card {
34namespace calypso {
35
36using namespace keyple::core::util;
37using namespace keyple::core::util::cpp;
38using namespace keyple::core::util::cpp::exception;
39
40const CalypsoSamCommand CmdSamSvPrepareUndebit::mCommand = CalypsoSamCommand::SV_PREPARE_UNDEBIT;
41
42const std::map<const int, const std::shared_ptr<StatusProperties>>
43 CmdSamSvPrepareUndebit::STATUS_TABLE = initStatusTable();
44
46 const std::vector<uint8_t>& svGetHeader,
47 const std::vector<uint8_t>& svGetData,
48 const std::vector<uint8_t>& svUndebitCmdBuildData)
49: AbstractSamCommand(mCommand)
50{
51 const uint8_t cla = SamUtilAdapter::getClassByte(productType);
52 const uint8_t p1 = 0x01;
53 const uint8_t p2 = 0xFF;
54 std::vector<uint8_t> data(16 + svGetData.size()); /* Header(4) + SvUndebit data (12) = 16 bytes*/
55
56 System::arraycopy(svGetHeader, 0, data, 0, 4);
57 System::arraycopy(svGetData, 0, data, 4, svGetData.size());
58 System::arraycopy(svUndebitCmdBuildData,
59 0,
60 data,
61 4 + svGetData.size(),
62 svUndebitCmdBuildData.size());
63
65 std::make_shared<ApduRequestAdapter>(
66 ApduUtil::build(cla, mCommand.getInstructionByte(), p1, p2, data)));
67}
68
69const std::map<const int, const std::shared_ptr<StatusProperties>>
70 CmdSamSvPrepareUndebit::initStatusTable()
71{
72 std::map<const int, const std::shared_ptr<StatusProperties>> m =
74
75 m.insert({0x6700,
76 std::make_shared<StatusProperties>("Incorrect Lc.",
78 m.insert({0x6985,
79 std::make_shared<StatusProperties>("Preconditions not satisfied.",
80 typeid(CalypsoSamAccessForbiddenException))});
81 m.insert({0x6A00,
82 std::make_shared<StatusProperties>("Incorrect P1 or P2",
83 typeid(CalypsoSamIllegalParameterException))});
84 m.insert({0x6A80,
85 std::make_shared<StatusProperties>("Incorrect incoming data.",
86 typeid(CalypsoSamIncorrectInputDataException))});
87 m.insert({0x6A83,
88 std::make_shared<StatusProperties>("Record not found: ciphering key not found",
89 typeid(CalypsoSamDataAccessException))});
90
91 return m;
92}
93
94const std::map<const int, const std::shared_ptr<StatusProperties>>&
96{
97 return STATUS_TABLE;
98}
99
100}
101}
102}
virtual void setApduRequest(const std::shared_ptr< ApduRequestAdapter > apduRequest) final
static const std::map< const int, const std::shared_ptr< StatusProperties > > STATUS_TABLE
static const CalypsoSamCommand SV_PREPARE_UNDEBIT
CmdSamSvPrepareUndebit(const CalypsoSam::ProductType productType, const std::vector< uint8_t > &svGetHeader, const std::vector< uint8_t > &svGetData, const std::vector< uint8_t > &svUndebitCmdBuildData)
const std::map< const int, const std::shared_ptr< StatusProperties > > & getStatusTable() const override
static uint8_t getClassByte(const ProductType productType)
CalypsoSam::ProductType ProductType