2

How can I search through all available slots in the machine so I can get each keystore for each slot, in Java?

Martin Paljak
  • 4,119
  • 18
  • 20
marcelo-ferraz
  • 3,147
  • 4
  • 38
  • 55

3 Answers3

9

As I've found, there is this a way:

PKCS11 p11 = PKCS11.getInstance("/usr/local/lib/libsiecap11.so", "C_GetFunctionList", null, false); 
long[] slots = p11.C_GetSlotList(true);  

thanks to this question

Community
  • 1
  • 1
marcelo-ferraz
  • 3,147
  • 4
  • 38
  • 55
2

This is not a very precise question.

If you are not precise, then the "most probable" solution is http://download.oracle.com/javase/6/docs/jre/api/security/smartcardio/spec/javax/smartcardio/CardTerminals.html

But you seem to be talking about PKCS#11 (which is NOT the direct mapping of a smart card hardware "slot")

Martin Paljak
  • 4,119
  • 18
  • 20
0

Write JNI code in C++ and call it from java.

Rocky Pulley
  • 22,531
  • 20
  • 68
  • 106