Nokia Extensions for JSR-257

com.nokia.nfc.nxp.mfstd
Interface MFStandardConnection

All Superinterfaces:
MFDataArea, javax.microedition.contactless.TagConnection

public interface MFStandardConnection
extends MFDataArea, javax.microedition.contactless.TagConnection

The interface representing the connection to a Mifare Standard 1k or 4k card. This interface extends the MFDataArea and thus the entire tag is accessible via this interface.

The device may have some default authentication keys that it uses. Typically these are known public keys such as the public MAD key A. These are used if the user doesn't specify a authentication key.


Field Summary
static int MAD_V1
          MAD version 1.
static int MAD_V2
          MAD version 2.
 
Method Summary
 MFApplicationDirectory createApplicationDirectory(MFKey createKey, MFKey.KeyB madKeyB, int madVersion)
          Creates an application directory to the card.
 MFApplicationDirectory getApplicationDirectory()
          Returns the application directory of the card in read-only mode.
 MFApplicationDirectory getApplicationDirectory(MFKey.KeyB keyB)
          Returns the application directory of the card.
 MFBlock getBlock(int blockIndex)
          Returns the block at the specified block index.
 int getBlockCount()
          Returns the total number of blocks in the card.
 MFManufacturerBlock getManufacturerBlock()
          Returns the manufacturer block of this card.
 MFSector getSector(int sectorIndex)
          Returns the sector at the specified sector index.
 int getSectorCount()
          Returns the total number of sectors in the card.
 
Methods inherited from interface com.nokia.nfc.nxp.mfstd.MFDataArea
read, size, toString, write, write
 

Field Detail

MAD_V1

static final int MAD_V1
MAD version 1.

See Also:
Constant Field Values

MAD_V2

static final int MAD_V2
MAD version 2.

See Also:
Constant Field Values
Method Detail

getManufacturerBlock

MFManufacturerBlock getManufacturerBlock()
Returns the manufacturer block of this card.

Returns:
the manufacturer block of this card. Never null.

getSectorCount

int getSectorCount()
Returns the total number of sectors in the card.

Returns:
the total number of sectors in the card.

getSector

MFSector getSector(int sectorIndex)
Returns the sector at the specified sector index. Valid sector index ranges from 0 to getSectorCount() - 1.

Parameters:
sectorIndex - the sector index.
Returns:
the MFSector object that corresponds with the specified index.
Throws:
java.lang.IllegalArgumentException - if the sectorIndex is invalid.

getBlockCount

int getBlockCount()
Returns the total number of blocks in the card.

Returns:
the total number of blocks in the card.

getBlock

MFBlock getBlock(int blockIndex)
Returns the block at the specified block index. Valid block index ranges from 0 to getBlockCount() - 1.

Parameters:
blockIndex - the block index.
Returns:
the MFBlock object that corresponds with the specified index.
Throws:
java.lang.IllegalArgumentException - if the blockIndex is invalid.

getApplicationDirectory

MFApplicationDirectory getApplicationDirectory()
                                               throws java.io.IOException,
                                                      MFStandardException
Returns the application directory of the card in read-only mode. If modifying the MAD is attempted using the returned object then the called method will immediately throw a MFStandardException. If the MAD sectors cannot be read then it is assumed that the application directory doesn't exist and the return value will be null.

Returns:
the application directory, or if not present.
Throws:
java.io.IOException - if a connection error occurs.
MFStandardException - if authentication fails, i.e. the MAD doesn't use the public key A.

getApplicationDirectory

MFApplicationDirectory getApplicationDirectory(MFKey.KeyB keyB)
                                               throws java.io.IOException,
                                                      MFStandardException
Returns the application directory of the card. The provided authentication key B is used when writing the MAD area. If the MAD sectors cannot be read then it is assumed that the application directory doesn't exist and the return value will be null.

Parameters:
keyB - the authentication key to use when modifying the MAD area. If null then the device's default keys are used.
Returns:
the application directory, or if not present.
Throws:
java.io.IOException - if a connection error occurs.
MFStandardException - if authentication fails, i.e. the MAD doesn't use the public key A.

createApplicationDirectory

MFApplicationDirectory createApplicationDirectory(MFKey createKey,
                                                  MFKey.KeyB madKeyB,
                                                  int madVersion)
                                                  throws MFStandardException,
                                                         java.io.IOException

Creates an application directory to the card. The authentication key createKey will be used when creating the MAD area and the key madKeyB will be written to the MAD sector's trailer as the B key.

Note that the reserved MAD sectors will be cleared and set into initial state. Any previous data is permanently lost from the MAD sector(s).

The madVersion parameter value must be either MAD_V1 or MAD_V2.

Parameters:
createKey - key to use when writing the MAD sectors. If null then the device's default keys are used.
madKeyB - the key to use as the B key in the MAD sector trailer(s).
madVersion - the MAD version to use.
Returns:
the created application directory.
Throws:
java.lang.NullPointerException - if madKeyB is null.
java.io.IOException - if a connection error occurs.
java.lang.IllegalArgumentException - if the madVersion is not valid.
MFStandardException - if authentication fails.

Nokia Extensions for JSR-257

Copyright � 2010 Nokia Corporation. All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.