Class ScriptedPolicyRule
java.lang.Object
net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
net.shibboleth.utilities.java.support.component.AbstractIdentifiedInitializableComponent
net.shibboleth.utilities.java.support.component.AbstractIdentifiableInitializableComponent
net.shibboleth.idp.attribute.filter.policyrule.impl.ScriptedPolicyRule
- All Implemented Interfaces:
PolicyRequirementRule
,Component
,DestructableComponent
,IdentifiableComponent
,IdentifiedComponent
,InitializableComponent
,UnmodifiableComponent
@ThreadSafe public class ScriptedPolicyRule extends AbstractIdentifiableInitializableComponent implements PolicyRequirementRule, UnmodifiableComponent
A
PolicyRequirementRule
that delegates to a JSR-223 script for its actual
processing.-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
ScriptedPolicyRule.PolicyRuleScriptEvaluator
Evaluator bound to the Matcher semantic.Nested classes/interfaces inherited from interface net.shibboleth.idp.attribute.filter.PolicyRequirementRule
PolicyRequirementRule.Tristate
-
Field Summary
Fields Modifier and Type Field Description private Object
customObject
The custom object we inject into all scripts.private org.slf4j.Logger
log
Class logger.private Function<AttributeFilterContext,ProfileRequestContext>
prcLookupStrategy
Strategy used to locate theProfileRequestContext
to use.private Function<ProfileRequestContext,SubjectContext>
scLookupStrategy
Strategy used to locate theSubjectContext
to use.private EvaluableScript
script
Script to be evaluated.private ScriptedPolicyRule.PolicyRuleScriptEvaluator
scriptEvaluator
Evaluator.Fields inherited from interface net.shibboleth.idp.attribute.filter.PolicyRequirementRule
MATCHES_ALL, MATCHES_NONE, REQUIREMENT_RULE_FAILS
-
Constructor Summary
Constructors Constructor Description ScriptedPolicyRule()
Constructor. -
Method Summary
Modifier and Type Method Description protected void
doInitialize()
boolean
equals(Object obj)
Object
getCustomObject()
Return the custom (externally provided) object.EvaluableScript
getScript()
Gets the script to be evaluated.int
hashCode()
PolicyRequirementRule.Tristate
matches(AttributeFilterContext filterContext)
Calculate the PolicyRule.void
setCustomObject(Object object)
Set the custom (externally provided) object.void
setProfileRequestContextLookupStrategy(Function<AttributeFilterContext,ProfileRequestContext> strategy)
Set the strategy used to locate theProfileRequestContext
associated with a givenAttributeFilterContext
.void
setScript(EvaluableScript matcherScript)
Sets the script to be evaluated.void
setSubjectContextLookupStrategy(Function<ProfileRequestContext,SubjectContext> strategy)
Set the strategy used to locate theSubjectContext
associated with a givenProfileRequestContext
.String
toString()
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractIdentifiableInitializableComponent
setId
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractIdentifiedInitializableComponent
getId
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
destroy, doDestroy, initialize, isDestroyed, isInitialized
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.shibboleth.utilities.java.support.component.IdentifiedComponent
getId
-
Field Details
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
script
Script to be evaluated. -
scriptEvaluator
Evaluator. -
prcLookupStrategy
Strategy used to locate theProfileRequestContext
to use. -
scLookupStrategy
Strategy used to locate theSubjectContext
to use. -
customObject
The custom object we inject into all scripts.
-
-
Constructor Details
-
ScriptedPolicyRule
public ScriptedPolicyRule()Constructor.
-
-
Method Details
-
getCustomObject
Return the custom (externally provided) object.- Returns:
- the custom object
-
setCustomObject
Set the custom (externally provided) object.- Parameters:
object
- the custom object
-
getScript
Gets the script to be evaluated.- Returns:
- the script to be evaluated
-
setScript
Sets the script to be evaluated.- Parameters:
matcherScript
- the script to be evaluated
-
setProfileRequestContextLookupStrategy
public void setProfileRequestContextLookupStrategy(@Nonnull Function<AttributeFilterContext,ProfileRequestContext> strategy)Set the strategy used to locate theProfileRequestContext
associated with a givenAttributeFilterContext
.- Parameters:
strategy
- strategy used to locate theProfileRequestContext
associated with a givenAttributeFilterContext
-
setSubjectContextLookupStrategy
public void setSubjectContextLookupStrategy(@Nonnull Function<ProfileRequestContext,SubjectContext> strategy)Set the strategy used to locate theSubjectContext
associated with a givenProfileRequestContext
.- Parameters:
strategy
- strategy used to locate theSubjectContext
associated with a givenProfileRequestContext
-
matches
@Nonnull public PolicyRequirementRule.Tristate matches(@Nonnull AttributeFilterContext filterContext)Calculate the PolicyRule.When the script is evaluated, the following property will be available via the
ScriptContext
:filterContext
- the current instance ofAttributeFilterContext
The script MUST return a
Evaluate what this rule means.Boolean
- Specified by:
matches
in interfacePolicyRequirementRule
- Parameters:
filterContext
- the context.- Returns:
- whether the rule holds
-
doInitialize
- Overrides:
doInitialize
in classAbstractIdentifiedInitializableComponent
- Throws:
ComponentInitializationException
-
equals
-
hashCode
public int hashCode() -
toString
-