22#include "CalypsoCard.h"
23#include "DirectoryHeader.h"
24#include "ElementaryFile.h"
27#include "ApduResponseApi.h"
28#include "SmartCardSpi.h"
36#include "LoggerFactory.h"
43using namespace calypsonet::terminal::calypso::card;
44using namespace calypsonet::terminal::card;
45using namespace calypsonet::terminal::card::spi;
46using namespace keyple::core::util::cpp;
73 void initializeWithPowerOnData(
const std::string& powerOnData);
83 void initializeWithFci(
const std::shared_ptr<ApduResponseApi> selectApplicationResponse);
97 bool isHce()
const override;
104 const std::vector<uint8_t>& getDfName()
const override;
117 const std::vector<uint8_t>& getCalypsoSerialNumberFull()
const;
124 const std::vector<uint8_t> getApplicationSerialNumber()
const override;
131 const std::vector<uint8_t>& getStartupInfoRawData()
const override;
140 uint8_t getPayloadCapacity()
const;
152 bool isModificationsCounterInBytes()
const;
164 int getModificationsCounter()
const;
171 uint8_t getPlatform()
const override;
178 uint8_t getApplicationType()
const override;
185 bool isExtendedModeSupported()
const override;
192 bool isRatificationOnDeselectSupported()
const override;
199 bool isSvFeatureAvailable()
const override;
206 bool isPinFeatureAvailable()
const override;
213 bool isPkiModeSupported()
const override;
220 uint8_t getApplicationSubtype()
const override;
227 uint8_t getSoftwareIssuer()
const override;
234 uint8_t getSoftwareVersion()
const override;
241 uint8_t getSoftwareRevision()
const override;
248 uint8_t getSessionModification()
const override;
255 const std::vector<uint8_t> getTraceabilityInformation()
const override;
262 bool isDfInvalidated()
const override;
269 bool isDfRatified()
const override;
284 void setSvData(
const uint8_t svKvc,
285 const std::vector<uint8_t>& svGetHeader,
286 const std::vector<uint8_t>& svGetData,
288 const int svLastTNum,
289 const std::shared_ptr<SvLoadLogRecord> svLoadLogRecord,
290 const std::shared_ptr<SvDebitLogRecord> svDebitLogRecord);
297 int getSvBalance()
const override;
304 int getSvLastTNum()
const override;
311 const std::shared_ptr<SvLoadLogRecord> getSvLoadLogRecord()
override;
318 const std::shared_ptr<SvDebitLogRecord> getSvDebitLogLastRecord()
override;
325 const std::vector<std::shared_ptr<SvDebitLogRecord>> getSvDebitLogAllRecords()
const override;
334 void setDfRatified(
const bool dfRatified);
350 const std::shared_ptr<DirectoryHeader> getDirectoryHeader()
const override;
361 CalypsoCard& setDirectoryHeader(
const std::shared_ptr<DirectoryHeader> directoryHeader);
368 const std::shared_ptr<ElementaryFile> getFileBySfi(
const uint8_t sfi)
const override;
375 const std::shared_ptr<ElementaryFile> getFileByLid(
const uint16_t lid)
const override;
383 const std::map<const uint8_t, const std::shared_ptr<ElementaryFile>> getAllFiles()
const
391 const std::vector<std::shared_ptr<ElementaryFile>>& getFiles()
const override;
398 bool isPinBlocked()
const override;
405 int getPinAttemptRemaining()
const override;
416 void setPinAttemptRemaining(
const int pinAttemptCounter);
427 void setFileHeader(
const uint8_t sfi,
const std::shared_ptr<FileHeaderAdapter> header);
440 void setContent(
const uint8_t sfi,
441 const uint8_t numRecord,
442 const std::vector<uint8_t>& content);
454 void setCounter(
const uint8_t sfi,
const uint8_t numCounter,
const std::vector<uint8_t>& content);
470 void setContent(
const uint8_t sfi,
471 const uint8_t numRecord,
472 const std::vector<uint8_t>& content,
473 const uint8_t offset);
488 void fillContent(
const uint8_t sfi,
489 const uint8_t numRecord,
490 const std::vector<uint8_t>& content,
491 const uint8_t offset);
505 void addCyclicContent(
const uint8_t sfi,
const std::vector<uint8_t> content);
531 const std::string& getPowerOnData()
const override;
538 const std::vector<uint8_t> getSelectApplicationResponse()
const override;
547 void setCardChallenge(
const std::vector<uint8_t>& cardChallenge);
557 void setTraceabilityInformation(
const std::vector<uint8_t>& traceabilityInformation);
566 void setSvOperationSignature(
const std::vector<uint8_t>& svOperationSignature);
576 const std::vector<uint8_t>& getCardChallenge()
const;
585 uint8_t getSvKvc()
const;
595 const std::vector<uint8_t>& getSvGetHeader()
const;
605 const std::vector<uint8_t>& getSvGetData()
const;
614 const std::vector<uint8_t>& getSvOperationSignature()
const;
626 std::ostream& os,
const std::shared_ptr<CalypsoCardAdapter> cca);
632 const std::unique_ptr<Logger> mLogger = LoggerFactory::getLogger(
typeid(
CalypsoCardAdapter));
637 static const std::string PATTERN_1_BYTE_HEX;
638 static const std::string PATTERN_2_BYTES_HEX;
643 static const int CARD_REV1_ATR_LENGTH;
644 static const int REV1_CARD_DEFAULT_WRITE_OPERATIONS_NUMBER_SUPPORTED_PER_SESSION;
645 static const int REV2_CARD_DEFAULT_WRITE_OPERATIONS_NUMBER_SUPPORTED_PER_SESSION;
646 static const int SI_BUFFER_SIZE_INDICATOR;
647 static const int SI_PLATFORM;
648 static const int SI_APPLICATION_TYPE;
649 static const int SI_APPLICATION_SUBTYPE;
650 static const int SI_SOFTWARE_ISSUER;
651 static const int SI_SOFTWARE_VERSION;
652 static const int SI_SOFTWARE_REVISION;
653 static const uint8_t PAY_LOAD_CAPACITY;
658 static const uint8_t APP_TYPE_WITH_CALYPSO_PIN;
659 static const uint8_t APP_TYPE_WITH_CALYPSO_SV;
660 static const uint8_t APP_TYPE_RATIFICATION_COMMAND_REQUIRED;
661 static const uint8_t APP_TYPE_CALYPSO_REV_32_MODE;
662 static const uint8_t APP_TYPE_WITH_PUBLIC_AUTHENTICATION;
667 static const std::vector<int> BUFFER_SIZE_INDICATOR_TO_BUFFER_SIZE;
672 std::shared_ptr<ApduResponseApi> mSelectApplicationResponse;
677 std::string mPowerOnData;
682 bool mIsExtendedModeSupported;
687 bool mIsRatificationOnDeselectSupported;
692 bool mIsSvFeatureAvailable;
697 bool mIsPinFeatureAvailable;
702 bool mIsPkiModeSupported;
707 bool mIsDfInvalidated;
717 std::vector<uint8_t> mCalypsoSerialNumber;
722 std::vector<uint8_t> mStartupInfo;
732 std::vector<uint8_t> mDfName;
737 int mModificationsCounterMax;
742 bool mIsModificationCounterInBytes;
747 std::shared_ptr<DirectoryHeader> mDirectoryHeader;
752 std::vector<std::shared_ptr<ElementaryFile>> mFiles;
757 std::vector<std::shared_ptr<ElementaryFile>> mFilesBackup;
767 uint16_t mCurrentLid;
772 std::shared_ptr<bool> mIsDfRatified;
777 std::shared_ptr<int> mPinAttemptCounter;
782 std::shared_ptr<int> mSvBalance;
792 std::shared_ptr<SvLoadLogRecord> mSvLoadLogRecord;
797 std::shared_ptr<SvDebitLogRecord> mSvDebitLogRecord;
807 std::vector<uint8_t> mCardChallenge;
812 std::vector<uint8_t> mTraceabilityInformation;
822 std::vector<uint8_t> mSvGetHeader;
827 std::vector<uint8_t> mSvGetData;
832 std::vector<uint8_t> mSvOperationSignature;
837 uint8_t mApplicationSubType;
842 uint8_t mApplicationType;
847 uint8_t mSessionModification;
863 void updateCurrentSfi(
const uint8_t sfi);
871 void updateCurrentLid(
const uint16_t lid);
882 const std::shared_ptr<ElementaryFileAdapter> getOrCreateFile();
891 static void copyFiles(
const std::vector<std::shared_ptr<ElementaryFile>>& src,
892 std::vector<std::shared_ptr<ElementaryFile>>& dest);
#define KEYPLECARDCALYPSO_API
CalypsoSam::ProductType ProductType
std::ostream & operator<<(std::ostream &os, const std::shared_ptr< ApduRequestAdapter > ara)