Ejemplo de lectura de la información de una tarjeta inteligente M de N Dinamo familia, producto, versión del sistema operativo, ATR, estado del PIN).
package doxy.examples;
import com.dinamonetworks.Dinamo;
import com.dinamonetworks.ScInfo;
import br.com.trueaccess.TacException;
public class SmartCardInspect {
public static void main(String[] args) throws TacException {
Dinamo api = new Dinamo();
if (!api.scIsLibLoaded()) {
System.out.println("Biblioteca do leitor Smart-card não disponível.");
return;
}
ScInfo info = api.scGetInfo();
System.out.println("ATR : " + toHex(info.getAtr(), info.getAtrSize()));
System.out.println("CSN : " + toHex(info.getCsn1(), info.getCsn1().length)
+ toHex(info.getCsn2(), info.getCsn2().length)
+ toHex(info.getIrn(), info.getIrn().length));
System.out.println("Family : " + info.getCardFamily());
System.out.println("Card Name : " + info.getCardProductName());
System.out.println("Card OS : " + info.getCardOsVersion());
System.out.printf ("Prog Ver : %02x%n", info.getCardProgramVersion() & 0xFF);
System.out.printf ("Chip Ver : %02x%n", info.getCardChipVersion() & 0xFF);
System.out.printf ("LOCK1 byte : %02x%n", info.getLockByte1() & 0xFF);
System.out.printf ("LOCK2 byte : %02x%n", info.getLockByte2() & 0xFF);
System.out.println("Card Type : " + (info.isHasLegacyCard() ? "Lg" : "Sm")
+ (info.isOEMKeyAvailable() ? "Oe" : "Gp"));
if (info.isFormatted()) {
System.out.println("PIN Locked : " + (info.isPINLocked()
? "yes (no more PIN changes)"
: "no (one more PIN change allowed)"));
int scr = info.isHasPINInfo() ? info.getPinSCR() : -1;
int mm = info.isHasPINInfo() ? info.getPinMMPN() : -1;
System.out.println("PIN SCR : " + scr);
System.out.println("PIN MM : " + mm);
}
System.out.println("Filesystem : " + (info.isFormatted() ? "formatted" : "unformatted"));
}
private static String toHex(byte[] data, int len) {
StringBuilder sb = new StringBuilder(len * 2);
for (int i = 0; i < len; i++) {
sb.append(String.format("%02x", data[i]));
}
return sb.toString();
}
}