Keyple Card Calypso C++ Library 2.1.0
Reference Terminal Reader API for C++
AbstractCardCommand.cpp
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#include "AbstractCardCommand.h"
14
15/* Keyple Card Calypso */
22#include "CardPinException.h"
28
29namespace keyple {
30namespace card {
31namespace calypso {
32
34: AbstractApduCommand(commandRef) {}
35
37{
38 return dynamic_cast<const CalypsoCardCommand&>(AbstractApduCommand::getCommandRef());
39}
40
42 const std::type_info& exceptionClass,
43 const std::string& message,
44 const CardCommand& commandRef,
45 const int statusWord) const {
46
47 const auto& command = dynamic_cast<const CalypsoCardCommand&>(commandRef);
48 const auto sw = std::make_shared<int>(statusWord);
49
50 if (exceptionClass == typeid(CardAccessForbiddenException)) {
51 return CardAccessForbiddenException(message, command, sw);
52 } else if (exceptionClass == typeid(CardDataAccessException)) {
53 return CardDataAccessException(message, command, sw);
54 } else if (exceptionClass == typeid(CardDataOutOfBoundsException)) {
55 return CardDataOutOfBoundsException(message, command, sw);
56 } else if (exceptionClass == typeid(CardIllegalArgumentException)) {
57 return CardIllegalArgumentException(message, command);
58 } else if (exceptionClass == typeid(CardIllegalParameterException)) {
59 return CardIllegalParameterException(message, command, sw);
60 } else if (exceptionClass == typeid(CardPinException)) {
61 return CardPinException(message, command, sw);
62 } else if (exceptionClass == typeid(CardSecurityContextException)) {
63 return CardSecurityContextException(message, command, sw);
64 } else if (exceptionClass == typeid(CardSecurityDataException)) {
65 return CardSecurityDataException(message, command, sw);
66 } else if (exceptionClass == typeid(CardSessionBufferOverflowException)) {
67 return CardSessionBufferOverflowException(message, command, sw);
68 } else if (exceptionClass == typeid(CardTerminatedException)) {
69 return CardTerminatedException(message, command, sw);
70 } else {
71 return CardUnknownStatusException(message, command, sw);
72 }
73}
74
76 const std::shared_ptr<ApduResponseApi> apduResponse)
77{
78 return dynamic_cast<AbstractCardCommand&>(AbstractApduCommand::setApduResponse(apduResponse));
79}
80
82{
83 try {
85 } catch (CalypsoApduCommandException& e) {
86 throw reinterpret_cast<CardCommandException&>(e);
87 }
88}
89
90}
91}
92}
virtual AbstractApduCommand & setApduResponse(const std::shared_ptr< ApduResponseApi > apduResponse)
virtual const CardCommand & getCommandRef() const
AbstractCardCommand(const CalypsoCardCommand &commandRef)
const CalypsoCardCommand & getCommandRef() const override
const CalypsoApduCommandException buildCommandException(const std::type_info &exceptionClass, const std::string &message, const CardCommand &commandRef, const int statusWord) const final
AbstractCardCommand & setApduResponse(const std::shared_ptr< ApduResponseApi > apduResponse) override