Question

I need API, that is able to get PKCS#11 certificates from smartcard on Java 7 both 32 and 64 versions. SunPKCS11 is not providing solution for 64 bit Java 7.

EDIT > Arjun Sol proposed to take a look at Open SC. Seems quite versatile API set, but now when I stumbled upon fact that my card is Gemplus and is not supported by this API, I am editing also description. So - Open SC cannot take care of all cards.

Was it helpful?

Solution

You may want to look at: https://www.opensc-project.org/opensc/wiki/Java

Smart card access itself can be handled natively:

http://docs.oracle.com/javase/6/docs/jre/api/security/smartcardio/spec/javax/smartcardio/package-summary.html

An example from the java doc (edited for readability):

// 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);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top