|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.linuxnet.jpcsc.Apdu
The Apdu class encapsulates an APDU. It allows to construct APDUs, convert between byte and string representations, and can be passed to Card.Transmit(). An Apdu instance uses a byte array to store the APDU header and data. This internal buffer is reused whenever a new APDU is constructed by calling one of the set(...) methods. You can incrementally add additional data bytes and the expected length by calling one of the add(...) methods. If the previously allocated APDU buffer is too small for a new APDU to create, reset() can be called to reallocate the internal buffer.
Nested Class Summary | |
static class |
Apdu.Format
The Format class described the format to use for converting APDU strings to buffers and vice versa. |
static interface |
Apdu.Wrapper
ApduWrapper wraps apdu data before sending to the card. |
Field Summary | |
static int |
HEX_COLON_HEX_FORMAT
Output format: hex:hex:hex |
static int |
HEX_SPACE_HEX_FORMAT
Output format: hex space hex space hex |
static int |
HEX_VOID_HEX_FORMAT
Output format: hexhexhex |
Constructor Summary | |
Apdu(byte[] ba)
Construct APDU by taking given buffer. |
|
Apdu(int len)
Allocate len bytes for internal APDU buffer. |
|
Apdu(int cla,
int ins,
int p1,
int p2,
int p3,
byte[] in,
int off,
int le)
Construct internal buffer from given data. |
Method Summary | |
void |
addByte(byte b)
Add a data byte to the APDU. |
void |
addByte(int b)
Add a data byte to the APDU. |
void |
addLe(int le)
Add expected length of data. |
void |
addString(java.lang.String s)
Add a string representing data to the APDU data area. |
static java.lang.String |
ba2s(byte[] ba)
Return string representation for byte array. |
static java.lang.String |
ba2s(byte[] ba,
Apdu.Format f)
Return string representation for byte array. |
static java.lang.String |
ba2s(byte[] ba,
int off,
int len)
Return string representation for byte array range. |
static java.lang.String |
ba2s(byte[] ba,
int off,
int len,
Apdu.Format f)
Return string representation for byte array range according to given format. |
static byte[] |
construct(int cla,
int ins,
int p1,
int p2,
int p3,
byte[] in,
int off,
int le)
Construct APDU and return it in a newly created array. |
void |
getBytes(byte[] ba,
int off)
Copy the currently defined APDU to given buffer. |
static void |
main(java.lang.String[] args)
Test the convert methods. |
void |
reset()
Reset the buffer. |
void |
reset(int len)
Reset Apdu, reallocate buffer. |
static byte[] |
s2ba(java.lang.String s)
Convert string to a byte array. |
static int |
s2ba(java.lang.String s,
byte[] ba,
int off)
Convert string to a byte array. |
void |
set(byte[] ba)
Copy the given APDU to the internal buffer. |
void |
set(byte[] ba,
int off,
int len)
Copy the given APDU (range from a byte array) to the internal buffer. |
void |
set(int cla,
int ins,
int p1,
int p2)
Create APDU payload from given data. |
void |
set(int cla,
int ins,
int p1,
int p2,
int p3,
byte[] in,
int off,
int le)
Create an APDU from the given data. |
void |
set(java.lang.String s)
Set APDU data from given string. |
java.lang.String |
toString()
Return string representation of APDU. |
java.lang.String |
toString(Apdu.Format format)
Return string representation of APDU according to given format specification. |
void |
wrapWith(Apdu.Wrapper wrapper)
Wrap the apdu buffer. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int HEX_SPACE_HEX_FORMAT
public static final int HEX_COLON_HEX_FORMAT
public static final int HEX_VOID_HEX_FORMAT
Constructor Detail |
public Apdu(byte[] ba)
public Apdu(int len)
public Apdu(int cla, int ins, int p1, int p2, int p3, byte[] in, int off, int le)
construct(int, int, int, int, int, byte[], int, int)
Method Detail |
public static byte[] construct(int cla, int ins, int p1, int p2, int p3, byte[] in, int off, int le)
cla
- CLA byte of APDU (byte #0)ins
- INS byte of APDU (byte #1)p1
- P1 byte of APDU (byte #2)p2
- P2 byte of APDU (byte #3)p3
- P3 or LC byte of APDU (byte #4). This byte is omitted if parameter has value -1, otherwise it contains number of bytes in buffer in sent to card.in
- byte array containing command data of APDU. If null, p3 is omitted.off
- offset starting at which data sending is to beginle
- LE byte of APDU (appended to APDU). This byte is omitted if parameter has value -1.
public final void reset()
public final void reset(int len)
public final void getBytes(byte[] ba, int off)
public final void set(byte[] ba)
public final void set(byte[] ba, int off, int len)
public final void set(int cla, int ins, int p1, int p2, int p3, byte[] in, int off, int le)
public final void set(int cla, int ins, int p1, int p2)
cla
- CLA byte of APDU (byte #0)ins
- INS byte of APDU (byte #1)p1
- P1 byte of APDU (byte #2)p2
- P2 byte of APDU (byte #3)public final void set(java.lang.String s)
s2ba() for the possible string format
public final void addByte(int b)
public final void addByte(byte b)
public final void addString(java.lang.String s)
s2ba() for the possible string format
public final void addLe(int le)
public void wrapWith(Apdu.Wrapper wrapper) throws java.rmi.RemoteException
wrapper
-
java.rmi.RemoteException
public java.lang.String toString()
public java.lang.String toString(Apdu.Format format)
public static java.lang.String ba2s(byte[] ba)
public static java.lang.String ba2s(byte[] ba, int off, int len)
public static java.lang.String ba2s(byte[] ba, Apdu.Format f)
public static java.lang.String ba2s(byte[] ba, int off, int len, Apdu.Format f)
public static byte[] s2ba(java.lang.String s)
public static int s2ba(java.lang.String s, byte[] ba, int off)
public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |