Keyple Card Calypso C++ Library 2.2.2
Reference Terminal Reader API for C++
CalypsoCardUtilAdapter.h
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#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
90 static void updateCalypsoCard(
91 std::shared_ptr<CalypsoCardAdapter> calypsoCard,
92 const std::vector<std::shared_ptr<AbstractApduCommand>>& commands,
93 const std::vector<std::shared_ptr<ApduResponseApi>>& apduResponses,
94 const bool isSessionOpen);
95
96private:
101
114 static void updateCalypsoCardOpenSession(
115 std::shared_ptr<CalypsoCardAdapter> calypsoCard,
116 std::shared_ptr<CmdCardOpenSession> cmdCardOpenSession,
117 const std::shared_ptr<ApduResponseApi> apduResponse);
118
127 static void updateCalypsoCardCloseSession(
128 std::shared_ptr<CmdCardCloseSession> cmdCardCloseSession,
129 const std::shared_ptr<ApduResponseApi> apduResponse);
130
143 static void updateCalypsoCardReadRecords(
144 const std::shared_ptr<CalypsoCardAdapter> calypsoCard,
145 const std::shared_ptr<CmdCardReadRecords> cmdCardReadRecords,
146 const std::shared_ptr<ApduResponseApi> apduResponse,
147 const bool isSessionOpen);
148
157 static void checkResponseStatusForStrictAndBestEffortMode(
158 const std::shared_ptr<AbstractCardCommand> command, const bool isSessionOpen);
159
173 static void updateCalypsoCardSearchRecordMultiple(
174 std::shared_ptr<CalypsoCardAdapter> calypsoCard,
175 std::shared_ptr<CmdCardSearchRecordMultiple> cmdCardSearchRecordMultiple,
176 const std::shared_ptr<ApduResponseApi> apduResponse,
177 const bool isSessionOpen);
178
191 static void updateCalypsoCardReadRecordMultiple(
192 std::shared_ptr<CalypsoCardAdapter> calypsoCard,
193 std::shared_ptr<CmdCardReadRecordMultiple> cmdCardReadRecordMultiple,
194 const std::shared_ptr<ApduResponseApi> apduResponse,
195 const bool isSessionOpen);
196
209 static void updateCalypsoCardReadBinary(std::shared_ptr<CalypsoCardAdapter> calypsoCard,
210 std::shared_ptr<CmdCardReadBinary> cmdCardReadBinary,
211 const std::shared_ptr<ApduResponseApi> apduResponse,
212 const bool isSessionOpen);
213
226 static void updateCalypsoCardWithFcp(
227 std::shared_ptr<CalypsoCardAdapter> calypsoCard,
228 std::shared_ptr<AbstractCardCommand> command,
229 const std::shared_ptr<ApduResponseApi> apduResponse);
230
244 static void updateCalypsoCardWithEfList(
245 std::shared_ptr<CalypsoCardAdapter> calypsoCard,
246 std::shared_ptr<CmdCardGetDataEfList> command,
247 const std::shared_ptr<ApduResponseApi> apduResponse);
248
260 static void updateCalypsoCardWithTraceabilityInformation(
261 std::shared_ptr<CalypsoCardAdapter> calypsoCard,
262 std::shared_ptr<CmdCardGetDataTraceabilityInformation> command,
263 const std::shared_ptr<ApduResponseApi> apduResponse);
264
275 static void updateCalypsoCardUpdateRecord(
276 std::shared_ptr<CalypsoCardAdapter> calypsoCard,
277 std::shared_ptr<CmdCardUpdateRecord> cmdCardUpdateRecord,
278 const std::shared_ptr<ApduResponseApi> apduResponse);
279
290 static void updateCalypsoCardWriteRecord(
291 std::shared_ptr<CalypsoCardAdapter> calypsoCard,
292 std::shared_ptr<CmdCardWriteRecord> cmdCardWriteRecord,
293 const std::shared_ptr<ApduResponseApi> apduResponse);
294
305 static void updateCalypsoCardUpdateBinary(
306 std::shared_ptr<CalypsoCardAdapter> calypsoCard,
307 std::shared_ptr<CmdCardUpdateOrWriteBinary> cmdCardUpdateBinary,
308 const std::shared_ptr<ApduResponseApi> apduResponse);
309
320 static void updateCalypsoCardWriteBinary(
321 std::shared_ptr<CalypsoCardAdapter> calypsoCard,
322 std::shared_ptr<CmdCardUpdateOrWriteBinary> cmdCardWriteBinary,
323 const std::shared_ptr<ApduResponseApi> apduResponse);
324
336 static void updateCalypsoCardAppendRecord(
337 std::shared_ptr<CalypsoCardAdapter> calypsoCard,
338 std::shared_ptr<CmdCardAppendRecord> cmdCardAppendRecord,
339 const std::shared_ptr<ApduResponseApi> apduResponse);
340
352 static void updateCalypsoCardIncreaseOrDecrease(
353 std::shared_ptr<CalypsoCardAdapter> calypsoCard,
354 std::shared_ptr<CmdCardIncreaseOrDecrease> cmdCardIncreaseOrDecrease,
355 const std::shared_ptr<ApduResponseApi> apduResponse);
356
368 static void updateCalypsoCardIncreaseOrDecreaseMultiple(
369 std::shared_ptr<CalypsoCardAdapter> calypsoCard,
370 std::shared_ptr<CmdCardIncreaseOrDecreaseMultiple> cmdCardIncreaseOrDecreaseMultiple,
371 const std::shared_ptr<ApduResponseApi> apduResponse);
372
383 static void updateCalypsoCardGetChallenge(
384 std::shared_ptr<CalypsoCardAdapter> calypsoCard,
385 std::shared_ptr<CmdCardGetChallenge> cmdCardGetChallenge,
386 const std::shared_ptr<ApduResponseApi> apduResponse);
387
401 static void updateCalypsoVerifyPin(std::shared_ptr<CalypsoCardAdapter> calypsoCard,
402 std::shared_ptr<CmdCardVerifyPin> cmdCardVerifyPin,
403 const std::shared_ptr<ApduResponseApi> apduResponse);
404
412 static void updateCalypsoChangePin(std::shared_ptr<CmdCardChangePin> cmdCardChangePin,
413 const std::shared_ptr<ApduResponseApi> apduResponse);
414
422 static void updateCalypsoChangeKey(std::shared_ptr<CmdCardChangeKey> cmdCardChangeKey,
423 const std::shared_ptr<ApduResponseApi> apduResponse);
424
437 static void updateCalypsoCardSvGet(
438 std::shared_ptr<CalypsoCardAdapter> calypsoCard,
439 std::shared_ptr<CmdCardSvGet> cmdCardSvGet,
440 const std::shared_ptr<ApduResponseApi> apduResponse);
441
455 static void updateCalypsoCardSvOperation(
456 std::shared_ptr<CalypsoCardAdapter> calypsoCard,
457 std::shared_ptr<AbstractCardCommand> cmdCardSvOperation,
458 const std::shared_ptr<ApduResponseApi> apduResponse);
459
468 static void updateCalypsoInvalidateRehabilitate(
469 std::shared_ptr<AbstractCardCommand> cmdCardInvalidateRehabilitate,
470 const std::shared_ptr<ApduResponseApi> apduResponse);
471
480 static const std::shared_ptr<DirectoryHeader> createDirectoryHeader(
481 const std::vector<uint8_t>& proprietaryInformation);
482
490 static ElementaryFile::Type getEfTypeFromCardValue(const uint8_t efType);
491
500 static const std::shared_ptr<FileHeaderAdapter> createFileHeader(
501 const std::vector<uint8_t>& proprietaryInformation);
502};
503
504}
505}
506}
static void updateCalypsoCard(std::shared_ptr< CalypsoCardAdapter > calypsoCard, const std::shared_ptr< AbstractCardCommand > command, const std::shared_ptr< ApduResponseApi > apduResponse, const bool isSessionOpen)