PCSC4Java  0.2
Library PCSC for Java language.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
fr.redbilled.pcscforjava.CommandAPDU Class Reference

List of all members.

Public Member Functions

 CommandAPDU (byte[] apdu)
 CommandAPDU (byte[] apdu, int apduOffset, int apduLength)
 CommandAPDU (ByteBuffer apdu)
 CommandAPDU (int cla, int ins, int p1, int p2)
 CommandAPDU (int cla, int ins, int p1, int p2, int ne)
 CommandAPDU (int cla, int ins, int p1, int p2, byte[] data)
 CommandAPDU (int cla, int ins, int p1, int p2, byte[] data, int dataOffset, int dataLength)
 CommandAPDU (int cla, int ins, int p1, int p2, byte[] data, int ne)
 CommandAPDU (int cla, int ins, int p1, int p2, byte[] data, int dataOffset, int dataLength, int ne)
int getCLA ()
int getINS ()
int getP1 ()
int getP2 ()
int getNc ()
byte[] getData ()
int getNe ()
byte[] getBytes ()
String toString ()
boolean equals (Object obj)
int hashCode ()

Detailed Description

A command APDU following the structure defined in ISO/IEC 7816-4. It consists of a four byte header and a conditional body of variable length. This class does not attempt to verify that the APDU encodes a semantically valid command.

Note that when the expected length of the response APDU is specified in the CommandAPDU(int,int,int,int,int) constructors}, the actual length (Ne) must be specified, not its encoded form (Le). Similarly, getNe} returns the actual value Ne. In other words, a value of 0 means "no data in the response APDU" rather than "maximum length."

This class supports both the short and extended forms of length encoding for Ne and Nc. However, note that not all terminals and Smart Cards are capable of accepting APDUs that use the extended form.

For the header bytes CLA, INS, P1, and P2 the Java type int is used to represent the 8 bit unsigned values. In the constructors, only the 8 lowest bits of the int value specified by the application are significant. The accessor methods always return the byte as an unsigned value between 0 and 255.

Instances of this class are immutable. Where data is passed in or out via byte arrays, defensive cloning is performed.

See also:
ResponseAPDU
CardChannel::transmit CardChannel.transmit
Since:
1.6
Author:
Andreas Sterbenz
JSR 268 Expert Group

Definition at line 65 of file CommandAPDU.java.


Constructor & Destructor Documentation

Constructs a CommandAPDU from a byte array containing the complete APDU contents (header and body).

Note that the apdu bytes are copied to protect against subsequent modification.

Parameters:
apduthe complete command APDU
Exceptions:
NullPointerExceptionif apdu is null
IllegalArgumentExceptionif apdu does not contain a valid command APDU

Definition at line 96 of file CommandAPDU.java.

Here is the caller graph for this function:

fr.redbilled.pcscforjava.CommandAPDU.CommandAPDU ( byte[]  apdu,
int  apduOffset,
int  apduLength 
)

Constructs a CommandAPDU from a byte array containing the complete APDU contents (header and body). The APDU starts at the index apduOffset in the byte array and is apduLength bytes long.

Note that the apdu bytes are copied to protect against subsequent modification.

Parameters:
apduthe complete command APDU
apduOffsetthe offset in the byte array at which the apdu data begins
apduLengththe length of the APDU
Exceptions:
NullPointerExceptionif apdu is null
IllegalArgumentExceptionif apduOffset or apduLength are negative or if apduOffset + apduLength are greater than apdu.length, or if the specified bytes are not a valid APDU

Definition at line 120 of file CommandAPDU.java.

Creates a CommandAPDU from the ByteBuffer containing the complete APDU contents (header and body). The buffer's position must be set to the start of the APDU, its limit to the end of the APDU. Upon return, the buffer's position is equal to its limit; its limit remains unchanged.

Note that the data in the ByteBuffer is copied to protect against subsequent modification.

Parameters:
apduthe ByteBuffer containing the complete APDU
Exceptions:
NullPointerExceptionif apdu is null
IllegalArgumentExceptionif apdu does not contain a valid command APDU

Definition at line 161 of file CommandAPDU.java.

fr.redbilled.pcscforjava.CommandAPDU.CommandAPDU ( int  cla,
int  ins,
int  p1,
int  p2 
)

Constructs a CommandAPDU from the four header bytes. This is case 1 in ISO 7816, no command body.

Parameters:
clathe class byte CLA
insthe instruction byte INS
p1the parameter byte P1
p2the parameter byte P2

Definition at line 176 of file CommandAPDU.java.

fr.redbilled.pcscforjava.CommandAPDU.CommandAPDU ( int  cla,
int  ins,
int  p1,
int  p2,
int  ne 
)

Constructs a CommandAPDU from the four header bytes and the expected response data length. This is case 2 in ISO 7816, empty command data field with Ne specified. If Ne is 0, the APDU is encoded as ISO 7816 case 1.

Parameters:
clathe class byte CLA
insthe instruction byte INS
p1the parameter byte P1
p2the parameter byte P2
nethe maximum number of expected data bytes in a response APDU
Exceptions:
IllegalArgumentExceptionif ne is negative or greater than 65536

Definition at line 195 of file CommandAPDU.java.

fr.redbilled.pcscforjava.CommandAPDU.CommandAPDU ( int  cla,
int  ins,
int  p1,
int  p2,
byte[]  data 
)

Constructs a CommandAPDU from the four header bytes and command data. This is case 3 in ISO 7816, command data present and Ne absent. The value Nc is taken as data.length. If data is null or its length is 0, the APDU is encoded as ISO 7816 case 1.

