com.linuxnet.jpcsc
Class Card

java.lang.Object
  extended bycom.linuxnet.jpcsc.Card

public final class Card
extends java.lang.Object

The Card-class offers the PCSC-functions related to connecting, disconnecting and transfering data to cards.


Field Summary
private  long card
          Native handle.
private  int proto
          Protocol used.
 
Constructor Summary
(package private) Card()
          Constructor.
 
Method Summary
 void BeginTransaction()
          Signal the start of a transaction.
 byte[] Control(int dwControlCode, byte[] in, int off, int len)
          Wrapper for SCardControl().
 void Disconnect(int param)
          Disconnect from card.
 void EndTransaction(int disposition)
          Signal end of a transaction.
 void finalize()
          Cleanup.
 int getProto()
          Return protocol used.
private  int NativeBeginTransaction()
           
private  byte[] NativeControl(int cc, byte[] in, int off, int len)
           
private  int NativeDisconnect(int param)
           
private  int NativeEndTransaction(int dispo)
           
private  int NativeReconnect(int dwSharedMode, int dwPreferredProtos, int dwInitialization)
           
private  int NativeStatus(State rs)
           
private  byte[] NativeTransmit(byte[] in, int off, int len)
           
private  int NativeTransmit(byte[] in, int inoff, int len, byte[] out, int outoff)
           
 void Reconnect(int dwSharedMode, int dwPreferredProtos, int dwInitialization)
          Reconnect to card.
 State Status()
          Return status of connection.
 byte[] Transmit(Apdu apdu)
          Transmit given APDU.
 byte[] Transmit(byte[] in, int off, int len)
          Transmit data.
 int Transmit(byte[] in, int inoff, int len, byte[] out, int outoff)
          Transmit data.
 byte[] Transmit(int cla, int ins, int p1, int p2, byte[] in)
          Transmit data to the card.
 byte[] Transmit(int cla, int ins, int p1, int p2, byte[] in, int le)
          Transmit data to the card.
 byte[] Transmit(int cla, int ins, int p1, int p2, byte[] in, int off, int len)
          Transmit data to the card.
 byte[] Transmit(int cla, int ins, int p1, int p2, byte[] in, int off, int len, int le)
          Transmit data to the card.
 byte[] Transmit(int cla, int ins, int p1, int p2, int p3, byte[] in, int off, int le)
          Transmit data to the card.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

card

private long card
Native handle.


proto

private int proto
Protocol used. It is cached in a Card-instance and set in Connect() and Reconnect().

Constructor Detail

Card

Card()
Constructor.

Method Detail

getProto

public final int getProto()
Return protocol used.


finalize

public final void finalize()
Cleanup.


Disconnect

public final void Disconnect(int param)
Disconnect from card.


Reconnect

public final void Reconnect(int dwSharedMode,
                            int dwPreferredProtos,
                            int dwInitialization)
Reconnect to card.


Transmit

public final byte[] Transmit(Apdu apdu)
Transmit given APDU. Result is returned in newly created array. In case of error, the native code raises a PCSCException.


Transmit

public final byte[] Transmit(byte[] in,
                             int off,
                             int len)
Transmit data. Result is returned in newly created array. Range within given array must contain properly constructed APDU. In case of error, the native code raises a PCSCException.


Transmit

public final byte[] Transmit(int cla,
                             int ins,
                             int p1,
                             int p2,
                             int p3,
                             byte[] in,
                             int off,
                             int le)
Transmit data to the card. Result is returned in a newly created array. The given APDU header information and data are stored in a newly created temporary array and passed to the native Transmit rotuines.

Parameters:
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.
off - offset starting at which data sending is to begin
le - LE byte of APDU (appended to APDU). This byte is omitted if parameter has value -1.
Returns:
response APDU as a byte array
Throws:
PCSCException - if communication failed or if some parameters are wrong

Transmit

