Split PolicyChecker from PolicyManager #128004
Open
+1,304
−1,198
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PolicyManager
has a number of responsibilities, including at least:check
methods that determine whether some required entitlement is presentThis PR splits those into two objects, with the immediate consequence being that we can now swap in a
PolicyManagerForTesting
that modifies the behaviour.With this change, the design looks as follows:
EntitlementChecker
interface has one method per sensitive JDK method. Its implementation (calledElasticsearchEntitlementChecker
) determines which kind of check we should do for each method. Its methods are all one-liners that callPolicyChecker
.PolicyChecker
interface has one method per distinct kind of check (about 27 methods in total). Its implementation (PolicyCheckerImpl
) has the job of determining the caller class, querying thePolicyManager
to determine what entitlements are granted to that class, and then checking whether the required entitlements are present.PolicyManager
class determines, for a given caller class, what entitlements that class has been granted, and whether it is trivially allowed.It's
PolicyManager
that implementsgetEntitlements
andisTriviallyAllowed
. The idea is that we'd create aPolicyManagerForTesting
that would override these to provide the required semantics when running in junit.