|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.ibm.jc.JCTerminal
Terminal abstraction for smart card communications. All Java-based off-card components rely on this abstract class to communicate with a card terminal of some smart card. This class offers a very simple and easy to use API. It addresses the standard functionality required by most smart card aware applications and the features offered by normal card terminals.
| Field Summary | |
static int |
CARD_PRESENT
Terminal state: card present in terminal slot (0x04). |
static int |
ERROR
Terminal state: some communication error happened (0x08). |
static int |
NOT_CONNECTED
Terminal state: process is not connected to terminal (0x01). |
static int |
PROTOCOL_T0
Protocol type for PPS: T=0 (0x00) |
static int |
PROTOCOL_T1
Protocol type for PPS: T=1 (0x01) |
static int |
PROTOCOL_TCL
Protocol type for PPS: T=CL (0x05) |
static int |
SLOT_EMPTY
Terminal state: no card present in terminal slot (0x02). |
| Constructor Summary | |
JCTerminal()
|
|
| Method Summary | |
abstract void |
close()
Close connection to card terminal. |
JCTerminal |
filterFor()
Determine if terminal is a filter. |
JCTerminal |
filterFor(JCTerminal term)
Attache some terminal to this terminal filter. |
void |
generateParityError(int n)
Schedule generation of parity error for the n-th character to be transmitted (in or out). |
java.lang.String |
getErrorMessage()
|
static JCTerminal |
getInstance(java.lang.String spec,
java.lang.String param)
Create an instance of the specified terminal. |
abstract int |
getState()
|
JCTerminal |
init(java.lang.Object param)
Initialize terminal. |
byte[] |
ioctl(int req,
byte[] param,
int off,
int len)
Perform terminal-dependent action... |
abstract void |
open()
Open the card terminal. |
void |
pps(int protocol,
int parameter)
Select protocol and parameters for subsequent communication (can only be applied immediately after card reset). |
abstract byte[] |
send(int nad,
byte[] toSend,
int offset,
int len)
Send data to the card (using the negotiated protocol). |
byte[] |
send(int nad,
int cla,
int ins,
int p1,
int p2,
int p3,
byte[] toSend,
int offset,
int le)
Send data to the card terminal. |
byte[] |
sendraw(byte[] data,
int off,
int len,
int timeout)
Send data to the card (using *no* protocol, raw bytes are transmitted without modification). |
java.lang.String |
toString()
|
abstract byte[] |
waitForCard(int time)
Wait for insertion of a card and return ATR (answer to reset). |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final int NOT_CONNECTED
public static final int SLOT_EMPTY
public static final int CARD_PRESENT
public static final int ERROR
public static final int PROTOCOL_T0
public static final int PROTOCOL_T1
public static final int PROTOCOL_TCL
| Constructor Detail |
public JCTerminal()
| Method Detail |
public static JCTerminal getInstance(java.lang.String spec,
java.lang.String param)
spec - the terminal specifier. This parameter can be null.param - this is used to initialize the terminal (see init method). This parameter can be null.
java.lang.RuntimeException - various runtime exceptions if instanciation or cast to JCTerminal fails.JCTerminal,
NativeJCTerminalpublic JCTerminal init(java.lang.Object param)
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.
public java.lang.String toString()
public java.lang.String getErrorMessage()
public JCTerminal filterFor()
public JCTerminal filterFor(JCTerminal term)
public abstract void open()
public abstract void close()
open()public abstract byte[] waitForCard(int 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.
time - the calls blocks for specified milliseconds.
public abstract int getState()
public abstract byte[] send(int nad,
byte[] toSend,
int offset,
int len)
JCard.send() should be used)
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 sentoffset - offset starting at which APDU data sending is to beginlen - number of bytes to be transmitted
JCException - if communication failed or if some parameters are wrongcom.ibm.jc.JCard.send
public byte[] sendraw(byte[] data,
int off,
int len,
int timeout)
data - byte array containing raw data to be sentoff - offset starting at which raw data sending is to beginlen - number of bytes to be transmittedtimeout - time to wait for response data (time unit is device-dependent, ignored by some readers)
JCException - if communication failed or if some parameters are wrong
public void pps(int protocol,
int parameter)
protocol - protocol type to be used (PROTOCOL_T0 or PROTOCOL_T1 in contact mode, PROTOCOL_TCL in contact-less mode)parameter - baud rate
JCException - if communication failed or if some parameters are wrongPROTOCOL_T0,
PROTOCOL_T1,
PROTOCOL_TCL,
sendpublic void generateParityError(int n)
n - index of character to manipulate (0-based)
JCException - if some parameters are wrong
public byte[] ioctl(int req,
byte[] param,
int off,
int len)
req - request codeparam - array holding request parameters (may be null)off - offset to parameterslen - length of parameters
JCException - if some parameters are wrong
public final byte[] send(int nad,
int cla,
int ins,
int p1,
int p2,
int p3,
byte[] toSend,
int offset,
int le)
JCard.send() should be used)
nad - node address to which data is being sentcla - 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.toSend - byte array containing command data of APDU. Command data starts at byte #5.offset - offset starting at which data sending is to beginle - LE byte of APDU (appended to APDU). This byte is omitted if parameter has value -1.
JCException - if communication failed or if some parameters are wrongcom.ibm.jc.JCard.send
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||