Java examples for javax.smartcardio:CardChannel
load Card Authentication
//package com.java2s; import javax.smartcardio.Card; import javax.smartcardio.CardChannel; import javax.smartcardio.CardException; import javax.smartcardio.CommandAPDU; import javax.smartcardio.ResponseAPDU; public class Main { public static void loadAuthentication(Card c) throws CardException { byte cla = (byte) 0xFF; byte ins = (byte) 0x82; byte p1 = (byte) 0x00; byte p2 = (byte) 0x00; byte lc = (byte) 0x06; byte key = (byte) 0xFF; byte[] params = new byte[] { cla, ins, p1, p2, lc, key, key, key, key, key, key };//from ww w . j a va 2 s.c o m CardChannel channel = c.getBasicChannel(); CommandAPDU command = new CommandAPDU(params); ResponseAPDU response = channel.transmit(command); validateResponse(response); } private static void validateResponse(ResponseAPDU response) throws CardException { if (response.getSW1() != 144) { throw new CardException( "No fue posible cargar la autenticaci?n"); } } }