24#include "ByteArrayUtil.h"
25#include "IllegalStateException.h"
31using namespace keyple::core::util;
32using namespace keyple::core::util::cpp;
34const int CmdCardGetDataEfList::DESCRIPTORS_OFFSET = 2;
35const int CmdCardGetDataEfList::DESCRIPTOR_DATA_OFFSET = 2;
36const int CmdCardGetDataEfList::DESCRIPTOR_DATA_SFI_OFFSET = 2;
37const int CmdCardGetDataEfList::DESCRIPTOR_TAG_LENGTH = 8;
38const int CmdCardGetDataEfList::DESCRIPTOR_DATA_LENGTH = 6;
40const std::map<const int, const std::shared_ptr<StatusProperties>>
41 CmdCardGetDataEfList::STATUS_TABLE = initStatusTable();
46 buildCommand(calypsoCardClass);
52 buildCommand(calypsoCard->getCardClass());
55void CmdCardGetDataEfList::buildCommand(
const CalypsoCardClass calypsoCardClass)
59 std::make_shared<ApduRequestAdapter>(
60 ApduUtil::build(calypsoCardClass.
getValue(),
71 const std::map<const std::shared_ptr<FileHeaderAdapter>,
const uint8_t> fileHeaderToSfiMap =
74 for (
const auto& entry : fileHeaderToSfiMap) {
85const std::map<const int, const std::shared_ptr<StatusProperties>>
86 CmdCardGetDataEfList::initStatusTable()
88 std::map<const int, const std::shared_ptr<StatusProperties>> m =
92 std::make_shared<StatusProperties>(
"Data object not found (optional mode not " \
96 std::make_shared<StatusProperties>(
"P1 or P2 value not supported.",
97 typeid(CardDataAccessException))});
102const std::map<const int, const std::shared_ptr<StatusProperties>>&
108const std::map<const std::shared_ptr<FileHeaderAdapter>,
const uint8_t>
112 std::map<const std::shared_ptr<FileHeaderAdapter>,
const uint8_t> fileHeaderToSfiMap;
113 const int nbFiles = rawList[1] / DESCRIPTOR_TAG_LENGTH;
115 for (
int i = 0; i < nbFiles; i++) {
116 fileHeaderToSfiMap.insert({
120 DESCRIPTORS_OFFSET + (i * DESCRIPTOR_TAG_LENGTH) + DESCRIPTOR_DATA_OFFSET,
122 + (i * DESCRIPTOR_TAG_LENGTH)
123 + DESCRIPTOR_DATA_OFFSET
124 + DESCRIPTOR_DATA_LENGTH)),
127 + (i * DESCRIPTOR_TAG_LENGTH)
128 + DESCRIPTOR_DATA_OFFSET
129 + DESCRIPTOR_DATA_SFI_OFFSET]});
132 return fileHeaderToSfiMap;
135const std::shared_ptr<FileHeaderAdapter> CmdCardGetDataEfList::createFileHeader(
136 const std::vector<uint8_t>& efDescriptorByteArray)
const
138 ElementaryFile::Type efType;
142 efType = ElementaryFile::Type::LINEAR;
146 efType = ElementaryFile::Type::CYCLIC;
150 efType = ElementaryFile::Type::COUNTERS;
154 efType = ElementaryFile::Type::BINARY;
158 efType = ElementaryFile::Type::SIMULATED_COUNTERS;
162 throw IllegalStateException(
"Unexpected EF type");
166 ->lid(ByteArrayUtil::extractShort(efDescriptorByteArray, 0))
168 .recordSize(efDescriptorByteArray[4])
169 .recordsNumber(efDescriptorByteArray[5])
static const std::map< const int, const std::shared_ptr< StatusProperties > > STATUS_TABLE
virtual const std::shared_ptr< ApduResponseApi > getApduResponse() const 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 GET_DATA
uint8_t getInstructionByte() const
static const int EF_TYPE_CYCLIC
static const int EF_TYPE_LINEAR
static const int EF_TYPE_SIMULATED_COUNTERS
static const int EF_TYPE_BINARY
static const int EF_TYPE_COUNTERS
bool isSessionBufferUsed() const override
CmdCardGetDataEfList(const CalypsoCardClass calypsoCardClass)
void parseApduResponse(const std::shared_ptr< ApduResponseApi > apduResponse) override
const std::map< const int, const std::shared_ptr< StatusProperties > > & getStatusTable() const override
const std::map< const std::shared_ptr< FileHeaderAdapter >, const uint8_t > getEfHeaders() const