Keyple Card Calypso C++ Library 2.1.0
Reference Terminal Reader API for C++
CalypsoCardUtilAdapter.h
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
13#pragma once
14
15#include <memory>
16
17/* Calypsonet Terminal Card */
18#include "ApduResponseApi.h"
19
20/* Keyple Card Calypso */
21#include "AbstractCardCommand.h"
22#include "CalypsoCardAdapter.h"
23#include "CmdCardAppendRecord.h"
24#include "CmdCardChangePin.h"
25#include "CmdCardChangeKey.h"
26#include "CmdCardCloseSession.h"
27#include "CmdCardGetChallenge.h"
32#include "CmdCardOpenSession.h"
33#include "CmdCardReadRecords.h"
34#include "CmdCardReadBinary.h"
37#include "CmdCardSvGet.h"
39#include "CmdCardUpdateRecord.h"
40#include "CmdCardVerifyPin.h"
41#include "CmdCardWriteRecord.h"
42
43namespace keyple {
44namespace card {
45namespace calypso {
46
47using namespace calypsonet::terminal::card;
48
57public:
70 static void updateCalypsoCard(std::shared_ptr<CalypsoCardAdapter> calypsoCard,
71 const std::shared_ptr<AbstractCardCommand> command,
72 const std::shared_ptr<ApduResponseApi> apduResponse,
73 const bool isSessionOpen);
74
87 static void updateCalypsoCard(
88 std::shared_ptr<CalypsoCardAdapter> calypsoCard,
89 const std::vector<std::shared_ptr<AbstractCardCommand>>& commands,
90 const std::vector<std::shared_ptr<ApduResponseApi>>& apduResponses,
91 const bool isSessionOpen);
92
93private:
98
110 static void updateCalypsoCardOpenSession(
111 std::shared_ptr<CalypsoCardAdapter> calypsoCard,
112 std::shared_ptr<CmdCardOpenSession> cmdCardOpenSession,
113 const std::shared_ptr<ApduResponseApi> apduResponse);
114
123 static void updateCalypsoCardCloseSession(
124 std::shared_ptr<CmdCardCloseSession> cmdCardCloseSession,
125 const std::shared_ptr<ApduResponseApi> apduResponse);
126
139 static void updateCalypsoCardReadRecords(
140 const std::shared_ptr<CalypsoCardAdapter> calypsoCard,
141 const std::shared_ptr<CmdCardReadRecords> cmdCardReadRecords,
142 const std::shared_ptr<ApduResponseApi> apduResponse,
143 const bool isSessionOpen);
144
153 static void checkResponseStatusForStrictAndBestEffortMode(
154 const std::shared_ptr<AbstractCardCommand> command, const bool isSessionOpen);
155
169 static void updateCalypsoCardSearchRecordMultiple(
170 std::shared_ptr<CalypsoCardAdapter> calypsoCard,
171 std::shared_ptr<CmdCardSearchRecordMultiple> cmdCardSearchRecordMultiple,
172 const std::shared_ptr<ApduResponseApi> apduResponse,
173 const bool isSessionOpen);
174
187 static void updateCalypsoCardReadRecordMultiple(
188 std::shared_ptr<CalypsoCardAdapter> calypsoCard,
189 std::shared_ptr<CmdCardReadRecordMultiple> cmdCardReadRecordMultiple,
190 const std::shared_ptr<ApduResponseApi> apduResponse,
191 const bool isSessionOpen);
192
205 static void updateCalypsoCardReadBinary(std::shared_ptr<CalypsoCardAdapter> calypsoCard,
206 std::shared_ptr<CmdCardReadBinary> cmdCardReadBinary,
207 const std::shared_ptr<ApduResponseApi> apduResponse,
208 const bool isSessionOpen);
209
222 static void updateCalypsoCardWithFcp(
223 std::shared_ptr<CalypsoCardAdapter> calypsoCard,
224 std::shared_ptr<AbstractCardCommand> command,
225 const std::shared_ptr<ApduResponseApi> apduResponse);
226
240 static void updateCalypsoCardWithEfList(
241 std::shared_ptr<CalypsoCardAdapter> calypsoCard,
242 std::shared_ptr<CmdCardGetDataEfList> command,
243 const std::shared_ptr<ApduResponseApi> apduResponse);
244
256 static void updateCalypsoCardWithTraceabilityInformation(
257 std::shared_ptr<CalypsoCardAdapter> calypsoCard,
258 std::shared_ptr<CmdCardGetDataTraceabilityInformation> command,
259 const std::shared_ptr<ApduResponseApi> apduResponse);
260
271 static void updateCalypsoCardUpdateRecord(
272 std::shared_ptr<CalypsoCardAdapter> calypsoCard,
273 std::shared_ptr<CmdCardUpdateRecord> cmdCardUpdateRecord,
274 const std::shared_ptr<ApduResponseApi> apduResponse);
275
286 static void updateCalypsoCardWriteRecord(
287 std::shared_ptr<CalypsoCardAdapter> calypsoCard,
288 std::shared_ptr<CmdCardWriteRecord> cmdCardWriteRecord,
289 const std::shared_ptr<ApduResponseApi> apduResponse);
290
301 static void updateCalypsoCardUpdateBinary(
302 std::shared_ptr<CalypsoCardAdapter> calypsoCard,
303 std::shared_ptr<CmdCardUpdateOrWriteBinary> cmdCardUpdateBinary,
304 const std::shared_ptr<ApduResponseApi> apduResponse);
305
316 static void updateCalypsoCardWriteBinary(
317 std::shared_ptr<CalypsoCardAdapter> calypsoCard,
318 std::shared_ptr<CmdCardUpdateOrWriteBinary> cmdCardWriteBinary,
319 const std::shared_ptr<ApduResponseApi> apduResponse);
320
332 static void updateCalypsoCardAppendRecord(
333 std::shared_ptr<CalypsoCardAdapter> calypsoCard,
334 std::shared_ptr<CmdCardAppendRecord> cmdCardAppendRecord,
335 const std::shared_ptr<ApduResponseApi> apduResponse);
336
348 static void updateCalypsoCardIncreaseOrDecrease(
349 std::shared_ptr<CalypsoCardAdapter> calypsoCard,
350 std::shared_ptr<CmdCardIncreaseOrDecrease> cmdCardIncreaseOrDecrease,
351 const std::shared_ptr<ApduResponseApi> apduResponse);
352
364 static void updateCalypsoCardIncreaseOrDecreaseMultiple(
365 std::shared_ptr<CalypsoCardAdapter> calypsoCard,
366 std::shared_ptr<CmdCardIncreaseOrDecreaseMultiple> cmdCardIncreaseOrDecreaseMultiple,
367 const std::shared_ptr<ApduResponseApi> apduResponse);
368
379 static void updateCalypsoCardGetChallenge(
380 std::shared_ptr<CalypsoCardAdapter> calypsoCard,
381 std::shared_ptr<CmdCardGetChallenge> cmdCardGetChallenge,
382 const std::shared_ptr<ApduResponseApi> apduResponse);
383
397 static void updateCalypsoVerifyPin(std::shared_ptr<CalypsoCardAdapter> calypsoCard,
398 std::shared_ptr<CmdCardVerifyPin> cmdCardVerifyPin,
399 const std::shared_ptr<ApduResponseApi> apduResponse);
400
408 static void updateCalypsoChangePin(std::shared_ptr<CmdCardChangePin> cmdCardChangePin,
409 const std::shared_ptr<ApduResponseApi> apduResponse);
410
418 static void updateCalypsoChangeKey(std::shared_ptr<CmdCardChangeKey> cmdCardChangeKey,
419 const std::shared_ptr<ApduResponseApi> apduResponse);
420
433 static void updateCalypsoCardSvGet(
434 std::shared_ptr<CalypsoCardAdapter> calypsoCard,
435 std::shared_ptr<CmdCardSvGet> cmdCardSvGet,
436 const std::shared_ptr<ApduResponseApi> apduResponse);
437
451 static void updateCalypsoCardSvOperation(
452 std::shared_ptr<CalypsoCardAdapter> calypsoCard,
453 std::shared_ptr<AbstractCardCommand> cmdCardSvOperation,
454 const std::shared_ptr<ApduResponseApi> apduResponse);
455
464 static void updateCalypsoInvalidateRehabilitate(
465 std::shared_ptr<AbstractCardCommand> cmdCardInvalidateRehabilitate,
466 const std::shared_ptr<ApduResponseApi> apduResponse);
467
476 static const std::shared_ptr<DirectoryHeader> createDirectoryHeader(
477 const std::vector<uint8_t>& proprietaryInformation);
478
486 static ElementaryFile::Type getEfTypeFromCardValue(const uint8_t efType);
487
496 static const std::shared_ptr<FileHeaderAdapter> createFileHeader(
497 const std::vector<uint8_t>& proprietaryInformation);
498};
499
500}
501}
502}
static void updateCalypsoCard(std::shared_ptr< CalypsoCardAdapter > calypsoCard, const std::shared_ptr< AbstractCardCommand > command, const std::shared_ptr< ApduResponseApi > apduResponse, const bool isSessionOpen)