|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--opencard.core.service.CardService
Provides specific smart card functionality to applications. This functionality may be, for example, an ISO 7816-4 file system or a ISO 7816-7 data base system. A concrete card service is almost always smart card operating system specific.
Communication with a smart card takes place through a CardChannel
that the card service either allocates from a CardServiceScheduler
or gets from a third party, for example another card service or the
corresponding SmartCard object if beginMutex is
invoked there.
The methods to allocate and release card channels provided here are
aware of channels that have been pre-set by a third party. A public
method providing card functionality in a class derived from
CardService will typically have the following structure:
public RetType doSomeThingWithCard(...) throws CardServiceException, CardTerminalException { ... // check parameters RetType retvalue = null; try { allocateCardChannel(); // ensure there is a channel CommandAPDU command = ...; ResponseAPDU response = getCardChannel().sendCommandAPDU(command); ... // evaluate response, maybe send further commands retvalue = ...; } finally { // despite any exceptions releaseCardChannel(); // free the card channel } return retvalue; }
CardChannel
,
CardServiceScheduler
,
SmartCard.beginMutex()
Constructor Summary | |
protected |
CardService()
Creates a new card service, which is not yet initialized. |
Method Summary | |
protected void |
allocateCardChannel()
Allocates a card channel iff one is required. |
SmartCard |
getCard()
Gets the smartcard object associated with this service. |
CardChannel |
getCardChannel()
Gets the card channel to use for communicating with the smartcard. |
CHVDialog |
getCHVDialog()
Returns the dialog for CHV input. |
protected void |
initialize(CardServiceScheduler scheduler,
SmartCard smartcard,
boolean blocking)
Initializes this service. |
protected void |
releaseCardChannel()
Releases the allocated card channel. |
void |
setCardChannel(CardChannel channel)
Sets the channel to use for communicating with the smartcard. |
void |
setCHVDialog(CHVDialog dialog)
Sets the CHV dialog to be used for getting passwords from the user. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
protected CardService()
initialize(opencard.core.service.CardServiceScheduler, opencard.core.service.SmartCard, boolean)
Method Detail |
public void setCardChannel(CardChannel channel)
channel
- the channel to use, or null to resetallocateCardChannel()
,
releaseCardChannel()
public final CardChannel getCardChannel()
public void setCHVDialog(CHVDialog dialog)
the
- CHV dialog to be usedpublic final CHVDialog getCHVDialog()
setCHVDialog(opencard.core.service.CHVDialog)
public final SmartCard getCard()
protected void initialize(CardServiceScheduler scheduler, SmartCard smartcard, boolean blocking) throws CardServiceException
scheduler
- where this service is going to allocate channelssmartcard
- which smartcard has to be supported by this serviceblocking
- whether channel allocation is going to be blockingCardServiceFactory
protected void allocateCardChannel() throws InvalidCardChannelException
setCardChannel(opencard.core.service.CardChannel)
,
getCardChannel()
,
releaseCardChannel()
,
CardChannel
,
CardServiceScheduler
protected void releaseCardChannel() throws InvalidCardChannelException
allocateCardChannel()
,
setCardChannel(opencard.core.service.CardChannel)
,
CardChannel
,
CardServiceScheduler
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |