opencard.opt.terminal
Class ISOCommandAPDU

java.lang.Object
  extended by opencard.core.terminal.APDU
      extended by opencard.core.terminal.CommandAPDU
          extended by opencard.opt.terminal.ISOCommandAPDU

public class ISOCommandAPDU
extends CommandAPDU


Field Summary
static int CASE_1
          Constants for the 7 cases of ISO CommandAPDUs
static int CASE_2E
           
static int CASE_2S
           
static int CASE_3E
           
static int CASE_3S
           
static int CASE_4E
           
static int CASE_4S
           
static int CLASS
          Constants for addressing in the APDU header array.
static int INSTRUCTION
           
protected  int lc
          The length of the data field of the APDU.
protected  int le
          The expected length of the ResponseAPDU.
static int P1
           
static int P2
           
 
Fields inherited from class opencard.core.terminal.APDU
apdu_buffer, apdu_length
 
Constructor Summary
ISOCommandAPDU(byte classByte, byte instruction, byte p1, byte p2)
          Constructs a new ISO command APDU (ISO 7816-4 CASE 1).
ISOCommandAPDU(byte classByte, byte instruction, byte p1, byte p2, byte[] data)
          Constructs a new ISO command APDU (ISO 7816-4 CASE 3).
ISOCommandAPDU(byte classByte, byte instruction, byte p1, byte p2, byte[] data, int le)
          Constructs a new ISO command APDU (ISO 7816-4 CASE 4).
ISOCommandAPDU(byte classByte, byte instruction, byte p1, byte p2, int le)
          Constructs a new ISO command APDU (ISO 7816-4 CASE 2).
ISOCommandAPDU(int size, byte classByte, byte instruction, byte p1, byte p2)
          Constructs a new ISO command APDU (ISO 7816-4 CASE 1).
ISOCommandAPDU(int size, byte classByte, byte instruction, byte p1, byte p2, byte[] data)
          Constructs a new ISO command APDU (ISO 7816-4 CASE 3).
ISOCommandAPDU(int size, byte classByte, byte instruction, byte p1, byte p2, byte[] data, int le)
          Constructs a new ISO command APDU (ISO 7816-4 CASE 4).
ISOCommandAPDU(int size, byte classByte, byte instruction, byte p1, byte p2, int le)
          Constructs a new ISO command APDU (ISO 7816-4 CASE 2).
 
Method Summary
 void append(byte b)
          Appends the given byte to the buffered APDU.
 void append(byte[] bytes)
          Appends the given byte array to the data field of the APDU.
 byte getCLA()
          Gets the class byte.
 byte getINS()
          Gets the instruction byte.
 int getIsoCase()
          Gets the CASE of this ISOCommandAPDU.
 int getLC()
          Gets the length lc of the data.
 int getLE()
          Gets the expected length le of the response APDU.
 byte getP1()
          Gets the P1 byte.
 byte getP2()
          Gets the P2 byte.
 java.lang.String toString()
          Gets a string representation of this APDU.
 
Methods inherited from class opencard.core.terminal.APDU
getBuffer, getByte, getBytes, getLength, setByte, setLength
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

lc

protected int lc
The length of the data field of the APDU.


le

protected int le
The expected length of the ResponseAPDU.


CASE_1

public static final int CASE_1
Constants for the 7 cases of ISO CommandAPDUs

See Also:
Constant Field Values

CASE_2S

public static final int CASE_2S
See Also:
Constant Field Values

CASE_2E

public static final int CASE_2E
See Also:
Constant Field Values

CASE_3S

public static final int CASE_3S
See Also:
Constant Field Values

CASE_3E

public static final int CASE_3E
See Also:
Constant Field Values

CASE_4S

public static final int CASE_4S
See Also:
Constant Field Values

CASE_4E

public static final int CASE_4E
See Also:
Constant Field Values

CLASS

public static final int CLASS
Constants for addressing in the APDU header array.

See Also:
Constant Field Values

INSTRUCTION

public static final int INSTRUCTION
See Also:
Constant Field Values

P1

public static final int P1
See Also:
Constant Field Values

P2

public static final int P2
See Also:
Constant Field Values
Constructor Detail

ISOCommandAPDU

public ISOCommandAPDU(byte classByte,
                      byte instruction,
                      byte p1,
                      byte p2)
Constructs a new ISO command APDU (ISO 7816-4 CASE 1).

Parameters:
classByte - The CLA byte as specfied in ISO 7816-4.
instruction - The INS byte.
p1 - Parameter byte P1.
p2 - Parameter byte P2.

ISOCommandAPDU

public ISOCommandAPDU(int size,
                      byte classByte,
                      byte instruction,
                      byte p1,
                      byte p2)
Constructs a new ISO command APDU (ISO 7816-4 CASE 1).

Parameters:
size - the size of the APDU buffer to create
classByte - The CLA byte as specfied in ISO 7816-4.
instruction - The INS byte.
p1 - Parameter byte P1.
p2 - Parameter byte P2.

ISOCommandAPDU

public ISOCommandAPDU(byte classByte,
                      byte instruction,
                      byte p1,
                      byte p2,
                      int le)
Constructs a new ISO command APDU (ISO 7816-4 CASE 2).

