Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

CTCard Class Reference
[General Card Classes]

This class describes a chipcard. More...

#include <ctcard.h>

Inheritance diagram for CTCard:

CTCardBase CTMemoryCard CTProcessorCard CTKVKCard CTGeldKarte HBCICard RSACard List of all members.

Public Member Functions

Constructors/Destructor
 CTCard (const CTCard &c)
virtual ~CTCard ()
Opening and closing operations
Methods to connect and disconnect the card. Most other methods only work if the card is open.

virtual CTError openCard ()
virtual CTError closeCard (bool force=false)
virtual CTError reopenCard ()
Informational methods
These methods tell you about the type and the status of the card.

virtual string cardType ()
virtual string cardTypes ()
bool isProcessorCard () const
unsigned int memorySize () const
Commands
These methods allow you to send a command to the card. Of course the card needs to be already open.

CTError makeAPDU (const string &command, string &cmdCache, string &apdu, const string &param1, const string &param2, const string &param3, const string &param4, const string &param5)
CTError execCommand (CTCommand &cmd)
CTError execCommand (const string &command, string &cmdCache, string &response, const string &param1="", const string &param2="", const string &param3="", const string &param4="", const string &param5="")
CTError selectFile (string &fcp, unsigned short fid)
CTError selectFile (string &fcp, const string &fid)
CTError readBinary (string &data, unsigned int offset, unsigned int size)
CTError readBinaryRaw (string &data, unsigned short offset, unsigned char size)
CTError updateBinary (const string &data, unsigned int offset)
CTError updateBinaryRaw (const string &data, unsigned short offset)

Protected Member Functions

virtual CallBackResult callback (bool first)

Detailed Description

This class describes a chipcard.

This is just to let you mount/unmount a card, request its status etc. It is very general. Special things are done in the classes which inherit this one (like CTMemoryCard and CTProcessorCard. This class (and its children) is the C++ interface to libchipcard. When there is interaction with the card reader/card necessary then this class will automatically create all other objects/structs whatsoever on the fly. These things are all hidden from you, so you only have to concentrate on this class here.

Author:
Martin Preuss<martin@libchipcard.de>


Constructor & Destructor Documentation

CTCard::CTCard const CTCard c  ) 
 

This constructor is mainly used by derived classes to transform a basic CTCard object to a more special one. This allows opening a card as a CTCard object and then create e.g. a CTMemoryCard from this one. The source card will be immediately closed. The only thing you should do with it is to delete it. You should NOT use it any longer !!

Parameters:
c reference to the CTCard object to be transformed
Author:
Martin Preuss<martin@libchipcard.de>

virtual CTCard::~CTCard  )  [virtual]
 


Member Function Documentation

virtual CallBackResult CTCard::callback bool  first  )  [protected, virtual]
 

Reimplemented from CTCardBase.

virtual string CTCard::cardType  )  [virtual]
 

This method returns a short name of the class which handles this card. A HBCI card for example returns "HBCICard". So you can use this method to check for the type of the card.

Reimplemented in CTGeldKarte, CTKVKCard, CTMemoryCard, CTProcessorCard, HBCICard, and RSACard.

virtual string CTCard::cardTypes  )  [virtual]
 

This method returns a comma separated list of all card types this card inherits including the type of this card, e.g. a HBCI card would return "CTProcessorCard, HBCICard". If you overload this method in your own class (you SHOULD) you simply have to call this method of the class it directly inherits. That class will then do the same, so that there is a list upon return.

Reimplemented in CTGeldKarte, CTKVKCard, CTMemoryCard, CTProcessorCard, HBCICard, and RSACard.

virtual CTError CTCard::closeCard bool  force = false  )  [virtual]
 

Call this if you have finished working with the card. After this method is called you may safely remove the card from the reader.

Author:
Martin Preuss<martin@libchipcard.de>
Returns:
CTError object that holds the result (call isOk() to see if there was an error)

Reimplemented in HBCICard, and RSACard.

CTError CTCard::execCommand const string &  command,
string &  cmdCache,
string &  response,
const string &  param1 = "",
const string &  param2 = "",
const string &  param3 = "",
const string &  param4 = "",
const string &  param5 = ""
 

