com.sun.javacard.apduio
Class Apdu

java.lang.Object
  extended by com.sun.javacard.apduio.Apdu

public class Apdu
extends java.lang.Object

This class represent a pair of C-APDU and R-APDU. It is used internally by several components of the Java Card development kit.


Field Summary
static int APDU_TYPE_MASK
          Mask to extract APDU type information: either ISO ecoding or not.
static int CASE_1
          The value which indicates this Apdu is an ISO 7816-3 Case 1 apdu
static int CASE_2E
          The value which indicates this Apdu is an ISO 7816-3 Case 2 Extended apdu
static int CASE_2S
          The value which indicates this Apdu is an ISO 7816-3 Case 2 Short apdu
static int CASE_3E
          The value which indicates this Apdu is an ISO 7816-3 Case 3 Extended apdu
static int CASE_3S
          The value which indicates this Apdu is an ISO 7816-3 Case 3 Short apdu
static int CASE_4E
          The value which indicates this Apdu is an ISO 7816-3 Case 4 Extended apdu
static int CASE_4S
          The value which indicates this Apdu is an ISO 7816-3 Case 4 Short apdu
static int CLA
          The offset in the command array to the ISO 7816-3 CLA octet.
 byte[] command
          Internal representation of the C-APDU header
static int COMMAND_ARRAY_SIZE
          Size of the command array
 byte[] dataIn
          Data part of the C-APDU
 byte[] dataOut
          Data part of the R-APDU
 boolean formatOP
          Descriptive Output Flag
static int INS
          The offset in the command array to the ISO 7816-3 INS octet.
 boolean isExtended
          Extended APDU flag
 int Lc
          Value of Lc
 int Le
          Value of Le
static int LOGICAL_CHN_MASK
          Mask to extract channel information out of the CLA byte.
static int P1
          The offset in the command array to the ISO 7816-3 P1 octet.
static int P2
          The offset in the command array to the ISO 7816-3 P2 octet.
static int P3
          The offset in the command array to the ISO 7816-3 P3 octet.
static java.util.Hashtable<java.lang.Object,java.lang.String> STATUS_CODES
           
 byte[] sw1sw2
          Status as byte array
 
Constructor Summary
Apdu()
          Creates a new instance of Apdu.
Apdu(byte[] b)
           
 
Method Summary
 int getCase()
          Return the ISO 7816-3 Case of this Apdu
 byte getChannelInfo()
          Determines the channel number
 byte[] getCommand()
          Get internal representation of the header of the C-APDU The header is just CLA, INS, P1, P2
 byte[] getCommandApduBytes()
          returns the command APDU as a byte array.
 byte[] getDataIn()
          Get the data part of the C-APDU
 byte[] getDataOut()
          Get the data part of the R-APDU
 int getLc()
          Get Lc
 int getLe()
          Get Le
 byte[] getResponseApduBytes()
          returns the response APDU as a byte array.
 int getStatus()
          Get status (SW bytes) as integer
 byte[] getSw1Sw2()
          Get status bytes
 byte makeISOInterIndustryCLA(byte CLAByte)
           
 void setDataIn(byte[] dataIn)
          Set the data of the C-APDU
 void setDataIn(byte[] dataIn, int length)
          Set the data of the C-APDU
 void setDataOut(byte[] dataOut)
          Set the data part of the R-APDU
 void setDataOut(byte[] dataOut, int length)
          Set the data part of the R-APDU
 void setLc(int Lc)
          Set the value of Lc
 void setLe(int Le)
          Set Le
 java.lang.String toString()
          Generate a string representation of this Apdu in the ApduTool output format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

COMMAND_ARRAY_SIZE

public static final int COMMAND_ARRAY_SIZE
Size of the command array

See Also:
Constant Field Values

CLA

public static final int CLA
The offset in the command array to the ISO 7816-3 CLA octet.

See Also:
Constant Field Values

INS

public static final int INS
The offset in the command array to the ISO 7816-3 INS octet.

See Also:
Constant Field Values

P1

public static final int P1
The offset in the command array to the ISO 7816-3 P1 octet.

See Also:
Constant Field Values

P2

public static final int P2
The offset in the command array to the ISO 7816-3 P2 octet.

See Also:
Constant Field Values

P3

public static final int P3
The offset in the command array to the ISO 7816-3 P3 octet.

See Also:
Constant Field Values

CASE_1

