Class CardID


  • public class CardID
    extends java.lang.Object
    Represents a smartcard's ATR (Answer To Reset). In addition to the ATR itself, the Slot where the card is inserted can be stored. The ATR is used for identifying cards. It usually contains some so-called historical characters which can be used to determine the type of card. Since the historical characters can be defined by the card issuer, they may also give a hint on the applications supported by the smartcard.
    Author:
    Dirk Husemann (hud@zurich.ibm.com), Mike Wendler (mwendler@de.ibm.com), Stephan Breideneich (sbreiden@de.ibm.com), Thomas Schaeck (schaeck@de.ibm.com), Roland Weber (rolweber@de.ibm.com)
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected byte[] atr
      The represented ATR.
      protected java.lang.String cachedResult
      The cached result of toString.
      protected byte[] historicals
      The historical characters of the ATR.
      protected int slotNr
      The slot which holds the card with this ATR.
      protected CardTerminal terminal  
    • Constructor Summary

      Constructors 
      Constructor Description
      CardID​(byte[] answerToResetResponse)
      Instantiates a new card ID representing the given ATR.
      CardID​(CardTerminal terminal, int slotID, byte[] answerToResetResponse)
      Instantiates a new card ID representing the given ATR from the given slot.
      CardID​(Slot slot, byte[] answerToResetResponse)
      Deprecated.
      use CardID(CardTerminal, int, byte[])
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)
      Compares this with another CardID object.
      byte[] getATR()
      Gets the represented ATR.
      CardTerminal getCardTerminal()
      Gets the instantiating terminal.
      byte[] getHistoricals()
      Gets the historical characters.
      Slot getSlot()
      Deprecated.
      use getSlotID(), getCardTerminal() instead
      int getSlotID()
      Gets the instantiating slot id.
      java.lang.String toString()
      Returns a String representation of this CardID object.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • atr

        protected byte[] atr
        The represented ATR.
      • historicals

        protected byte[] historicals
        The historical characters of the ATR. There can be at most 15 historical characters. If there are no historical characters, this attribute holds null, not an empty array.
      • slotNr

        protected int slotNr
        The slot which holds the card with this ATR.
      • cachedResult

        protected java.lang.String cachedResult
        The cached result of toString.
        See Also:
        toString()
    • Constructor Detail

      • CardID

        public CardID​(byte[] answerToResetResponse)
               throws CardTerminalException
        Instantiates a new card ID representing the given ATR.
        Parameters:
        answerToResetResponse - a byte array holding the ATR to represent
        Throws:
        CardTerminalException - if the ATR is invalid
      • CardID

        public CardID​(CardTerminal terminal,
                      int slotID,
                      byte[] answerToResetResponse)
               throws CardTerminalException
        Instantiates a new card ID representing the given ATR from the given slot.
        Parameters:
        terminal - the terminal where the card with this ATR is inserted
        slotID - the slot where the card with this ATR is inserted.
        answerToResetResponse - a byte array holding the ATR
        Throws:
        CardTerminalException - if the ATR is invalid
    • Method Detail

      • getATR

        public byte[] getATR()
        Gets the represented ATR. The returned byte array holds a copy of the ATR. It can safely be modified.
        Returns:
        a byte array holding the ATR
      • getHistoricals

        public byte[] getHistoricals()
        Gets the historical characters. Despite their name, the historical characters are byte values. They do not have to be printable characters. Therefore, they are returned as a byte array, not as a string. The byte array is newly allocated and can safely be modified.
        Returns:
        a byte array containing the historical characters, or null if the ATR does not include any
      • getSlot

        public Slot getSlot()
        Deprecated.
        use getSlotID(), getCardTerminal() instead
        Gets the instantiating Slot.
        Returns:
        the Slot where the card with this ATR is inserted, or null if unknown
      • getSlotID

        public int getSlotID()
        Gets the instantiating slot id.
        Returns:
        the SlotID or 0 if unknown
      • getCardTerminal

        public CardTerminal getCardTerminal()
        Gets the instantiating terminal.
        Returns:
        the terminal or null if unknown
      • equals

        public boolean equals​(java.lang.Object obj)
        Compares this with another CardID object. They are equal if the represented ATRs are equal.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - the CardID to compare with
        Returns:
        true if the object represents the same ATR, false if it represents a different ATR or no ATR at all
      • toString

        public java.lang.String toString()
        Returns a String representation of this CardID object.
        Overrides:
        toString in class java.lang.Object
        Returns:
        A String representation of this CardID object.