eID middleware | ![]() |
00001 /* **************************************************************************** 00002 * eID Middleware Project. 00003 * Copyright (C) 2008-2009 FedICT. 00004 * 00005 * This is free software; you can redistribute it and/or modify it 00006 * under the terms of the GNU Lesser General Public License version 00007 * 3.0 as published by the Free Software Foundation. 00008 * 00009 * This software is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Lesser General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public 00015 * License along with this software; if not, see 00016 * http://www.gnu.org/licenses/. 00017 **************************************************************************** */ 00018 #pragma once 00019 00020 #ifndef __PTEIDLIB_H__ 00021 #define __PTEIDLIB_H__ 00022 00023 #include <string> 00024 #include <vector> 00025 #include <map> 00026 #include "eidlibdefines.h" 00027 00028 namespace eIDMW 00029 { 00030 00031 struct SDK_Context; 00032 00033 class CMutex; 00034 class PTEID_Exception; 00035 00036 /******************************************************************************//** 00037 * Base class for the object of PTEID SDK (Can not be instantiated). 00038 *********************************************************************************/ 00039 class PTEID_Object 00040 { 00041 public: 00042 PTEIDSDK_API virtual ~PTEID_Object()=0; /**< Destructor */ 00043 00044 00045 NOEXPORT_PTEIDSDK void Init(const SDK_Context *context,void *impl); /**< For internal use : Initialize pimpl */ 00046 00047 /** 00048 * Release the objects instantiated within this PTEID_Object. 00049 * Automatically call in the destructor. 00050 */ 00051 NOEXPORT_PTEIDSDK void Release(); 00052 00053 protected: 00054 PTEID_Object(const SDK_Context *context,void *impl); /**< For internal use : Constructor */ 00055 void addObject(PTEID_Object *impl); /**< For internal use : Add linked object */ 00056 void backupObject(unsigned long idx); /**< For internal use : Backup linked object */ 00057 PTEID_Object *getObject(unsigned long idx); /**< For internal use : Return an object by its index */ 00058 PTEID_Object *getObject(void *impl); /**< For internal use : Return an object by its impl */ 00059 void delObject(unsigned long idx); /**< For internal use : Delete an object by its index */ 00060 void delObject(void *impl); /**< For internal use : Delete an object by its impl */ 00061 00062 void checkContextStillOk() const; /**< For internal use : check if the Context is still correct (the card hasn't changed) */ 00063 00064 PTEID_Object(const PTEID_Object& obj); /**< Copy not allowed - not implemented */ 00065 PTEID_Object& operator= (const PTEID_Object& obj); /**< Copy not allowed - not implemented */ 00066 00067 bool m_delimpl; /**< For internal use : m_impl object must be deleted */ 00068 void *m_impl; /**< For internal use : pimpl pointer */ 00069 unsigned long m_ulIndexExtAdd; /**< For internal use : extended add object */ 00070 std::map<unsigned long,PTEID_Object *> m_objects; /**< For internal use : Map of object instantiated within this PTEID_Object */ 00071 00072 SDK_Context *m_context; /**< For internal use : context structure */ 00073 00074 //CMutex *m_mutex; 00075 }; 00076 00077 class PTEID_Card; 00078 00079 class CByteArray; 00080 00081 /******************************************************************************//** 00082 * This class is used to receive/pass bytes array from/to different method in the SDK. 00083 *********************************************************************************/ 00084 class PTEID_ByteArray : public PTEID_Object 00085 { 00086 public: 00087 PTEIDSDK_API PTEID_ByteArray(); /**< Default constructor */ 00088 PTEIDSDK_API PTEID_ByteArray(const PTEID_ByteArray &bytearray); /**< Copy constructor */ 00089 00090 /** 00091 * Constructor - initialize a byte array with an array of unsigned char. 00092 * 00093 * @param pucData is the byte array 00094 * @param ulSize is the size of the array 00095 */ 00096 PTEIDSDK_API PTEID_ByteArray(const unsigned char * pucData, unsigned long ulSize); 00097 00098 PTEIDSDK_API virtual ~PTEID_ByteArray(); /**< Destructor */ 00099 00100 /** 00101 * Append data to the byte array. 00102 * 00103 * @param pucData is the byte array 00104 * @param ulSize is the size of the array 00105 */ 00106 PTEIDSDK_API void Append(const unsigned char * pucData, unsigned long ulSize); 00107 00108 /** 00109 * Append data to the byte array. 00110 */ 00111 PTEIDSDK_API void Append(const PTEID_ByteArray &data); 00112 00113 /** 00114 * Remove the data from the byte array. 00115 */ 00116 PTEIDSDK_API void Clear(); 00117 00118 /** 00119 * Return true if the content of data is the same as this. 00120 */ 00121 PTEIDSDK_API bool Equals(const PTEID_ByteArray &data) const; 00122 00123 /** 00124 * Return the number of bytes in the array. 00125 */ 00126 PTEIDSDK_API unsigned long Size() const; 00127 00128 /** 00129 * Return the array of bytes in the object. 00130 * If Size() == 0, then NULL is returned. 00131 */ 00132 PTEIDSDK_API const unsigned char *GetBytes() const; 00133 00134 /** 00135 * Writing the binary content to a file. 00136 */ 00137 PTEIDSDK_API bool writeToFile(const char * csFilePath); 00138 00139 /** 00140 * Copy content of bytearray. 00141 */ 00142 PTEIDSDK_API PTEID_ByteArray &operator=(const PTEID_ByteArray &bytearray); 00143 00144 NOEXPORT_PTEIDSDK PTEID_ByteArray(const SDK_Context *context,const CByteArray &impl); /**< For internal use : construct from lower level object*/ 00145 NOEXPORT_PTEIDSDK PTEID_ByteArray &operator=(const CByteArray &bytearray); /**< For internal use : copy from lower level object*/ 00146 }; 00147 00148 /******************************************************************************//** 00149 * These structure are used for compatibility with old C sdk. 00150 *********************************************************************************/ 00151 struct PTEID_RawData_Eid 00152 { 00153 PTEID_ByteArray idData; 00154 PTEID_ByteArray idSigData; 00155 PTEID_ByteArray addrData; 00156 PTEID_ByteArray addrSigData; 00157 PTEID_ByteArray pictureData; 00158 PTEID_ByteArray cardData; 00159 PTEID_ByteArray tokenInfo; 00160 PTEID_ByteArray certRN; 00161 PTEID_ByteArray challenge; 00162 PTEID_ByteArray response; 00163 }; 00164 00165 struct PTEID_RawData_Sis 00166 { 00167 PTEID_ByteArray idData; 00168 }; 00169 00170 /** 00171 * This define give an easy access to singleton (no declaration/instantiation is needed). 00172 * 00173 * Usage : ReaderSet.SomeMethod(). 00174 */ 00175 #define ReaderSet PTEID_ReaderSet::instance() 00176 00177 /** 00178 * Init the SDK (Optional). 00179 */ 00180 #define PTEID_InitSDK() PTEID_ReaderSet::initSDK() 00181 00182 /** 00183 * Release the SDK. 00184 * THIS MUST BE CALLED WHEN THE SDK IS NOT NEEDED ANYMORE AND BEFORE THE APPLICATION IS CALLED. 00185 * IF NOT RELEASE PROPERLY, AN EXCEPTION PTEID_ExReleaseNeeded IS THROWN. 00186 */ 00187 #define PTEID_ReleaseSDK() PTEID_ReaderSet::releaseSDK() 00188 00189 class PTEID_ReaderContext; 00190 class APL_ReaderContext; 00191 00192 /******************************************************************************//** 00193 * This is a singleton class that is the starting point to get all other objects. 00194 * You get an instance from the static instance() method (or using the define ReaderSet). 00195 * Then you get a READER (PTEID_ReaderContext) 00196 * -> from this reader, you a CARD (PTEID_Card or derived class) 00197 * -> from this card, you get DOCUMENT (PTEID_XMLDoc or derived class) 00198 * -> ... 00199 *********************************************************************************/ 00200 class PTEID_ReaderSet : public PTEID_Object 00201 { 00202 public: 00203 PTEIDSDK_API static PTEID_ReaderSet &instance(); /**< Return the singleton object (create it at first use) */ 00204 00205 /** 00206 * Init the SDK (Optional). 00207 * @param bManageTestCard If true the applayer must ask if test cards are allowed (used for compatibility with old C API). 00208 * @param bManageTestCard If false other applications (ex. gui) take that into their scope 00209 */ 00210 PTEIDSDK_API static void initSDK(bool bManageTestCard=false); 00211 PTEIDSDK_API static void releaseSDK(); /**< Release the SDK */ 00212 00213 PTEIDSDK_API virtual ~PTEID_ReaderSet(); /**< Destructor */ 00214 00215 /** 00216 * Release the readers (Useful if readers had changed). 00217 * 00218 * @param bAllReference If true all the invalid reference/pointer are destroyed. 00219 * @param bAllReference PUT THIS PARAMETER TO TRUE IS THREAD UNSAFE. 00220 * @param bAllReference You have to be sure that you will not use any old reference/pointer after this release 00221 */ 00222 PTEIDSDK_API void releaseReaders(bool bAllReference=false); 00223 00224 /** 00225 * Return true if readers has been added or removed 00226 */ 00227 PTEIDSDK_API bool isReadersChanged() const; 00228 00229 /** 00230 * Get the list of the reader. 00231 * Return an array of const char * 00232 * The last pointer is NULL 00233 * Usage : const char * const *ppList=PTEID_ReaderSet::readerList(); 00234 * for(const char * const *ppName=ppList;*ppName!=NULL;ppName++) {...} 00235 * 00236 * @param bForceRefresh force the reconnection to the lower layer to see if reader list have changed 00237 */ 00238 PTEIDSDK_API const char * const *readerList(bool bForceRefresh=false); 00239 00240 /** 00241 * Return the first readercontext with a card. 00242 * If no card is present, return the firs reader. 00243 * If no reader exist, throw an exception PTEID_ExNoReader. 00244 */ 00245 PTEIDSDK_API PTEID_ReaderContext &getReader(); 00246 00247 /** 00248 * Get the reader by its name. 00249 */ 00250 PTEIDSDK_API PTEID_ReaderContext &getReaderByName(const char *readerName); 00251 00252 /** 00253 * Return the number of card readers connected to the computer. 00254 * 00255 * @param bForceRefresh force the reconnection to the lower layer to see if reader list have changed 00256 */ 00257 PTEIDSDK_API unsigned long readerCount(bool bForceRefresh=false); 00258 00259 /** 00260 * Get the name of the reader by its Index. 00261 * Throw PTEID_ExParamRange exception if the index is out of range. 00262 */ 00263 PTEIDSDK_API const char *getReaderName(unsigned long ulIndex); 00264 00265 /** 00266 * Get the reader by its Index. 00267 * Throw PTEID_ExParamRange exception if the index is out of range. 00268 */ 00269 PTEIDSDK_API PTEID_ReaderContext &getReaderByNum(unsigned long ulIndex); 00270 00271 /** 00272 * Return the reader containing the card with this SN. 00273 * If no card with this SN is found, throw an exception PTEID_ExParamRange. 00274 */ 00275 PTEIDSDK_API PTEID_ReaderContext &getReaderByCardSerialNumber(const char *cardSerialNumber); 00276 00277 /** 00278 * Flush the cached files. 00279 * Return if any files were flushed (T/F). 00280 */; 00281 PTEIDSDK_API bool flushCache(); /**< Flush the cache */ 00282 00283 NOEXPORT_PTEIDSDK PTEID_ReaderContext &getReader(APL_ReaderContext *pAplReader); /**< For internal use - Not exported*/ 00284 00285 private: 00286 PTEID_ReaderSet(); /**< For internal use : Constructor */ 00287 00288 PTEID_ReaderSet(const PTEID_ReaderSet& reader); /**< Copy not allowed - not implemented */ 00289 PTEID_ReaderSet& operator= (const PTEID_ReaderSet& reader); /**< Copy not allowed - not implemented */ 00290 00291 }; 00292 00293 class PTEID_Card; 00294 class PTEID_EIDCard; 00295 class PTEID_KidsCard; 00296 class PTEID_ForeignerCard; 00297 class PTEID_SISCard; 00298 00299 /******************************************************************************//** 00300 * This class represent a reader. 00301 * You get reader object from the ReaderSet 00302 * either by its index (getReaderByNum) or by its name (getReaderByName). 00303 * Once you have a reader object, you can check if a card is present (isCardPresent). 00304 * Then you can ask which type of card is in the reader with getCardType() 00305 * and then get a card object using one of this method : 00306 * getCard, getEIDCard, getKidsCard, getForeignerCard or getSISCard. 00307 *********************************************************************************/ 00308 class PTEID_ReaderContext : public PTEID_Object 00309 { 00310 public: 00311 /** 00312 * Construct using a fileType and fileName. 00313 * No physical reader are connected (m_reader=NULL) 00314 */ 00315 PTEIDSDK_API PTEID_ReaderContext(PTEID_FileType fileType,const char *fileName); 00316 00317 /** 00318 * Construct using a fileType and its content (for compatibility with SetRawFile). 00319 * No physical reader are connected (m_reader=NULL) 00320 */ 00321 PTEIDSDK_API PTEID_ReaderContext(PTEID_FileType fileType,const PTEID_ByteArray &data); 00322 00323 /** 00324 * Construct using Raw data for Eid. 00325 * No physical reader are connected (m_reader=NULL) 00326 */ 00327 PTEIDSDK_API PTEID_ReaderContext(const PTEID_RawData_Eid &data); 00328 00329 /** 00330 * Construct using Raw data for Sis. 00331 * No physical reader are connected (m_reader=NULL) 00332 */ 00333 PTEIDSDK_API PTEID_ReaderContext(const PTEID_RawData_Sis &data); 00334 00335 PTEIDSDK_API virtual ~PTEID_ReaderContext(); /**< Destructor */ 00336 00337 /** 00338 * Return the name of the reader. 00339 */ 00340 PTEIDSDK_API const char *getName(); 00341 00342 /** 00343 * Return true if a card is present and false otherwise. 00344 */ 00345 PTEIDSDK_API bool isCardPresent(); 00346 00347 /** 00348 * Release the card. 00349 * 00350 * @param bAllReference If true all the invalid reference/pointer are destroyed. 00351 * @param bAllReference PUT THIS PARAMETER TO TRUE IS THREAD UNSAFE. 00352 * @param bAllReference You have to be sure that you will not use any old reference/pointer after this release 00353 */ 00354 PTEIDSDK_API void releaseCard(bool bAllReference=false); 00355 00356 /** 00357 * Return true if a card has changed since the last called (with the same ulOldId parameter). 00358 */ 00359 PTEIDSDK_API bool isCardChanged(unsigned long &ulOldId); 00360 00361 /** 00362 * Return the type of the card in the reader. 00363 * 00364 * Throw PTEID_ExNoCardPresent exception if no card is present. 00365 */ 00366 PTEIDSDK_API PTEID_CardType getCardType(); 00367 00368 /** 00369 * Get the card in the reader. 00370 * Instantiation is made regarding the type of the card 00371 * (PTEID_EIDCard, PTEID_KidsCard, PTEID_ForeignerCard or PTEID_SISCard). 00372 * 00373 * If no card is present in the reader, exception PTEID_ExNoCardPresent is thrown. 00374 * If the card type is not supported, exception PTEID_ExCardTypeUnknown is thrown. 00375 */ 00376 PTEIDSDK_API PTEID_Card &getCard(); 00377 00378 /** 00379 * Get the EIDcard in the reader. 00380 * Instantiation is made regarding the type of the card 00381 * (PTEID_EIDCard, PTEID_KidsCard, PTEID_ForeignerCard). 00382 * 00383 * If no card is present in the reader, exception PTEID_ExNoCardPresent is thrown. 00384 * If the card is not an EIDcard, exception PTEID_ExCardBadType is thrown. 00385 */ 00386 PTEIDSDK_API PTEID_EIDCard &getEIDCard(); 00387 00388 /** 00389 * Get the KidsCard in the reader. 00390 * 00391 * If no card is present in the reader, exception PTEID_ExNoCardPresent is thrown. 00392 * If the card is not a KidsCard, exception PTEID_ExCardBadType is thrown. 00393 */ 00394 PTEIDSDK_API PTEID_KidsCard &getKidsCard(); 00395 00396 /** 00397 * Get the ForeignerCard in the reader. 00398 * 00399 * If no card is present in the reader, exception PTEID_ExNoCardPresent is thrown 00400 * If the card is not a ForeignerCard, exception PTEID_ExCardBadType is thrown. 00401 */ 00402 PTEIDSDK_API PTEID_ForeignerCard &getForeignerCard(); 00403 00404 /** 00405 * Get the SISCard in the reader. 00406 * 00407 * If no card is present in the reader, exception PTEID_ExNoCardPresent is thrown. 00408 * If the card is not a SISCard, exception PTEID_ExCardBadType is thrown. 00409 */ 00410 PTEIDSDK_API PTEID_SISCard &getSISCard(); 00411 00412 /** 00413 * Specify a callback function to be called each time a 00414 * card is inserted/remove in/from this reader. 00415 * 00416 * @return A handle can be used to stop the callbacks when they are no longer needed. 00417 */ 00418 PTEIDSDK_API unsigned long SetEventCallback(void (* callback)(long lRet, unsigned long ulState, void *pvRef), void *pvRef); 00419 00420 /** 00421 * To tell that the callbacks are not longer needed. 00422 * @param ulHandle is the handle return by SetEventCallback 00423 */ 00424 PTEIDSDK_API void StopEventCallback(unsigned long ulHandle); 00425 00426 PTEIDSDK_API void BeginTransaction(); /**< Begin a transaction with the reader */ 00427 PTEIDSDK_API void EndTransaction(); /**< End the transaction */ 00428 00429 PTEIDSDK_API bool isVirtualReader(); /**< Return true if this is a virtual reader (create from a file) */ 00430 00431 private: 00432 PTEID_ReaderContext(const PTEID_ReaderContext& reader); /**< Copy not allowed - not implemented */ 00433 PTEID_ReaderContext& operator= (const PTEID_ReaderContext& reader); /**< Copy not allowed - not implemented */ 00434 00435 PTEID_ReaderContext(const SDK_Context *context,APL_ReaderContext *impl); /**< For internal use : Constructor */ 00436 00437 unsigned long m_cardid; 00438 //CMutex *m_mutex; 00439 00440 friend PTEID_ReaderContext &PTEID_ReaderSet::getReader(APL_ReaderContext *pAplReader); /**< For internal use : This method must access protected constructor */ 00441 }; 00442 00443 class PTEID_XMLDoc; 00444 class APL_Card; 00445 00446 /******************************************************************************//** 00447 * Abstract base class for all the card type supported. 00448 * The PTEID_ReaderContext::getCard() method will return such an object. 00449 *********************************************************************************/ 00450 class PTEID_Card : public PTEID_Object 00451 { 00452 public: 00453 PTEIDSDK_API virtual ~PTEID_Card()=0; /**< Destructor */ 00454 00455 /** 00456 * Return the type of the card 00457 */ 00458 PTEIDSDK_API virtual PTEID_CardType getType(); 00459 00460 /** 00461 * Return a document from the card. 00462 * Throw PTEID_ExDocTypeUnknown exception if the document doesn't exist for this card. 00463 */ 00464 PTEIDSDK_API virtual PTEID_XMLDoc& getDocument(PTEID_DocumentType type)=0; 00465 00466 /** 00467 * Return a raw data from the card. 00468 * Throw PTEID_ExFileTypeUnknown exception if the document doesn't exist for this card. 00469 */ 00470 PTEIDSDK_API virtual const PTEID_ByteArray& getRawData(PTEID_RawDataType type)=0; 00471 00472 /** 00473 * Send an APDU command to the card and get the result. 00474 * @param cmd is the apdu command 00475 * @return a PTEID_ByteArray containing the result 00476 */ 00477 PTEIDSDK_API virtual PTEID_ByteArray sendAPDU(const PTEID_ByteArray& cmd); 00478 00479 /** 00480 * Read a File from the card. 00481 * @param fileID is the path of the file 00482 * @param ulOffset is the offset to begins the reading 00483 * @param ulMaxLength is the maximum length of bytes to read 00484 * @return A PTEID_ByteArray with the content of the file 00485 */ 00486 PTEIDSDK_API virtual PTEID_ByteArray readFile(const char *fileID, unsigned long ulOffset=0, unsigned long ulMaxLength=0); 00487 00488 /** 00489 * Write a file to the card. 00490 * @param fileID is the path of the file 00491 * @param oData contents the bytes to write 00492 * @param ulOffset is the offset to begins the writing 00493 */ 00494 PTEIDSDK_API virtual bool writeFile(const char *fileID, const PTEID_ByteArray& oData,unsigned long ulOffset=0); 00495 00496 protected: 00497 PTEID_Card(const SDK_Context *context,APL_Card *impl);/**< For internal use : Constructor */ 00498 00499 private: 00500 PTEID_Card(const PTEID_Card& card); /**< Copy not allowed - not implemented */ 00501 PTEID_Card& operator= (const PTEID_Card& card); /**< Copy not allowed - not implemented */ 00502 00503 }; 00504 00505 class APL_MemoryCard; 00506 00507 /******************************************************************************//** 00508 * Abstract base class for Memory card. 00509 *********************************************************************************/ 00510 class PTEID_MemoryCard : public PTEID_Card 00511 { 00512 public: 00513 PTEIDSDK_API virtual ~PTEID_MemoryCard()=0; /**< Destructor */ 00514 00515 protected: 00516 PTEID_MemoryCard(const SDK_Context *context,APL_Card *impl);/**< For internal use : Constructor */ 00517 00518 private: 00519 PTEID_MemoryCard(const PTEID_MemoryCard& card); /**< Copy not allowed - not implemented */ 00520 PTEID_MemoryCard& operator= (const PTEID_MemoryCard& card); /**< Copy not allowed - not implemented */ 00521 }; 00522 00523 class PTEID_Pin; 00524 class PTEID_Pins; 00525 class PTEID_Certificates; 00526 class APL_SmartCard; 00527 00528 /******************************************************************************//** 00529 * Abstract base class for Smart card. 00530 *********************************************************************************/ 00531 class PTEID_SmartCard : public PTEID_Card 00532 { 00533 public: 00534 PTEIDSDK_API virtual ~PTEID_SmartCard()=0; /**< Destructor */ 00535 00536 /** 00537 * Select an application from the card 00538 */ 00539 PTEIDSDK_API void selectApplication(const PTEID_ByteArray &applicationId); 00540 00541 /** 00542 * Send an APDU command to the card and get the result. 00543 * @param cmd is the apdu command 00544 * @param pin is the pin to ask for writing 00545 * @param csPinCode is the code of the pin (it will be asked if needed and not set) 00546 * @return a PTEID_ByteArray containing the result 00547 */ 00548 PTEIDSDK_API virtual PTEID_ByteArray sendAPDU(const PTEID_ByteArray& cmd,PTEID_Pin *pin=NULL,const char *csPinCode=""); 00549 00550 /** 00551 * Read a File from the card. 00552 * 00553 * If no pin is passed and a pin is needed by the card, the pin code will be asked anyway. 00554 * 00555 * @param fileID is the path of the file 00556 * @param in return the file 00557 * @param pin is the pin to ask for reading 00558 * @param csPinCode is the code of the pin (it will be asked if needed and not set) 00559 */ 00560 PTEIDSDK_API virtual long readFile(const char *fileID, PTEID_ByteArray &in,PTEID_Pin *pin=NULL,const char *csPinCode=""); 00561 00562 /** 00563 * Write a file to the card. 00564 * Throw PTEID_ExCmdNotAllowed exception you're not allowed to write the file. 00565 * 00566 * If no pin is passed and a pin is needed by the card, the pin code will be asked anyway. 00567 * 00568 * @param fileID is the path of the file 00569 * @param out contents the bytes to write 00570 * @param pin is the pin to ask for writing 00571 * @param csPinCode is the code of the pin (it will be asked if needed and not set) 00572 */ 00573 PTEIDSDK_API virtual bool writeFile(const char *fileID,const PTEID_ByteArray &out,PTEID_Pin *pin=NULL,const char *csPinCode=""); 00574 00575 /** 00576 * Return the number of pin on the card. 00577 */ 00578 PTEIDSDK_API virtual unsigned long pinCount(); 00579 00580 /** 00581 * Return an object to access all the pins on the card. 00582 */ 00583 PTEIDSDK_API virtual PTEID_Pins& getPins(); 00584 00585 /** 00586 * Return the number of certificate on the card. 00587 */ 00588 PTEIDSDK_API virtual unsigned long certificateCount(); 00589 00590 /** 00591 * Return an object to access all the certificates on the card. 00592 */ 00593 PTEIDSDK_API virtual PTEID_Certificates& getCertificates(); 00594 00595 /** 00596 * Return the challenge. 00597 * 00598 * @param bForceNewInit force a new initialization of the couple challenge/response 00599 */ 00600 PTEIDSDK_API virtual const PTEID_ByteArray &getChallenge(bool bForceNewInit = false); 00601 00602 /** 00603 * Return the response to the challenge. 00604 */ 00605 PTEIDSDK_API virtual const PTEID_ByteArray &getChallengeResponse(); 00606 00607 /** 00608 * Return true if the response of the card to the given challenge is the same as the response expected. 00609 * For virtual card (from file), always return false. 00610 * 00611 * @param challenge is the challenge to check 00612 * @param response is the response expected from the card 00613 */ 00614 PTEIDSDK_API virtual bool verifyChallengeResponse(const PTEID_ByteArray &challenge, const PTEID_ByteArray &response) const; 00615 00616 protected: 00617 PTEID_SmartCard(const SDK_Context *context,APL_Card *impl); /**< For internal use : Constructor */ 00618 00619 private: 00620 PTEID_SmartCard(const PTEID_SmartCard& card); /**< Copy not allowed - not implemented */ 00621 PTEID_SmartCard& operator= (const PTEID_SmartCard& card); /**< Copy not allowed - not implemented */ 00622 }; 00623 00624 class PTEID_SisFullDoc; 00625 class PTEID_SisId; 00626 class APL_SISCard; 00627 00628 /******************************************************************************//** 00629 * This class represents a SIS card. 00630 * To get such an object you have to ask it from the ReaderContext. 00631 *********************************************************************************/ 00632 class PTEID_SISCard : public PTEID_MemoryCard 00633 { 00634 public: 00635 PTEIDSDK_API virtual ~PTEID_SISCard(); /**< Destructor */ 00636 00637 /** 00638 * Return a document from the card. 00639 * Throw PTEID_ExDocTypeUnknown exception if the document doesn't exist for this card. 00640 */ 00641 PTEIDSDK_API virtual PTEID_XMLDoc& getDocument(PTEID_DocumentType type); 00642 00643 /** 00644 * Get the full document. 00645 */ 00646 PTEIDSDK_API PTEID_SisFullDoc& getFullDoc(); 00647 00648 /** 00649 * Get the id document. 00650 */ 00651 PTEIDSDK_API PTEID_SisId& getID(); 00652 00653 /** 00654 * Return a raw data from the card. 00655 * Throw PTEID_ExFileTypeUnknown exception if the document doesn't exist for this card. 00656 */ 00657 PTEIDSDK_API virtual const PTEID_ByteArray& getRawData(PTEID_RawDataType type); 00658 00659 /** 00660 * Get the id RawData. 00661 */ 00662 PTEIDSDK_API const PTEID_ByteArray& getRawData_Id(); 00663 00664 private: 00665 PTEID_SISCard(const PTEID_SISCard& card); /**< Copy not allowed - not implemented */ 00666 PTEID_SISCard& operator= (const PTEID_SISCard& card); /**< Copy not allowed - not implemented */ 00667 00668 PTEID_SISCard(const SDK_Context *context,APL_Card *impl); /**< For internal use : Constructor */ 00669 00670 friend PTEID_Card &PTEID_ReaderContext::getCard(); /**< For internal use : This method must access protected constructor */ 00671 00672 }; 00673 00674 class PTEID_EIdFullDoc; 00675 class PTEID_EId; 00676 class PTEID_Picture; 00677 class PTEID_CardVersionInfo; 00678 class PTEID_Certificate; 00679 class APL_EIDCard; 00680 00681 /******************************************************************************//** 00682 * This class represents a Portugal EID card. 00683 * To get such an object you have to ask it from the ReaderContext. 00684 *********************************************************************************/ 00685 class PTEID_EIDCard : public PTEID_SmartCard 00686 { 00687 public: 00688 PTEIDSDK_API virtual ~PTEID_EIDCard(); /**< Destructor */ 00689 00690 /** 00691 * Return true if the user allow the application. 00692 */ 00693 PTEIDSDK_API static bool isApplicationAllowed(); 00694 00695 /** 00696 * Return true this is a test card. 00697 */ 00698 PTEIDSDK_API virtual bool isTestCard(); 00699 00700 /** 00701 * Return true if test card are allowed. 00702 */ 00703 PTEIDSDK_API virtual bool getAllowTestCard(); 00704 00705 /** 00706 * Set the flag to allow the test cards. 00707 */ 00708 PTEIDSDK_API virtual void setAllowTestCard(bool allow); 00709 00710 /** 00711 * Return the status of the data (RRN certificate validity). 00712 */ 00713 PTEIDSDK_API virtual PTEID_CertifStatus getDataStatus(); 00714 00715 /** 00716 * Return a document from the card. 00717 * Throw PTEID_ExDocTypeUnknown exception if the document doesn't exist for this card. 00718 */ 00719 PTEIDSDK_API virtual PTEID_XMLDoc& getDocument(PTEID_DocumentType type); 00720 00721 PTEIDSDK_API PTEID_EIdFullDoc& getFullDoc(); /**< Get the full document */ 00722 PTEIDSDK_API PTEID_EId& getID(); /**< Get the id document */ 00723 PTEIDSDK_API PTEID_Picture& getPicture(); /**< Get the picture document */ 00724 PTEIDSDK_API PTEID_CardVersionInfo& getVersionInfo(); /**< Get the info document */ 00725 00726 PTEIDSDK_API PTEID_Certificate &getCert(PTEID_CertifType type);/**< Return certificate by type from the card */ 00727 PTEIDSDK_API PTEID_Certificate &getRrn(); /**< Return the RRN certificate from the card */ 00728 PTEIDSDK_API PTEID_Certificate &getRoot(); /**< Return the root certificate from the card */ 00729 PTEIDSDK_API PTEID_Certificate &getCA(); /**< Return the ca certificate from the card */ 00730 PTEIDSDK_API PTEID_Certificate &getSignature(); /**< Return the signature certificate from the card */ 00731 PTEIDSDK_API PTEID_Certificate &getAuthentication(); /**< Return the authentication certificate from the card */ 00732 00733 /** 00734 * Return a raw data from the card. 00735 * Throw PTEID_ExFileTypeUnknown exception if the document doesn't exist for this card. 00736 */ 00737 PTEIDSDK_API virtual const PTEID_ByteArray& getRawData(PTEID_RawDataType type); 00738 00739 PTEIDSDK_API const PTEID_ByteArray& getRawData_Id(); /**< Get the Id RawData */ 00740 PTEIDSDK_API const PTEID_ByteArray& getRawData_IdSig(); /**< Get the IdSig RawData */ 00741 PTEIDSDK_API const PTEID_ByteArray& getRawData_Addr(); /**< Get the Addr RawData */ 00742 PTEIDSDK_API const PTEID_ByteArray& getRawData_AddrSig(); /**< Get the AddrSig RawData */ 00743 PTEIDSDK_API const PTEID_ByteArray& getRawData_Picture(); /**< Get the picture RawData */ 00744 PTEIDSDK_API const PTEID_ByteArray& getRawData_CardInfo(); /**< Get the Card Info RawData */ 00745 PTEIDSDK_API const PTEID_ByteArray& getRawData_TokenInfo(); /**< Get the Token Info RawData */ 00746 PTEIDSDK_API const PTEID_ByteArray& getRawData_CertRRN(); /**< Get the Cert RRN RawData */ 00747 PTEIDSDK_API const PTEID_ByteArray& getRawData_Challenge(); /**< Get the challenge RawData */ 00748 PTEIDSDK_API const PTEID_ByteArray& getRawData_Response(); /**< Get the response RawData */ 00749 00750 protected: 00751 PTEID_EIDCard(const SDK_Context *context,APL_Card *impl); /**< For internal use : Constructor */ 00752 00753 private: 00754 PTEID_EIDCard(const PTEID_EIDCard& card); /**< Copy not allowed - not implemented */ 00755 PTEID_EIDCard& operator= (const PTEID_EIDCard& card); /**< Copy not allowed - not implemented */ 00756 00757 friend PTEID_Card &PTEID_ReaderContext::getCard(); /**< For internal use : This method must access protected constructor */ 00758 }; 00759 00760 class APL_KidsCard; 00761 00762 /******************************************************************************//** 00763 * This class represents a Kids card which is a particular PTEID_EIDCard. 00764 * To get such an object you have to ask it from the ReaderContext. 00765 *********************************************************************************/ 00766 class PTEID_KidsCard : public PTEID_EIDCard 00767 { 00768 public: 00769 PTEIDSDK_API virtual ~PTEID_KidsCard(); /**< Destructor */ 00770 00771 private: 00772 PTEID_KidsCard(const PTEID_KidsCard& card); /**< Copy not allowed - not implemented */ 00773 PTEID_KidsCard& operator= (const PTEID_KidsCard& card); /**< Copy not allowed - not implemented */ 00774 00775 PTEID_KidsCard(const SDK_Context *context,APL_Card *impl);/**< For internal use : Constructor */ 00776 00777 friend PTEID_Card &PTEID_ReaderContext::getCard(); /**< For internal use : This method must access protected constructor */ 00778 }; 00779 00780 class APL_ForeignerCard; 00781 00782 /******************************************************************************//** 00783 * This class represents a Foreigner card which is a particular PTEID_EIDCard. 00784 * To get such an object you have to ask it from the ReaderContext. 00785 *********************************************************************************/ 00786 class PTEID_ForeignerCard : public PTEID_EIDCard 00787 { 00788 public: 00789 PTEIDSDK_API virtual ~PTEID_ForeignerCard(); /**< Destructor */ 00790 00791 private: 00792 PTEID_ForeignerCard(const PTEID_ForeignerCard& card); /**< Copy not allowed - not implemented */ 00793 PTEID_ForeignerCard& operator= (const PTEID_ForeignerCard& card); /**< Copy not allowed - not implemented */ 00794 00795 PTEID_ForeignerCard(const SDK_Context *context,APL_Card *impl); /**< For internal use : Constructor */ 00796 00797 friend PTEID_Card &PTEID_ReaderContext::getCard(); /**< For internal use : This method must access protected constructor */ 00798 }; 00799 00800 class APL_XMLDoc; 00801 00802 /******************************************************************************//** 00803 * Abstract base class for all the documents. 00804 *********************************************************************************/ 00805 class PTEID_XMLDoc : public PTEID_Object 00806 { 00807 public: 00808 PTEIDSDK_API virtual ~PTEID_XMLDoc()=0; /**< Destructor */ 00809 00810 PTEIDSDK_API virtual bool isAllowed(); /**< The document is allowed */ 00811 00812 PTEIDSDK_API virtual PTEID_ByteArray getXML(); /**< Return the document in an XML format */ 00813 PTEIDSDK_API virtual PTEID_ByteArray getCSV(); /**< Return the document in an CSV format */ 00814 PTEIDSDK_API virtual PTEID_ByteArray getTLV(); /**< Return the document in an TLV format */ 00815 00816 /** 00817 * Write the xml document into the file csFilePath. 00818 * @return true if succeeded 00819 */ 00820 PTEIDSDK_API virtual bool writeXmlToFile(const char * csFilePath); 00821 00822 /** 00823 * Write the csv document into the file csFilePath. 00824 * @return true if succeeded 00825 */ 00826 PTEIDSDK_API virtual bool writeCsvToFile(const char * csFilePath); 00827 00828 /** 00829 * Write the tlv document into the file csFilePath. 00830 * @return true if succeeded 00831 */ 00832 PTEIDSDK_API virtual bool writeTlvToFile(const char * csFilePath); 00833 00834 protected: 00835 PTEID_XMLDoc(const SDK_Context *context,APL_XMLDoc *impl); /**< For internal use : Constructor */ 00836 00837 private: 00838 PTEID_XMLDoc(const PTEID_XMLDoc& doc); /**< Copy not allowed - not implemented */ 00839 PTEID_XMLDoc& operator= (const PTEID_XMLDoc& doc); /**< Copy not allowed - not implemented */ 00840 00841 }; 00842 00843 class APL_Biometric; 00844 00845 /******************************************************************************//** 00846 * Abstract base class for the biometric documents. 00847 *********************************************************************************/ 00848 class PTEID_Biometric : public PTEID_XMLDoc 00849 { 00850 public: 00851 PTEIDSDK_API virtual ~PTEID_Biometric()=0; /**< Destructor */ 00852 00853 protected: 00854 PTEID_Biometric(const SDK_Context *context,APL_Biometric *impl); /**< For internal use : Constructor */ 00855 00856 private: 00857 PTEID_Biometric(const PTEID_Biometric& doc); /**< Copy not allowed - not implemented */ 00858 PTEID_Biometric& operator= (const PTEID_Biometric& doc); /**< Copy not allowed - not implemented */ 00859 }; 00860 00861 class APL_Crypto; 00862 00863 /******************************************************************************//** 00864 * Abstract base class for the cryptographic documents. 00865 *********************************************************************************/ 00866 class PTEID_Crypto : public PTEID_XMLDoc 00867 { 00868 public: 00869 PTEIDSDK_API virtual ~PTEID_Crypto()=0; /**< Destructor */ 00870 00871 protected: 00872 PTEID_Crypto(const SDK_Context *context,APL_Crypto *impl); /**< For internal use : Constructor */ 00873 00874 private: 00875 PTEID_Crypto(const PTEID_Crypto& doc); /**< Copy not allowed - not implemented */ 00876 PTEID_Crypto& operator= (const PTEID_Crypto& doc); /**< Copy not allowed - not implemented */ 00877 }; 00878 00879 class APL_DocVersionInfo; 00880 00881 /******************************************************************************//** 00882 * Class for the info document. 00883 * You can get such an object from PTEID_EIDCard::getVersionInfo() (or getDocument). 00884 *********************************************************************************/ 00885 class PTEID_CardVersionInfo : public PTEID_XMLDoc 00886 { 00887 public: 00888 PTEIDSDK_API virtual ~PTEID_CardVersionInfo(); /**< Destructor */ 00889 00890 PTEIDSDK_API const char *getSerialNumber(); /**< Return the Serial Number of the card */ 00891 PTEIDSDK_API const char *getComponentCode(); /**< Return the ComponenCode of the card */ 00892 PTEIDSDK_API const char *getOsNumber(); /**< Return the OS Number of the card */ 00893 PTEIDSDK_API const char *getOsVersion(); /**< Return the OS Version of the card */ 00894 PTEIDSDK_API const char *getSoftmaskNumber(); /**< Return the Softmask Number of the card */ 00895 PTEIDSDK_API const char *getSoftmaskVersion(); /**< Return the Softmask Version of the card */ 00896 PTEIDSDK_API const char *getAppletVersion(); /**< Return the Applet Version of the card */ 00897 PTEIDSDK_API const char *getGlobalOsVersion(); /**< Return the Global Os Version of the card */ 00898 PTEIDSDK_API const char *getAppletInterfaceVersion(); /**< Return the Applet Interface Version of the card */ 00899 PTEIDSDK_API const char *getPKCS1Support(); /**< Return the PKCS#1 Support of the card */ 00900 PTEIDSDK_API const char *getKeyExchangeVersion(); /**< Return the Key Exchange Version of the card */ 00901 PTEIDSDK_API const char *getAppletLifeCycle(); /**< Return the Applet Life Cycle of the card */ 00902 PTEIDSDK_API const char *getGraphicalPersonalisation(); /**< Return field GraphicalPersonalisation from the TokenInfo file */ 00903 PTEIDSDK_API const char *getElectricalPersonalisation(); /**< Return field ElectricalPersonalisation from the TokenInfo file */ 00904 PTEIDSDK_API const char *getElectricalPersonalisationInterface(); /**< Return field ElectricalPersonalisationInterface from the TokenInfo file */ 00905 PTEIDSDK_API const PTEID_ByteArray &getSignature(); /**< Return the signature of the card info */ 00906 00907 private: 00908 PTEID_CardVersionInfo(const PTEID_CardVersionInfo& doc); /**< Copy not allowed - not implemented */ 00909 PTEID_CardVersionInfo& operator= (const PTEID_CardVersionInfo& doc); /**< Copy not allowed - not implemented */ 00910 00911 PTEID_CardVersionInfo(const SDK_Context *context,APL_DocVersionInfo *impl); /**< For internal use : Constructor */ 00912 00913 friend PTEID_CardVersionInfo& PTEID_EIDCard::getVersionInfo(); /**< For internal use : This method must access protected constructor */ 00914 }; 00915 00916 class APL_PictureEid; 00917 00918 /******************************************************************************//** 00919 * Class for the picture document on a EID Card. 00920 * You can get such an object from PTEID_EIDCard::getPicture() (or getDocument). 00921 *********************************************************************************/ 00922 class PTEID_Picture : public PTEID_Biometric 00923 { 00924 public: 00925 PTEIDSDK_API virtual ~PTEID_Picture(); /**< Destructor */ 00926 00927 PTEIDSDK_API const PTEID_ByteArray& getData(); /**< Return the picture itself (jpg format) */ 00928 PTEIDSDK_API const PTEID_ByteArray& getHash(); /**< Return the hash of the picture */ 00929 00930 private: 00931 PTEID_Picture(const PTEID_Picture& doc); /**< Copy not allowed - not implemented */ 00932 PTEID_Picture& operator= (const PTEID_Picture& doc); /**< Copy not allowed - not implemented */ 00933 00934 PTEID_Picture(const SDK_Context *context,APL_PictureEid *impl);/**< For internal use : Constructor */ 00935 00936 friend PTEID_Picture& PTEID_EIDCard::getPicture(); /**< For internal use : This method must access protected constructor */ 00937 }; 00938 00939 class APL_DocSisId; 00940 00941 /******************************************************************************//** 00942 * Class for the id document on a SIS Card. 00943 * You can get such an object from PTEID_SISCard::getID() (or getDocument). 00944 *********************************************************************************/ 00945 class PTEID_SisId : public PTEID_XMLDoc 00946 { 00947 public: 00948 PTEIDSDK_API virtual ~PTEID_SisId(); /**< Destructor */ 00949 00950 PTEIDSDK_API const char *getName(); /**< Return Name field */ 00951 PTEIDSDK_API const char *getSurname(); /**< Return Surname field */ 00952 PTEIDSDK_API const char *getInitials(); /**< Return Initials field */ 00953 PTEIDSDK_API const char *getGender(); /**< Return Gender field */ 00954 PTEIDSDK_API const char *getDateOfBirth(); /**< Return Date Of Birth field */ 00955 PTEIDSDK_API const char *getSocialSecurityNumber(); /**< Return Social Security Number field */ 00956 PTEIDSDK_API const char *getLogicalNumber(); /**< Return Logical Number field */ 00957 PTEIDSDK_API const char *getDateOfIssue(); /**< Return Date Of Issue field */ 00958 PTEIDSDK_API const char *getValidityBeginDate(); /**< Return Validity Begin Date field */ 00959 PTEIDSDK_API const char *getValidityEndDate(); /**< Return Validity End Date field */ 00960 00961 private: 00962 PTEID_SisId(const PTEID_SisId& doc); /**< Copy not allowed - not implemented */ 00963 PTEID_SisId& operator= (const PTEID_SisId& doc); /**< Copy not allowed - not implemented */ 00964 00965 PTEID_SisId(const SDK_Context *context,APL_DocSisId *impl); /**< For internal use : Constructor */ 00966 00967 friend PTEID_SisId& PTEID_SISCard::getID(); /**< For internal use : This method must access protected constructor */ 00968 }; 00969 00970 class APL_DocEId; 00971 00972 /******************************************************************************//** 00973 * Class for the id document on a EID Card. 00974 * You can get such an object from PTEID_EIDCard::getID() (or getDocument). 00975 *********************************************************************************/ 00976 class PTEID_EId : public PTEID_XMLDoc 00977 { 00978 public: 00979 PTEIDSDK_API virtual ~PTEID_EId(); /**< Destructor */ 00980 00981 PTEIDSDK_API const char *getDocumentVersion(); /**< Return Document Version field */ 00982 PTEIDSDK_API const char *getDocumentType(); /**< Return Document Type field */ 00983 PTEIDSDK_API const char *getFirstName(); /**< Return Complete First Names */ 00984 PTEIDSDK_API const char *getFirstName1(); /**< Return First Name part 1 (2 first given name) */ 00985 PTEIDSDK_API const char *getFirstName2(); /**< Return First Name part 2 (first letter of the 3rd given name) */ 00986 PTEIDSDK_API const char *getSurname(); /**< Return Surname field */ 00987 PTEIDSDK_API const char *getGender(); /**< Return Gender field */ 00988 PTEIDSDK_API const char *getDateOfBirth(); /**< Return Date Of Birth field */ 00989 PTEIDSDK_API const char *getLocationOfBirth(); /**< Return Location Of Birth field */ 00990 PTEIDSDK_API const char *getNobility(); /**< Return Nobility field */ 00991 PTEIDSDK_API const char *getNationality(); /**< Return Nationality field */ 00992 PTEIDSDK_API const char *getNationalNumber(); /**< Return National Number field */ 00993 PTEIDSDK_API const char *getDuplicata(); /**< Return Duplicata field */ 00994 PTEIDSDK_API const char *getSpecialOrganization(); /**< Return Special Organization field */ 00995 PTEIDSDK_API const char *getMemberOfFamily(); /**< Return Member Of Family field */ 00996 PTEIDSDK_API const char *getLogicalNumber(); /**< Return Logical Number field */ 00997 PTEIDSDK_API const char *getChipNumber(); /**< Return Chip Number field */ 00998 PTEIDSDK_API const char *getValidityBeginDate(); /**< Return Validity Begin Date field */ 00999 PTEIDSDK_API const char *getValidityEndDate(); /**< Return Validity End Date field */ 01000 PTEIDSDK_API const char *getIssuingMunicipality(); /**< Return Issuing Municipality field */ 01001 PTEIDSDK_API const char *getAddressVersion(); /**< Return Address Version field */ 01002 PTEIDSDK_API const char *getStreet(); /**< Return Street field */ 01003 PTEIDSDK_API const char *getZipCode(); /**< Return Zip Code field */ 01004 PTEIDSDK_API const char *getMunicipality(); /**< Return Municipality field */ 01005 PTEIDSDK_API const char *getCountry(); /**< Return Country field */ 01006 PTEIDSDK_API const char *getSpecialStatus(); /**< Return Special Status field */ 01007 01008 private: 01009 PTEID_EId(const PTEID_EId& doc); /**< Copy not allowed - not implemented */ 01010 PTEID_EId& operator= (const PTEID_EId& doc); /**< Copy not allowed - not implemented */ 01011 01012 PTEID_EId(const SDK_Context *context,APL_DocEId *impl); /**< For internal use : Constructor */ 01013 01014 friend PTEID_EId& PTEID_EIDCard::getID(); /**< For internal use : This method must access protected constructor */ 01015 }; 01016 01017 class APL_SisFullDoc; 01018 01019 /******************************************************************************//** 01020 * Class for the full document Sis. 01021 *********************************************************************************/ 01022 class PTEID_SisFullDoc : public PTEID_XMLDoc 01023 { 01024 public: 01025 PTEIDSDK_API virtual ~PTEID_SisFullDoc(); /**< Destructor */ 01026 01027 protected: 01028 PTEID_SisFullDoc(const SDK_Context *context,APL_SisFullDoc *impl); /**< For internal use : Constructor */ 01029 01030 private: 01031 PTEID_SisFullDoc(const PTEID_SisFullDoc& doc); /**< Copy not allowed - not implemented */ 01032 PTEID_SisFullDoc& operator= (const PTEID_SisFullDoc& doc); /**< Copy not allowed - not implemented */ 01033 01034 friend PTEID_SisFullDoc& PTEID_SISCard::getFullDoc(); /**< For internal use : This method must access protected constructor */ 01035 }; 01036 01037 class APL_EIdFullDoc; 01038 01039 /******************************************************************************//** 01040 * Class for the full document Eid. 01041 *********************************************************************************/ 01042 class PTEID_EIdFullDoc : public PTEID_XMLDoc 01043 { 01044 public: 01045 PTEIDSDK_API virtual ~PTEID_EIdFullDoc(); /**< Destructor */ 01046 01047 protected: 01048 PTEID_EIdFullDoc(const SDK_Context *context,APL_EIdFullDoc *impl); /**< For internal use : Constructor */ 01049 01050 private: 01051 PTEID_EIdFullDoc(const PTEID_EIdFullDoc& doc); /**< Copy not allowed - not implemented */ 01052 PTEID_EIdFullDoc& operator= (const PTEID_EIdFullDoc& doc); /**< Copy not allowed - not implemented */ 01053 01054 friend PTEID_EIdFullDoc& PTEID_EIDCard::getFullDoc(); /**< For internal use : This method must access protected constructor */ 01055 }; 01056 class PTEID_Pin; 01057 class APL_Pins; 01058 01059 /******************************************************************************//** 01060 * Container class for all pins on the card. 01061 *********************************************************************************/ 01062 class PTEID_Pins : public PTEID_Crypto 01063 { 01064 public: 01065 PTEIDSDK_API virtual ~PTEID_Pins(); /**< Destructor */ 01066 01067 PTEIDSDK_API unsigned long count(); /**< The number of pins on the card */ 01068 01069 /** 01070 * Get the pin by its Index. 01071 * Throw PTEID_ExParamRange exception if the index is out of range. 01072 */ 01073 PTEIDSDK_API PTEID_Pin &getPinByNumber(unsigned long ulIndex); 01074 01075 private: 01076 PTEID_Pins(const PTEID_Pins& pins); /**< Copy not allowed - not implemented */ 01077 PTEID_Pins& operator= (const PTEID_Pins& pins); /**< Copy not allowed - not implemented */ 01078 01079 PTEID_Pins(const SDK_Context *context,APL_Pins *impl); /**< For internal use : Constructor */ 01080 01081 friend PTEID_Pins& PTEID_SmartCard::getPins(); /**< For internal use : This method must access protected constructor */ 01082 }; 01083 01084 class APL_Pin; 01085 01086 /******************************************************************************//** 01087 * Class that represent one Pin. 01088 *********************************************************************************/ 01089 class PTEID_Pin : public PTEID_Crypto 01090 { 01091 public: 01092 PTEIDSDK_API virtual ~PTEID_Pin(); /**< Destructor */ 01093 01094 PTEIDSDK_API unsigned long getIndex(); /**< Get the index of the pin */ 01095 PTEIDSDK_API unsigned long getType(); /**< Get the type of the pin */ 01096 PTEIDSDK_API unsigned long getId(); /**< Get the id of the pin */ 01097 PTEIDSDK_API PTEID_PinUsage getUsageCode(); /**< Get the usage code of the pin */ 01098 PTEIDSDK_API unsigned long getFlags(); /**< Get the flags of the pin */ 01099 PTEIDSDK_API const char *getLabel(); /**< Get the label of the pin */ 01100 01101 PTEIDSDK_API const PTEID_ByteArray &getSignature(); /**< Return the signature of the pin */ 01102 01103 /** 01104 * Return the remaining tries for giving the good pin. 01105 * 01106 * This opperation is not supported by all card. 01107 * 01108 * @return -1 if not supported 01109 * @return the number of remaining tries in the other case 01110 */ 01111 PTEIDSDK_API long getTriesLeft(); 01112 01113 /** 01114 * Ask the card to verify the pin. 01115 * A popup will ask for the code. 01116 * @return true if success and false if failed 01117 */ 01118 PTEIDSDK_API bool verifyPin(); 01119 01120 /** 01121 * Ask the card to verify the pin. 01122 * 01123 * @param csPin is the pin code to verify (if csPin is empty, a popup will ask for the code) 01124 * @param ulRemaining return the remaining tries (only if verifying failed) 01125 * 01126 * @return true if success and false if failed 01127 */ 01128 PTEIDSDK_API bool verifyPin(const char *csPin,unsigned long &ulRemaining); 01129 01130 /** 01131 * Ask the card to change the pin. 01132 * A popup will ask for the codes 01133 * @return true if success and false if failed 01134 */ 01135 PTEIDSDK_API bool changePin(); 01136 01137 /** 01138 * Ask the card to change the pin. 01139 * 01140 * if csPin1 or csPin2 are empty, a popup will ask for the codes. 01141 * 01142 * @param csPin1 is the old pin code 01143 * @param csPin2 is the new pin code 01144 * @param ulRemaining return the remaining tries (only when operation failed) 01145 * 01146 * @return true if success and false if failed 01147 */ 01148 PTEIDSDK_API bool changePin(const char *csPin1,const char *csPin2,unsigned long &ulRemaining); 01149 01150 private: 01151 PTEID_Pin(const PTEID_Pin& pin); /**< Copy not allowed - not implemented */ 01152 PTEID_Pin& operator= (const PTEID_Pin& pin); /**< Copy not allowed - not implemented */ 01153 01154 PTEID_Pin(const SDK_Context *context,APL_Pin *impl); /**< For internal use : Constructor */ 01155 01156 friend PTEID_Pin &PTEID_Pins::getPinByNumber(unsigned long ulIndex); /**< For internal use : This method must access protected constructor */ 01157 }; 01158 01159 class APL_Crl; 01160 01161 /******************************************************************************//** 01162 * Class that represents one CRL. 01163 *********************************************************************************/ 01164 class PTEID_Crl : public PTEID_Object 01165 { 01166 public: 01167 /** 01168 * Create a Crl from its uri (without any certificate link). 01169 * As there is no issuer, this CRL can't be verify and some method are not allowed 01170 * (ex. getIssuer). 01171 * These methods throw PTEID_ExBadUsage exception. 01172 */ 01173 PTEIDSDK_API PTEID_Crl(const char *uri); 01174 01175 PTEIDSDK_API virtual ~PTEID_Crl(void); /**< Destructor */ 01176 01177 PTEIDSDK_API const char *getUri(); /**< Return the uri of the CRL */ 01178 01179 PTEIDSDK_API const char *getIssuerName(); /**< Return the name of the issuer of the certificate */ 01180 01181 /** 01182 * Return the issuer certificate. 01183 * 01184 * if there is no issuer (root), PTEID_ExCertNoIssuer exception is thrown. 01185 */ 01186 PTEIDSDK_API PTEID_Certificate &getIssuer(); 01187 01188 /** 01189 * Return the CRL as a byte array. 01190 * If it comes from a Certif we verify the signature. 01191 * If it's created from the URL only we DON'T verify the signature. 01192 * @param crl will content the crl 01193 * @param bForceDownload : if true the CRL in the cache is not valid anymore and we force a new download 01194 */ 01195 PTEIDSDK_API PTEID_CrlStatus getData(PTEID_ByteArray &crl,bool bForceDownload=false); 01196 01197 NOEXPORT_PTEIDSDK PTEID_Crl(const SDK_Context *context,APL_Crl *impl); /**< For internal use : Constructor */ 01198 01199 private: 01200 PTEID_Crl(const PTEID_Crl& crl); /**< Copy not allowed - not implemented */ 01201 PTEID_Crl &operator= (const PTEID_Crl& crl); /**< Copy not allowed - not implemented */ 01202 }; 01203 01204 class APL_OcspResponse; 01205 01206 /******************************************************************************//** 01207 * Class that represents one OCSP Response. 01208 *********************************************************************************/ 01209 class PTEID_OcspResponse : public PTEID_Object 01210 { 01211 public: 01212 /** 01213 * Create an OcspResponse object from the URI only and CertID. 01214 * This OCSP Response is not link to any certificate so some methods could not be used. 01215 * These methods throw PTEID_ExBadUsage exception. 01216 */ 01217 PTEIDSDK_API PTEID_OcspResponse(const char *uri,PTEID_HashAlgo hashAlgorithm,const PTEID_ByteArray &issuerNameHash,const PTEID_ByteArray &issuerKeyHash,const PTEID_ByteArray &serialNumber); 01218 01219 PTEIDSDK_API virtual ~PTEID_OcspResponse(void); /**< Destructor */ 01220 01221 PTEIDSDK_API const char *getUri(); /**< Return the uri of the responder */ 01222 01223 /** 01224 * Return the response. 01225 */ 01226 PTEIDSDK_API PTEID_CertifStatus getResponse(PTEID_ByteArray &response); 01227 01228 NOEXPORT_PTEIDSDK PTEID_OcspResponse(const SDK_Context *context,APL_OcspResponse *impl); /**< For internal use : Constructor */ 01229 01230 private: 01231 PTEID_OcspResponse(const PTEID_OcspResponse& ocsp); /**< Copy not allowed - not implemented */ 01232 PTEID_OcspResponse &operator= (const PTEID_OcspResponse& ocsp); /**< Copy not allowed - not implemented */ 01233 }; 01234 01235 class APL_Certifs; 01236 01237 /******************************************************************************//** 01238 * Container class for all certificates on the card. 01239 *********************************************************************************/ 01240 class PTEID_Certificates : public PTEID_Crypto 01241 { 01242 public: 01243 /** 01244 * Create an PTEID_Certificates store without any link to a card. 01245 * This store is not link to any Card, so some methods could not be used. 01246 * These methods throw PTEID_ExBadUsage exception. 01247 */ 01248 PTEIDSDK_API PTEID_Certificates(); 01249 01250 PTEIDSDK_API virtual ~PTEID_Certificates(); /**< Destructor */ 01251 01252 PTEIDSDK_API unsigned long countFromCard(); /**< The number of certificates on the card */ 01253 PTEIDSDK_API unsigned long countAll(); /**< The number of certificates (on the card or not) */ 01254 01255 /** 01256 * Get the ulIndex certificate from the card. 01257 * Throw PTEID_ExParamRange exception if the index is out of range. 01258 */ 01259 PTEIDSDK_API PTEID_Certificate &getCertFromCard(unsigned long ulIndexCard); 01260 01261 /** 01262 * Return the certificate with the number ulIndexAll. 01263 * 01264 * ATTENTION ulIndexAll and ulIndexCard are two different index. 01265 * Index will change if new certificates are added with addCert(). 01266 */ 01267 PTEIDSDK_API PTEID_Certificate &getCert(unsigned long ulIndexAll); 01268 01269 /** 01270 * Return the certificate by type. 01271 */ 01272 PTEIDSDK_API PTEID_Certificate &getCert(PTEID_CertifType type); 01273 01274 PTEIDSDK_API PTEID_Certificate &getRrn(); /**< Return the RRN certificate from the card */ 01275 PTEIDSDK_API PTEID_Certificate &getRoot(); /**< Return the root certificate from the card */ 01276 PTEIDSDK_API PTEID_Certificate &getCA(); /**< Return the ca certificate from the card */ 01277 PTEIDSDK_API PTEID_Certificate &getSignature(); /**< Return the signature certificate from the card */ 01278 PTEIDSDK_API PTEID_Certificate &getAuthentication(); /**< Return the authentication certificate from the card */ 01279 01280 /** 01281 * Add a new certificate to the store. 01282 */ 01283 PTEIDSDK_API PTEID_Certificate &addCertificate(PTEID_ByteArray &cert); 01284 01285 01286 private: 01287 PTEID_Certificates(const PTEID_Certificates& certifs); /**< Copy not allowed - not implemented */ 01288 PTEID_Certificates& operator= (const PTEID_Certificates& certifs);/**< Copy not allowed - not implemented */ 01289 01290 PTEID_Certificates(const SDK_Context *context,APL_Certifs *impl);/**< For internal use : Constructor */ 01291 01292 friend PTEID_Certificates& PTEID_SmartCard::getCertificates(); /**< For internal use : This method must access protected constructor */ 01293 }; 01294 01295 class APL_Certif; 01296 01297 /******************************************************************************//** 01298 * Class that represent one certificate. 01299 *********************************************************************************/ 01300 class PTEID_Certificate : public PTEID_Crypto 01301 { 01302 public: 01303 PTEIDSDK_API virtual ~PTEID_Certificate(); /**< Destructor */ 01304 01305 PTEIDSDK_API const char *getLabel(); /**< Return the label of the certificate */ 01306 PTEIDSDK_API unsigned long getID(); /**< Return the id of the certificate */ 01307 01308 /** 01309 * Return the status of the certificate using default validation level (from config). 01310 */ 01311 PTEIDSDK_API PTEID_CertifStatus getStatus(); 01312 01313 /** 01314 * Return the status of the certificate. 01315 */ 01316 PTEIDSDK_API PTEID_CertifStatus getStatus(PTEID_ValidationLevel crl, PTEID_ValidationLevel ocsp); 01317 01318 PTEIDSDK_API PTEID_CertifType getType(); /**< Return the type of the certificate */ 01319 01320 PTEIDSDK_API const PTEID_ByteArray &getCertData();/**< Return the content of the certificate */ 01321 PTEIDSDK_API void getFormattedData(PTEID_ByteArray &data); /**< Return the content of the certificate without ending zero */ 01322 PTEIDSDK_API const char *getSerialNumber(); /**< Return the serial number of the certificate */ 01323 PTEIDSDK_API const char *getOwnerName(); /**< Return the name of the owner of the certificate */ 01324 PTEIDSDK_API const char *getIssuerName(); /**< Return the name of the issuer of the certificate */ 01325 PTEIDSDK_API const char *getValidityBegin(); /**< Return the validity begin date of the certificate */ 01326 PTEIDSDK_API const char *getValidityEnd(); /**< Return the validity end date of the certificate */ 01327 PTEIDSDK_API unsigned long getKeyLength(); /**< Return the length of public/private key on the certificate */ 01328 01329 /** 01330 * Return true if this is a root certificate. 01331 */ 01332 PTEIDSDK_API bool isRoot(); 01333 01334 /** 01335 * Return the test status. 01336 * 01337 * @return true if test certificate 01338 * @return false if good one 01339 */ 01340 PTEIDSDK_API bool isTest(); 01341 01342 /** 01343 * Return true if the certificate chain end by the one of pteid root. 01344 */ 01345 PTEIDSDK_API bool isFromPteidValidChain(); 01346 01347 /** 01348 * This certificate comes from the card. 01349 */ 01350 PTEIDSDK_API bool isFromCard(); 01351 01352 /** 01353 * Return the issuer certificate. 01354 * 01355 * if there is no issuer (root), PTEID_ExCertNoIssuer exception is thrown 01356 */ 01357 PTEIDSDK_API PTEID_Certificate &getIssuer(); 01358 01359 /** 01360 * Return the number of children for this certificate. 01361 */ 01362 PTEIDSDK_API unsigned long countChildren(); 01363 01364 /** 01365 * Return the children certificate (certificate that has been issued by this one). 01366 * 01367 * @param ulIndex is the children index (the index for the first child is 0) 01368 * Throw PTEID_ExParamRange exception if the index is out of range 01369 */ 01370 PTEIDSDK_API PTEID_Certificate &getChildren(unsigned long ulIndex); 01371 01372 /** 01373 * Return the crl of the certificate. 01374 */ 01375 PTEIDSDK_API PTEID_Crl &getCRL(); 01376 01377 /** 01378 * Return the ocsp response object of the certificate. 01379 */ 01380 PTEIDSDK_API PTEID_OcspResponse &getOcspResponse(); 01381 01382 01383 PTEIDSDK_API PTEID_CertifStatus verifyCRL(bool forceDownload=false); /**< Verify the certificate trough CRL validation */ 01384 PTEIDSDK_API PTEID_CertifStatus verifyOCSP(); /**< Verify the certificate trough OCSP validation */ 01385 01386 private: 01387 PTEID_Certificate(const PTEID_Certificate& certif); /**< Copy not allowed - not implemented */ 01388 PTEID_Certificate& operator= (const PTEID_Certificate& certif); /**< Copy not allowed - not implemented */ 01389 01390 PTEID_Certificate(const SDK_Context *context,APL_Certif *impl); /**< For internal use : Constructor */ 01391 01392 friend PTEID_Certificate &PTEID_Certificates::getCert(unsigned long ulIndex); /**< For internal use : This method must access protected constructor */ 01393 friend PTEID_Certificate &PTEID_Certificates::getCertFromCard(unsigned long ulIndex); /**< For internal use : This method must access protected constructor */ 01394 friend PTEID_Certificate &PTEID_Certificates::getCert(PTEID_CertifType type); /**< For internal use : This method must access protected constructor */ 01395 friend PTEID_Certificate &PTEID_Crl::getIssuer(); /**< For internal use : This method must access protected constructor */ 01396 friend PTEID_Certificate &PTEID_Certificates::addCertificate(PTEID_ByteArray &cert); /**< For internal use : This method must access protected constructor */ 01397 }; 01398 01399 class APL_Config; 01400 01401 /******************************************************************************//** 01402 * Class to access the config parameters. 01403 *********************************************************************************/ 01404 class PTEID_Config : public PTEID_Object 01405 { 01406 public: 01407 /** 01408 * Create object to access parameter Param. 01409 */ 01410 PTEIDSDK_API PTEID_Config(PTEID_Param Param); 01411 01412 /** 01413 * Create object to access a string parameter. 01414 */ 01415 PTEIDSDK_API PTEID_Config(const char *csName, const char *czSection, const char *csDefaultValue); 01416 01417 /** 01418 * Create object to access a numerical parameter. 01419 */ 01420 PTEIDSDK_API PTEID_Config(const char *csName, const char *czSection, long lDefaultValue); 01421 01422 PTEIDSDK_API virtual ~PTEID_Config(); /**< Destructor */ 01423 01424 PTEIDSDK_API const char *getString(); /**< Return the string value (Throw exception for numerical parameter) */ 01425 PTEIDSDK_API long getLong(); /**< Return the numerical value (Throw exception for string parameter) */ 01426 01427 PTEIDSDK_API void setString(const char *csValue); /**< Set the string value (Throw exception for numerical parameter) */ 01428 PTEIDSDK_API void setLong(long lValue); /**< Set the numerical value (Throw exception for string parameter) */ 01429 01430 private: 01431 PTEID_Config(const PTEID_Config& config); /**< Copy not allowed - not implemented */ 01432 PTEID_Config& operator= (const PTEID_Config& config); /**< Copy not allowed - not implemented */ 01433 01434 PTEID_Config(APL_Config *impl); /**< For internal use : Constructor */ 01435 }; 01436 01437 /******************************************************************************//** 01438 * Function for Logging. 01439 *********************************************************************************/ 01440 PTEIDSDK_API void PTEID_LOG(PTEID_LogLevel level, const char *module_name, const char *format, ...); 01441 01442 } 01443 01444 #endif //__PTEIDLIB_H__