Keyple Service C++ Library - 3.3.5
Component of the Keyple C++ middleware
InternalDto.cpp
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ *
3 * *
4 * See the NOTICE file(s) distributed with this work for additional *
5 * information regarding copyright ownership. *
6 * *
7 * This program and the accompanying materials are made available under the *
8 * terms of the Eclipse Public License 2.0 which is available at *
9 * http://www.eclipse.org/legal/epl-2.0 *
10 * *
11 * SPDX-License-Identifier: EPL-2.0 *
12 ******************************************************************************/
13
14#include "keyple/core/service/InternalDto.hpp"
15
16#include <memory>
17#include <string>
18#include <utility>
19#include <vector>
20
21#include "keyple/core/util/cpp/exception/UnsupportedOperationException.hpp"
22
23namespace keyple {
24namespace core {
25namespace service {
26
27using keyple::core::util::cpp::exception::UnsupportedOperationException;
28
29/* CARD SELECTION ADAPTER
30 * ----------------------------------------------------------------------- */
31
32InternalDto::CardSelectionAdapter::CardSelectionAdapter(
33 const std::shared_ptr<CardSelectionExtensionSpi> src)
34: mCardSelectionRequest(
35 std::unique_ptr<CardSelectionRequest>(
36 new CardSelectionRequest(src->getCardSelectionRequest())))
37{
38}
39
40std::unique_ptr<CardSelectionRequestSpi>
41InternalDto::CardSelectionAdapter::getCardSelectionRequest()
42{
43 return std::move(mCardSelectionRequest);
44}
45
46std::shared_ptr<SmartCardSpi>
47InternalDto::CardSelectionAdapter::parse(
48 const std::shared_ptr<
49 CardSelectionResponseApi>& /* cardSelectionResponseApi */)
50{
51 throw UnsupportedOperationException(
52 "Method not supported for internal DTO");
53}
54
55/* CARD SELECTION REQUEST
56 * ----------------------------------------------------------------------- */
57
58InternalDto::CardSelectionRequest::CardSelectionRequest(
59 const std::shared_ptr<CardSelectionRequestSpi> src)
60{
61 if (src->getCardRequest() != nullptr) {
62 mCardRequest = std::make_shared<CardRequest>(src->getCardRequest());
63 }
64
65 mSuccessfulSelectionStatusWords = src->getSuccessfulSelectionStatusWords();
66}
67
68const std::vector<int>&
69InternalDto::CardSelectionRequest::getSuccessfulSelectionStatusWords() const
70{
71 return mSuccessfulSelectionStatusWords;
72}
73
74const std::shared_ptr<CardRequestSpi>
75InternalDto::CardSelectionRequest::getCardRequest() const
76{
77 return mCardRequest;
78}
79
80/* CARD REQUEST
81 * ----------------------------------------------------------------------- */
82
83InternalDto::CardRequest::CardRequest(const std::shared_ptr<CardRequestSpi> src)
84{
85 for (const auto& apduRequestSpi : src->getApduRequests()) {
86 mApduRequests.push_back(std::make_shared<ApduRequest>(apduRequestSpi));
87 }
88
89 mStopOnUnsuccessfulStatusWord = src->stopOnUnsuccessfulStatusWord();
90}
91
92const std::vector<std::shared_ptr<ApduRequestSpi>>&
93InternalDto::CardRequest::getApduRequests() const
94{
95 return mApduRequests;
96}
97
98bool
99InternalDto::CardRequest::stopOnUnsuccessfulStatusWord() const
100{
101 return mStopOnUnsuccessfulStatusWord;
102}
103
104/* APDU REQUEST
105 * ----------------------------------------------------------------------- */
106
107InternalDto::ApduRequest::ApduRequest(const std::shared_ptr<ApduRequestSpi> src)
108: mApdu(src->getApdu())
109, mSuccessfulStatusWords(src->getSuccessfulStatusWords())
110, mInfo(src->getInfo())
111{
112}
113
114const std::vector<uint8_t>&
115InternalDto::ApduRequest::getApdu() const
116{
117 return mApdu;
118}
119
120void
121InternalDto::ApduRequest::setApdu(const std::vector<uint8_t>& apdu)
122{
123 mApdu = apdu;
124}
125
126const std::vector<int>&
127InternalDto::ApduRequest::getSuccessfulStatusWords() const
128{
129 return mSuccessfulStatusWords;
130}
131
132const std::string&
133InternalDto::ApduRequest::getInfo() const
134{
135 return mInfo;
136}
137
138} /* namespace service */
139} /* namespace core */
140} /* namespace keyple */