This example demonstrates how to use a smart card (for example, the SIM card) to digitally sign data, it implements the PKI API in the Security and Trust Services API 1.0 defined in JSR-177.
Note: This example only shows how to digitally sign data, not to receive or authenticate these signatures.
The application demonstrates how to:
Create a text field for entering the text to be signed.
A default text "ToBeSigned" is suggested when you open the application. The maximum length of the field is 100 characters.
Choose an appropriate signing option from the Options list.
The options available are:
AuthenSignByteHasContent for signing Byte data for authentication purposes including content
AuthenSignByteNoContent for signing Byte data for authentication purposes excluding content
AuthenSignStringHasContent for signing String data for authentication purposes including content
AuthenSignStringNoContent for signing String data for authentication purposes excluding content
CMSWithContent for creating a CMS formatted signature including content
CMSNoContent for creating a CMS formatted signature excluding content
Search for a certificate stored on the smart card of your device. Note that your PIN is automatically asked when accessing the smart card.
Generate a signed data package or a signature using the certificate. When the signing is finished, you can see a message on the screen saying "Already signed".