Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- be.fedict.commons-eid - 0.6.5
- com.itextpdf - 5.5.10
- org.bouncycastle - 1.55
- BeIDCardManager manager = new BeIDCardManager();
- manager.addBeIDCardEventListener(new BeIDCardEventsListener() {
- public void eIDCardInserted(CardTerminal arg0, BeIDCard arg1) {
- log.info("Inserted");
- try {
- dostuffwithmycard(arg1);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
- protected static void dostuffwithmycard(BeIDCard card) throws IOException, DocumentException, GeneralSecurityException {
- Security.addProvider(new BeIDProvider());
- KeyStore keyStore = KeyStore.getInstance("BeID");
- keyStore.load(null, null);
- PrivateKey authnPrivateKey = (PrivateKey) keyStore.getKey("Authentication", null);
- Signature signature = Signature.getInstance("SHA1withRSA");
- signature.initSign(authnPrivateKey);
- PdfReader reader = new PdfReader("C:\Untitled.pdf");
- FileOutputStream os = new FileOutputStream( "C:\temp\Signed.pdf");
- PdfStamper stamper = PdfStamper.createSignature(reader, os, '