19#include "IllegalArgumentException.h"
20#include "IllegalStateException.h"
35using namespace keyple::core::util;
36using namespace keyple::core::util::cpp;
37using namespace keyple::core::util::cpp::exception;
40const std::map<const int, const std::shared_ptr<StatusProperties>>
41 CmdCardVerifyPin::STATUS_TABLE = initStatusTable();
44 const std::shared_ptr<CalypsoCardAdapter> calypsoCard,
45 const bool encryptPinTransmission,
46 const std::vector<uint8_t>& pin)
47:
AbstractCardCommand(mCommand, 0, calypsoCard), mCla(calypsoCard->getCardClass().getValue())
50 (!encryptPinTransmission && pin.size() != 4) ||
51 (encryptPinTransmission && pin.size() != 8)) {
53 throw IllegalArgumentException(
"The PIN must be 4 bytes long");
57 const uint8_t p1 = 0x00;
58 const uint8_t p2 = 0x00;
62 std::make_shared<ApduRequestAdapter>(
65 addSubName(encryptPinTransmission ?
"ENCRYPTED" :
"PLAIN");
67 mReadCounterOnly =
false;
71:
AbstractCardCommand(mCommand, 0, calypsoCard), mCla(calypsoCard->getCardClass().getValue())
73 const uint8_t p1 = 0x00;
74 const uint8_t p2 = 0x00;
77 std::make_shared<ApduRequestAdapter>(
82 mReadCounterOnly =
true;
94 switch (apduResponse->getStatusWord()) {
117 if (!mReadCounterOnly) {
129const std::map<const int, const std::shared_ptr<StatusProperties>>
130 CmdCardVerifyPin::initStatusTable()
132 std::map<const int, const std::shared_ptr<StatusProperties>> m =
136 std::make_shared<StatusProperties>(
"Lc value not supported (only 00h, 04h or 08h " \
140 std::make_shared<StatusProperties>(
"Transaction Counter is 0.",
141 typeid(CardTerminatedException))});
143 std::make_shared<StatusProperties>(
"Security conditions not fulfilled (Get " \
144 "Challenge not done: challenge unavailable).",
145 typeid(CardSecurityContextException))});
147 std::make_shared<StatusProperties>(
"Access forbidden (a session is open or DF is " \
149 typeid(CardAccessForbiddenException))});
151 std::make_shared<StatusProperties>(
"Incorrect PIN (1 attempt remaining).",
152 typeid(CardPinException))});
154 std::make_shared<StatusProperties>(
"Incorrect PIN (2 attempt remaining).",
155 typeid(CardPinException))});
157 std::make_shared<StatusProperties>(
"Presentation rejected (PIN is blocked).",
158 typeid(CardPinException))});
160 std::make_shared<StatusProperties>(
"PIN function not present.",
161 typeid(CardIllegalParameterException))});
166const std::map<const int, const std::shared_ptr<StatusProperties>>&
static const std::map< const int, const std::shared_ptr< StatusProperties > > STATUS_TABLE
virtual void addSubName(const std::string &subName) final
virtual void setApduRequest(const std::shared_ptr< ApduRequestAdapter > apduRequest) final
void parseApduResponse(const std::shared_ptr< ApduResponseApi > apduResponse) override
std::shared_ptr< CalypsoCardAdapter > getCalypsoCard() const
static const CalypsoCardCommand VERIFY_PIN
uint8_t getInstructionByte() const
void parseApduResponse(const std::shared_ptr< ApduResponseApi > apduResponse) override
const std::map< const int, const std::shared_ptr< StatusProperties > > & getStatusTable() const override
bool isSessionBufferUsed() const override
CmdCardVerifyPin(const std::shared_ptr< CalypsoCardAdapter > calypsoCard, const bool encryptPinTransmission, const std::vector< uint8_t > &pin)