Nokia Extensions for JSR-257

com.nokia.nfc.nxp.mfstd
Class MFTrailerContents

java.lang.Object
  extended by com.nokia.nfc.nxp.mfstd.MFTrailerContents

public class MFTrailerContents
extends java.lang.Object

Describes the contents of a sector trailer, including authentication keys and access bits.


Field Summary
static int MAX_GPB_VALUE
          The largest general purpose byte (GPB) value.
static int MIN_GPB_VALUE
          The smallest general purpose byte (GPB) value.
 
Constructor Summary
MFTrailerContents()
          Constructs a new MFTrailerContents instance.
MFTrailerContents(byte[] trailerBlock)
          Constructs a new MFTrailerContents instance using the given trailer block bytes.
MFTrailerContents(MFKey.KeyA keyA, MFKey.KeyB keyB, MFAccessBits accessBits, int gpb)
          Constructs a new MFTrailerContents instance using the specified values.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Tests if the given object equal to this object.
 MFAccessBits getAccessBits()
          Returns the access bits of the trailer.
 int getGeneralPurposeByte()
          Returns the general purpose byte (GPB) of this sector trailer.
 MFKey.KeyA getKeyA()
          Returns the authentication key A.
 MFKey.KeyB getKeyB()
          Returns the authentication key B.
 void setAccessBits(MFAccessBits accessBits)
          Sets the access bits of the sector trailer.
 void setGeneralPurposeByte(int gpb)
          Sets the new general purpose byte (GPB) value.
 void setKeyA(MFKey.KeyA key)
          Set the authentication key A.
 void setKeyB(MFKey.KeyB key)
          Set the authentication key B.
 byte[] toByteArray()
          Returns the contents of the sector trailer as a byte array.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_GPB_VALUE

public static final int MAX_GPB_VALUE
The largest general purpose byte (GPB) value.

See Also:
Constant Field Values

MIN_GPB_VALUE

public static final int MIN_GPB_VALUE
The smallest general purpose byte (GPB) value.

See Also:
Constant Field Values
Constructor Detail

MFTrailerContents

public MFTrailerContents()
Constructs a new MFTrailerContents instance. All object fields are set to null and the general purpose byte is set to 0. The trailer contents must be set with the set methods before using this object.


MFTrailerContents

public MFTrailerContents(MFKey.KeyA keyA,
                         MFKey.KeyB keyB,
                         MFAccessBits accessBits,
                         int gpb)
Constructs a new MFTrailerContents instance using the specified values.

Parameters:
keyA - the authentication key A.
keyB - the authentication key B.
accessBits - the access bits.
gpb - the general purpose byte.
Throws:
java.lang.NullPointerException - if keyA, keyB or accessBits is null.
java.lang.IllegalArgumentException - if gpb value is out of range.

MFTrailerContents

public MFTrailerContents(byte[] trailerBlock)
Constructs a new MFTrailerContents instance using the given trailer block bytes. The trailerBlock.length must equal to 16.

Parameters:
trailerBlock - sector trailer block contents.
Throws:
java.lang.NullPointerException - if trailerBlock is null.
java.lang.IllegalArgumentException - if trailerBlock is not a valid trailer block.
Method Detail

getKeyB

public MFKey.KeyB getKeyB()
Returns the authentication key B.

Returns:
the authentication key B or null if it has not been set.

getKeyA

public MFKey.KeyA getKeyA()
Returns the authentication key A.

Returns:
the authentication key A or null if it has not been set.

setKeyB

public void setKeyB(MFKey.KeyB key)
Set the authentication key B.

Parameters:
key - the authentication key B.
Throws:
java.lang.NullPointerException - if key is null.

setKeyA

public void setKeyA(MFKey.KeyA key)
Set the authentication key A.

Parameters:
key - the authentication key A.
Throws:
java.lang.NullPointerException - if key is null.

getAccessBits

public MFAccessBits getAccessBits()
Returns the access bits of the trailer.

Returns:
the access bits.

setAccessBits

public void setAccessBits(MFAccessBits accessBits)
Sets the access bits of the sector trailer.

Parameters:
accessBits - the access bits.
Throws:
java.lang.NullPointerException - if accessBits is null.

setGeneralPurposeByte

public void setGeneralPurposeByte(int gpb)
Sets the new general purpose byte (GPB) value. Valid values range from 0 to 255.

Parameters:
gpb - the general purpose byte value.
Throws:
java.lang.IllegalArgumentException - if gpb is out of range.

getGeneralPurposeByte

public int getGeneralPurposeByte()
Returns the general purpose byte (GPB) of this sector trailer. The general purpose byte is the fourth access bits byte but it is not used for storing access information. The default GPB value is 0.

Returns:
the general purpose byte.

toByteArray

public byte[] toByteArray()
Returns the contents of the sector trailer as a byte array. If either one of the authentication keys or the access bits are undefined then those parts are represented as zeroes.

Returns:
the sector trailer as a byte array.
Throws:
java.lang.NullPointerException - if either of the keys or the access bits are not set.

equals

public boolean equals(java.lang.Object obj)
Tests if the given object equal to this object. Two MFTrailerContents objects are equal if the general purpose byte, key A, key B and access bits are equal.

Overrides:
equals in class java.lang.Object
Returns:
true if the objects are equal and false if not.

Nokia Extensions for JSR-257

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