Keyple Card Calypso C++ Library - 3.2.2
Component of the Keyple C++ middleware
CommandGetDataTraceabilityInformation.cpp
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ *
3 * *
4 * See the NOTICE file(s) distributed with this work for additional *
5 * information regarding copyright ownership. *
6 * *
7 * This program and the accompanying materials are made available under the *
8 * terms of the Eclipse Public License 2.0 which is available at *
9 * http://www.eclipse.org/legal/epl-2.0 *
10 * *
11 * SPDX-License-Identifier: EPL-2.0 *
12 ******************************************************************************/
13
14#include "keyple/card/calypso/CommandGetDataTraceabilityInformation.hpp"
15
16#include <map>
17#include <memory>
18
19#include "keyple/card/calypso/CalypsoCardAdapter.hpp"
20#include "keyple/card/calypso/CalypsoCardClass.hpp"
21#include "keyple/card/calypso/CalypsoCardConstant.hpp"
22#include "keyple/card/calypso/CardCommandRef.hpp"
23#include "keyple/card/calypso/CardDataAccessException.hpp"
24#include "keyple/core/util/ApduUtil.hpp"
25
26namespace keyple {
27namespace card {
28namespace calypso {
29
30using keyple::core::util::ApduUtil;
31
32const std::map<int, const std::shared_ptr<Command::StatusProperties>>
33 CommandGetDataTraceabilityInformation::STATUS_TABLE = [] {
34 std::map<int, const std::shared_ptr<Command::StatusProperties>> m(
35 Command::STATUS_TABLE);
36
37 m.insert(
38 {{0x6A88,
39 std::make_shared<StatusProperties>(
40 "Data object not found (optional mode not "
41 "available)",
42 typeid(CardDataAccessException))},
43 {0x6B00,
44 std::make_shared<StatusProperties>(
45 "P1 or P2 value not supported",
46 typeid(CardDataAccessException))}});
47 return m;
48 }();
49
50CommandGetDataTraceabilityInformation::CommandGetDataTraceabilityInformation(
51 const std::shared_ptr<DtoAdapters::TransactionContextDto>&
52 transactionContext,
53 const std::shared_ptr<DtoAdapters::CommandContextDto>& commandContext)
54: Command(CardCommandRef::GET_DATA, nullptr, transactionContext, commandContext)
55{
56 const std::uint8_t cardClass
57 = transactionContext->getCard() != nullptr
58 ? transactionContext->getCard()->getCardClass().getValue()
59 : CalypsoCardClass::ISO.getValue();
60
61 /* APDU Case 2 - always outside secure session */
62 setApduRequest(
63 std::make_shared<DtoAdapters::ApduRequestAdapter>(ApduUtil::build(
64 cardClass,
65 getCommandRef().getInstructionByte(),
66 CalypsoCardConstant::TAG_TRACEABILITY_INFORMATION_MSB,
67 CalypsoCardConstant::TAG_TRACEABILITY_INFORMATION_MSB,
68 0)));
69
70 addSubName("TRACEABILITY_INFORMATION");
71}
72
73void
74CommandGetDataTraceabilityInformation::finalizeRequest()
75{
76 /* NOP */
77}
78
79bool
80CommandGetDataTraceabilityInformation ::
81 isCryptoServiceRequiredToFinalizeRequest() const
82{
83 return false;
84}
85
86bool
87CommandGetDataTraceabilityInformation ::
88 synchronizeCryptoServiceBeforeCardProcessing()
89{
90 return true;
91}
92
93void
94CommandGetDataTraceabilityInformation::parseResponse(
95 std::shared_ptr<ApduResponseApi> apduResponse)
96{
97 Command::setApduResponseAndCheckStatus(apduResponse);
98
99 getTransactionContext()->getCard()->setTraceabilityInformation(
100 apduResponse->getDataOut());
101}
102
103const std::map<int, const std::shared_ptr<Command::StatusProperties>>&
104CommandGetDataTraceabilityInformation::getStatusTable() const
105{
106 return STATUS_TABLE;
107}
108
109} /* namespace calypso */
110} /* namespace card */
111} /* namespace keyple */