Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java - how to detect smartcard hotplug

Tags:

java

security

I load dynamically pkcs11 security Provider in java and it works as long as the smart card reader is inserted before running the application. Could anyone please tell me how to detect a smartcard hotplug when the application is running? Actually I need something like pcsc_scan in java. The environment is Ubuntu 9.10 with java 1.6.0_20. Thanks in advance

like image 860
user428539 Avatar asked Oct 22 '25 02:10

user428539


2 Answers

Can you use the javax.smartcardio.* API in conjunction with PKCS #11?

The CardTerminal class has isCardPresent(), waitForCardPresent(timeout), and waitForCardAbsent(timeout) methods which can be used in a seperate thread to poll for card insertion events.

like image 141
martijno Avatar answered Oct 24 '25 16:10

martijno


PKCS#11 doesn't define a standard way to actively notify the application about device insertion/removal. The best you can do is to run a thread which will check the number of slots and their state once a second or so.

like image 42
Eugene Mayevski 'Callback Avatar answered Oct 24 '25 17:10

Eugene Mayevski 'Callback