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

com.ibm.opencard.service
Class MFCChannelState

java.lang.Object
  |
  +--com.ibm.opencard.service.MFCChannelState

public class MFCChannelState
extends java.lang.Object

The smartcard's internal state, as seen through a logical channel. Every smartcard maintains an internal state, consisting of at least the selected directory and some permanent access conditions, namely CHV and authentication. If a card provides several logical channels for communication, only a part of this state is relevant for a service that uses this channel.
This class represents the internal state, as it is seen through one logical channel. If there are several channels, there could be another class that represents the global part of the state, which would be accessed from here. However, the current MFC cards do not support logical channels, so there is no such class.
The state represented here consist of the selected directory and file, the file cache, and information on the currently selected file. Access conditions are not represented, since we do not want to re-program the Card OS. Instead, commands are issued following an optimistic approach: The card will tell us if the access conditions are not satisfied.
The file cache found here is a candidate for a global state if there are logical channels. Obviously, the file cache does not represent the full hierarchical directory structure found on the card, but only the part of it that has been accessed by now.

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

Constructor Summary
MFCChannelState()
          Creates a new channel state.
 
Method Summary
 void cacheObjectInfo(CardFilePath obj, MFCCardObjectInfo info)
          Stores object information in the cache.
 MFCCardObjectInfo getCurrentInfo()
          Gets the information about the current selection.
 CardFilePath getCurrentPath()
          Gets the current path.
 MFCCardObjectInfo lookupObjectInfo(CardFilePath obj)
          Retrieves object information from the cache.
 void removeObjectInfo(CardFilePath obj)
          Removes object information from the cache.
 void setCurrentInfo(MFCCardObjectInfo info)
          Sets the object information about the current selection.
 void setCurrentPath(CardFilePath path)
          Sets the current path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MFCChannelState

public MFCChannelState()
Creates a new channel state.
Method Detail

setCurrentPath

public final void setCurrentPath(CardFilePath path)
Sets the current path. The information about the current selection gets implicitly reset to null.
Parameters:
path - the currently selected directory or file, or null to invalidate
See Also:
getCurrentPath(), getCurrentInfo(), setCurrentInfo(com.ibm.opencard.service.MFCCardObjectInfo)

getCurrentPath

public final CardFilePath getCurrentPath()
Gets the current path.
Returns:
the path to the currently selected object on the card, or null if not set
See Also:
setCurrentPath(opencard.opt.iso.fs.CardFilePath), setCurrentInfo(com.ibm.opencard.service.MFCCardObjectInfo)

setCurrentInfo

public final void setCurrentInfo(MFCCardObjectInfo info)
Sets the object information about the current selection. The current selection can be a file, a directory, a key, and so on. Depending on the kind of selected object, an information structure derived from MFCCardObjectInfo can be stored here.
The generic card service implementation uses this method to store information after a select has been performed. It uses an object passed to it's constructor to parse the smartcard's response to the command. It is a card service factory's responsibility to supply a parser that generates the information that will be needed by the respective service after a select has been performed. For example, a file service will require file information in which the record size of a structured file can be queried.
If a select command fails, the information should be set to null to avoid a mismatch between current selection and current information. This can be achieved by setting a new current path, which will implicitly clear the current info.
Parameters:
info - information about the current selection
See Also:
getCurrentInfo()

getCurrentInfo

public final MFCCardObjectInfo getCurrentInfo()
Gets the information about the current selection.
Returns:
the information set with setCurrentInfo, or null if none is set
See Also:
setCurrentInfo(com.ibm.opencard.service.MFCCardObjectInfo)

lookupObjectInfo

public final MFCCardObjectInfo lookupObjectInfo(CardFilePath obj)
Retrieves object information from the cache.
Parameters:
obj - a card file path as object identifier
Returns:
the object information, or null on cache miss

cacheObjectInfo

public final void cacheObjectInfo(CardFilePath obj,
                                  MFCCardObjectInfo info)
Stores object information in the cache.
Parameters:
obj - a file path as object identifier
info - the information to store

removeObjectInfo

public final void removeObjectInfo(CardFilePath obj)
Removes object information from the cache.
Parameters:
key - a card file path as object identifier