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);
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
CASE_2
public static final int CASE_2
Represents the case 2 command APDU structure.
Since:
JDE 4.1.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
CASE_3
public static final int CASE_3
Represents the case 3 command APDU structure.
Since:
JDE 4.1.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
CASE_4
public static final int CASE_4
Represents the case 4 command APDU structure.
Since:
JDE 4.1.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Constructor Detail
CommandAPDU
public CommandAPDU(byte CLA,
byte INS,
byte P1,
byte P2)
Constructs a case 1 CommandAPDU object.
Parameters:
CLA - The class of the instruction.
INS - The instruction.
P1 - Parameter One.
P2 - Parameter Two.
Since:
JDE 4.1.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
CommandAPDU
public CommandAPDU(byte CLA,
byte INS,
byte P1,
byte P2,
byte[] LcData,
int Le)
Constructs a case 4 CommandAPDU object.
Parameters:
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.
Since:
JDE 4.1.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
CommandAPDU
public CommandAPDU(byte CLA,
byte INS,
byte P1,
byte P2,
int Le)
Constructs a case 2 CommandAPDU object.
Parameters:
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.
Since:
JDE 4.1.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Method Detail
appendLcData
public void appendLcData(byte[] moreLcData)
Append data to the command data.
Note that this automatically sets the command data length, and determines
if the command is sent is short or extended mode.
Parameters:
moreLcData - The data to append.
Since:
JDE 4.1.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
appendLcData
public void appendLcData(byte[] moreLcData,
int offset,
int length)
Append data to the command data.
Note that this automatically sets the command data length, and determines
if the command is sent is short or extended mode.
Parameters:
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.
Since:
JDE 4.1.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
getAPDU
public byte[] getAPDU()
Get the full APDU command, including the Command header and body if one
exists.
Returns:
The full command APDU.
Since:
JDE 4.1.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
getCase
public int getCase()
Get the case of the APDU.
This can be one of CASE_1, CASE_2, CASE_3, CASE_4 or CASE_UNKNOWN.
Returns:
An integer representing the case of the APDU.
Since:
JDE 4.1.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
getCLA
public byte getCLA()
Returns the class type of the instruction.
Returns:
The class type of the instruction.
Since:
JDE 4.1.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
getINS
public byte getINS()
Returns the instruction.
Returns:
The instruction code.
Since:
JDE 4.1.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
getLc
public int getLc()
Get the command data length.
Note that the command data length is set automatically by setting the command data.
Returns:
The command data length, or -1 if there is no command data ( case 1 and case 2 ).
Since:
JDE 4.1.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
getLcData
public byte[] getLcData()
Get the command data.
Returns:
A reference to the command data.
Since:
JDE 4.1.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
getLe
public int getLe()
Get the maximum number of bytes expected in the data field of the
ResponseAPDU.
Returns:
An integer representing the number of bytes in the data field, or
-1 if there is no data ( case 1 and case 3 ).
Since:
JDE 4.1.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
getP1
public byte getP1()
Get the first instruction parameter.
Returns:
Instruction Parameter One.
Since:
JDE 4.1.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
getP2
public byte getP2()
Get the second instruction parameter.
Returns:
Instruction Parameter Two.
Since:
JDE 4.1.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
isExtended
public boolean isExtended()
Determine if the APDU command set so far is of type short or extended.
Returns:
True if the command APDU is extended ( two byte lengths ),
false if the command APDU is short ( one byte length ). Returns false if
the command is a case 1 structure, where there is no length data.
Since:
JDE 4.1.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
set
public void set(byte CLA,
byte INS,
byte P1,
byte P2)
Reinitializes a CommandAPDU object to a case 1 structure.
Parameters:
CLA - The class of the instruction.
INS - The instruction.
P1 - Parameter One.
P2 - Parameter Two.
Since:
JDE 4.1.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
set
public void set(byte CLA,
byte INS,
byte P1,
byte P2,
byte[] LcData,
int Le)
Reinitializes a CommandAPDU object to a case 4 structure.
Parameters:
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.
Since:
JDE 4.1.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
set
public void set(byte CLA,
byte INS,
byte P1,
byte P2,
int Le)
Reinitializes a CommandAPDU object to a case 2 structure.
Parameters:
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.
Since:
JDE 4.1.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
setLcData
public void setLcData(byte[] LcData)
Set the command data.
Note that this automatically sets the command data length, and determines
if the command is sent is short or extended mode.
Parameters:
LcData - The command data.
Since:
JDE 4.1.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
setLcData
public void setLcData(byte[] LcData,
int offset,
int length)
Set the command data.
Note that this automatically sets the command data length, and determines
if the command is sent is short or extended mode.
Parameters:
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.
Since:
JDE 4.1.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
setLe
public void setLe(int Le)
Set the maximum number of bytes expected in the data field of the
ResponseAPDU object.
Parameters:
Le - The maximum number of bytes expected in the data field of the
ResponseAPDU.
Since:
JDE 4.1.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Copyright 1999-2009 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.