ServerT0Protocol (Java Card 3 Platform, APDU I/O Library)
Date: 2009-11-05

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## 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
`ServerT0Protocol(java.io.InputStream in, java.io.OutputStream out)` Constructs a ServerT0Protocol using an InputStream and an OutputStream.

Method Summary
`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.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ServerT0Protocol

    public ServerT0Protocol(java.io.InputStream in,
                            java.io.OutputStream out)

  Constructs a ServerT0Protocol using an InputStream and an OutputStream.

  Parameters:
    `in` - The InputStream connected to the CAD.
    `out` - The OutputStream connected to the CAD.

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`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.