Keyple Card Calypso C++ Library 2.1.0
Reference Terminal Reader API for C++
CardSecuritySettingAdapter.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 <map>
16#include <memory>
17#include <string>
18
19/* Calypsonet Terminal Calypso */
20#include "CalypsoSam.h"
21#include "CardSecuritySetting.h"
22#include "WriteAccessLevel.h"
23
24/* Calypsonet Terminal Reader */
25#include "CardReader.h"
26
27/* Keyple Card Calypso */
29
30namespace keyple {
31namespace card {
32namespace calypso {
33
34using namespace calypsonet::terminal::calypso;
35using namespace calypsonet::terminal::calypso::sam;
36using namespace calypsonet::terminal::calypso::transaction;
37using namespace calypsonet::terminal::reader;
38
45class KEYPLECARDCALYPSO_API CardSecuritySettingAdapter final : public CardSecuritySetting {
46public:
52
58 CardSecuritySetting& setSamResource(const std::shared_ptr<CardReader> samReader,
59 const std::shared_ptr<CalypsoSam> calypsoSam) override;
60
66 CardSecuritySettingAdapter& enableMultipleSession() override;
67
73 CardSecuritySettingAdapter& enableRatificationMechanism() override;
74
80 CardSecuritySettingAdapter& enablePinPlainTransmission() override;
81
87 CardSecuritySettingAdapter& enableTransactionAudit() override;
88
94 CardSecuritySettingAdapter& enableSvLoadAndDebitLog() override;
95
101 CardSecuritySettingAdapter& authorizeSvNegativeBalance() override;
102
108 CardSecuritySettingAdapter& assignKif(const WriteAccessLevel writeAccessLevel,
109 const uint8_t kvc,
110 const uint8_t kif) override;
111
117 CardSecuritySettingAdapter& assignDefaultKif(const WriteAccessLevel writeAccessLevel,
118 const uint8_t kif) override;
119
125 CardSecuritySettingAdapter& assignDefaultKvc(const WriteAccessLevel writeAccessLevel,
126 const uint8_t kvc) override;
127
133 CardSecuritySettingAdapter& addAuthorizedSessionKey(const uint8_t kif, const uint8_t kvc)
134 override;
135
141 CardSecuritySettingAdapter& addAuthorizedSvKey(const uint8_t kif, const uint8_t kvc) override;
142
148 CardSecuritySettingAdapter& setPinVerificationCipheringKey(const uint8_t kif, const uint8_t kvc)
149 override;
150
156 CardSecuritySettingAdapter& setPinModificationCipheringKey(const uint8_t kif, const uint8_t kvc)
157 override;
158
166 std::shared_ptr<CardReader> getSamReader() const;
167
176 std::shared_ptr<CalypsoSam> getCalypsoSam() const;
177
185 bool isMultipleSessionEnabled() const;
186
194 bool isRatificationMechanismEnabled() const;
195
203 bool isPinPlainTransmissionEnabled() const;
204
212 bool isTransactionAuditEnabled() const;
213
221 bool isSvLoadAndDebitLogEnabled() const;
222
230 bool isSvNegativeBalanceAuthorized() const;
231
242 const std::shared_ptr<uint8_t> getKif(const WriteAccessLevel writeAccessLevel,
243 const uint8_t kvc) const;
244
254 const std::shared_ptr<uint8_t> getDefaultKif(const WriteAccessLevel writeAccessLevel) const;
255
265 const std::shared_ptr<uint8_t> getDefaultKvc(const WriteAccessLevel writeAccessLevel) const;
266
276 bool isSessionKeyAuthorized(const std::shared_ptr<uint8_t> kif,
277 const std::shared_ptr<uint8_t> kvc) const;
278
288 bool isSvKeyAuthorized(const std::shared_ptr<uint8_t> kif,
289 const std::shared_ptr<uint8_t> kvc) const;
290
298 const std::shared_ptr<uint8_t> getPinVerificationCipheringKif() const;
299
307 const std::shared_ptr<uint8_t> getPinVerificationCipheringKvc() const;
308
316 const std::shared_ptr<uint8_t> getPinModificationCipheringKif() const;
317
325 const std::shared_ptr<uint8_t> getPinModificationCipheringKvc() const;
326
327private:
331 static const std::string WRITE_ACCESS_LEVEL;
332
336 std::shared_ptr<CardReader> mSamReader;
337
341 std::shared_ptr<CalypsoSam> mCalypsoSam;
342
346 bool mIsMultipleSessionEnabled;
347
351 bool mIsRatificationMechanismEnabled;
352
356 bool mIsPinPlainTransmissionEnabled;
357
361 bool mIsTransactionAuditEnabled;
362
366 bool mIsSvLoadAndDebitLogEnabled;
367
371 bool mIsSvNegativeBalanceAuthorized;
372
376 std::map<WriteAccessLevel, std::map<uint8_t, uint8_t>> mKifMap;
377
381 std::map<WriteAccessLevel, uint8_t> mDefaultKifMap;
382
386 std::map<WriteAccessLevel, uint8_t> mDefaultKvcMap;
387
391 std::vector<int> mAuthorizedSessionKeys;
392
396 std::vector<int> mAuthorizedSvKeys;
397
401 std::shared_ptr<uint8_t> mPinVerificationCipheringKif;
402
406 std::shared_ptr<uint8_t> mPinVerificationCipheringKvc;
407
411 std::shared_ptr<uint8_t> mPinModificationCipheringKif;
412
416 std::shared_ptr<uint8_t> mPinModificationCipheringKvc;
417};
418
419}
420}
421}
#define KEYPLECARDCALYPSO_API