Class AbstractEntityAttributePolicyRule
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.AbstractPolicyRule
net.shibboleth.idp.attribute.filter.policyrule.saml.impl.AbstractEntityAttributePolicyRule
- All Implemented Interfaces:
PolicyRequirementRule
,Component
,DestructableComponent
,IdentifiableComponent
,IdentifiedComponent
,InitializableComponent
- Direct Known Subclasses:
AbstractEntityAttributeExactPolicyRule
,AbstractEntityAttributeRegexPolicyRule
Base class for matchers that check whether a particular entity attribute is present and contains a given value.
Given the metadata for an entity, this class takes care of navigation to the attribute and extracting the values, including optimized handling of mapped attributes.
Classes wishing to implement Entity Attribute matchers implement getEntityMetadata(AttributeFilterContext)
to navigate to the entity (probably recipient or issuer) and entityAttributeValueMatches(Set)
to
implement the comparison (probably string or regexp).
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.shibboleth.idp.attribute.filter.PolicyRequirementRule
PolicyRequirementRule.Tristate
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate String
The name of the entity attribute the entity must have.private boolean
Whether to ignore unmapped attributes as an optimization.private final org.slf4j.Logger
Class logger.private String
The name format of the entity attribute the entity must have.Fields inherited from interface net.shibboleth.idp.attribute.filter.PolicyRequirementRule
MATCHES_ALL, MATCHES_NONE, REQUIREMENT_RULE_FAILS
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
protected abstract boolean
entityAttributeValueMatches
(Set<String> entityAttributeValues) Checks whether the given entity attribute's values match for particular implementations of this functor.Gets the name of the entity attribute the entity must have.private void
getEntityAttributeValues
(XMLObject metadataObject, String name, Set<String> valueAccumulator) Gets the entity attribute values from the given metadata.protected abstract EntityDescriptor
getEntityMetadata
(AttributeFilterContext filterContext) Gets the entity descriptor for the entity to check.boolean
Gets whether to ignore unmapped/decoded EntityAttribute extensions as an optimization.private void
getMappedEntityAttributeValues
(XMLObject metadataObject, Set<String> valueAccumulator) Gets the mapped entity attribute values from the given metadata.Gets the name format of the entity attribute the entity must have.private String
getStringValue
(XMLObject object) Function to return an XMLObject in string form.matches
(AttributeFilterContext filterContext) Checks to see if the entity returned bygetEntityMetadata(AttributeFilterContext)
contains the entity attribute specified by this matcher's configuration.void
setAttributeName
(String attributeName) Sets the name of the entity attribute the entity must have.void
setIgnoreUnmappedEntityAttributes
(boolean flag) Sets whether to ignore unmapped/decoded EntityAttribute extensions as an optimization.void
setNameFormat
(String attributeNameFormat) Sets the name format of the entity attribute the entity must have.Methods inherited from class net.shibboleth.idp.attribute.filter.policyrule.impl.AbstractPolicyRule
getLogPrefix
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, equals, finalize, getClass, hashCode, notify, notifyAll, toString, 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. -
attrName
The name of the entity attribute the entity must have. -
nameFormat
The name format of the entity attribute the entity must have. -
ignoreUnmappedEntityAttributes
private boolean ignoreUnmappedEntityAttributesWhether to ignore unmapped attributes as an optimization.
-
-
Constructor Details
-
AbstractEntityAttributePolicyRule
public AbstractEntityAttributePolicyRule()
-
-
Method Details
-
getAttributeName
Gets the name of the entity attribute the entity must have.- Returns:
- name of the entity attribute the entity must have
-
setAttributeName
Sets the name of the entity attribute the entity must have.- Parameters:
attributeName
- name of the entity attribute the entity must have
-
getNameFormat
Gets the name format of the entity attribute the entity must have.- Returns:
- name format of the entity attribute the entity must have
-
setNameFormat
Sets the name format of the entity attribute the entity must have.- Parameters:
attributeNameFormat
- name format of the entity attribute the entity must have
-
getIgnoreUnmappedEntityAttributes
public boolean getIgnoreUnmappedEntityAttributes()Gets whether to ignore unmapped/decoded EntityAttribute extensions as an optimization.- Returns:
- whether to ignore unmapped/decoded EntityAttribute extensions as an optimization
-
setIgnoreUnmappedEntityAttributes
public void setIgnoreUnmappedEntityAttributes(boolean flag) Sets whether to ignore unmapped/decoded EntityAttribute extensions as an optimization.Defaults to false. Only applies if
getNameFormat()
property is non-null.- Parameters:
flag
- flag to set
-
doInitialize
- Overrides:
doInitialize
in classAbstractPolicyRule
- Throws:
ComponentInitializationException
-
matches
Checks to see if the entity returned bygetEntityMetadata(AttributeFilterContext)
contains the entity attribute specified by this matcher's configuration.- Parameters:
filterContext
- current request context- Returns:
- whether the entity has the configured attribute whether the rule holds
-
getEntityMetadata
@Nullable protected abstract EntityDescriptor getEntityMetadata(AttributeFilterContext filterContext) Gets the entity descriptor for the entity to check.- Parameters:
filterContext
- current filter request context- Returns:
- entity descriptor for the entity to check or null if not found
-
entityAttributeValueMatches
protected abstract boolean entityAttributeValueMatches(@Nonnull @NotEmpty @NonnullElements Set<String> entityAttributeValues) Checks whether the given entity attribute's values match for particular implementations of this functor.- Parameters:
entityAttributeValues
- the entity attribute values- Returns:
- true if the value matches, false if not
-
getEntityAttributeValues
private void getEntityAttributeValues(@Nonnull XMLObject metadataObject, @Nullable @NotEmpty String name, @Nonnull @NonnullElements Set<String> valueAccumulator) Gets the entity attribute values from the given metadata.If both the attribute name and name format for this match functor is configured then both must match, otherwise only the attribute name must match.
- Parameters:
metadataObject
- the metadata objectname
- name of metadata objectvalueAccumulator
- stores values of the designated attribute
-
getMappedEntityAttributeValues
private void getMappedEntityAttributeValues(@Nonnull XMLObject metadataObject, @Nonnull @NonnullElements Set<String> valueAccumulator) Gets the mapped entity attribute values from the given metadata.- Parameters:
metadataObject
- the metadata objectvalueAccumulator
- stores values of the designated attribute
-
getStringValue
Function to return an XMLObject in string form.- Parameters:
object
- object to decode- Returns:
- decoded string, or null
-