Package net.shibboleth.profile.context.logic

# Class LoopDetectionPredicate

java.lang.Object
net.shibboleth.profile.context.logic.AbstractRelyingPartyPredicate
net.shibboleth.profile.context.logic.LoopDetectionPredicate

All Implemented Interfaces:
  `Predicate<ProfileRequestContext>`

public class LoopDetectionPredicate extends AbstractRelyingPartyPredicate
A condition that relies on a `Meter` to detect looping SPs.

Since:
  4.1.0

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`private class`
`LoopDetectionPredicate.DefaultTagGenerator`
Default tag generator that hashes the RP ID.

## Field Summary

Fields
Modifier and Type
Field
Description
`private Predicate<ProfileRequestContext>`
`activationCondition`
Generalized condition in place of dedicated map.
`private final org.slf4j.Logger`
`log`
Class logger.
`private final com.codahale.metrics.MetricRegistry`
`privateRegistry`
Private registry to isolate timers.
`private Map<String,String>`
`relyingPartyMap`
Map of RP names to meter names.
`private Function<ProfileRequestContext,String>`
`tagGenerationStrategy`
Used with generalized condition to compute name to use in loop metric.
`private long`
`threshold`
Count to trigger warning.
`private Function<ProfileRequestContext,String>`
`usernameLookupStrategy`
Lookup strategy to obtain subject name.

## Constructor Summary

Constructors
Constructor
Description
`LoopDetectionPredicate()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`void`
`setActivationCondition(Predicate<ProfileRequestContext> condition)`
Sets a generalized activation condition to apply in addition to the hardcoded map of RPs.
`void`
`setRelyingPartyMap(Map<String,String> map)`
Set the map of relying party names to meter names to track counts.
`void`
`setTagGenerationStrategy(Function<ProfileRequestContext,String> strategy)`
Sets a generalized tag generation strategy to produce the loop detection metric name.
`void`
`setThreshold(long value)`
Set the warning threshold for the 1 minute moving average to exceed.
`void`
`setUsernameLookupStrategy(Function<ProfileRequestContext,String> strategy)`
Set lookup strategy to obtain username.
`boolean`
`test(ProfileRequestContext input)`

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

`getRelyingPartyContext, getRelyingPartyContextLookupStrategy, setRelyingPartyContextLookupStrategy`

### 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.

### privateRegistry

@Nonnull private final com.codahale.metrics.MetricRegistry privateRegistry
Private registry to isolate timers.

### threshold

private long threshold
Count to trigger warning.

### relyingPartyMap

@Nonnull private Map<String,String> relyingPartyMap
Map of RP names to meter names.

### activationCondition

@Nonnull private Predicate<ProfileRequestContext> activationCondition
Generalized condition in place of dedicated map.

### tagGenerationStrategy

@Nonnull private Function<ProfileRequestContext,String> tagGenerationStrategy
Used with generalized condition to compute name to use in loop metric.

### usernameLookupStrategy

@Nonnull private Function<ProfileRequestContext,String> usernameLookupStrategy
Lookup strategy to obtain subject name.

## Constructor Details

### LoopDetectionPredicate

public LoopDetectionPredicate() throws NoSuchAlgorithmException
Constructor.

Throws:
  `NoSuchAlgorithmException` - if unable to create digester

## Method Details

### setThreshold

public void setThreshold(@Positive long value)
Set the warning threshold for the 1 minute moving average to exceed.

Defaults to 20.

Parameters:
  `value` - threshold to use

### setRelyingPartyMap

public void setRelyingPartyMap(@Nullable Map<String,String> map)
Set the map of relying party names to meter names to track counts.

Parameters:
  `map` - map of RP/meter mappings

### setUsernameLookupStrategy

public void setUsernameLookupStrategy(@Nonnull Function<ProfileRequestContext,String> strategy)
Set lookup strategy to obtain username.

Parameters:
  `strategy` - lookup strategy

### setActivationCondition

public void setActivationCondition(@Nonnull Predicate<ProfileRequestContext> condition)
Sets a generalized activation condition to apply in addition to the hardcoded map of RPs.

Defaults to false.

Parameters:
  `condition` - condition to set
Since:
  5.2.0

### setTagGenerationStrategy

public void setTagGenerationStrategy(@Nonnull Function<ProfileRequestContext,String> strategy)
Sets a generalized tag generation strategy to produce the loop detection metric name.

Defaults to the SHA-1 hash of the RP name.

Parameters:
  `strategy` - function to produce metric name
Since:
  5.2.0

### test

public boolean test(@Nullable ProfileRequestContext input)