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

com.ibm.opencard.service
Class MFC35ObjectSRParser

java.lang.Object
  |
  +--com.ibm.opencard.service.MFC35ObjectSRParser
Direct Known Subclasses:
MFC35FileSRParser

public class MFC35ObjectSRParser
extends java.lang.Object
implements MFCSelectResponseParser

A select response parser for generic select commands. This parser decodes the access information contained in a typical MFC select response to a file or directory. It also determines whether the object is an elementary file or a directory. It does not parse any additional file or directory information.

This class is rather a sample implementation of the interface MFCSelectResponseParser than useful in itself. Typically, the object info will be extended to include file or key information. An appropriate select response parse will be required, which may look very much like this one, or may even extend this one.

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

Field Summary
protected  MFCAccessParser access_parser
          The underlying parser for access conditions.
protected static byte FILE_HEADER_TAG
          The standard ASN.1 tag for a MFC file header.
protected static byte FT_DF_NOASC
          The file type DF without ASC execution.
protected static byte FT_DF_WITHASC
          The file type DF with ASC execution.
 
Constructor Summary
MFC35ObjectSRParser(MFCAccessParser accpar)
          Instantiates a generic select response parser for MFC 3.5 and above.
 
Method Summary
protected  void parseObjectHeader(MFCCardObjectInfo info, byte[] header)
          Parses an object header and sets up information accordingly.
 MFCCardObjectInfo parseSelectResponse(byte[] response)
          Interprets a smartcard's response to a select command.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILE_HEADER_TAG

protected static final byte FILE_HEADER_TAG
The standard ASN.1 tag for a MFC file header.

FT_DF_NOASC

protected static final byte FT_DF_NOASC
The file type DF without ASC execution.

FT_DF_WITHASC

protected static final byte FT_DF_WITHASC
The file type DF with ASC execution.

access_parser

protected MFCAccessParser access_parser
The underlying parser for access conditions.
Constructor Detail

MFC35ObjectSRParser

public MFC35ObjectSRParser(MFCAccessParser accpar)
Instantiates a generic select response parser for MFC 3.5 and above.
Parameters:
accpar - the parser for access information
Method Detail

parseSelectResponse

public MFCCardObjectInfo parseSelectResponse(byte[] response)
                                      throws BadHeaderException
Interprets a smartcard's response to a select command. This method is required in the interface MFCSelectResponseParser. The implementation here just parses the access information encoded in a standard MFC select response and checks whether a dedicated file was selected.
Specified by:
parseSelectResponse in interface MFCSelectResponseParser
Parameters:
response - the response data sent by the smartcard
Returns:
the generic information gathered from the smartcard's response
Throws:
BadHeaderException - the response could not be parsed correctly

parseObjectHeader

protected void parseObjectHeader(MFCCardObjectInfo info,
                                 byte[] header)
                          throws BadHeaderException
Parses an object header and sets up information accordingly. Actually, all objects on a MFC smartcard are files. The term object is used since only part of the file header information is evaluated here.
This method must be invoked exactly once for a particular object (or derived) info. Before the invocation, the information is not set up appropriately. It is not possible to re-use object information by invoking this method a second time with a different header.
Parameters:
info - the information object to initialize
header - the information in an encoded form
Throws:
BadHeaderException - the header could not be parsed