OpenCard  
 
OCF, the OpenCard Framework is a standard Java framework for working with Smart Cards.  
 

com.ibm.opencard.script
Class MFCScriptService

java.lang.Object
  |
  +--opencard.core.service.CardService
        |
        +--com.ibm.opencard.service.MFCCardService
              |
              +--com.ibm.opencard.script.MFCScriptService

public class MFCScriptService
extends MFCCardService
implements ServiceProvider, APDUSender

A card service executing scripts generated by IBM's smart card toolkit. This script card service uses handlers to execute most of the requests composing a script. The requests handled directly here are those to execute a procedure defined in the script, and those to send an APDU to the smartcard. The handlers that execute the rest of the orders have to do their job themselfes, or may use a card service that is an instance of MFCCardService. This restriction is the reason for the MFC prefix in the class name.

Version:
$Id: MFCScriptService.java,v 1.1 1999/12/02 16:06:05 damke Exp $

Fields inherited from class com.ibm.opencard.service.MFCCardService
card_type
 
Constructor Summary
MFCScriptService()
          Default constructor.
 
Method Summary
protected  void allocateChannel()
          Allocates a card channel.
 void executeOrder(java.lang.String order, Script script, Dictionary dictionary, TLVBuffer blackboard)
          Executes a given order within a script.
 MFCCardService getService(java.lang.Class clazz)
          Returns a MFC card service of the requested class.
protected  void initHandlerChain()
          Initializes the handler chain of this script card service.
protected  void initialize(CardServiceScheduler scheduler, SmartCard smartcard, boolean blocking)
          Initializes this script card service.
protected  void releaseChannel()
          Releases a card channel.
 ResponseAPDU sendCommand(CommandAPDU command)
          Sends a command to the smartcard and returns the response.
 
Methods inherited from class com.ibm.opencard.service.MFCCardService
allocateCardChannel, checkFileArg, getMFCChannel, getRoot, initGeneric, provideCredentials, releaseCardChannel, selectObject, setCHVDialog, setParentChannel
 
Methods inherited from class opencard.core.service.CardService
getCard, getCardChannel, getCHVDialog, setCardChannel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MFCScriptService

public MFCScriptService()
Default constructor. Before the created service can actually be used, initialize has to be invoked.
See Also:
initialize(opencard.core.service.CardServiceScheduler, opencard.core.service.SmartCard, boolean)
Method Detail

initialize

protected void initialize(CardServiceScheduler scheduler,
                          SmartCard smartcard,
                          boolean blocking)
                   throws CardServiceException
Initializes this script card service. This method invokes initGeneric in the base class. Then, it instantiates the handler chain. Note that the base class will not be fully initialized. The select operation defined there will not be available for this service.
Parameters:
scheduler - where to allocate channels
smartcard - which smartcard to contact
blocking - whether operation shall be blocking
Throws:
CardServiceException - never thrown
Overrides:
initialize in class MFCCardService
See Also:
MFCCardService.initialize(opencard.core.service.CardServiceScheduler, opencard.core.service.SmartCard, boolean), initHandlerChain()

initHandlerChain

protected final void initHandlerChain()
Initializes the handler chain of this script card service. The handlers are needed for most of the request types that can be found in a script. The handlers that should be instantiated can be specified in the property OpenCard.IBM.Handler. The default value for this property is defined in default_handlers.
If handlers to be loaded cannot be initialized, this is reported via the trace mechanism. However, no exception is thrown and no other kind of error is reported, since this script service may be able to execute a script anyway, if that script does not contain requests for which the missing handlers are needed.
Of course, the reasons for this error behavior includes the US export restrictions. There is a handler for cryptographic operations, which may not be exported.
See Also:
#default_handlers

allocateChannel

protected void allocateChannel()
Allocates a card channel. The channel is passed to all child services that have been allocated by the handlers.

releaseChannel

protected void releaseChannel()
Releases a card channel. All child services are informed that the channel is no longer allocated.

getService

public MFCCardService getService(java.lang.Class clazz)
                          throws CardServiceException
Returns a MFC card service of the requested class. The service is registered, and will be prepared for use before the handler chain is invoked. This method is meant to be invoked only by the handlers in the handler chain of this service.
If the requested service interface is APDUSender, or any other class implemented by this script service, a reference to this is returned.
Specified by:
getService in interface ServiceProvider
Parameters:
clazz - the class of the requested service, has to be a subclass of MFCCardService
Returns:
an instance of the requested MFC card service, or null if it could not be found
Throws:
CardServiceException - if the requested service was found, but could not be obtained
See Also:
com.ibm.opencard.handler.APDUSender

sendCommand

public final ResponseAPDU sendCommand(CommandAPDU command)
                               throws CardTerminalException
Sends a command to the smartcard and returns the response. This method is required by the interface APDUSender. It should only be invoked by the handlers in the handler chain, and only while a script is executed.
Specified by:
sendCommand in interface APDUSender
Parameters:
command - the command to send to the smartcard
Returns:
the response from the smartcard
Throws:
CardTerminalException - the underlying terminal encountered an error when communicating with the smartcard
See Also:
com.ibm.opencard.handler.APDUSender

executeOrder

public void executeOrder(java.lang.String order,
                         Script script,
                         Dictionary dictionary,
                         TLVBuffer blackboard)
                  throws CardServiceException,
                         CardTerminalException
Executes a given order within a script. Optionally, a dictionary and a blackboard can be passed.
Parameters:
order - the name of the script procedure to be executed
script - the script containing the procedure that shall be executed, and all subprocedures invoked from there
dictionary - the dictionary to be used, null if none
blackboard - the blackbaord to be used, null if none
Throws:
CardServiceException - if an error was encountered while interpreting the script or while trying to handle a request in the script
CardTerminalException - if the terminal encountered an error while communicating with the smartcard in order to execute a request in the script