public final byte[] Transmit(int cla,
                             int ins,
                             int p1,
                             int p2,
                             byte[] in,
                             int off,
                             int len,
                             int le)
Transmit data to the card. Result is returned in a newly created array. The given APDU header information and data are stored in a newly created temporary array and passed to the native Transmit rotuines. The given range of the given in buffer is sent to the card.

Parameters:
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)
in - byte array containing command data of APDU.
off - offset starting at which data sending is to begin
len - number of bytes to be transmitted
le - LE byte of APDU (appended to APDU). This byte is omitted if parameter has value -1.
Returns:
response APDU as a byte array
Throws:
PCSCException - if communication failed or if some parameters are wrong

Transmit

public final byte[] Transmit(int cla,
                             int ins,
                             int p1,
                             int p2,
                             byte[] in,
                             int le)
Transmit data to the card. Result is returned in a newly created array. The given APDU header information and data are stored in a newly created temporary array and passed to the native Transmit rotuines. The given in buffer is fully sent to the card.

Parameters:
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)
in - byte array containing command data of APDU.
le - LE byte of APDU (appended to APDU). This byte is omitted if parameter has value -1.
Returns:
response APDU as a byte array
Throws:
PCSCException - if communication failed or if some parameters are wrong

Transmit

public final byte[] Transmit(int cla,
                             int ins,
                             int p1,
                             int p2,
                             byte[] in,
                             int off,
                             int len)
Transmit data to the card. Result is returned in a newly created array. The given APDU header information and data are stored in a newly created temporary array and passed to the native Transmit rotuines. The given range of the in buffer is sent and the expected length field is left out.

Parameters:
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)
in - byte array containing command data of APDU.
off - offset starting at which data sending is to begin
len - number of bytes to be transmitted
Returns:
response APDU as a byte array
Throws:
PCSCException - if communication failed or if some parameters are wrong

Transmit

public final byte[] Transmit(int cla,
                             int ins,
                             int p1,
                             int p2,
                             byte[] in)
Transmit data to the card. Result is returned in a newly created array. The given APDU header information and data are stored in a newly created temporary array and passed to the native Transmit rotuines. The in buffer is sent completely, the expected length field is left out.

Parameters:
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)
in - byte array containing command data of APDU.
Returns:
response APDU as a byte array
Throws:
PCSCException - if communication failed or if some parameters are wrong

Transmit

public final int Transmit(byte[] in,
                          int inoff,
                          int len,
                          byte[] out,
                          int outoff)
Transmit data. Result is returned in the passed array at given offset. The range within the given buffer in must hold a properly constructed APDU. On success, the returned value will hold the number of bytes stored in the result buffer. In case of an error, a PCSCException is raised. The exception instance then contains the PCSC error code. If sending the APDU was successful, the number of bytes received are returned.


Status

public final State Status()
Return status of connection.


BeginTransaction

public final void BeginTransaction()
Signal the start of a transaction.


EndTransaction

public final void EndTransaction(int disposition)
Signal end of a transaction.


Control

public final byte[] Control(int dwControlCode,
                            byte[] in,
                            int off,
                            int len)
Wrapper for SCardControl(). Note that PCSC for Linux does not support the dwControlCode paramter.


NativeDisconnect

private int NativeDisconnect(int param)

NativeTransmit

private byte[] NativeTransmit(byte[] in,
                              int off,
                              int len)

NativeTransmit

private int NativeTransmit(byte[] in,
                           int inoff,
                           int len,
                           byte[] out,
                           int outoff)

NativeStatus

private int NativeStatus(State rs)

NativeBeginTransaction

private int NativeBeginTransaction()

NativeEndTransaction

private int NativeEndTransaction(int dispo)

NativeReconnect

private int NativeReconnect(int dwSharedMode,
                            int dwPreferredProtos,
                            int dwInitialization)

NativeControl

private byte[] NativeControl(int cc,
                             byte[] in,
                             int off,
                             int len)