Working with several PKCS#11 vendors
446516Apr 28 2011 — edited May 26 2011Hello everybody.
I'm working on an application that digitally signs PDFs documents. At this moment, it's working just for Aladdin eToken, and, for an obvious reason, I want to expand it to others token vendors like iKey.
So, I use the Jave Security API in this way, to create a Provider dynamically:
String pkcs11config = "";
pkcs11config += "name = Aladdin-eToken\n";
pkcs11config += "library = " + driverLocation + "\n";
InputStream confStream = new ByteArrayInputStream(pkcs11config.getBytes());
provider = new SunPKCS11(confStream);
Security.addProvider(provider);
builder = KeyStore.Builder.newInstance("PKCS11", provider, new KeyStore.CallbackHandlerProtection(passwordCallbackHandler));
builder.getKeyStore(); //the KEYSTORE!!
This works very well for Aladdin eToken, because I've got the driver location hardcoded... so, the question is: How can I recognize what token has been inserted to use the correct diriver??
IMPORTANT: This application runs on Windows, and I'm using JDK 1.5
Thanks in advance!! Gervasio