com.ibm.jc.terminal
Class PCSCJCTerminal

java.lang.Object
  extended bycom.ibm.jc.JCTerminal
      extended bycom.ibm.jc.terminal.PCSCJCTerminal

public class PCSCJCTerminal
extends JCTerminal

This jct terminal sits on top of JPCSC to talk with PCSC terminals and readers. Thus, you have to have JPCSC properly installed and jpcsc.jar and its native library libjpcsc.so or jpcsc.dll must be reachable by the VM.


Field Summary
 
Fields inherited from class com.ibm.jc.JCTerminal
CARD_PRESENT, ERROR, NOT_CONNECTED, PROTOCOL_T0, PROTOCOL_T1, PROTOCOL_TCL, SLOT_EMPTY
 
Constructor Summary
PCSCJCTerminal()
           
 
Method Summary
 void close()
          Close connection to card terminal.
 void finalize()
           
 java.lang.String getErrorMessage()
           
 int getState()
           
 JCTerminal init(java.lang.Object param)
          A valid argument string has the form "readername|flags" or readername|flags where reader name might be the name of a reader or "any" where the first available reader is chosen.
 void open()
          Open the card terminal.
 byte[] send(int nad, byte[] toSend, int offset, int len)
          Send data to the card (using the negotiated protocol).
 java.lang.String toString()
           
 byte[] waitForCard(int time)
          Wait for insertion of a card and return ATR (answer to reset).
 
Methods inherited from class com.ibm.jc.JCTerminal
filterFor, filterFor, generateParityError, getInstance, ioctl, pps, send, sendraw
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PCSCJCTerminal

public PCSCJCTerminal()
Method Detail

init

public JCTerminal init(java.lang.Object param)
A valid argument string has the form "readername|flags" or readername|flags where reader name might be the name of a reader or "any" where the first available reader is chosen. Flags so far might either be e or s, leading to a exclusive or shared connection to the PCSC daemon, and d for switching on debug output. If no parameter s or e is given, the first reader a card is inserted in is chosen. If no reader contains a card, the first reader returned by PCSC is chosen. By default, all connections to cards are exclusive during the session. In the shell, use "/terminal PCSC|any|s" to get a shared connection for the first available PCSC reader.

Overrides:
init in class JCTerminal
Parameters:
param - some parameter initializing the terminal. The possible types and meanings depend on the specific terminal. It is expected that all terminals support at least some String based initialization.
Returns:
this

finalize

public void finalize()

open

public void open()
Description copied from class: JCTerminal
Open the card terminal. Access to the terminal by other processes usually is not possible anylonger.

Specified by:
open in class JCTerminal

close

public void close()
Description copied from class: JCTerminal
Close connection to card terminal. The caller can reconnect to the terminal using the open() method.

Specified by:
close in class JCTerminal
See Also:
JCTerminal.open()

waitForCard

public byte[] waitForCard(int time)
Description copied from class: JCTerminal
Wait for insertion of a card and return ATR (answer to reset). If a card is already inserted this explicitly resets the card and returns the ATR. If no card is inserted the call blocks for a specified amount of time.

Note, not all terminals support the time parameter. It is only guaranteed that the call will not block longer than the specified time. It might return immediately with null.

Specified by:
waitForCard in class JCTerminal
Parameters:
time - the calls blocks for specified milliseconds.
Returns:
ATR (answer to reset) or null if no ATR could be retrieved. The reason might be that no card is inserted or because of communication problems.

getState

public int getState()
Specified by:
getState in class JCTerminal
Returns:
the status of the terminal. See constants. The status condition of the last call to the terminal.

send

public byte[] send(int nad,
                   byte[] toSend,
                   int offset,
                   int len)
Description copied from class: JCTerminal
Send data to the card (using the negotiated protocol). (To make applications independent of logical channels JCard.send() should be used)

Specified by:
send in class JCTerminal
Parameters:
nad - node address to which data is being sent (high nibble = destination address, low = source address). Address values: 2=host, 1=terminal, 0=card. A value of 0 means from host to card.
toSend - byte array containing APDU data to be sent
offset - offset starting at which APDU data sending is to begin
len - number of bytes to be transmitted
Returns:
response APDU as a byte array
See Also:
com.ibm.jc.JCard.send

toString

public java.lang.String toString()
Overrides:
toString in class JCTerminal
Returns:
a description of the card terminal settings and the current terminal state. The string might span multiple lines and should not end with a new line. This default implementation returns the terminal name and the state as hexdecimal value. The terminal is either the full class name or the T part if the class name is of the form com.ibm.jc.terminal.TJCTerminal.

getErrorMessage

public java.lang.String getErrorMessage()
Overrides:
getErrorMessage in class JCTerminal
Returns:
a description of the last error. If not error is registered or if there is not verbose description a null value is returned. This default implementation returns null.