public class FileViewProvider extends Provider
Prerequisites: This Provider requires an ISO/IEC 7816-4 compliant file system on the SE. If this file system is implemented by an Applet within the SE then this Applet must be preselected before this Provider can be used, in case that the Applet is not default selected (e.g. the GSM Applet as default selected Applet on UICC)
Notes:
Modifier and Type | Class and Description |
---|---|
class |
FileViewProvider.FCP
File Control Parameter contain information of a selected file.
|
class |
FileViewProvider.Record
Record class serves as container for record data.
|
Modifier and Type | Field and Description |
---|---|
static int |
APPEND_RECORD
Indicates for record write operations that the record shell be appended.
|
static int |
CURRENT_FILE
Indicates for file operation methods that the currently selected file
shall be used for the file operation.
|
static int |
INFO_NOT_AVAILABLE
Indicates that the demanded information is not available.
|
Constructor and Description |
---|
FileViewProvider(Channel channel)
Encapsulates the defined channel by a FileViewProvider object that can be
used for performing file operations on it.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
readBinary(int sfi,
int offset,
int length)
Reads content of the selected transparent file at the position specified
by offset and length.
|
FileViewProvider.Record |
readRecord(int sfi,
int recNumber)
Returns the record which corresponds to the specified record number.
|
int[] |
searchRecord(int sfi,
byte[] searchPattern)
Returns the record numbers that contains the defined search pattern.
|
FileViewProvider.FCP |
selectByFID(int fileID)
Selects the file specified by the FID.
|
FileViewProvider.FCP |
selectByPath(java.lang.String path,
boolean fromCurrentDF)
Selects the file specified by a path.
|
FileViewProvider.FCP |
selectParent()
Selects the parent DF of the current DF.
|
void |
writeBinary(int sfi,
byte[] data,
int offset,
int length)
Writes the defined data into the selected file at the position specified
by offset and length.
|
void |
writeRecord(int sfi,
FileViewProvider.Record rec)
Writes a record into the specified file.
|
getChannel
public static final int CURRENT_FILE
public static final int INFO_NOT_AVAILABLE
public static final int APPEND_RECORD
public FileViewProvider(Channel channel) throws java.lang.IllegalStateException
Note: A file must be selected before a file operation can be performed. The file can be implicitly selected via a short file identifier (SFI) by the file operation method itself or explicitly by defining the file ID (FID) with selectByFID(int) or path with selectByPath(String, boolean).
channel
- The channel that shall be used by this Provider for file
operations.java.lang.IllegalStateException
- if the defined channel is closed.public FileViewProvider.FCP selectByPath(java.lang.String path, boolean fromCurrentDF) throws java.lang.IllegalStateException, java.lang.IllegalArgumentException, java.lang.SecurityException, java.lang.UnsupportedOperationException, java.io.IOException
Note:
path
- The path that references a file (DF or EF) on the Secure
Element. This path shall not contain the current DF or MF at the
beginning of the path.fromCurrentDF
- If true then the path is selected from the current
DF, if false then the path is selected from the MF.java.lang.IllegalStateException
- if the defined channel is closed.java.lang.IllegalArgumentException
- if the file couldn't be selected.
TODO: should be an IllegalReferenceErrorjava.lang.IllegalArgumentException
- if the defined path is invalid.java.lang.SecurityException
- if the operation is not allowed because the
security conditions are not satisfied.java.lang.UnsupportedOperationException
- if this operation is not supported.java.io.IOException
- Lower-lever API exception.public FileViewProvider.FCP selectByFID(int fileID) throws java.lang.IllegalStateException, java.lang.IllegalArgumentException, java.lang.SecurityException, java.lang.UnsupportedOperationException, java.io.IOException
Notes:
fileID
- The FID that references the file (DF or EF) on the Secure
Element. The FID must be in the range of (0x0000-0xFFFF).java.lang.IllegalStateException
- if the defined channel is closed.java.lang.IllegalArgumentException
- if the file couldn't be selected.
TODO: should be an IllegalReferenceErrorjava.lang.IllegalArgumentException
- if the defined fileID is not valid.java.lang.SecurityException
- if the operation is not allowed because the
security conditions are not satisfied.java.lang.UnsupportedOperationException
- if this operation is not supported.java.io.IOException
- Lower-lever API exception.public FileViewProvider.FCP selectParent() throws java.lang.IllegalStateException, java.lang.SecurityException, java.lang.UnsupportedOperationException, java.io.IOException
Note:
java.lang.IllegalStateException
- if the defined channel is closed.java.lang.IllegalArgumentException
- if the file couldn't be selected.
TODO: should be an IllegalReferenceErrorjava.lang.SecurityException
- if the operation is not allowed because the
security conditions are not satisfied.java.lang.UnsupportedOperationException
- if this operation is not supported.java.io.IOException
- Lower-lever API exception.public FileViewProvider.Record readRecord(int sfi, int recNumber) throws java.lang.IllegalStateException, java.lang.IllegalArgumentException, java.lang.SecurityException, java.lang.UnsupportedOperationException, java.io.IOException
Note: This method is based on the ISO/IEC 7816-4 command READ RECORD.
sfi
- The SFI of the file which shall be selected for this read
operation. CURRENT_FILE can be applied if the file is already
selected. The sfi must be in the range of (1-30).recNumber
- The record number that references the record that should
be read.java.lang.IllegalStateException
- if the used channel is closed, if no file
is currently selected, if the currently selected file is not a
record based file or if the record couldn't be read.java.lang.IllegalArgumentException
- if the file couldn't be selected via
SFI.
TODO: should be an IllegalReferenceErrorjava.lang.IllegalArgumentException
- if the defined sfi is not valid or if
the defined record ID is invalid.java.lang.SecurityException
- if the operation is not allowed because the
security conditions are not satisfied.java.lang.UnsupportedOperationException
- if this operation is not supported.java.io.IOException
- Lower-lever API exception.public void writeRecord(int sfi, FileViewProvider.Record rec) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException, java.lang.SecurityException, java.lang.UnsupportedOperationException, java.io.IOException
Note: This method is based on the ISO/IEC 7816-4 command APPEND RECORD and UPDATE RECORD (which replaces existing bytes).
sfi
- The SFI of the file which shall be selected for this write
operation. CURRENT_FILE can be applied if the file is already
selected. The SFI must be in the range of (1-30).rec
- The Record that shall be written.java.lang.IllegalStateException
- if the used channel is closed, if no file
is currently selected, if the currently selected file is not a
record based file or if the record couldn't be written.java.lang.IllegalArgumentException
- if the file couldn't be selected via
SFI.
TODO: should be an IllegalReferenceErrorjava.lang.IllegalArgumentException
- if the defined Record is invalid, if the
defined SFI is not valid.java.lang.SecurityException
- if the operation is not allowed because the
security conditions are not satisfied.java.lang.UnsupportedOperationException
- if this operation is not supported.java.io.IOException
- Lower-lever API exception.public int[] searchRecord(int sfi, byte[] searchPattern) throws java.lang.IllegalStateException, java.lang.IllegalArgumentException, java.lang.SecurityException, java.lang.UnsupportedOperationException, java.io.IOException
Note:This method is based on the ISO/IEC 7816-4 command SEARCH RECORD with simple search.
sfi
- The SFI of the file which shall be selected for this search
operation. CURRENT_FILE can be applied if the file is already
selected. The sfi must be in the range of (1-30).searchPattern
- The pattern that shall match with Records.java.lang.IllegalStateException
- if the used channel is closed, if no file
is currently selected, if the currently selected file is not a
record based file or if the data couldn't be searched.java.lang.IllegalArgumentException
- if the file couldn't be selected via
SFI.
TODO: should be an IllegalReferenceErrorjava.lang.IllegalArgumentException
- if the defined SFI is not valid, if the
search pattern is empty or if the search pattern is too long.java.lang.SecurityException
- if the operation is not allowed because the
security conditions are not satisfied.java.lang.UnsupportedOperationException
- if this operation is not supported.java.io.IOException
- Lower-lever API exception.public byte[] readBinary(int sfi, int offset, int length) throws java.lang.IllegalStateException, java.lang.IllegalArgumentException, java.lang.SecurityException, java.lang.UnsupportedOperationException, java.io.IOException
Note:This method is based on the ISO/IEC 7816-4 command READ BINARY.
sfi
- The SFI of the file which shall be selected for this read
operation. CURRENT_FILE can be applied if the file is already
selected. The sfi must be in the range of (1-30).offset
- Defines the start point of the file where the data should
be read.length
- Defines the length of the data which should be read. If set
to 0, all possible data within the limit of
ISO7816#MAX_COMMAND_DATA_LENGTH
will be read.java.lang.IllegalStateException
- if the used channel is closed, if no file
is currently selected, if the currently selected file is not a
transparent file or if the data couldn't be read.java.lang.IllegalArgumentException
- if the file couldn't be selected via
SFI.
TODO: should be an IllegalReferenceErrorjava.lang.IllegalArgumentException
- if the defined sfi is not valid or if
the defined offset and length couldn't be applied.java.lang.SecurityException
- if the operation is not allowed because the
security conditions are not satisfied.java.lang.UnsupportedOperationException
- if this operation is not supported.java.io.IOException
- Lower-lever API exception.public void writeBinary(int sfi, byte[] data, int offset, int length) throws java.lang.IllegalStateException, java.lang.IllegalArgumentException, java.lang.SecurityException, java.lang.UnsupportedOperationException, java.io.IOException
Note:This method is based on the ISO/IEC 7816-4 command UPDATE BINARY.
sfi
- The SFI of the file which shall be selected for this write
operation. CURRENT_FILE can be applied if the file is already
selected. The sfi must be in the range of (1-30).data
- The data which shall be written.offset
- Defines the position in the file where the data should be
stored.length
- Defines the length of the data which shall be written.java.lang.IllegalStateException
- if the used channel is closed, if no file
is currently selected, if the currently selected file is not a
transparent file or if the record couldn't be written.java.lang.IllegalArgumentException
- if the file couldn't be selected via
SFI.
TODO: should be an IllegalReferenceErrorjava.lang.IllegalArgumentException
- if the defined sfi is not valid, if the
defined data array is empty or too short or if the defined offset
and length couldn't be applied.java.lang.SecurityException
- if the operation is not allowed because the
security conditions are not satisfied.java.lang.UnsupportedOperationException
- if this operation is not supported.java.io.IOException
- Lower-lever API exception.SEEK for Android Copyright 2015, Giesecke & Devrient GmbH