|
Nokia Extensions for JSR-257 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface MFApplicationDirectory
Provides access to Mifare Standard Card's application directory (MAD).
The create and delete methods of this interface communicate with
the card. The rest of the methods use the information that was
read from the card during the getApplicationDirectory
and
createApplicationDirectory
of the MFStandardConnection
interface.
Calling the create and delete methods of course update this information.
Applications are identified by using application identifiers (AID). The term AID slot refers to a sector that is reserved for application use. The first AID slot index is 0 and it refers to the sector number 1. If MAD version 2 is used then the AID slot index 15 refers to sector number 17 - the second MAD sector is sector number 16 and is not a valid AID slot. MAD version 1 means that the first sector of a 1k or 4k card is used for storing the application directory information. If MAD version 2 is used then sector number 16 is also used for storing this information. MAD version 2 only applies for Mifare Standard 4k cards.
Application identifiers are represented in this interface as byte arrays. The array has two bytes. The first byte in the array is the least significant byte, i.e. the application code. The second byte is the most significant byte - the function cluster code.
MAD trailer is updated only when the GPB needs to be changed. If
default keys are being used and the trailer must be written then the
key 0xFFFFFFFFFFFF
is used as the B key.
Field Summary | |
---|---|
static int |
AID_LENGTH
Amount of bytes used for representing an application identifier. |
Method Summary | |
---|---|
boolean |
canWrite()
Checks whether if modifying the MAD area is allowed using this MFApplicationDirectory instance, i.e. whether the application directory was opened in read-only mode or not. |
MFApplication |
create(byte[] newAID,
byte[] initialContents,
MFTrailerContents trailer,
boolean continuous)
Creates a new application with given the AID and contents. |
MFApplication |
create(byte[] newAID,
int[] entryIndexes,
MFTrailerContents trailer)
Creates a new application with given the AID and reserves the specified slots for the application. |
MFApplication |
create(byte[] newAID,
int sizeToAllocate,
MFTrailerContents trailer,
boolean continuous)
Creates a new application with given the AID. |
void |
delete(byte[] aid)
Deletes the application specified by the application identifier. |
byte[] |
getAID(int aidIndex)
Returns the AID of the application in slot aidIndex . |
int |
getApplicationCount()
Returns the number of different applications listed in the application directory. |
int |
getGPB()
Returns the general purpose byte (GPB) of the MAD. |
int |
getInfo()
Returns the contents of the MAD's Info field. |
int |
getVersion()
Returns the version of the MAD. |
boolean |
isFree(int aidIndex)
Checks whether the specified AID slot is free, i.e. not reserved for any application. |
int |
numSlots()
Returns the amount of AID slots. |
MFApplication |
open(byte[] aid)
Opens access to the specified application. |
int |
size(boolean continuous)
Returns the number of bytes available for applications, i.e. the number of bytes not reserved for any application. |
Field Detail |
---|
static final int AID_LENGTH
Method Detail |
---|
boolean canWrite()
true
if writing is allowed and false
if not.byte[] getAID(int aidIndex)
aidIndex
.
aidIndex
- index of the AID slot.
java.lang.IllegalArgumentException
- if aidIndex
< 0 or
aidIndex
> numSlots()-1
.boolean isFree(int aidIndex)
aidIndex
- index of the AID slot.
true
if the AID slot is not reserved
for any application and false
if it is.
java.lang.IllegalArgumentException
- if aidIndex
< 0 or
aidIndex
> numSlots()-1
.int numSlots()
int getApplicationCount()
int size(boolean continuous)
continous
is set to true
then this method
will return the largest continuous data area available.
continuous
- if only continues free areas should be checked.
int getInfo()
int getVersion()
MFStandardConnection.MAD_V1
,
MFStandardConnection.MAD_V2
int getGPB()
MFApplication open(byte[] aid) throws java.io.IOException, MFStandardException
aid
- the application identifier.
null
if the application does not exist.
MFStandardException
- if authentication fails.
java.io.IOException
- if a connection error occurs.
java.lang.IllegalArgumentException
- if aid.length
is not AID_LENGTH
.
java.lang.NullPointerException
- if aid
is null
.void delete(byte[] aid) throws java.io.IOException, MFStandardException
0x00 00
.
aid
- the application identifier.
MFStandardException
- if authentication fails or this object is in read-only mode.
java.io.IOException
- if a connection error occurs.
java.lang.IllegalArgumentException
- if the application does not exist.
java.lang.IllegalArgumentException
- if aid.length
is not AID_LENGTH
.
java.lang.NullPointerException
- if the aid
is null
.MFApplication create(byte[] newAID, int sizeToAllocate, MFTrailerContents trailer, boolean continuous) throws java.io.IOException, MFStandardException
Creates a new application with given the AID. Reserves the specified
amount of space for the application (as number of sectors).
If the trailer
parameter is null
then
it is left up to the application to initialize the trailers.
This method will update the MAD contents and if necessary write the
trailers of the reserved sectors.
Note that the trailer
object must always define
both authentication keys and access bits.
newAID
- identifier of the applicationsizeToAllocate
- number of sectors to reserve for the application.trailer
- the sector trailer contents to be used for application's sectors.continuous
- defines if the reserved area should be continuous or not.
null
.
MFStandardException
- if authentication fails or this object is in read-only mode.
java.io.IOException
- if a connection error occurs.
java.lang.IllegalArgumentException
- if the specified space cannot be reserved for the application
or sizeToAllocate
is 0
.
java.lang.IllegalArgumentException
- if newAID.length
is not AID_LENGTH
.
java.lang.NullPointerException
- if the newAID
is null
.MFApplication create(byte[] newAID, byte[] initialContents, MFTrailerContents trailer, boolean continuous) throws java.io.IOException, MFStandardException
Creates a new application with given the AID and contents.
The amount of reserved sectors is decided based on the length of the
initialContents
array.
If the trailer
parameter is null
then
it is left up to the application to initialize the trailers.
This method will update the MAD contents, write the initial contents
to the reserved sectors and if necessary write the
trailers of the reserved sectors.
The key B of the specified trailer will be used for writing data to the reserved sectors. The initial contents will be written to the beginning of the reserved application area.
Note that the trailer
object must always define
both authentication keys and access bits.
newAID
- identifier of the applicationinitialContents
- the initial application contents to be written.trailer
- the sector trailer contents to be used for application's sectors.continuous
- defines if the reserved area should be continuous or not.
null
.
MFStandardException
- if authentication fails or this object is in read-only mode.
java.io.IOException
- if a connection error occurs.
java.lang.IllegalArgumentException
- if the initialContents
length is 0.
java.lang.IllegalArgumentException
- if the specified space cannot be reserved for the application.
java.lang.IllegalArgumentException
- if newAID.length
is not AID_LENGTH
.
java.lang.NullPointerException
- if the newAID
or initialContents
is null
.MFApplication create(byte[] newAID, int[] entryIndexes, MFTrailerContents trailer) throws java.io.IOException, MFStandardException
Creates a new application with given the AID and reserves the
specified slots for the application.
If the trailer
parameter is null
then
it is left up to the application to initialize the trailers.
This method will update the MAD contents and if necessary write the
trailers of the reserved sectors.
Note that the trailer
object must always define
both authentication keys and access bits.
The entryIndexes
array must be ordered so that
the first element specifies the slot with the smallest slot index and
the last element specifies the slot with the largest slot index.
newAID
- identifier of the applicationentryIndexes
- the AID slots to reserve for the application.trailer
- the sector trailer contents to be used for application's sectors.
null
.
MFStandardException
- if authentication fails or this object is in read-only mode.
java.io.IOException
- if a connection error occurs.
java.lang.IllegalArgumentException
- if the entryIndexes
length is 0.
java.lang.IllegalArgumentException
- if the specified space cannot be reserved for the application.
java.lang.IllegalArgumentException
- if newAID.length
is not AID_LENGTH
.
java.lang.NullPointerException
- if the newAID
or
entryIndexes
is null
.
|
Nokia Extensions for JSR-257 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |