You can find the class SmartCardManager
in the sample codes section of the distributed package. This class is published as open source in order for you to customize it according to your own needs. Basic signature operations can be performed by this class which has the following functions:
A sample usage is as follows:
//Enable APDU usage SmartCardManager.useAPDU(true); //Connect a smartcard. If more than one smart card connected, user selects one of them SmartCardManager scm = SmartCardManager.getInstance(); //Get qualified certificate. If more than one qualified certificate, user selects one of them. ECertificate cert = scm.getSignatureCertificate(true, false); //Create signer BaseSignersigner = scm.getSigner("12345", cert); /** * Create signature */ //If not sign again with selected card logout. scm.logout(); //To select new card and new certificate, call reset. scm.reset();
The method getInstance()
checks if a new card has been plugged in or the existing card has been taken out. Before every signing operation call the method getInstance()
of SmartCardManager
. In the sample code above, the operations are sequentially in a short period of time, the object is retrieved just once.