use of javax.smartcardio.TerminalFactory in project open-ecard by ecsec.
the class PCSCTest method connect.
private void connect() {
try {
// File libPcscLite = new File("/usr/lib/libpcsclite.so.1");
// if (libPcscLite.exists()) {
// System.setProperty("sun.security.smartcardio.library", libPcscLite.getAbsolutePath());
// }
TerminalFactory t = TerminalFactory.getInstance("PC/SCs", null);
// TerminalFactory t = TerminalFactory.getDefault();
CardTerminals c = t.terminals();
logger.info("Card terminals: {}", c.list().size());
List terminals = c.list();
if (terminals.isEmpty()) {
logger.info("No presend cards!");
} else {
for (int i = 0; i < terminals.size(); i++) {
CardTerminal ct = (CardTerminal) terminals.get(i);
if (ct.isCardPresent()) {
Card card = ct.connect("*");
connection = card.getBasicChannel();
logger.info("Card found at card terminal " + i + ": ", card.toString());
}
}
}
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
}
}
Aggregations