Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Working with several PKCS#11 vendors

446516Apr 28 2011 — edited May 26 2011
Hello 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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 23 2011
Added on Apr 28 2011
13 comments
963 views