jpos / jPOS

jPOS Project
http://jpos.org
GNU Affero General Public License v3.0
599 stars 458 forks source link

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

Open alcarraz opened 9 months ago

alcarraz commented 9 months ago

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():
    1. Add a readonly property, and throw an exception if called.
    2. When calling load, pass a parameter to force the file loading.

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