com.ibm.opencard.service
Class MFC35CardServiceImpl
java.lang.Object
|
+--com.ibm.opencard.service.MFC35CardServiceImpl
- Direct Known Subclasses:
- MFC41CardServiceImpl
- public class MFC35CardServiceImpl
- extends java.lang.Object
- implements MFCCardServiceImpl
Implementation of generic card services for MFC 3.5 and some above.
This class is stateless, one object can be used by as many card services
as required, and for as many smartcards as required.
- Version:
- $Id: MFC35CardServiceImpl.java,v 1.1 1999/12/02 16:06:06 damke Exp $
|
Method Summary |
protected void |
clearPath()
Clear the path stored. |
protected CardFilePath |
determinePath(MFCChannelState state,
CardChannel channel)
Determines the currently selected path.
|
protected ResponseAPDU |
doneSelect(MFCCardChannel chan)
Finish the select operation initiated by initSelect.
|
protected void |
execCommand(MFCCardChannel chan,
CommandAPDU apdu)
Execute a ready-to-use command, given by the CommandAPDU.
|
protected void |
execSelect(MFCCardChannel chan,
boolean info)
Select the path that is stored by now.
|
protected void |
initSelect(boolean info)
Initialize a select operation.
|
protected void |
nextSelect(MFCCardChannel chan,
CardFilePathComponent comp)
Add a path component to the current select operation.
|
protected ResponseAPDU |
performSelect(MFCCardChannel channel,
CardFilePath path,
boolean info)
Perform a select operation for the given path. |
MFCCardObjectInfo |
selectObject(MFCCardChannel channel,
CardFilePath path,
boolean info,
MFCSelectResponseParser srparser)
Select an object on the smartcard.
|
protected void |
sendSelectAPDU(MFCCardChannel channel,
boolean info)
Send a select command to the smartcard.
|
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
mfc_codes
protected MFCCodes mfc_codes
- The class and instruction codes for the MFC commands.
p1_file_id
protected byte p1_file_id
- The P1 byte for selection by a single file ID.
p1_path_abs
protected byte p1_path_abs
- The P1 byte for selection by an absolute path.
p1_path_rel
protected byte p1_path_rel
- The P1 byte for selection by a relative path.
p2_select_info
protected byte p2_select_info
- The P2 byte for a select that returns the file header.
p2_select_quiet
protected byte p2_select_quiet
- The P2 byte for a select that does not return anything.
path_component
protected short[] path_component
path_length
protected int path_length
path_absolute
protected boolean path_absolute
path_error
protected boolean path_error
info_required
protected boolean info_required
last_response
protected ResponseAPDU last_response
select_apdu
protected CommandAPDU select_apdu
- A re-usable command APDU for select.
It gets initialized on initSelect,
is used by execSelect, and must be
reset to length 2 immediately after using it.
- See Also:
initSelect(boolean),
execSelect(com.ibm.opencard.service.MFCCardChannel, boolean)
MFC35CardServiceImpl
public MFC35CardServiceImpl(MFCCodes codes)
- Creates a new generic card service implementation for MFC 3.5 and above.
This implementation is parameterized by the command codes, so it can
be used for MFC cards other than 3.5.
- Parameters:
codes - the CLAss and INStruction codes
determinePath
protected final CardFilePath determinePath(MFCChannelState state,
CardChannel channel)
- Determines the currently selected path.
The path stored in the channel state may be invalid, if another
service has performed a SELECT operation. This is checked via
the state object that can be found in the channel itself. This
service stores a tag object there. If another service changes
the channel state, this will be detected. The other service's
state will be overwritten by the tag object again.
This mechanism will not detect state invalidations by services
like opencard.opt.util.PassThruCardService, that do
not store a state.
- Parameters:
state - the state from which to take the pathchannel - the channel to check for dirty indication- Returns:
- the path that is currently selected,
or null if unknown
- See Also:
PassThruCardService
clearPath
protected final void clearPath()
- Clear the path stored.
initSelect
protected void initSelect(boolean info)
- Initialize a select operation.
A call to this method will be followed by one or more calls
to nextSelect for the path components, and at last
a call to doneSelect. The last response received
from the smartcard will be returned by doneSelect.
If info is true on invocation of this method, the
smartcard's response will include the header of the selected
file or directory, otherwise not.
- Parameters:
info - true if the file info must be evaluated- See Also:
nextSelect(com.ibm.opencard.service.MFCCardChannel, opencard.opt.iso.fs.CardFilePathComponent),
doneSelect(com.ibm.opencard.service.MFCCardChannel)
nextSelect
protected void nextSelect(MFCCardChannel chan,
CardFilePathComponent comp)
throws CardTerminalException
- Add a path component to the current select operation.
If necessary, a command with the previously added components
will be sent to the smartcard. The component passed as an
argument will never be part of the select operation
that is performed. This ensures that a command with at least
one path component is sent to the smartcard on invocation of
doneSelect. The commands sent before can therefore
be quiet selects.
The MFC 3.5 and 4.0 supports selection by file ID only.
Short file identifiers are converted to the full file ID.
If other types of path components must be supported, derived
classes may override this method. It may be necessary to
override execSelect, too.
- Parameters:
chan - the contact to the smartcardcomp - the path component to add- Throws:
- CardTerminalException - if the terminal encountered an error
- See Also:
doneSelect(com.ibm.opencard.service.MFCCardChannel),
execSelect(com.ibm.opencard.service.MFCCardChannel, boolean)
doneSelect
protected ResponseAPDU doneSelect(MFCCardChannel chan)
throws CardTerminalException
- Finish the select operation initiated by initSelect.
This method will invoke execSelect to perform the select
operation for the last components stored by nextSelect.
The implementation of nextSelect ensures that there is
at least one component that still has to be selected.
- Returns:
- the last response received from the smartcard
- Throws:
- CardTerminalException - if the terminal encountered an error
- See Also:
execSelect(com.ibm.opencard.service.MFCCardChannel, boolean),
nextSelect(com.ibm.opencard.service.MFCCardChannel, opencard.opt.iso.fs.CardFilePathComponent)
execCommand
protected void execCommand(MFCCardChannel chan,
CommandAPDU apdu)
throws CardTerminalException
- Execute a ready-to-use command, given by the CommandAPDU.
The command is send directly without any validation/verification
or interpretation to the card.
- Parameters:
chan - the channel to the smartcardapdu - the CommandAPDU, containing a ready-to-use Command sequence
execSelect
protected void execSelect(MFCCardChannel chan,
boolean info)
throws CardTerminalException
- Select the path that is stored by now.
path_length holds the number of file IDs in the path,
the IDs are stored in path_component. If the path is
an absolute path from the master file, path_absolute
is true, otherwise it is false.
- Parameters:
chan - the channel to the smartcardinfo - true if the file info is needed- Throws:
- CardTerminalException - if the terminal encountered an error
- See Also:
nextSelect(com.ibm.opencard.service.MFCCardChannel, opencard.opt.iso.fs.CardFilePathComponent),
doneSelect(com.ibm.opencard.service.MFCCardChannel)
sendSelectAPDU
protected void sendSelectAPDU(MFCCardChannel channel,
boolean info)
throws CardTerminalException
- Send a select command to the smartcard.
The command has to be stored in select_apdu. Before sending
the APDU, a zero Le byte will be appended if needsZeroLe of
the MFCCodes specifies so. The response will be stored in
last_response.
If an error occurs executing the command, path_error
is set to true. If path_error is already
true, nothing will be sent. The command APDU gets reset to
length 2 in any case.
- Parameters:
channel - how to contact the smartcardinfo - whether information should be returned- Throws:
- CardTerminalException - if the terminal encountered an error
- See Also:
select_apdu,
last_response,
path_error,
MFCCodes,
MFCCodes.needsZeroLe()
performSelect
protected ResponseAPDU performSelect(MFCCardChannel channel,
CardFilePath path,
boolean info)
throws CardServiceObjectNotAvailableException,
CardTerminalException
- Perform a select operation for the given path.
- Parameters:
channel - how to contact the smartcardpath - what to selectinfo - whether file info is needed- Returns:
- The response from the smartcard.
If info was true, and no error occured,
it includes the file header.
- Throws:
- CardServiceObjectNotAvailableException - the target could not be selected
- CardTerminalException - if the terminal encountered an error
selectObject
public MFCCardObjectInfo selectObject(MFCCardChannel channel,
CardFilePath path,
boolean info,
MFCSelectResponseParser srparser)
throws CardServiceObjectNotAvailableException,
CardServiceUnexpectedResponseException,
CardTerminalException
- Select an object on the smartcard.
Optionally return file information.
- Specified by:
- selectObject in interface MFCCardServiceImpl
- Parameters:
channel - how to contact the smartcardpath - what to selectinfo - whether to return information, true if sosrparser - helper that interprets the select response,
may be null if no info is returned- Returns:
- information on the selected object, if requested
- Throws:
- CardServiceObjectNotAvailableException - if the target could not be selected
- CardServiceUnexpectedResponseException - if the select response could not be parsed correctly
- CardTerminalException - if the terminal encountered a problem
|