com.isbc.smartcard.esmarttoken.utils

## Class TerminalUtils

- java.lang.Object
- - com.isbc.smartcard.esmarttoken.utils.TerminalUtils

-     public class TerminalUtils
      extends Object

  Utils for smartcard's reader and smartcard
  Author:
    Sergey Panov

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static TerminalUtilsImpl.CARDTYPE` | `getCardTypeByATR(String atr)` Get card type by ATR
    `static String` | `getCardUID(javax.smartcardio.CardTerminal terminal)` Get token UID
    `static javax.smartcardio.CardTerminal` | `getFirstValidTerminal()` Found first suitable reader for working in this API
    `static boolean` | `isCardPresent(javax.smartcardio.CardTerminal terminal)` Check if card presented on the reader.
    `static boolean` | `isRightCard(javax.smartcardio.CardTerminal terminal)` Check if any EsmartToken card is inserted into the reader
    `static boolean` | `isTerminalValid(javax.smartcardio.CardTerminal terminal)` Check if reader suitable for working in this API
    `static boolean` | `isTerminalValid(String terminalName)` Check if reader suitable for working in this API
    `static void` | `loadConfig(String filename)` Load configuration parameters from file
    `static void` | `resetTerminal(javax.smartcardio.CardTerminal terminal)` Try to reset reader
    `static int` | `SCARD_CTL_CODE(int code)`
    `static javax.smartcardio.CardTerminals` | `terminals()` Get all available readers

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### loadConfig

          public static void loadConfig(String filename)
                                 throws IOException

      Load configuration parameters from file
      Parameters:
        `filename` - path and file name
      Throws:
        `IOException` - Exception

    - #### getCardTypeByATR

          public static TerminalUtilsImpl.CARDTYPE getCardTypeByATR(String atr)

      Get card type by ATR
      Parameters:
        `atr` - ATR string
      Returns:
        Enum CARDTYPE

    - #### isTerminalValid

          public static boolean isTerminalValid(javax.smartcardio.CardTerminal terminal)

      Check if reader suitable for working in this API
      Parameters:
        `terminal` - reader object
      Returns:
        boolean TRUE - if reader is valid, FALSE if not

    - #### isTerminalValid

          public static boolean isTerminalValid(String terminalName)

      Check if reader suitable for working in this API
      Parameters:
        `terminalName` - reader name
      Returns:
        boolean TRUE - if reader is valid, FALSE if not

    - #### isRightCard

          public static boolean isRightCard(javax.smartcardio.CardTerminal terminal)

      Check if any EsmartToken card is inserted into the reader
      Parameters:
        `terminal` - reader object
      Returns:
        boolean TRUE - if card is inserted right now and valid, FALSE if not

    - #### getCardUID

          public static String getCardUID(javax.smartcardio.CardTerminal terminal)
                                   throws Exception

      Get token UID
      Parameters:
        `terminal` - reader object
      Returns:
        String Smartcard UID or null
      Throws:
        `Exception` - Exception

    - #### getFirstValidTerminal

          public static javax.smartcardio.CardTerminal getFirstValidTerminal()
                                                                      throws javax.smartcardio.CardException

      Found first suitable reader for working in this API
      Returns:
        CardTerminal object or null if no suitable reader was found
      Throws:
        `javax.smartcardio.CardException` - Throw if there is no any reader (not only suitable)
      See Also:
        `isTerminalValid(CardTerminal terminal)`

    - #### resetTerminal

          public static void resetTerminal(javax.smartcardio.CardTerminal terminal)
                                    throws Exception

      Try to reset reader
      Parameters:
        `terminal` - reader object
      Throws:
        `javax.smartcardio.CardException` - Throw if something wrong with PC/SC
        `Exception` - Throw if something wrong with HEX decoding
      See Also:
        `HexUtils`

    - #### terminals

          public static javax.smartcardio.CardTerminals terminals()
                                                           throws javax.smartcardio.CardException

      Get all available readers
      Returns:
        CardTerminals object or null if no suitable reader was found
      Throws:
        `javax.smartcardio.CardException` - Throw if some thing wrong with PC/SC

    - #### isCardPresent

          public static boolean isCardPresent(javax.smartcardio.CardTerminal terminal)
                                       throws javax.smartcardio.CardException

      Check if card presented on the reader. Also implement workaroung for the bug CardTerminal.isCardPresent always returns false under Mac OS http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7200271
      Parameters:
        `terminal` - reader object
      Returns:
        boolean TRUE - if a card presented, FALSE if not
      Throws:
        `javax.smartcardio.CardException` - Throw if some thing wrong with PC/SC

    - #### SCARD_CTL_CODE

          public static int SCARD_CTL_CODE(int code)

Copyright © 2018. All rights reserved.