jPOS icon indicating copy to clipboard operation
jPOS copied to clipboard

SimpleKeyFile.getKeys() seems to load the key file for every key.

Open alcarraz opened this issue 2 years ago • 0 comments

Doesn’t this load the file for every key?

https://github.com/jpos/jPOS/blob/c837c2f135c0ea4866148ab4a880565dda412c63/jpos/src/main/java/org/jpos/security/SimpleKeyFile.java#L213

Perhaps we could call load() at the beginning of the getKeys() method, and add an overload of getkey() that receives a boolean telling if it has to perform the load(), then in getKey(String) call it with true, and in getKeys() call it with false.

Other possible enhancements could be to add configuration properties for:

  1. loading only if the file timestamp changed.
  2. setting load frequency, i.e., don't check if elapsed time is less than some given period, in this case we would have two options for setKey():
  3. Add a readonly property, and throw an exception if called.
  4. When calling load, pass a parameter to force the file loading.

I'm willing to implement decided options in a PR.

alcarraz avatar Sep 30 '23 00:09 alcarraz