public class BasicPolicyFinderModule extends PolicyFinderModule
PolicyFinderModule
that
accepts already created AbstractPolicy
s and supports
finding by context and reference. All policies are held forever once
added to this module, and cannot be refreshed or removed. New policies
may be added at any point. You may optionally specify a combining
algorithm to use when more than one applicable policy is found, and then
a new PolicySet is wrapped around the policies using this algorithm. If
no combining algorithm is provided, then an error is returned if more
than one policy matches.
This module is provided as an example, but is still fully functional, and
should be useful for many simple applications. This is provided in the
support
package rather than the core codebase because it
implements non-standard behavior.
Constructor and Description |
---|
BasicPolicyFinderModule()
Creates a
BasicPolicyFinderModule . |
BasicPolicyFinderModule(PolicyCombiningAlgorithm combiningAlg)
Creates a
BasicPolicyFinderModule that can combine
multiple applicable policies under a single, dynamic PolicySet. |
Modifier and Type | Method and Description |
---|---|
boolean |
addPolicy(AbstractPolicy policy)
Adds a policy that will be available both by reference and by
matching to a context.
|
boolean |
addPolicyNoRef(AbstractPolicy policy)
Adds a policy that will be available only by matching to a context.
|
boolean |
addPolicyOnlyRef(AbstractPolicy policy)
Adds a policy that will be available only by reference.
|
PolicyFinderResult |
findPolicy(EvaluationCtx context)
Finds a policy based on a request's context.
|
PolicyFinderResult |
findPolicy(URI idReference,
int type,
VersionConstraints constraints,
PolicyMetaData parentMetaData)
Attempts to find a policy by reference, based on the provided
parameters.
|
void |
init(PolicyFinder finder)
Initialize this module.
|
boolean |
isIdReferenceSupported()
Always returns
true since this module does support
finding policies based on reference. |
boolean |
isRequestSupported()
Always returns
true since this module does support
finding policies based on context matching. |
getIdentifier, invalidateCache
public BasicPolicyFinderModule()
BasicPolicyFinderModule
.public BasicPolicyFinderModule(PolicyCombiningAlgorithm combiningAlg)
BasicPolicyFinderModule
that can combine
multiple applicable policies under a single, dynamic PolicySet.combiningAlg
- the algorithm to use in a new PolicySet when more
than one policy appliespublic boolean addPolicy(AbstractPolicy policy)
policy
- the policy to addpublic boolean addPolicyNoRef(AbstractPolicy policy)
policy
- the policy to addpublic boolean addPolicyOnlyRef(AbstractPolicy policy)
policy
- the policy to addpublic boolean isRequestSupported()
true
since this module does support
finding policies based on context matching.isRequestSupported
in class PolicyFinderModule
public boolean isIdReferenceSupported()
true
since this module does support
finding policies based on reference.isIdReferenceSupported
in class PolicyFinderModule
public void init(PolicyFinder finder)
PolicyFinder
when a PDP is created.init
in class PolicyFinderModule
finder
- the PolicyFinder
using this modulepublic PolicyFinderResult findPolicy(EvaluationCtx context)
findPolicy
in class PolicyFinderModule
context
- the representation of the request datapublic PolicyFinderResult findPolicy(URI idReference, int type, VersionConstraints constraints, PolicyMetaData parentMetaData)
findPolicy
in class PolicyFinderModule
idReference
- an identifier specifying some policytype
- type of reference (policy or policySet) as identified by
the fields in PolicyReference
constraints
- any optional constraints on the version of the
referenced policy (this will never be null, but
it may impose no constraints, and in fact will
never impose constraints when used from a pre-2.0
XACML policy)parentMetaData
- the meta-data from the parent policy, which
provides XACML version, factories, etc.Copyright © 2023 JBoss by Red Hat. All rights reserved.