This method sends a command using the config file driven command engine. You specify the name of the command (like "read_binary" and the parameters to it (for "read_binary" this would be the offset and size of the data to read).

Returns:
reuslt of the operation (call isOk() on it)
Parameters:
command name of the command to execute
cmdCache this string will be used to store the fully resolved path and name of the command. The command given (e.g. "read_binary") will be looked up internally, thereby taking into account the type of the reader and the card to which the command is to be applied. If the command has been found its full path will be stored in this variable. However, if this string is not empty upon call this method assumes that the cache already contains the full path, so it will not be looked up.
response reference to a string to receive the response
param1 first parameter to the command
param2 2nd parameter to the command
param3 3rd parameter to the command

CTError CTCard::execCommand CTCommand cmd  ) 
 

Sends a command to the card reader terminal and retrieves its answer. When this method returns the members lr, sw1, sw2 and data are changed to reflect the answer. This method is used by EVERY other command method (like selectFile(), readBinary() etc).

Author:
Martin Preuss<martin@libchipcard.de>
Parameters:
cmd reference to the CTCommand struct
Returns:
CTError object that holds the result (call isOk() to see if there was an error)

bool CTCard::isProcessorCard  )  const
 

Returns true if the card is a processor card. This is only valid if the card is open.

Author:
Martin Preuss<martin@libchipcard.de>

CTError CTCard::makeAPDU const string &  command,
string &  cmdCache,
string &  apdu,
const string &  param1,
const string &  param2,
const string &  param3,
const string &  param4,
const string &  param5
 

unsigned int CTCard::memorySize  )  const [inline]
 

Returns the size of the memory on the card. Mostly used with memory cards, while processor cards sometimes return 0 (like the hbci card does). Please note that some cards seem to be lieing about their size ! This is only valid if the card is open.

Author:
Martin Preuss<martin@libchipcard.de>
Returns:
size of memory in bytes

virtual CTError CTCard::openCard  )  [virtual]
 

Opens the card for usage. This way the card is powered on. This method does some basic checks and retrieves basic information about the card (whether it is a memory card or a processor card, the size of the memory etc). When this method successfully returns the card may be used.

Author:
Martin Preuss<martin@libchipcard.de>
Returns:
CTError object that holds the result (call isOk() to see if there was an error)

Reimplemented in CTGeldKarte, HBCICard, and RSACard.

CTError CTCard::readBinary string &  data,
unsigned int  offset,
unsigned int  size
 

Reads data from the currently selected file.

Author:
Martin Preuss<martin@libchipcard.de>
Parameters:
data reference to a string to receive the data
offset guess what ;-)
size how many bytes do you want to read today ?
Returns:
CTError object that holds the result (call isOk() to see if there was an error)

CTError CTCard::readBinaryRaw string &  data,
unsigned short  offset,
unsigned char  size
 

virtual CTError CTCard::reopenCard  )  [virtual]
 

When this method is called normally the card is already opened by means of openCard(). However, it is likely that openCard() has been called assuming this card is only a CTCard() object, nothing special. You may then call THIS method here on all known card classes to check for the type of this card. This method must assume that any file on the card is already selected, so it is in most cases a good idea to select the MF as the first action of this method. If the executing class finds that the card inserted is not of a type it can handle then it MUST return an error.

Reimplemented in CTGeldKarte, CTKVKCard, CTMemoryCard, CTProcessorCard, HBCICard, and RSACard.

CTError CTCard::selectFile string &  fcp,
const string &  fid
 

This is the simplest form of the select file command. It should work with every card.

Author:
Martin Preuss<martin@libchipcard.de>
Returns:
CTError object that holds the result (call isOk() to see if there was an error)
Parameters:
fcp a reference to a string to receive the FCI
fid file identifier

CTError CTCard::selectFile string &  fcp,
unsigned short  fid
 

This is the simplest form of the select file command. It should work with every card.

Author:
Martin Preuss<martin@libchipcard.de>
Returns:
CTError object that holds the result (call isOk() to see if there was an error)
Parameters:
fcp a reference to a string to receive the FCI
fid the two byte file identifier

CTError CTCard::updateBinary const string &  data,
unsigned int  offset
 

Writes data into the currently selected file.

Author:
Martin Preuss<martin@libchipcard.de>
Returns:
CTError object that holds the result (call isOk() to see if there was an error)
Parameters:
data reference to a string to be send
offset guess what ;-) Please note that some cards do not allow to write the first 26 bytes !
number of bytes to send

CTError CTCard::updateBinaryRaw const string &  data,
unsigned short  offset
 


The documentation for this class was generated from the following file:
Generated on Wed Jul 28 14:56:50 2004 for libchipcard by doxygen 1.3.7