public static final int CASE_1
The value which indicates this Apdu is an ISO 7816-3 Case 1 apdu

See Also:
Constant Field Values

CASE_2S

public static final int CASE_2S
The value which indicates this Apdu is an ISO 7816-3 Case 2 Short apdu

See Also:
Constant Field Values

CASE_3S

public static final int CASE_3S
The value which indicates this Apdu is an ISO 7816-3 Case 3 Short apdu

See Also:
Constant Field Values

CASE_4S

public static final int CASE_4S
The value which indicates this Apdu is an ISO 7816-3 Case 4 Short apdu

See Also:
Constant Field Values

CASE_2E

public static final int CASE_2E
The value which indicates this Apdu is an ISO 7816-3 Case 2 Extended apdu

See Also:
Constant Field Values

CASE_3E

public static final int CASE_3E
The value which indicates this Apdu is an ISO 7816-3 Case 3 Extended apdu

See Also:
Constant Field Values

CASE_4E

public static final int CASE_4E
The value which indicates this Apdu is an ISO 7816-3 Case 4 Extended apdu

See Also:
Constant Field Values

LOGICAL_CHN_MASK

public static final int LOGICAL_CHN_MASK
Mask to extract channel information out of the CLA byte.

See Also:
Constant Field Values

APDU_TYPE_MASK

public static final int APDU_TYPE_MASK
Mask to extract APDU type information: either ISO ecoding or not.

See Also:
Constant Field Values

command

public byte[] command
Internal representation of the C-APDU header


Lc

public int Lc
Value of Lc


dataIn

public byte[] dataIn
Data part of the C-APDU


Le

public int Le
Value of Le


dataOut

public byte[] dataOut
Data part of the R-APDU


sw1sw2

public byte[] sw1sw2
Status as byte array


isExtended

public boolean isExtended
Extended APDU flag


formatOP

public boolean formatOP
Descriptive Output Flag


STATUS_CODES

public static final java.util.Hashtable<java.lang.Object,java.lang.String> STATUS_CODES
Constructor Detail

Apdu

public Apdu(byte[] b)
Parameters:
b -

Apdu

public Apdu()
Creates a new instance of Apdu.

Method Detail

getCommand

public byte[] getCommand()
Get internal representation of the header of the C-APDU The header is just CLA, INS, P1, P2

Returns:
The header of the C-APDU

getDataIn

public byte[] getDataIn()
Get the data part of the C-APDU

Returns:
The data

setDataIn

public void setDataIn(byte[] dataIn)
Set the data of the C-APDU

Parameters:
dataIn - The data

setLc

public void setLc(int Lc)
Set the value of Lc

Parameters:
Lc - value of the Lc

setDataIn

public void setDataIn(byte[] dataIn,
                      int length)
Set the data of the C-APDU

Parameters:
dataIn - The data
length - the data length

getLc

public int getLc()
Get Lc

Returns:
The Lc

setDataOut

public void setDataOut(byte[] dataOut)
Set the data part of the R-APDU

Parameters:
dataOut - The data

setLe

public void setLe(int Le)
Set Le

Parameters:
Le - value of Le

setDataOut

public void setDataOut(byte[] dataOut,
                       int length)
Set the data part of the R-APDU

Parameters:
dataOut - The data
length - The data length

getLe

public int getLe()
Get Le

Returns:
The Le

getDataOut

public byte[] getDataOut()
Get the data part of the R-APDU

Returns:
The data part of the R-APDU

getSw1Sw2

public byte[] getSw1Sw2()
Get status bytes

Returns:
The status bytes

getStatus

public int getStatus()
Get status (SW bytes) as integer

Returns:
The status

getCase

public int getCase()
Return the ISO 7816-3 Case of this Apdu

Returns:
An int value indicating the ISO case.

getChannelInfo

public byte getChannelInfo()
Determines the channel number

Returns:
The channel number

makeISOInterIndustryCLA

public byte makeISOInterIndustryCLA(byte CLAByte)

getCommandApduBytes

public byte[] getCommandApduBytes()
returns the command APDU as a byte array.

Returns:
The command APDU

getResponseApduBytes

public byte[] getResponseApduBytes()
returns the response APDU as a byte array.

Returns:
The response APDU

toString

public java.lang.String toString()
Generate a string representation of this Apdu in the ApduTool output format.

Overrides:
toString in class java.lang.Object
Returns:
String representation of this Apdu


Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.