com.ibm.opencard.isofs
Class MFCFileAccess
java.lang.Object
|
+--opencard.core.service.CardService
|
+--com.ibm.opencard.service.MFCCardService
|
+--com.ibm.opencard.isofs.MFCFileAccess
- Direct Known Subclasses:
- MFCFileSystem
- public class MFCFileAccess
- extends MFCCardService
- implements FileAccessCardService
A file access service for MFC smartcards.
It provides methods for reading and updating smartcard files.
- Version:
- $Id: MFCFileAccess.java,v 1.1 1999/12/02 16:06:04 damke Exp $
|
Constructor Summary |
MFCFileAccess()
Creates a new MFC file access card service.
|
|
Method Summary |
void |
appendRecord(CardFilePath file,
byte[] data)
|
byte[] |
decrease(CardFilePath file,
int delta)
Decreases the value stored in a record of a structured file.
|
boolean |
exists(CardFilePath file)
Checks whether a file or directory exists on the smartcard.
|
CardFileInfo |
getFileInfo(CardFilePath file)
Returns information about a file on the smartcard.
|
byte[] |
increase(CardFilePath file,
int delta)
Increases the value stored in a record of a structured file.
|
void |
initFileAccess(MFCFileParameter parameter)
Initializes this service from encapsulated parameters.
|
protected void |
initialize(CardServiceScheduler scheduler,
SmartCard smartcard,
boolean blocking)
Initializes this service.
|
byte[] |
read(CardFilePath file,
int offset,
int length)
Reads data from a transparent smartcard file. |
byte[] |
readRecord(CardFilePath file,
int record)
Reads data from a structured smartcard file. |
byte[][] |
readRecords(CardFilePath file,
int number)
Reads data from a structured, cyclic file.
|
MFCFileInfo |
selectFile(CardFilePath file)
Selects a file or directory on the smartcard.
|
void |
write(CardFilePath file,
int foffset,
byte[] source)
Writes a complete array to a transparent smartcard file.
|
void |
write(CardFilePath file,
int foffset,
byte[] source,
int soffset,
int length)
Writes data to a transparent smartcard file. |
void |
writeRecord(CardFilePath file,
int record,
byte[] source)
Writes data to a structured smartcard file.
|
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
file_access_impl
protected MFCFileAccessImpl file_access_impl
- The file system card service implementation to use.
MFCFileAccess
public MFCFileAccess()
- Creates a new MFC file access card service.
Before the service can actually be used, it has to be initialized
by invoking initialize. If this service has to be initialized
as part of a derived service, initFileAccess has to be
invoked instead.
- See Also:
initialize(opencard.core.service.CardServiceScheduler, opencard.core.service.SmartCard, boolean),
initFileAccess(com.ibm.opencard.isofs.MFCFileParameter)
initialize
protected void initialize(CardServiceScheduler scheduler,
SmartCard smartcard,
boolean blocking)
throws CardServiceException
- Initializes this service.
This is an entry point for initializing the MFC file access card
service. It invokes initFileAccess to perform the actual
initialization. Derived services must not invoke this method, but
have to invoke initFileAccess directly.
- Parameters:
scheduler - where to allocate channelssmartcard - which smartcard to contactblocking - whether operation shall be blocking- Overrides:
- initialize in class MFCCardService
- See Also:
initFileAccess(com.ibm.opencard.isofs.MFCFileParameter),
MFCCardService.initialize(opencard.core.service.CardServiceScheduler, opencard.core.service.SmartCard, boolean)
initFileAccess
public final void initFileAccess(MFCFileParameter parameter)
throws CardServiceException
- Initializes this service from encapsulated parameters.
This method initializes the local attributes and invokes
initGeneric in the base class.
- Parameters:
parameter - an object encapsulating the parameters to this service- Throws:
- CardServiceException - if the initialization failed.
With the current implementation, this cannot happen.
- See Also:
MFCFileParameter,
MFCCardService.initGeneric(com.ibm.opencard.service.MFCCardServiceParameter)
selectFile
public final MFCFileInfo selectFile(CardFilePath file)
throws CardServiceObjectNotAvailableException,
CardServiceUnexpectedResponseException,
CardTerminalException
- Selects a file or directory on the smartcard.
The implementation of this method is provided by the base class,
MFCCardService. This file card service uses a file info
parser to interpret the card's response to the SELECT command, so
file or directory specific information will be available.
- Parameters:
file - the file or directory to select- Returns:
- information about the object that has been selected
- Throws:
- CardServiceObjectNotAvailableException - if the target could not be selected
- CardServiceUnexpectedResponseException - if the select response could not be parsed, or
an unexpected error status was reported
- CardTerminalException - if the terminal encountered an error
- See Also:
MFCCardService.selectObject(com.ibm.opencard.service.MFCCardChannel, opencard.opt.iso.fs.CardFilePath, boolean),
MFC35FileSRParser,
MFCFileInfo
exists
public final boolean exists(CardFilePath file)
throws CardServiceUnexpectedResponseException,
CardTerminalException
- Checks whether a file or directory exists on the smartcard.
The target will be selected, without requesting information.
If the select succeeds, the target exists and true
is returned.
- Specified by:
- exists in interface FileAccessCardService
- Parameters:
file - the file or directory to check for- Returns:
- true if the file or directory exists,
false if not
- Throws:
- CardServiceUnexpectedResponseException - if the card reported an unexpected error status
- CardTerminalException - if the terminal encountered an error
getFileInfo
public CardFileInfo getFileInfo(CardFilePath file)
throws CardServiceObjectNotAvailableException,
CardServiceUnexpectedResponseException,
CardTerminalException
- Returns information about a file on the smartcard.
The information can be used to determine whether the file is a
dedicated file, transparent, structured, and so on. Some other
information, for example the file size or an optional record
size, can be queried, too.
- Specified by:
- getFileInfo in interface FileAccessCardService
- Parameters:
file - the file or directory about which to return information- Returns:
- information about the specified target
- Throws:
- CardServiceObjectNotAvailableException - if the target could not be selected
- CardServiceUnexpectedResponseException - if the select response could not be parsed, or
an unexpected error status was reported
- CardTerminalException - if the terminal encountered an error
read
public byte[] read(CardFilePath file,
int offset,
int length)
throws CardServiceException,
CardTerminalException
- Reads data from a transparent smartcard file.
- Specified by:
- read in interface FileAccessCardService
- Parameters:
file - the file to read fromoffset - index of first byte to readlength - number of bytes to read- Returns:
- the data read in a byte array
- Throws:
- CardServiceException - if anything went wrong
- CardTerminalException - if the terminal encountered an error
readRecord
public byte[] readRecord(CardFilePath file,
int record)
throws CardServiceException,
CardTerminalException
- Reads data from a structured smartcard file.
- Specified by:
- readRecord in interface FileAccessCardService
- Parameters:
file - the file to read fromrecord - the record to read (0 for first)- Returns:
- the data read in a byte array
- Throws:
- CardServiceException - if anything went wrong
- CardTerminalException - if the terminal encountered an error
readRecords
public byte[][] readRecords(CardFilePath file,
int number)
throws CardServiceException,
CardTerminalException
- Reads data from a structured, cyclic file.
This method reads the first records from a structured file.
It is especially intended for reading cyclic files.
- Specified by:
- readRecords in interface FileAccessCardService
- Parameters:
file - the file to read fromnumber - the number of records to read- Throws:
- CardServiceException - if anything went wrong
- CardTerminalException - if the terminal encountered an error
write
public void write(CardFilePath file,
int foffset,
byte[] source,
int soffset,
int length)
throws CardServiceException,
CardTerminalException
- Writes data to a transparent smartcard file.
- Specified by:
- write in interface FileAccessCardService
- Parameters:
file - the file to write tofoffset - file index to start writing atsource - the data to writesoffset - array index of data to writelength - number of bytes to write- Throws:
- CardServiceException - if anything went wrong
- CardTerminalException - if the terminal encountered an error
write
public void write(CardFilePath file,
int foffset,
byte[] source)
throws CardServiceException,
CardTerminalException
- Writes a complete array to a transparent smartcard file.
This is a convenience method that requires less arguments,
but does not allow to write only parts of the source array.
- Specified by:
- write in interface FileAccessCardService
- Parameters:
file - the file to write tofoffset - file index to start writing atsource - the data to write- See Also:
write(opencard.opt.iso.fs.CardFilePath, int, byte[], int, int)
writeRecord
public void writeRecord(CardFilePath file,
int record,
byte[] source)
throws CardServiceException,
CardTerminalException
- Writes data to a structured smartcard file.
Structured smartcard files consist of records, usually with
a fixed record size. The byte array passed as data source to
this method must have exactly the size of the record to write.
- Specified by:
- writeRecord in interface FileAccessCardService
- Parameters:
file - the file to write torecord - the number of the record to write (0 for first)source - the data to write- Throws:
- CardServiceException - if anything went wrong
- CardTerminalException - if the terminal encountered an error
appendRecord
public void appendRecord(CardFilePath file,
byte[] data)
throws CardServiceException,
CardTerminalException
- Specified by:
- appendRecord in interface FileAccessCardService
increase
public byte[] increase(CardFilePath file,
int delta)
throws CardServiceException,
CardTerminalException
- Increases the value stored in a record of a structured file.
This operation is typically used for purse applications, in conjunction
with cyclic record files. The record updated is always the first one.
- Parameters:
file - the file in which to increase a record's valuedelta - the 3-byte amount by which to increase the value- Returns:
- the contents of the modified record after the operation
- Throws:
- CardServiceException - if anything went wrong
- CardTerminalException - if the terminal encountered an error
decrease
public byte[] decrease(CardFilePath file,
int delta)
throws CardServiceException,
CardTerminalException
- Decreases the value stored in a record of a structured file.
This operation is typically used for purse applications, in conjunction
with cyclic record files. The record updated is always the first one.
- Parameters:
file - the file in which to decrease a record's valuedelta - the 3-byte amount by which to decrease the value- Returns:
- the contents of the modified record after the operation
- Throws:
- CardServiceException - if anything went wrong
- CardTerminalException - if the terminal encountered an error
|