Class CadT1

  • Direct Known Subclasses:
    CadT1Client

    public class CadT1
    extends CadDevice
    The CadT1 class manages the encodes and decodes T=1 transport level messages between an InputStream and an OutputStream. This class wraps T=1 commands in a reader layer. basically, in order to send commands to the reader, a wrapper protocol has been defined. The wrapper protocol wraps message as follows: +---------+--------+---------------+-----+ | OPCODE | LENGTH | ...MESSAGE... | LRC | +---------+--------+---------------+-----+ 1 byte 2 bytes n bytes 1 byte See T1Block class for further reference.
    • Constructor Detail

      • CadT1

        public CadT1​(java.io.InputStream in,
                     java.io.OutputStream out)
        Create a new instance of the CadT1 class using an InputStream and an OutputStream.
        Parameters:
        in - The InputStream to read from.
        out - The OutputStream to write to.
    • Method Detail

      • exchangeBlock

        public boolean exchangeBlock​(T1Block blockTo,
                                     T1Block blockFrom)
                              throws java.io.IOException,
                                     T1Exception
        Implement T=1 I-block, R-block and S-block primitives Exchanges a block between the terminal and the Card reader.
        Parameters:
        blockTo - T1Block instance representing the block to send to the other entity.
        blockFrom - T1Block instance representing the block received from the other entity.
        Returns:
        true if the exchange compelted successfully, false otherwise.
        Throws:
        T1Exception - if a T=1 protocol or transport protocol inconsistency is detected
        java.io.IOException - if a problem with the I/O exchange mechanism occurs.
      • receiveBlock

        public boolean receiveBlock​(T1Block blockFrom)
                             throws java.io.IOException,
                                    T1Exception
        Reads the first T=1 Block from the terminal, setting the information inteh block passed as parameter. Method assumes that caller is on the card side.
        Parameters:
        blockFrom - Block in which to receive the data.
        Throws:
        T1Exception - if a transport protocol inconsistency is detected.
        java.io.IOException - if a problem with the I/O exchange mechanism.
      • sendATR

        public boolean sendATR​(byte[] atrData)
                        throws java.io.IOException,
                               T1Exception
        Sends the Aswer-To-Reset bytes to the terminal. Assumes that caller is located at the Card end.
        Parameters:
        atrData - Byte array containing the ATR string.
        Returns:
        true if the exchange compelted successfully, false otherwise.
        Throws:
        T1Exception - if a transport protocol inconsistency is detected
        java.io.IOException - if a problem with the I/O exchange mechanism occurs.
      • getMaxIFSSize

        public int getMaxIFSSize()
        Returns the maximum IFS size supported by this CAD T=1 instance.
        Returns:
        manimum T=1 IFS field Block size.
      • retrieveATR

        public byte[] retrieveATR()
                           throws java.io.IOException,
                                  T1Exception
        Receives the Aswer-To-Reset bytes from the card. Assumes that caller is located at the terminal end.
        Returns:
        byte array containing the ATR bytes from the card.
        Throws:
        T1Exception - if a transport protocol inconsistency is detected
        java.io.IOException - if a problem with the I/O exchange mechanism occurs.
      • receivePowerUp

        public boolean receivePowerUp()
                               throws java.io.IOException,
                                      T1Exception
        Receives the power-up command from the terminal. Assumes that caller is located at the card end.
        Returns:
        true if the power-up command is received successfully, false otherwise.
        Throws:
        T1Exception - if a transport protocol inconsistency is detected
        java.io.IOException - if a problem with the I/O exchange mechanism occurs.
      • sendPowerUp

        public void sendPowerUp()
                         throws java.io.IOException,
                                T1Exception
        Sends the power-up command to the card. Assumes that caller is located at the terminal end.
        Throws:
        T1Exception - if a transport protocol inconsistency is detected
        java.io.IOException - if a problem with the I/O exchange mechanism occurs.
      • sendPowerDown

        public void sendPowerDown()
                           throws java.io.IOException,
                                  T1Exception
        Sends the power-down command to the card. Assumes that caller is located at the terminal end.
        Throws:
        T1Exception - if a transport protocol inconsistency is detected
        java.io.IOException - if a problem with the I/O exchange mechanism occurs.