Parameters:
classByte - The CLA byte as specfied in ISO 7816-4.
instruction - The INS byte.
p1 - Parameter byte P1.
p2 - Parameter byte P2.
le - An integer value giving the expected length of the response APDU. This value can be in the range of -1 to 65536, where -1 means no length is expected and 0 means the maximum length supported is expected.

ISOCommandAPDU

public ISOCommandAPDU(int size,
                      byte classByte,
                      byte instruction,
                      byte p1,
                      byte p2,
                      int le)
Constructs a new ISO command APDU (ISO 7816-4 CASE 2).

Parameters:
size - the size of the APDU buffer to create
classByte - The CLA byte as specfied in ISO 7816-4.
instruction - The INS byte.
p1 - Parameter byte P1.
p2 - Parameter byte P2.
le - An integer value giving the expected length of the response APDU. This value can be in the range of -1 to 65536, where -1 means no length is expected and 0 means the maximum length supported is expected.

ISOCommandAPDU

public ISOCommandAPDU(byte classByte,
                      byte instruction,
                      byte p1,
                      byte p2,
                      byte[] data)
Constructs a new ISO command APDU (ISO 7816-4 CASE 3).

Parameters:
classByte - The CLA byte as specfied in ISO 7816-4.
instruction - The INS byte.
p1 - Parameter byte P1.
p2 - Parameter byte P2.
data - The command APDU data as a byte array. The length lc (which is part of the body of the APDU) is derived from the array length.

ISOCommandAPDU

public ISOCommandAPDU(int size,
                      byte classByte,
                      byte instruction,
                      byte p1,
                      byte p2,
                      byte[] data)
Constructs a new ISO command APDU (ISO 7816-4 CASE 3).

Parameters:
size - the size of the APDU buffer to create
classByte - The CLA byte as specfied in ISO 7816-4.
instruction - The INS byte.
p1 - Parameter byte P1.
p2 - Parameter byte P2.
data - The command APDU data as a byte array. The length lc (which is part of the body of the APDU) is derived from the array length.

ISOCommandAPDU

public ISOCommandAPDU(byte classByte,
                      byte instruction,
                      byte p1,
                      byte p2,
                      byte[] data,
                      int le)
Constructs a new ISO command APDU (ISO 7816-4 CASE 4).

Parameters:
classByte - The CLA byte as specfied in ISO 7816-4.
instruction - The INS byte.
p1 - Parameter byte P1.
p2 - Parameter byte P2.
data - The command APDU data as a byte array. The length lc (which is part of the body of the APDU) is derived from the array length.
le - An integer value giving the expected length of the response APDU. This value can be in the range of -1 to 65536, where -1 means no length is expected and 0 means the maximum length supported is expected.

ISOCommandAPDU

public ISOCommandAPDU(int size,
                      byte classByte,
                      byte instruction,
                      byte p1,
                      byte p2,
                      byte[] data,
                      int le)
Constructs a new ISO command APDU (ISO 7816-4 CASE 4).

Parameters:
size - the size of the APDU buffer to create
classByte - The CLA byte as specfied in ISO 7816-4.
instruction - The INS byte.
p1 - Parameter byte P1.
p2 - Parameter byte P2.
data - The command APDU data as a byte array. The length lc (which is part of the body of the APDU) is derived from the array length.
le - An integer value giving the expected length of the response APDU. This value can be in the range of -1 to 65536, where -1 means no length is expected and 0 means the maximum length supported is expected.
Method Detail

getCLA

public byte getCLA()
Gets the class byte.

Returns:
Class byte of the APDU.

getINS

public byte getINS()
Gets the instruction byte.

Returns:
A byte value.

getP1

public byte getP1()
Gets the P1 byte.

Returns:
A byte value.

getP2

public byte getP2()
Gets the P2 byte.

Returns:
A byte value.

getLC

public int getLC()
Gets the length lc of the data.

Returns:
An integer value giving the length. The value 0 indicates that there is no body.

getLE

public int getLE()
Gets the expected length le of the response APDU.

Returns:
An integer value giving the length. The value -1 indicates that no value is specified.

getIsoCase

public int getIsoCase()
Gets the CASE of this ISOCommandAPDU. ISO 7816-4 distinguishes 7 cases. In addition, coding can be proprietary (e.g., in the context of secure messaging).

Returns:
An integer value indicating the case.

append

public void append(byte[] bytes)
            throws java.lang.IndexOutOfBoundsException
Appends the given byte array to the data field of the APDU.

Overrides:
append in class APDU
Parameters:
bytes - the byte array to be appended
Throws:
java.lang.IndexOutOfBoundsException - The buffer size is exceeded or a le exists in buffer.

append

public void append(byte b)
            throws java.lang.IndexOutOfBoundsException
Appends the given byte to the buffered APDU.

Overrides:
append in class APDU
Parameters:
b - the byte to be appended
Throws:
java.lang.IndexOutOfBoundsException - The buffer size is exceeded or a le exists in buffer.

toString

public java.lang.String toString()
Gets a string representation of this APDU.

Overrides:
toString in class APDU
Returns:
A string describing this APDU.
NOTE: For non-ISO conform Command APDU's the body of the Command APDU is not formatted.