Package net.shibboleth.profile.context.logic

# Class SimpleAttributePredicate

java.lang.Object
net.shibboleth.profile.context.logic.AbstractAttributePredicate
net.shibboleth.profile.context.logic.SimpleAttributePredicate

All Implemented Interfaces:
  `Predicate<ProfileRequestContext>`

public class SimpleAttributePredicate extends AbstractAttributePredicate
Predicate that evaluates an `AttributeContext` and checks for particular attribute/value pairs.

A map to a collection of strings is used to represent the attribute(s) and value(s) to evaluate. The values are evaluated as a disjunction (OR) and the attributes are evaluated as a conjunction (AND).

This handles only simple string-valued data, or if scope is supplied, requires scoped values.

For the special case of checking for an attribute's presence, regardless of values, the '*' value is supported. Note that this does NOT exclude pathological cases such as empty or null values. A more advanced predicate should be used to deal with such cases.

## Field Summary

Fields
Modifier and Type
Field
Description
`private ListMultimap<String,String>`
`attributeValueMap`
Map of attribute IDs to values.
`private final org.slf4j.Logger`
`log`
Class logger.
`private String`
`scope`
Optional scope to check.

## Constructor Summary

Constructors
Constructor
Description
`SimpleAttributePredicate()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`protected boolean`
`allowNullAttributeContext()`
Get the result of the predicate in the case the attribute context is null.
`protected boolean`
`findMatch(String toMatch, IdPAttribute attribute)`
Look for a matching value in an attribute.
`protected boolean`
`hasMatch(Map<String,IdPAttribute> attributeMap)`
Abstract implementation of the condition to evaluate.
`void`
`setAttributeValueMap(Map<String,Collection<String>> map)`
Set the map of attribute/value pairs (as a map of string collections) to check for.
`void`
`setScope(String s)`
Set a scope to check for.

### Methods inherited from class net.shibboleth.profile.context.logic.AbstractAttributePredicate

`getAttributeContextLookupStrategy, isUseUnfilteredAttributes, setAttributeContextLookupStrategy, setUseUnfilteredAttributes, test`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface java.util.function.Predicate

`and, negate, or`

## Field Details

### log

@Nonnull private final org.slf4j.Logger log
Class logger.

### attributeValueMap

@Nonnull private ListMultimap<String,String> attributeValueMap
Map of attribute IDs to values.

### scope

@Nullable @NotEmpty private String scope
Optional scope to check.

## Constructor Details

### SimpleAttributePredicate

public SimpleAttributePredicate()
Constructor.

## Method Details

### setAttributeValueMap

public void setAttributeValueMap(@Nonnull Map<String,Collection<String>> map)
Set the map of attribute/value pairs (as a map of string collections) to check for.

Parameters:
  `map` - map of attribute/value pairs

### setScope

public void setScope(@Nullable @NotEmpty String s)
Set a scope to check for.

If set, values that "match" must be scoped with this value. A "*" will match any scope, but one must exist.

Parameters:
  `s` - scope to check for
Since:
  4.2.0

### allowNullAttributeContext

protected boolean allowNullAttributeContext()
Get the result of the predicate in the case the attribute context is null.

Defaults to false unless overridden by a subclass.

This will return false unless no values and scope to check for were specified to the condition.

Overrides:
  `allowNullAttributeContext` in class `AbstractAttributePredicate`
Returns:
  null context result

### hasMatch

protected boolean hasMatch(@Nonnull Map<String,IdPAttribute> attributeMap)
Abstract implementation of the condition to evaluate.

Specified by:
  `hasMatch` in class `AbstractAttributePredicate`
Parameters:
  `attributeMap` - the attributes to evaluate
Returns:
  the condition result

### findMatch

protected boolean findMatch(@Nonnull @NotEmpty String toMatch, @Nonnull IdPAttribute attribute)
Look for a matching value in an attribute.

Parameters:
  `toMatch` - value to look for
  `attribute` - attribute to check
Returns:
  true iff the value is one of the attribute's values