Example usage for javax.smartcardio ATR getBytes

List of usage examples for javax.smartcardio ATR getBytes

Introduction

In this page you can find the example usage for javax.smartcardio ATR getBytes.

Prototype

public byte[] getBytes() 

Source Link

Document

Returns a copy of the bytes in this ATR.

Usage

From source file:davmail.util.ClientCertificateTest.java

public void testCardReaders() throws CardException {
    for (CardTerminal terminal : TerminalFactory.getDefault().terminals().list()) {
        System.out.println("Card terminal: " + terminal.getName() + " "
                + (terminal.isCardPresent() ? "Card present" : "No card"));
        terminal.waitForCardPresent(10);
        if (terminal.isCardPresent()) {
            Card c = null;//from  ww  w.ja  va 2 s  .  c o  m
            try {
                c = terminal.connect("T=0");
            } catch (Exception e) {
                // failover
                c = terminal.connect("T=1");
            }

            ATR atr = c.getATR();

            byte[] bytes = atr.getBytes();
            System.out.print("card:");

            for (byte b : bytes) {
                System.out.print(" " + Integer.toHexString(b & 0xff));
            }
            System.out.println();

        }
    }
}

From source file:src.eidreader.EstEIDUtil.java

public static boolean matchesEidAtr(ATR atr) { // from eid-applet-core...PcscEid.java
    byte[] atrBytes = atr.getBytes();
    if (atrBytes.length != ATR_PATTERN.length) {
        return false;
    }/*from  w w w.j a  va2 s. c o m*/
    for (int idx = 0; idx < atrBytes.length; idx++) {
        atrBytes[idx] &= ATR_MASK[idx];
    }
    if (Arrays.equals(atrBytes, ATR_PATTERN)) {
        return true;
    }
    return false;
}