Class AttributeFilterImpl
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.ext.spring.service.AbstractServiceableComponent<AttributeFilter>
net.shibboleth.idp.attribute.filter.impl.AttributeFilterImpl
- All Implemented Interfaces:
AttributeFilter
,Component
,DestructableComponent
,IdentifiableComponent
,IdentifiedComponent
,InitializableComponent
,ServiceableComponent<AttributeFilter>
,Aware
,ApplicationContextAware
@ThreadSafe
public class AttributeFilterImpl
extends AbstractServiceableComponent<AttributeFilter>
implements AttributeFilter
Service that filters out attributes and values based upon loaded policies.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final List<AttributeFilterPolicy>
Filter policies used by this engine.private final org.slf4j.Logger
Class logger.private String
Log prefix.private Function<AttributeFilterContext,
MetricContext> Strategy to get theMetricContext
for timing. -
Constructor Summary
ConstructorsConstructorDescriptionAttributeFilterImpl
(String engineId, Collection<AttributeFilterPolicy> policies) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
void
filterAttributes
(AttributeFilterContext filterContext) Filters attributes and values.protected Collection<IdPAttributeValue>
getFilteredValues
(String attributeId, AttributeFilterContext filterContext) Gets the permitted values for the given attribute from theAttributeFilterWorkContext.getPermittedIdPAttributeValues()
and removes all denied values given in theAttributeFilterWorkContext.getDeniedAttributeValues()
.Gets the immutable collection of filter policies.protected String
Get the prefix for logging.private boolean
startTimer
(AttributeFilterContext filterContext) Conditionally start a timer at the beginning of the filtering process.private void
stopTimer
(AttributeFilterContext filterContext) Conditionally stop a timer at the end of the filtering process.Methods inherited from class net.shibboleth.ext.spring.service.AbstractServiceableComponent
doDestroy, getApplicationContext, pinComponent, setApplicationContext, unloadComponent, unpinComponent
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, 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. -
filterPolicies
Filter policies used by this engine. -
logPrefix
Log prefix. -
metricContextLookupStrategy
Strategy to get theMetricContext
for timing.
-
-
Constructor Details
-
AttributeFilterImpl
public AttributeFilterImpl(@Nonnull @NotEmpty String engineId, @Nullable @NonnullElements Collection<AttributeFilterPolicy> policies) Constructor.- Parameters:
engineId
- ID of this enginepolicies
- filter policies used by this engine
-
-
Method Details
-
getFilterPolicies
Gets the immutable collection of filter policies.- Specified by:
getFilterPolicies
in interfaceAttributeFilter
- Returns:
- immutable collection of filter policies
-
filterAttributes
public void filterAttributes(@Nonnull AttributeFilterContext filterContext) throws AttributeFilterException Filters attributes and values. This filtering process may remove attributes and values but must never add them.- Specified by:
filterAttributes
in interfaceAttributeFilter
- Parameters:
filterContext
- context containing the attributes to be filtered and collecting the results of the filtering process- Throws:
AttributeFilterException
- thrown if there is a problem retrieving or applying the attribute filter policy
-
getFilteredValues
@Nullable protected Collection<IdPAttributeValue> getFilteredValues(@Nonnull @NotEmpty String attributeId, @Nonnull AttributeFilterContext filterContext) Gets the permitted values for the given attribute from theAttributeFilterWorkContext.getPermittedIdPAttributeValues()
and removes all denied values given in theAttributeFilterWorkContext.getDeniedAttributeValues()
.- Parameters:
attributeId
- ID of the attribute whose values are to be retrievedfilterContext
- current attribute filter context- Returns:
- null if no values were permitted to be released, an empty collection if values were permitted but then all were removed by deny policies, a collection containing permitted values
-
doInitialize
- Overrides:
doInitialize
in classAbstractServiceableComponent<AttributeFilter>
- Throws:
ComponentInitializationException
-
getLogPrefix
Get the prefix for logging.- Returns:
- Returns the logPrefix.
-
getComponent
- Specified by:
getComponent
in interfaceServiceableComponent<AttributeFilter>
- Specified by:
getComponent
in classAbstractServiceableComponent<AttributeFilter>
-
startTimer
Conditionally start a timer at the beginning of the filtering process.- Parameters:
filterContext
- attribute filtering context- Returns:
- true iff the
stopTimer(AttributeFilterContext)
method needs to be called
-
stopTimer
Conditionally stop a timer at the end of the filtering process.- Parameters:
filterContext
- attribute filtering context
-