OpenCard Framework 1.2 Programmer's Guide - OpenSCDP
OpenCard Framework 1.2 Programmer's Guide - OpenSCDP
OpenCard Framework 1.2 Programmer's Guide - OpenSCDP
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
}<br />
}<br />
// do something with the wanted terminal<br />
// ...<br />
} catch <strong>OpenCard</strong> Exceptions {<br />
// handle exception<br />
// ...<br />
}<br />
Once you have the reference to the wanted terminal, you can either use the<br />
application-driven model and wait for a card using the SmartCard’s waitForCard()<br />
method to pass it a CardRequest object with the card terminal set (by means of the<br />
setCardTerminal() method), or you can use the event-driven model and get the<br />
card using the SmartCard’s getSmartCard() method to pass it the<br />
CardTerminalEvent object you received via the cardInserted() notification.<br />
Gaining exclusive access to the smart card<br />
Referencing files<br />
Exclusive access to smart cards can be required in situations where an application<br />
needs to perform a semantic function on the card that requires an uninterrupted<br />
sequence of smart card operations. A good example for this requirement is a<br />
payment application such as running in an automatic teller machine (ATM) 11 that<br />
has to debit the card and credit some account (or vice versa) by a certain amount<br />
within a transaction context.<br />
In your applications, you can acquire a mutex context by calling the beginMutex()<br />
method and release it by calling endMutex() on the SmartCard object. For the<br />
application to be well-behaved, you should claim the mutex context for as short a<br />
period as possible to avoid unnecessarily blocking other applications (or threads)<br />
from accessing the card.<br />
ISO-1716-4 defines four different ways of referencing files within a smart card.<br />
They are:<br />
Referencing by file identifier:<br />
Files may be referenced by a file identifier coded in two bytes. For<br />
uniqueness, EFs (files) and DFs (directories) under a common DF shall<br />
have different file identifiers. The MF (root directory) shall have a file ID of<br />
hexadecimal value 0x3f00.<br />
Referencing by path:<br />
Files may referenced by a path, i.e. a concatenation of file identifiers. The<br />
path begins with the identifier of the MF or of the current DF, the order of<br />
the identifiers is parent to child. In case the identifier of the current<br />
directory is unknown, a hexadecimal value of 0x3fff can be used instead<br />
(reserved value).<br />
Referencing by short EF identifier:<br />
EFs can be referenced by a short EF identifier coded on five bits with<br />
values in the range from 1 to 30. The value 0 is used to reference the<br />
currently selected EF. Short EF identifiers cannot be used in a path or as a<br />
file ID.<br />
11. ATM’s typically take in the cards for the period of interaction to prevent early removal of the card by the user.<br />
Chapter 5. Advanced programming with OCF 35