Note that the data bytes are copied to protect against subsequent modification.

Parameters:
clathe class byte CLA
insthe instruction byte INS
p1the parameter byte P1
p2the parameter byte P2
datathe byte array containing the data bytes of the command body
Exceptions:
IllegalArgumentExceptionif data.length is greater than 65535

Definition at line 216 of file CommandAPDU.java.

fr.redbilled.pcscforjava.CommandAPDU.CommandAPDU ( int  cla,
int  ins,
int  p1,
int  p2,
byte[]  data,
int  dataOffset,
int  dataLength 
)

Constructs a CommandAPDU from the four header bytes and command data. This is case 3 in ISO 7816, command data present and Ne absent. The value Nc is taken as dataLength. If dataLength is 0, the APDU is encoded as ISO 7816 case 1.

Note that the data bytes are copied to protect against subsequent modification.

Parameters:
clathe class byte CLA
insthe instruction byte INS
p1the parameter byte P1
p2the parameter byte P2
datathe byte array containing the data bytes of the command body
dataOffsetthe offset in the byte array at which the data bytes of the command body begin
dataLengththe number of the data bytes in the command body
Exceptions:
NullPointerExceptionif data is null and dataLength is not 0
IllegalArgumentExceptionif dataOffset or dataLength are negative or if dataOffset + dataLength are greater than data.length or if dataLength is greater than 65535

Definition at line 243 of file CommandAPDU.java.

fr.redbilled.pcscforjava.CommandAPDU.CommandAPDU ( int  cla,
int  ins,
int  p1,
int  p2,
byte[]  data,
int  ne 
)

Constructs a CommandAPDU from the four header bytes, command data, and expected response data length. This is case 4 in ISO 7816, command data and Ne present. The value Nc is taken as data.length if data is non-null and as 0 otherwise. If Ne or Nc are zero, the APDU is encoded as case 1, 2, or 3 per ISO 7816.

Note that the data bytes are copied to protect against subsequent modification.

Parameters:
clathe class byte CLA
insthe instruction byte INS
p1the parameter byte P1
p2the parameter byte P2
datathe byte array containing the data bytes of the command body
nethe maximum number of expected data bytes in a response APDU
Exceptions:
IllegalArgumentExceptionif data.length is greater than 65535 or if ne is negative or greater than 65536

Definition at line 268 of file CommandAPDU.java.

fr.redbilled.pcscforjava.CommandAPDU.CommandAPDU ( int  cla,
int  ins,
int  p1,
int  p2,
byte[]  data,
int  dataOffset,
int  dataLength,
int  ne 
)

Constructs a CommandAPDU from the four header bytes, command data, and expected response data length. This is case 4 in ISO 7816, command data and Le present. The value Nc is taken as dataLength. If Ne or Nc are zero, the APDU is encoded as case 1, 2, or 3 per ISO 7816.

Note that the data bytes are copied to protect against subsequent modification.

Parameters:
clathe class byte CLA
insthe instruction byte INS
p1the parameter byte P1
p2the parameter byte P2
datathe byte array containing the data bytes of the command body
dataOffsetthe offset in the byte array at which the data bytes of the command body begin
dataLengththe number of the data bytes in the command body
nethe maximum number of expected data bytes in a response APDU
Exceptions:
NullPointerExceptionif data is null and dataLength is not 0
IllegalArgumentExceptionif dataOffset or dataLength are negative or if dataOffset + dataLength are greater than data.length, or if ne is negative or greater than 65536, or if dataLength is greater than 65535

Definition at line 381 of file CommandAPDU.java.


Member Function Documentation

Compares the specified object with this command APDU for equality. Returns true if the given object is also a CommandAPDU and its bytes are identical to the bytes in this CommandAPDU.

Parameters:
objthe object to be compared for equality with this command APDU
Returns:
true if the specified object is equal to this command APDU

Definition at line 579 of file CommandAPDU.java.

Here is the call graph for this function:

Here is the caller graph for this function:

Returns a copy of the bytes in this APDU.

Returns:
a copy of the bytes in this APDU.

Definition at line 558 of file CommandAPDU.java.

Returns the value of the class byte CLA.

Returns:
the value of the class byte CLA.

Definition at line 487 of file CommandAPDU.java.

Returns a copy of the data bytes in the command body. If this APDU as no body, this method returns a byte array with length zero.

Returns:
a copy of the data bytes in the command body or the empty byte array if this APDU has no body.

Definition at line 537 of file CommandAPDU.java.

Returns the value of the instruction byte INS.

Returns:
the value of the instruction byte INS.

Definition at line 496 of file CommandAPDU.java.

Returns the number of data bytes in the command body (Nc) or 0 if this APDU has no body. This call is equivalent to getData().length.

Returns:
the number of data bytes in the command body or 0 if this APDU has no body.

Definition at line 526 of file CommandAPDU.java.

Returns the maximum number of expected data bytes in a response APDU (Ne).

Returns:
the maximum number of expected data bytes in a response APDU.

Definition at line 549 of file CommandAPDU.java.

Returns the value of the parameter byte P1.

Returns:
the value of the parameter byte P1.

Definition at line 505 of file CommandAPDU.java.

Returns the value of the parameter byte P2.

Returns:
the value of the parameter byte P2.

Definition at line 514 of file CommandAPDU.java.

Returns the hash code value for this command APDU.

Returns:
the hash code value for this command APDU.

Definition at line 595 of file CommandAPDU.java.

Returns a string representation of this command APDU.

Returns:
a String representation of this command APDU.

Definition at line 567 of file CommandAPDU.java.


The documentation for this class was generated from the following file: