Package org.jmrtd
Class DefaultFileSystem
- java.lang.Object
-
- org.jmrtd.DefaultFileSystem
-
- All Implemented Interfaces:
net.sf.scuba.smartcards.FileSystemStructured
public class DefaultFileSystem extends Object implements net.sf.scuba.smartcards.FileSystemStructured
A file system for ICAO MRTDs (and similar file systems). This translates abstract high level selection and read binary commands to concrete low level file related APDUs which are sent to the ICC through the card service.- Since:
- 0.7.0
- Version:
- $Revision: 1799 $
- Author:
- The JMRTD team ([email protected])
-
-
Field Summary
Fields Modifier and Type Field Description static int
NO_SFI
Invalid short identifier.
-
Constructor Summary
Constructors Constructor Description DefaultFileSystem(APDULevelReadBinaryCapable service, boolean isSFIEnabled)
Creates a file system.DefaultFileSystem(APDULevelReadBinaryCapable service, boolean isSFIEnabled, Map<Short,Byte> fidToSFI)
Creates a file system.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description net.sf.scuba.smartcards.FileInfo[]
getSelectedPath()
Returns the selected path.byte[]
readBinary(int offset, int length)
Reads a block of bytes.void
selectFile(short fid)
Selects a file.byte[]
sendReadBinary(int offset, int le, boolean isTLVEncodedOffsetNeeded)
Sends aREAD BINARY
command using a short file identifier to the passport, using the wrapper when a secure channel has been set up.byte[]
sendReadBinary(int sfi, int offset, int le, boolean isTLVEncodedOffsetNeeded)
Sends aREAD BINARY
command using a short file identifier to the passport, using the wrapper when a secure channel has been set up.void
sendSelectFile(short fid)
Selects a file within the MRTD application.void
setWrapper(net.sf.scuba.smartcards.APDUWrapper wrapper)
Sets the current wrapper to the given APDU wrapper.
-
-
-
Field Detail
-
NO_SFI
public static final int NO_SFI
Invalid short identifier.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DefaultFileSystem
public DefaultFileSystem(APDULevelReadBinaryCapable service, boolean isSFIEnabled)
Creates a file system.- Parameters:
service
- the card service supporting low-levelSELECT
and/orREAD BINARY
commandsisSFIEnabled
- whether the file system should use short file identifiers inREAD BINARY
commands
-
DefaultFileSystem
public DefaultFileSystem(APDULevelReadBinaryCapable service, boolean isSFIEnabled, Map<Short,Byte> fidToSFI)
Creates a file system.- Parameters:
service
- the card service supporting low-levelSELECT
and/orREAD BINARY
commandsisSFIEnabled
- whether the file system should use short file identifiers inREAD BINARY
commandsfidToSFI
- maps file identifiers to short file identifiers
-
-
Method Detail
-
setWrapper
public void setWrapper(net.sf.scuba.smartcards.APDUWrapper wrapper)
Sets the current wrapper to the given APDU wrapper. Subsequent APDUs will be wrapped before sending to the ICC.- Parameters:
wrapper
- an APDU wrapper
-
getSelectedPath
public net.sf.scuba.smartcards.FileInfo[] getSelectedPath() throws net.sf.scuba.smartcards.CardServiceException
Returns the selected path.- Specified by:
getSelectedPath
in interfacenet.sf.scuba.smartcards.FileSystemStructured
- Returns:
- the path components
- Throws:
net.sf.scuba.smartcards.CardServiceException
- on error
-
selectFile
public void selectFile(short fid) throws net.sf.scuba.smartcards.CardServiceException
Selects a file.- Specified by:
selectFile
in interfacenet.sf.scuba.smartcards.FileSystemStructured
- Parameters:
fid
- indicates the file to select- Throws:
net.sf.scuba.smartcards.CardServiceException
- on error communicating over the service
-
readBinary
public byte[] readBinary(int offset, int length) throws net.sf.scuba.smartcards.CardServiceException
Reads a block of bytes.- Specified by:
readBinary
in interfacenet.sf.scuba.smartcards.FileSystemStructured
- Parameters:
offset
- offset index in the selected filelength
- the number of bytes to read- Returns:
- a copy of the bytes read
- Throws:
net.sf.scuba.smartcards.CardServiceException
- on error
-
sendSelectFile
public void sendSelectFile(short fid) throws net.sf.scuba.smartcards.CardServiceException
Selects a file within the MRTD application.- Parameters:
fid
- a file identifier- Throws:
net.sf.scuba.smartcards.CardServiceException
- on error
-
sendReadBinary
public byte[] sendReadBinary(int offset, int le, boolean isTLVEncodedOffsetNeeded) throws net.sf.scuba.smartcards.CardServiceException
Sends aREAD BINARY
command using a short file identifier to the passport, using the wrapper when a secure channel has been set up.- Parameters:
offset
- offset into the filele
- the expected length of the file to readisTLVEncodedOffsetNeeded
- whether to encode the offset in a TLV object (typically for offset larger than 32767)- Returns:
- a byte array of length
le
with (the specified part of) the contents of the currently selected file - Throws:
net.sf.scuba.smartcards.CardServiceException
- on tranceive error
-
sendReadBinary
public byte[] sendReadBinary(int sfi, int offset, int le, boolean isTLVEncodedOffsetNeeded) throws net.sf.scuba.smartcards.CardServiceException
Sends aREAD BINARY
command using a short file identifier to the passport, using the wrapper when a secure channel has been set up.- Parameters:
sfi
- the short file identifier byte as int value (between 0 and 255)offset
- offset into the filele
- the expected length of the file to readisTLVEncodedOffsetNeeded
- whether to encode the offset in a TLV object (typically for offset larger than 32767)- Returns:
- a byte array of length
le
with (the specified part of) the contents of the currently selected file - Throws:
net.sf.scuba.smartcards.CardServiceException
- on tranceive error
-
-