|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--net.rim.device.api.smartcard.CommandAPDU
Represents a command Application Protocol Data Unit (APDU). ISO 7816-4 defines
Command APDUs. The CommandAPDU object is designed as mutable
to minimize garbage collection.
+--------------------------------------------------+
| CLA | INS | P1 | P2 | Lc Field | Data | Le Field |
+--------------------------------------------------+
The command header is composed of CLA, INS, P1, P2.
LcField = Length of data contained in the Data field
LeField = Length of data expected in the response
The body is composed of combinations of Lc Field, Data and Le Field as described below in the 4 cases.
There are 4 structures of command APDUs as illustrated in ISO/IEC 7816-4:
Case 1:
+----------------+
| Command Header |
+----------------+
Case 2:
+---------------------------+
| Command Header | Le Field |
+---------------------------+
Case 3:
+----------------------------------------+
| Command Header | Lc Field | Data Field |
+----------------------------------------+
Case 4:
+---------------------------------------------------+
| Command Header | Lc Field | Data Field | Le Field |
+---------------------------------------------------+
Typical usage scenario:
CommandAPDU cmd = new CommandAPDU( CLASS, INS, P1, P2 );
ResponseAPDU response = new ResponseAPDU();
byte cmdToSend[] = { (byte)0x00, (byte)0xa0, (byte)0x00, (byte)0x00,
(byte)0x02, (byte)0x3f, (byte)0x00};
cmd.setLcData( dataToSend );
reader.sendAPDU(cmd, response);
SmartCardReaderSession,
SmartCardSession,
ResponseAPDU| Field Summary | ||
|
static int |
CASE_1
|
|
static int |
CASE_2
Represents the case 2 command APDU structure. |
|
static int |
CASE_3
Represents the case 3 command APDU structure. |
|
static int |
CASE_4
Represents the case 4 command APDU structure. |
| Constructor Summary | ||
|
CommandAPDU(byte CLA,
byte INS,
byte P1,
byte P2)
Constructs a case 1 CommandAPDU object. |
|
|
CommandAPDU(byte CLA,
byte INS,
byte P1,
byte P2,
byte[] LcData)
Constructs a case 3 CommandAPDU object. |
|
|
CommandAPDU(byte CLA,
byte INS,
byte P1,
byte P2,
byte[] LcData,
int Le)
Constructs a case 4 CommandAPDU object. |
|
|
CommandAPDU(byte CLA,
byte INS,
byte P1,
byte P2,
int Le)
Constructs a case 2 CommandAPDU object. |
|
| Method Summary | ||
|
void |
appendLcData(byte[] moreLcData)
Append data to the command data. |
|
void |
appendLcData(byte[] moreLcData,
int offset,
int length)
Append data to the command data. |
|
byte[] |
getAPDU()
Get the full APDU command, including the Command header and body if one exists. |
|
int |
getCase()
Get the case of the APDU. |
|
byte |
getCLA()
Returns the class type of the instruction. |
|
byte |
getINS()
Returns the instruction. |
|
int |
getLc()
Get the command data length. |
|
byte[] |
getLcData()
Get the command data. |
|
int |
getLe()
Get the maximum number of bytes expected in the data field of the ResponseAPDU. |
|
byte |
getP1()
Get the first instruction parameter. |
|
byte |
getP2()
Get the second instruction parameter. |
|
boolean |
isExtended()
Determine if the APDU command set so far is of type short or extended. |
|
void |
set(byte CLA,
byte INS,
byte P1,
byte P2)
Reinitializes a CommandAPDU object to a case 1 structure. |
|
void |
set(byte CLA,
byte INS,
byte P1,
byte P2,
byte[] LcData)
Reinitializes a CommandAPDU
|
|
void |
set(byte CLA,
byte INS,
byte P1,
byte P2,
byte[] LcData,
int Le)
Reinitializes a CommandAPDU object to a case 4 structure. |
|
void |
set(byte CLA,
byte INS,
byte P1,
byte P2,
int Le)
Reinitializes a CommandAPDU object to a case 2 structure. |
|
void |
setLcData(byte[] LcData)
Set the command data. |
|
void |
setLcData(byte[] LcData,
int offset,
int length)
Set the command data. |
|
void |
setLe(int Le)
Set the maximum number of bytes expected in the data field of the ResponseAPDU object. |
|
String |
toString()
Returns a String representation of the object. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final int CASE_1
public static final int CASE_2
public static final int CASE_3
public static final int CASE_4
| Constructor Detail |
public CommandAPDU(byte CLA,
byte INS,
byte P1,
byte P2)
CommandAPDU object.
CLA - The class of the instruction.INS - The instruction.P1 - Parameter One.P2 - Parameter Two.
public CommandAPDU(byte CLA,
byte INS,
byte P1,
byte P2,
byte[] LcData)
CommandAPDU object.
CLA - The class of the instruction.INS - The instruction.P1 - Parameter One.P2 - Parameter Two.LcData - The command data.
public CommandAPDU(byte CLA,
byte INS,
byte P1,
byte P2,
byte[] LcData,
int Le)
CommandAPDU object.
CLA - The class of the instruction.INS - The instruction.P1 - Parameter One.P2 - Parameter Two.LcData - The command data.Le - The maximum number of bytes expected in the data field of the ResponseAPDU.
public CommandAPDU(byte CLA,
byte INS,
byte P1,
byte P2,
int Le)
CommandAPDU object.
CLA - The class of the instruction.INS - The instruction.P1 - Parameter One.P2 - Parameter Two.Le - The maximum number of bytes expected in the data field of the ResponseAPDU.
Note that to create an APDU of form Case 2E, from the ISO/IEC 7816-4 spec, with Le = 0, then Le = 65536 should
be entered into the constructor.| Method Detail |
public void appendLcData(byte[] moreLcData)
Note that this automatically sets the command data length, and determines if the command is sent is short or extended mode.
moreLcData - The data to append.
public void appendLcData(byte[] moreLcData,
int offset,
int length)
Note that this automatically sets the command data length, and determines if the command is sent is short or extended mode.
moreLcData - The data to append.offset - The offset into the LcData array to start using.length - The number of bytes of the LcData to use starting from the offset.public byte[] getAPDU()
public int getCase()
This can be one of CASE_1, CASE_2, CASE_3, CASE_4 or CASE_UNKNOWN.
public byte getCLA()
public byte getINS()
public int getLc()
Note that the command data length is set automatically by setting the command data.
public byte[] getLcData()
public int getLe()
ResponseAPDU.
public byte getP1()
public byte getP2()
public boolean isExtended()
public void set(byte CLA,
byte INS,
byte P1,
byte P2)
CommandAPDU object to a case 1 structure.
CLA - The class of the instruction.INS - The instruction.P1 - Parameter One.P2 - Parameter Two.
public void set(byte CLA,
byte INS,
byte P1,
byte P2,
byte[] LcData)
CommandAPDUCLA - The class of the instruction.INS - The instruction.P1 - Parameter One.P2 - Parameter Two.LcData - The command data.
public void set(byte CLA,
byte INS,
byte P1,
byte P2,
byte[] LcData,
int Le)
CommandAPDU object to a case 4 structure.
CLA - The class of the instruction.INS - The instruction.P1 - Parameter One.P2 - Parameter Two.LcData - The command data.Le - The maximum number of bytes expected in the data field of the ResponseAPDU.
public void set(byte CLA,
byte INS,
byte P1,
byte P2,
int Le)
CommandAPDU object to a case 2 structure.
CLA - The class of the instruction.INS - The instruction.P1 - Parameter One.P2 - Parameter Two.Le - The maximum number of bytes expected in the data field of the ResponseAPDU.public void setLcData(byte[] LcData)
Note that this automatically sets the command data length, and determines if the command is sent is short or extended mode.
LcData - The command data.
public void setLcData(byte[] LcData,
int offset,
int length)
Note that this automatically sets the command data length, and determines if the command is sent is short or extended mode.
LcData - The command data.offset - Offset into the LcData array to start using.length - Number of bytes of the LcData to use starting from the offset.public void setLe(int Le)
ResponseAPDU object.
Le - The maximum number of bytes expected in the data field of the
ResponseAPDU.public String toString()
The String includes the the full command APDU in hex byte pairs
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Copyright 1999-2007 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.