You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.
I have prototyped this and it works well, however there are shortcomings:
Brittleness: Refactoring of fully qualified class name requires update to config file
Security: using classname for configuration requires knowledge of and exposes class structure. I also have concerns this mechanism could be abused to load arbitrary classes.
@tombentley I have evaluated using ServiceLoader to load KMS implementations. This looks great with one important exception: the service implementation loaded is a single instance per kms type (e.g., vault, key-protect, etc.) however we may have multiple different KMS configs for the same KMS type.
Take for example, three configurations for keys on the same and different vault instances:
The polymorphic call to retrieve a key is very simple when a KMS instance is created for each configuration. We just need to retrieve by key ID:
SecretKey key = kms.getKey(keyRef);
By contrast, in the case of ServiceLoader creating a KMS instance for each KMS type, the caller must pass the kms config as well in order to inform the KMS provider from which KMS of that type to retrieve the the key:
SecretKey key = kms.getKey(keyRef, kmsDef);
The KMS provider must manage all the kms systems and configurations of its respective type. This complicates the provider implementation somewhat.
To merge the two concepts of service providers and kms config instances, the instances created by the service loader would be factories which in turn create type and config-specific kms instances. This would allow for any type-specific initialization/config.
Initial plan was to specify classname of KMS implementation as a field within the KMS config such as:
I have prototyped this and it works well, however there are shortcomings:
This is reinforced by a recent post by Gunnar Morling:
https://twitter.com/gunnarmorling/status/1547253835911122945
Example of using Java ServiceLoader with short names by Gunnar:
https://github.com/kroxylicious/kproxy/blob/main/kroxylicious/src/main/java/io/kroxylicious/proxy/internal/filter/FilterContributorManager.java
ServiceLoader Javadoc:
https://docs.oracle.com/javase/10/docs/api/java/util/ServiceLoader.html
The text was updated successfully, but these errors were encountered: