Class CadT1Dual


  • public class CadT1Dual
    extends java.lang.Object
    The CadT1Dual class manages two T1 connections It uses two instances of ServerT1Data to store status of the protocols Two initialize the class, use constructor with contacted socket and set contacted_atr It contactless connection is also available, set also contactless socket and contactless atr This class uses two instances of T1BlockReade to listen to incoming blocks
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static int MAX_IFS_SIZE  
    • Constructor Summary

      Constructors 
      Constructor Description
      CadT1Dual​(java.net.Socket contactedSocket)
      Create a new instance of the CadT1 class using socket representing the contacted connection.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addCadServerListener​(CadServerListener listener)
      Register a new CadServerListener to be notified of state changes.
      static void discardIncomingGetLe​(CadT1Dual cadObj, short[] LEN, short numBytesExpected, short numBytesReceived)  
      byte getActiveInterface()  
      int getMaxIFSSize()
      Returns the maximum IFS size supported by this CAD T=1 instance.
      byte getSecondaryInterfaceEvent()  
      static void placeDataInBuffer​(CadT1Dual cadObj, byte[] bufferINF, short[] LEN, short offset, short buffSize)  
      boolean receiveBlock​(T1Block blockFrom, boolean switchInterface)
      Reads the first T=1 Block from the terminal, setting the information in the block passed as parameter.
      void setContactedATR​(byte[] contacted_atr)  
      void setContactlessATR​(byte[] contactless_atr)  
      void setContactlessSocket​(java.net.Socket contactlessSocket)  
      boolean t1Abort()  
      short t1GetIFSC()
      This method returns the T=1 maximum supported card Information Field block size (IFSC).
      short t1GetIFSD()
      This method returns the T=1 maximum supported device Information Field block size (IFSD).
      static byte t1GetNAD()
      This method returns the T=1 NAD byte for the last block received.
      boolean t1LastBlockReceived()
      This method returns true if the last T=1 block in a chain has been received (i.e.
      short t1RcvBlock​(byte[] bufferINF, short[] LEN, short offset, short buffSize)
      This method receives a T=1 block of data - if none are pending - or copies the data of an already- received block into the APDU buffer at the offset specified.
      short t1SndBlockRcvAck​(byte[] buffer, int dataOffset, int dataLength, boolean isLastBlock, boolean switchInterface)
      This method sends a T=1 block data in the APDU buffer specified bythe offset and length passed, and waits for acknowledgement transmission, without copying any data that might come along on that transmission.
      boolean t1Wait()
      This method initiates a T=1 wait sequence to indicate the terminal that more time is required to process input, and thus avoid a timeout.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CadT1Dual

        public CadT1Dual​(java.net.Socket contactedSocket)
        Create a new instance of the CadT1 class using socket representing the contacted connection.
        Parameters:
        contactedSocket -
    • Method Detail

      • setContactedATR

        public void setContactedATR​(byte[] contacted_atr)
        Parameters:
        contacted_atr -
      • setContactlessATR

        public void setContactlessATR​(byte[] contactless_atr)
        Parameters:
        contactless_atr -
      • getSecondaryInterfaceEvent

        public byte getSecondaryInterfaceEvent()
        Returns:
        secondary interface event
      • getActiveInterface

        public byte getActiveInterface()
        Returns:
        active interface
      • setContactlessSocket

        public void setContactlessSocket​(java.net.Socket contactlessSocket)
        Parameters:
        contactlessSocket -
      • receiveBlock

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

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

        public boolean t1Wait()
                       throws T1Exception
        This method initiates a T=1 wait sequence to indicate the terminal that more time is required to process input, and thus avoid a timeout. Only Java Card runtime environment can invoke this method.
        Returns:
        0 on success.
        Throws:
        T1Exception
      • t1LastBlockReceived

        public boolean t1LastBlockReceived()
        This method returns true if the last T=1 block in a chain has been received (i.e. block with the M bit set to 1), false otherwise. Only Java Card runtime environment can invoke this method.
        Returns:
        true if last block recevied, false otherwise.
      • addCadServerListener

        public void addCadServerListener​(CadServerListener listener)
        Register a new CadServerListener to be notified of state changes.
        Parameters:
        listener - The listener to register.
      • discardIncomingGetLe

        public static void discardIncomingGetLe​(CadT1Dual cadObj,
                                                short[] LEN,
                                                short numBytesExpected,
                                                short numBytesReceived)
      • placeDataInBuffer

        public static void placeDataInBuffer​(CadT1Dual cadObj,
                                             byte[] bufferINF,
                                             short[] LEN,
                                             short offset,
                                             short buffSize)
      • t1SndBlockRcvAck

        public short t1SndBlockRcvAck​(byte[] buffer,
                                      int dataOffset,
                                      int dataLength,
                                      boolean isLastBlock,
                                      boolean switchInterface)
                               throws T1Exception
        This method sends a T=1 block data in the APDU buffer specified bythe offset and length passed, and waits for acknowledgement transmission, without copying any data that might come along on that transmission. On dual interface cards, the acknowledgement might come from a different interface if the interface is not locked. Only Java Card runtime environment can invoke this method.
        Parameters:
        buffer - Data buffer
        dataOffset - offset to data
        dataLength - length of data
        isLastBlock - last block of APDU flag
        switchInterface - OK to switch interface
        Returns:
        0 on success, other value in error.
        Throws:
        T1Exception
      • t1RcvBlock

        public short t1RcvBlock​(byte[] bufferINF,
                                short[] LEN,
                                short offset,
                                short buffSize)
                         throws T1Exception
        This method receives a T=1 block of data - if none are pending - or copies the data of an already- received block into the APDU buffer at the offset specified. If the data cannot fit into the APDU buffer, the remaining data will be copied the next time this method is called. Only Java Card runtime environment can invoke this method.
        Parameters:
        bufferINF -
        LEN -
        offset -
        buffSize -
        Returns:
        number of bytes received on success, negative values on error.
        Throws:
        T1Exception
      • t1GetNAD

        public static byte t1GetNAD()
        This method returns the T=1 NAD byte for the last block received. Only Java Card runtime environment can invoke this method.
        Returns:
        T=1 NAD value.
      • t1GetIFSC

        public short t1GetIFSC()
        This method returns the T=1 maximum supported card Information Field block size (IFSC). Only Java Card runtime environment can invoke this method.
        Returns:
        T=1 IFSC value.
      • t1GetIFSD

        public short t1GetIFSD()
        This method returns the T=1 maximum supported device Information Field block size (IFSD). Only Java Card runtime environment can invoke this method.
        Returns:
        T=1 IFSD value.