Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StaticTopLevelPolicyElementEvaluator instantiation problem. #32

Closed
miladamery opened this issue Aug 9, 2018 · 2 comments
Closed

StaticTopLevelPolicyElementEvaluator instantiation problem. #32

miladamery opened this issue Aug 9, 2018 · 2 comments

Comments

@miladamery
Copy link

Hi. i'm trying to create a custom policy provider. i need to use

@Value("classpath*:**/policies/**.xml)
private Resource[] resources;

and use those resources as files for policy providing. its a spring resource thing.
but meanwhile in the process i'm facing:

protected StaticTopLevelPolicyElementEvaluator getPolicy(String policyId,
			Optional<PolicyVersionPatterns> policyPolicyVersionPatterns) throws IndeterminateEvaluationException {
...
}

what i read at mongodb policy provider reference or CorRefPolicyProvider code i see a static class called PolicyEvaluators which is responsible for instantiating this. but this class is in core-pdp-engine and in wiki says that i should have core-pdp-api dependency. so my question is shall i go and implement my own PolicyEvaluator or i should use the one in core-pdp-engine to instantiate it?

@cdanger
Copy link
Member

cdanger commented Aug 11, 2018

StaticTopLevelPolicyElementEvaluator is a very generic interface for a policy evaluator. The PolicyEvaluators#getInstance(...) methods are just some convenient ways to create such type of object from a XACML/XML-schema-derived Policy(Set), parsed with JAXB framework. If you indeed use XML/JAXB classes as input, then yes, it is a good idea to reuse PolicyEvaluators helper class; and in this case you can just replace core-pdp-api with core-pdp-engine as dependency in your POM, because core-pdp-engine already depends on core-pdp-api.

If you don't use XACML literally (you may use a JSON variant of your own or some kind of simplified policy format for convenience), or you are not using JAXB for XML-to-Java mapping, it may not be a good idea (not efficient) to use PolicyEvaluators as is.

In any case, you do not have to use PolicyEvaluators in all cases (it is just a helper class), and core-pdp-api is just the minimum required dependency to implement a PolicyProvider.

@miladamery
Copy link
Author

thanks for answer. this helper class helps a lot. i'm going to reuse it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants