Package com.sun.javacard.apduio
Class ServerT0Protocol
- java.lang.Object
-
- com.sun.javacard.apduio.ServerT0Protocol
-
public class ServerT0Protocol extends java.lang.Object
The ServerT0Protocol class maintains the context used in the server side T=0 protocol.- See Also:
T0ServerState
-
-
Constructor Summary
Constructors Constructor Description ServerT0Protocol(java.io.InputStream in, java.io.OutputStream out)
Constructs a ServerT0Protocol using an InputStream and an OutputStream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCadServerListener(CadServerListener listener)
Register a new CadServerListener to be notified of state changes.void
removeCadServerListener(CadServerListener listener)
Remove a CadServerListener from the list of listeners to be notified of state changes.void
sendATR(byte[] atr)
Wait for a POWER_UP command to be received from the CAD and send the ATR (Answer To Reset) back to the CAD.byte
t0RcvCommand(byte[] command)
Receive a five byte T=0 command APDU into the command array.byte
t0RcvData(byte[] buffer, short offset, short count, byte procByte)
Receive the data portion of a T=0 APDU.byte
t0SndData(byte[] buffer, short offset, short count)
Send the data portion of a T=0 APDU.byte
t0SndData(byte[] buffer, short offset, short count, byte procByte)
Send the data portion of a T=0 APDU.byte
t0SndStatusRcvCommand(byte[] command, short sw1sw2)
Send the status bytes SW1/SW2 and receive a five byte T=0 header into the command array.
-
-
-
Method Detail
-
addCadServerListener
public void addCadServerListener(CadServerListener listener)
Register a new CadServerListener to be notified of state changes.- Parameters:
listener
- The listener to register.
-
removeCadServerListener
public void removeCadServerListener(CadServerListener listener)
Remove a CadServerListener from the list of listeners to be notified of state changes.- Parameters:
listener
- The listener to remove.
-
t0RcvCommand
public byte t0RcvCommand(byte[] command)
Receive a five byte T=0 command APDU into the command array. This method is invoked following the sendATR() method prior to starting the send/receive cycle.- Parameters:
command
- The byte array to receive data into. The array must be at least five bytes long.- Returns:
- 0 on success, 1 on I/O error
-
t0SndStatusRcvCommand
public byte t0SndStatusRcvCommand(byte[] command, short sw1sw2)
Send the status bytes SW1/SW2 and receive a five byte T=0 header into the command array.- Parameters:
command
- The byte array to receive data into. The array must be at least five bytes long.sw1sw2
- the status bytes SW1 and SW2 are combined into the short sw1sw2- Returns:
- 0 on success, 1 on I/O error
-
t0RcvData
public byte t0RcvData(byte[] buffer, short offset, short count, byte procByte)
Receive the data portion of a T=0 APDU. The procedure byte is sent to the CAD prior to receiving the data.- Parameters:
buffer
- The buffer into which the data is read.offset
- The index in buffer in which to start storing the bytes read.count
- The number of bytes to read.procByte
- The procedure byte to send.- Returns:
- 0 on success, 1 on I/O error
-
t0SndData
public byte t0SndData(byte[] buffer, short offset, short count, byte procByte)
Send the data portion of a T=0 APDU. The procedure byte is sent to the CAD prior to sending the data.- Parameters:
buffer
- The buffer from which the data is sent.offset
- The index in buffer in which to start sending from.count
- The number of bytes to send.procByte
- The procedure byte to send.- Returns:
- 0 on success, 1 on I/O error
-
t0SndData
public byte t0SndData(byte[] buffer, short offset, short count)
Send the data portion of a T=0 APDU.- Parameters:
buffer
- The buffer from which the data is sent.offset
- The index in buffer in which to start sending from.count
- The number of bytes to send.- Returns:
- 0 on success, 1 on I/O error
-
sendATR
public void sendATR(byte[] atr) throws java.io.IOException, TLP224Exception
Wait for a POWER_UP command to be received from the CAD and send the ATR (Answer To Reset) back to the CAD. This method must be called prior to any other method in this class.- Parameters:
atr
- The byte array which contains the ATR to send.- Throws:
java.io.IOException
- If an IO error occured while attempting to send the ATR.TLP224Exception
-
-