A Java library to use Belgium eID cards


Today, I used my Belgium Electronic ID smart card to digitally sign my Tax Declaration.  Nothing new here, it happens now since six years in a row (I just wonder how many countries have setup such an end-to-end digital system, including digital signature, to interact with various administrations).

As every year, I wonder what API and libraries are available to programmatically extract or sign data with the smart card : a bunch of low level PC/SC API calls, a couple of Java-through-JNI samples, but nothing really high level and easy to use.  Most of the examples returned by Google are quite old, not adapted to Java SE 6, not running in 64 bits mode and are not working on Mac OS X … sigh !

This year however was different, Google spotted eidlib, a Java SE 6 native library wrapping operations of the Belgium eID card.

This API is different from all the other I know : it uses the Java SE 6 javax.smartcard i/o framework to directly communicate with the card reader, exchanging APDU as required per the card protocol.

This is by far the easiest to use Java library for eID I found so far.  You just need to include the JAR file into your classpath, then write simple code like :

           BeID eID = new BeID(true); // We allow information to be fetched from test cards

           // We fetch the information
           System.out.println("InformationRetrieval -- ID information:");
           System.out.println(eID.getIDData().toString());
           System.out.println("InformationRetrieval -- Address information:");
           System.out.println(eID.getIDAddress().toString());
           System.out.println("InformationRetrieval -- Photo is saved to file:");
           eID.getIDPhoto().writeToFile(eID.getIDData().getName());

Et voilà … ready to include strong authentication and signature in your own applications.  I tested every example provided on the web site with NetBeans 6.9, using Java SE 6 64 bits on Snow Leopard.

This library was developed by Kristof Overdulve, at that time student at the University of Antwerp, for his Bachelor thesis.  Kuddo !

[UPDATE]

Bart pointed me to this eID Applet project.  If all you wanna do is include eID authentication or signature in your web application, then the eID applet is probably the way to go.

, , , ,

  1. #1 by Ellan Cadlett on 27/12/2010 - 14:28

    I am pleased that I discovered this site , precisely the right information that I was looking for! .

  2. #2 by Caes on 19/06/2011 - 15:08

    Wonderful…
    Exactly what I was looking for 😉
    Thanks a lot

  3. #3 by jeff on 26/09/2011 - 22:03

    Thanks for this… also exactly what I need!

  4. #4 by elen on 29/03/2013 - 10:16

    You could put the code of the class BeID
    please

  5. #5 by sst on 29/03/2013 - 10:34

    The BeID class is part of the library I am talking about in this article. You can download it from http://code.google.com/p/eidlib/source/checkout

  6. #6 by elen on 29/03/2013 - 11:02

    thanks 🙂

  7. #7 by elen on 15/04/2013 - 08:44

    I’ve used this library in java aplication and it works great
    but now I’m using an applet and does not read well the accents
    some solution??

  8. #8 by Sébastien Stormacq on 15/04/2013 - 19:34

    Hello, I did not develop this Library, nor am I maintaining it. I would suggest you to contact the developer / owner / maintainer of the library.

    Good Luck !

(will not be published)