|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.dalsemi.onewire.container.CommandAPDU
A CommandAPDU
represents an ISO 7816-4 specified
Application Protocol Data Unit (APDU) sent to a
smart card. A response from the smart card is in turn represented
by a ResponseAPDU
.
According to ISO 7816-4, a CommandAPDU
has the following
format:
HEADER | BODY CLA INS P1 P2 | [LC] [DATA] [LE]where
CLA
is the class byte
INS
is the instruction byte
P1
is the first parameter byte
P2
is the second parameter byte
LC
is the number of bytes present in the data block
DATA
is an byte array of data to be sent
LE
is the maximum number of bytes expected in the ResponseAPDU
[ ]
denotes optional fields
byte[] buffer = {(byte)0x90, (byte)0x00, (byte)0x00, (byte)0x00,
(byte)0x01, (byte)0x02, (byte)0x03};
CommandAPDU capdu = new CommandAPDU(buffer);
CommandAPDU capdu = new CommandAPDU((byte)0x90, (byte)0x00, (byte)0x00, (byte)0x00,
(byte)0x01, (byte)0x02, (byte)0x03);
ResponseAPDU
,
OneWireContainer16
Field Summary | |
static int |
CLA
Index for addressing CLA in this CommandAPDU
apduBuffer . |
static int |
INS
Index for addressing INS in this CommandAPDU
apduBuffer . |
static int |
LC
Index for addressing LC in this CommandAPDU
apduBuffer . |
static int |
P1
Index for addressing P1 in this CommandAPDU
apduBuffer . |
static int |
P2
Index for addressing P2 in this CommandAPDU
apduBuffer . |
Constructor Summary | |
CommandAPDU(byte[] buffer)
Constructs a new ISO 7816-4 CommandAPDU . |
|
CommandAPDU(byte cla,
byte ins,
byte p1,
byte p2)
Constructs a new ISO 7816-4 CASE 1 CommandAPDU . |
|
CommandAPDU(byte cla,
byte ins,
byte p1,
byte p2,
byte[] data)
Constructs a new ISO 7816-4 CASE 3 CommandAPDU . |
|
CommandAPDU(byte cla,
byte ins,
byte p1,
byte p2,
byte[] data,
int le)
Constructs a new ISO 7816-4 CASE 4 CommandAPDU . |
|
CommandAPDU(byte cla,
byte ins,
byte p1,
byte p2,
int le)
Constructs a new ISO 7816-4 CASE 2 CommandAPDU . |
Method Summary | |
byte[] |
getBuffer()
Gets this CommandAPDU apduBuffer . |
byte |
getByte(int index)
Gets the byte at the specified offset in the apduBuffer . |
byte[] |
getBytes()
Gets a byte array of the buffered CommandAPDU . |
byte |
getCLA()
Gets the CLA byte value. |
byte |
getINS()
Gets the INS byte value. |
int |
getLC()
Gets the length of data field ( LC ). |
int |
getLE()
Gets the expected length of ResponseAPDU (LE ). |
int |
getLength()
Gets the length of the buffered CommandAPDU . |
byte |
getP1()
Gets the first parameter ( P1 ) byte value. |
byte |
getP2()
Gets the second parameter ( P2 ) byte value. |
void |
setByte(int index,
byte value)
Sets the byte value at the specified offset in the apduBuffer . |
String |
toString()
Gets a string representation of this CommandAPDU . |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int CLA
CLA
in this CommandAPDU
apduBuffer
.public static final int INS
INS
in this CommandAPDU
apduBuffer
.public static final int P1
P1
in this CommandAPDU
apduBuffer
.public static final int P2
P2
in this CommandAPDU
apduBuffer
.public static final int LC
LC
in this CommandAPDU
apduBuffer
.Constructor Detail |
public CommandAPDU(byte[] buffer)
CommandAPDU
.buffer
- the entire CommandAPDU
as a byte arraypublic CommandAPDU(byte cla, byte ins, byte p1, byte p2)
CommandAPDU
.cla
- CLA
byteins
- INS
bytep1
- parameter byte P1
p2
- parameter byte P2
public CommandAPDU(byte cla, byte ins, byte p1, byte p2, int le)
CommandAPDU
.cla
- CLA
byteins
- INS
bytep1
- parameter byte P1
p2
- parameter byte P2
le
- length of expected ResponseAPDU
,
ranges from -1
to
255
, where -1
is no length
and 0
is the maximum length
supportedResponseAPDU
public CommandAPDU(byte cla, byte ins, byte p1, byte p2, byte[] data)
CommandAPDU
.cla
- CLA
byteins
- INS
bytep1
- parameter byte P1
p2
- parameter byte P2
data
- this CommandAPDU
data as a byte array,
LC
is derived from this data
array lengthpublic CommandAPDU(byte cla, byte ins, byte p1, byte p2, byte[] data, int le)
CommandAPDU
.cla
- CLA
byteins
- INS
bytep1
- parameter byte P1
p2
- parameter byte P2
data
- CommandAPDU
data as a byte array,
LC
is derived from this data
array lengthle
- length of expected ResponseAPDU
,
ranges from -1
to
255
, where -1
is no length
and 0
is the maximum length
supportedResponseAPDU
Method Detail |
public byte getCLA()
CLA
byte value.CLA
byte of this CommandAPDU
public byte getINS()
INS
byte value.INS
byte of this CommandAPDU
public byte getP1()
P1
) byte value.P1
byte of this CommandAPDU
public byte getP2()
P2
) byte value.P2
byte of this CommandAPDU
public int getLC()
LC
).CommandAPDU
, 0
indicates that there is no bodypublic int getLE()
ResponseAPDU
(LE
).ResponseAPDU
to this CommandAPDU
,
-1
indicates that no value is specifiedResponseAPDU
public final byte[] getBuffer()
CommandAPDU
apduBuffer
.
This method allows user to manipulate the buffered CommandAPDU
.apduBuffer
that holds the current CommandAPDU
getBytes()
public final byte getByte(int index)
apduBuffer
.
This method can only be used to access the CommandAPDU
currently stored. It is not possible to read beyond the
end of the CommandAPDU
.index
- the offset in the apduBuffer
-1
if the offset is invalidsetByte(int, byte)
,
getLength()
public final byte[] getBytes()
CommandAPDU
.
The byte array returned gets allocated with the exact size of the
buffered CommandAPDU
. To get direct access to the
internal apduBuffer
, use getBuffer()
.CommandAPDU
copied into a new arraygetBuffer()
public final int getLength()
CommandAPDU
.CommandAPDU
currently storedpublic final void setByte(int index, byte value)
apduBuffer
.
This method can only be used to modify a CommandAPDU
already stored. It is not possible to set bytes beyond
the end of the current CommandAPDU
.index
- the offset in the apduBuffer
value
- the new byte value to storegetByte(int)
,
getLength()
public String toString()
CommandAPDU
.toString
in class Object
CommandAPDU
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |