Question

As I saw in GitHub, MuscleApplet is outdated. I would like to know what is the best way to store data persistently on java smart card?

Data are consist of Name, Family, Picture, and Description.

All fields have dynamic length, so I don't want to consider a static byte array to each one.

Was it helpful?

Solution

I'll answer the programming part of your question.

There is three ways to store dynamic data in an Applet:

  1. Create a byte array created at personalization time. This is only useful if the property is static once the card has been personalized (i.e. in the operational phase).

  2. Create a static byte array for each card, and save the length during personalization. This has the drawback that there is a maximum size for each property, but the size is now configurable, even during operational phase.

  3. Create a data structure out of multiple byte arrays and primitive types and dynamically allocate / free byte arrays for it.

Note that to deallocate memory (for option 3) you will have to rely on the - rather primitive, and possibly unavailable - garbage collection provided by the Java Card runtime.

Also note that if you have many card owners you need to calculate the maximum memory usage for each person. If you want each user to be able to store the same number of properties then allocating the maximum size for each field should not be an issue.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top