Keyple Card Calypso C++ Library 2.2.2
Reference Terminal Reader API for C++
CardSecuritySettingAdapter.h
Go to the documentation of this file.
1/**************************************************************************************************
2 * Copyright (c) 2023 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 */
30
31namespace keyple {
32namespace card {
33namespace calypso {
34
35using namespace calypsonet::terminal::calypso;
36using namespace calypsonet::terminal::calypso::sam;
37using namespace calypsonet::terminal::calypso::transaction;
38using namespace calypsonet::terminal::reader;
39
47: public CommonSecuritySettingAdapter<CardSecuritySetting>,
48 public CardSecuritySetting {
49public:
56 CardSecuritySetting& setSamResource(const std::shared_ptr<CardReader> samReader,
57 const std::shared_ptr<CalypsoSam> calypsoSam) override;
58
64 CardSecuritySettingAdapter& enableMultipleSession() override;
65
71 CardSecuritySettingAdapter& enableRatificationMechanism() override;
72
78 CardSecuritySettingAdapter& enablePinPlainTransmission() override;
79
85 CardSecuritySettingAdapter& enableSvLoadAndDebitLog() override;
86
92 CardSecuritySettingAdapter& authorizeSvNegativeBalance() override;
93
99 CardSecuritySettingAdapter& assignKif(const WriteAccessLevel writeAccessLevel,
100 const uint8_t kvc,
101 const uint8_t kif) override;
102
108 CardSecuritySettingAdapter& assignDefaultKif(const WriteAccessLevel writeAccessLevel,
109 const uint8_t kif) override;
110
116 CardSecuritySettingAdapter& assignDefaultKvc(const WriteAccessLevel writeAccessLevel,
117 const uint8_t kvc) override;
118
124 CardSecuritySettingAdapter& addAuthorizedSessionKey(const uint8_t kif, const uint8_t kvc)
125 override;
126
132 CardSecuritySettingAdapter& addAuthorizedSvKey(const uint8_t kif, const uint8_t kvc) override;
133
139 CardSecuritySettingAdapter& setPinVerificationCipheringKey(const uint8_t kif, const uint8_t kvc)
140 override;
141
147 CardSecuritySettingAdapter& setPinModificationCipheringKey(const uint8_t kif, const uint8_t kvc)
148 override;
149
157 bool isMultipleSessionEnabled() const;
158
166 bool isRatificationMechanismEnabled() const;
167
175 bool isPinPlainTransmissionEnabled() const;
176
184 bool isSvLoadAndDebitLogEnabled() const;
185
193 bool isSvNegativeBalanceAuthorized() const;
194
205 const std::shared_ptr<uint8_t> getKif(const WriteAccessLevel writeAccessLevel,
206 const uint8_t kvc) const;
207
217 const std::shared_ptr<uint8_t> getDefaultKif(const WriteAccessLevel writeAccessLevel) const;
218
228 const std::shared_ptr<uint8_t> getDefaultKvc(const WriteAccessLevel writeAccessLevel) const;
229
239 bool isSessionKeyAuthorized(const std::shared_ptr<uint8_t> kif,
240 const std::shared_ptr<uint8_t> kvc) const;
241
251 bool isSvKeyAuthorized(const std::shared_ptr<uint8_t> kif,
252 const std::shared_ptr<uint8_t> kvc) const;
253
261 const std::shared_ptr<uint8_t> getPinVerificationCipheringKif() const;
262
270 const std::shared_ptr<uint8_t> getPinVerificationCipheringKvc() const;
271
279 const std::shared_ptr<uint8_t> getPinModificationCipheringKif() const;
280
288 const std::shared_ptr<uint8_t> getPinModificationCipheringKvc() const;
289
290private:
294 static const std::string WRITE_ACCESS_LEVEL;
295
299 bool mIsMultipleSessionEnabled = false;
300
304 bool mIsRatificationMechanismEnabled = false;
305
309 bool mIsPinPlainTransmissionEnabled = false;
310
314 bool mIsSvLoadAndDebitLogEnabled = false;
315
319 bool mIsSvNegativeBalanceAuthorized = false;
320
324 std::map<WriteAccessLevel, std::map<uint8_t, uint8_t>> mKifMap;
325
329 std::map<WriteAccessLevel, uint8_t> mDefaultKifMap;
330
334 std::map<WriteAccessLevel, uint8_t> mDefaultKvcMap;
335
339 std::vector<int> mAuthorizedSessionKeys;
340
344 std::vector<int> mAuthorizedSvKeys;
345
349 std::shared_ptr<uint8_t> mPinVerificationCipheringKif;
350
354 std::shared_ptr<uint8_t> mPinVerificationCipheringKvc;
355
359 std::shared_ptr<uint8_t> mPinModificationCipheringKif;
360
364 std::shared_ptr<uint8_t> mPinModificationCipheringKvc;
365};
366
367}
368}
369}
#define KEYPLECARDCALYPSO_API