Package opencard.opt.applet
Class BasicAppletCardService
- java.lang.Object
-
- opencard.core.service.CardService
-
- opencard.opt.applet.BasicAppletCardService
-
- Direct Known Subclasses:
AppletProxy
,SmartCardHSMCardService
public class BasicAppletCardService extends CardService
This service offers methods to applications or proxies derived from it, which send a given command APDU to the card applet identified by the given application identifier and which return the result APDU. All instances associated with the same physical card share a common state object attached to the the used channel by the first BasicAppletCardService instance. This state object, an instance of CardState, keeps track of the currently selected applet and is used by BasicAppletCardServices to avoid unnecessary selection of applets.- Since:
- OCF1.2
- Author:
- Frank Seliger (seliger@de.ibm.com), Thomas Schaeck (schaeck@de.ibm.com), Christophe.Muller@research.gemplus.com
- See Also:
CardServiceScheduler
,CardChannel
,AppletID
-
-
Constructor Summary
Constructors Constructor Description BasicAppletCardService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
checkSelectResponse(AppletInfo info)
Check response returned from applet Override in derived classprotected AppletSelector
getAppletSelector()
Get the applet selector.protected CardState
getCardState(CardChannel channel)
Gets the associated state object.protected void
initialize(CardServiceScheduler scheduler, SmartCard card, boolean blocking)
Instantiates a BasicAppletCardService and tie it both to its CardServiceScheduler and its using SmartCard object.protected boolean
isSelected(CardChannel channel)
Allow derived class to veto select if applet is already selected, e.g.protected ResponseAPDU
sendCommandAPDU(CardChannel channel, AppletID appletID, CommandAPDU commandAPDU)
Sends a CommandAPDU to the applet on the card that has the given application identifier using the given channel.ResponseAPDU
sendCommandAPDU(AppletID appletID, CommandAPDU commandAPDU)
Sends a CommandAPDU to the applet on the card that has the given application identifier.protected ResponseAPDU
sendVerifiedAPDU(CardChannel channel, AppletID appletID, CommandAPDU verificationAPDU, CHVControl chvControl, int timeout)
Send a verify CHV command APDU to the card applet with the given application identifier after filling in the password obtained from the CHV dialog currently associated with this card service.protected void
setAppletSelector(AppletSelector s)
Set the applet selector.-
Methods inherited from class opencard.core.service.CardService
allocateCardChannel, getCard, getCardChannel, getCHVDialog, releaseCardChannel, setCardChannel, setCHVDialog
-
-
-
-
Method Detail
-
getAppletSelector
protected AppletSelector getAppletSelector()
Get the applet selector.- Returns:
- A helper object that implements the "AppletSelector" interface.
-
getCardState
protected CardState getCardState(CardChannel channel)
Gets the associated state object. We store the CardState in the same way as the state of an applet proxy or applet. This has the advantage that the state is guaranteed to exist only once per card channel and thus per card.- Returns:
- The state object representing the state of the card.
-
initialize
protected void initialize(CardServiceScheduler scheduler, SmartCard card, boolean blocking) throws CardServiceException
Instantiates a BasicAppletCardService and tie it both to its CardServiceScheduler and its using SmartCard object.- Overrides:
initialize
in classCardService
- Parameters:
scheduler
- The scheduler of this CardExecutiveCardService.card
- The controlling SmartCard object.blocking
- Specify the wait behavior for obtaining a CardChannel from the CardServiceScheduler.- Throws:
CardServiceException
- if the service could not be initialized. The object created via the default constructor may not be used if this happens.- See Also:
CardServiceFactory
-
checkSelectResponse
protected void checkSelectResponse(AppletInfo info)
Check response returned from applet Override in derived class- Parameters:
info
- The application info returned from the AppletSelector
-
isSelected
protected boolean isSelected(CardChannel channel) throws CardTerminalException
Allow derived class to veto select if applet is already selected, e.g. because the applet is already active and a re-select would clear the security status- Parameters:
channel
- The CardChannel to be used for sending the select command to the card.- Returns:
- true is applet is already selected and select should be skipped
- Throws:
CardTerminalException
-
sendCommandAPDU
protected ResponseAPDU sendCommandAPDU(CardChannel channel, AppletID appletID, CommandAPDU commandAPDU) throws CardTerminalException, CardServiceException
Sends a CommandAPDU to the applet on the card that has the given application identifier using the given channel.- Parameters:
channel
- channel to be used for sending APDUs to the smart cardappletID
- application identifier of destination appletcommandAPDU
- CommandAPDU to send- Returns:
- The resulting ResponseAPDU as received from the card.
- Throws:
CardTerminalException
CardServiceException
-
sendCommandAPDU
public ResponseAPDU sendCommandAPDU(AppletID appletID, CommandAPDU commandAPDU) throws CardTerminalException, CardServiceException
Sends a CommandAPDU to the applet on the card that has the given application identifier.- Parameters:
appletID
- application identifier of destination appletcommandAPDU
- CommandAPDU to send- Returns:
- The resulting ResponseAPDU as received from the card.
- Throws:
CardTerminalException
CardServiceException
-
sendVerifiedAPDU
protected ResponseAPDU sendVerifiedAPDU(CardChannel channel, AppletID appletID, CommandAPDU verificationAPDU, CHVControl chvControl, int timeout) throws CardServiceException, CardTerminalException
Send a verify CHV command APDU to the card applet with the given application identifier after filling in the password obtained from the CHV dialog currently associated with this card service.- Parameters:
channel
- The CardChannel to be used for sending the command APDU.appletID
- The application identifier of the applet to which the verification APDU shall be sent.verificationAPDU
- The command APDU for password verification into which the password shall be inserted.chvControl
- The CHV control to be used for password input.timeout
- The timeout to be used.- Returns:
- The response APDU returned by the card as response to the verify password command.
- Throws:
CardServiceException
CardTerminalException
-
setAppletSelector
protected void setAppletSelector(AppletSelector s)
Set the applet selector.Subclasses may need to redefine the way applet selection is performed. They can do that by specifying a class implementing "AppletSelector" and call setAppletSelector with a new helper object that will be used in place of the default ISO implementation.
-
-