I have implemented an Andoid app - server side application. The server communicates with the smart card reader. When the user touches the button in the Android app, a connenction is being built to the server to get the user authenticated. The exchanged messages between the app and server have the following format:
<type> 0x00 0x00 0x00 <length> 0x00 0x00 0x00 <[data]>
- If the message has the type value
06
that indicates an error in the smart card reader. - If the message has the type value
07
that indicates an error in the smart card.
I am using code like below for the communication with the smart card reader:
// show the list of available terminals
TerminalFactory factory = TerminalFactory.getDefault();
List<CardTerminal> terminals = factory.terminals().list();
System.out.println("Terminals: " + terminals);
// get the first terminal
CardTerminal terminal = terminals.get(0);
// establish a connection with the card
Card card = terminal.connect("T=0");
System.out.println("card: " + card);
CardChannel channel = card.getBasicChannel();
ResponseAPDU r = channel.transmit(new CommandAPDU(c1));
System.out.println("response: " + toString(r.getBytes()));
// disconnect
card.disconnect(false);
The Smart Card IO API has the CardException
class for exceptions. My problem is that I do not know when to send the message of type 06
or 07
because I can not differentiate between errors that are generated by the card and errors that are generated by the reader when the CardException
is thrown. How can I manage that?