Package net.shibboleth.idp.authn.context

# Class PreferredPrincipalContext

java.lang.Object
org.opensaml.messaging.context.BaseContext
net.shibboleth.idp.authn.context.PreferredPrincipalContext

All Implemented Interfaces:
  `Iterable<BaseContext>`

public final class PreferredPrincipalContext extends BaseContext
A context that holds information about an authentication request's preference for a specific custom `Principal`.

Authentication protocols with features for preferring specific forms of authentication with optional semantics will populate this context type with an expression of those preferences in the form of an ordered list of custom `Principal` objects.

Since:
  3.4.0
Parent:
  `AuthenticationContext`
Added:
  Before the authentication process begins

## Nested Class Summary

## Nested classes/interfaces inherited from class org.opensaml.messaging.context.BaseContext

`BaseContext.ContextSetNoRemoveIteratorDecorator, BaseContext.DeprecatedContextClassNameLookAside`

## Field Summary

Fields
Modifier and Type
Field
Description
`private List<Principal>`
`preferredPrincipals`
The principals reflecting the preference.

## Constructor Summary

Constructors
Constructor
Description
`PreferredPrincipalContext()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`List<Principal>`
`getPreferredPrincipals()`
Get an immutable list of principals reflecting the request preferences.
`boolean`
`isAcceptable(Collection<Principal> principals)`
Helper method that evaluates `Principal` objects against this context to determine if the input is compatible with it.
`boolean`
`isAcceptable(PrincipalSupportingComponent component)`
Helper method that evaluates a `PrincipalSupportingComponent` against this context to determine if the input is compatible with it.
`<T extends Principal>
boolean`
`isAcceptable(T principal)`
Helper method that evaluates a `Principal` object against this context to determine if the input is compatible with it.
`PreferredPrincipalContext`
`setPreferredPrincipals(List<Principal> principals)`
Set list of principals reflecting the request preferences.

### Methods inherited from class org.opensaml.messaging.context.BaseContext

`addSubcontext, addSubcontext, clearSubcontexts, containsSubcontext, createSubcontext, ensureSubcontext, ensureSubcontext, getParent, getSubcontext, getSubcontext, getSubcontext, getSubcontext, iterator, removeFromParent, removeSubcontext, removeSubcontext, setParent`

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

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

### Methods inherited from interface java.lang.Iterable

`forEach, spliterator`

## Field Details

### preferredPrincipals

@Nonnull private List<Principal> preferredPrincipals
The principals reflecting the preference.

## Constructor Details

### PreferredPrincipalContext

public PreferredPrincipalContext()
Constructor.

## Method Details

### getPreferredPrincipals

@Nonnull @Unmodifiable @NotLive public List<Principal> getPreferredPrincipals()
Get an immutable list of principals reflecting the request preferences.

Returns:
  immutable list of principals

### setPreferredPrincipals

@Nonnull public PreferredPrincipalContext setPreferredPrincipals(@Nonnull List<Principal> principals)
Set list of principals reflecting the request preferences.

Parameters:
  `principals` - list of principals
Returns:
  this context

### isAcceptable

public boolean isAcceptable(@Nonnull PrincipalSupportingComponent component)
Helper method that evaluates a `PrincipalSupportingComponent` against this context to determine if the input is compatible with it.

Parameters:
  `component` - component to evaluate
Returns:
  true iff the input is compatible with the requested authentication preferences

### isAcceptable

public boolean isAcceptable(@Nonnull Collection<Principal> principals)
Helper method that evaluates `Principal` objects against this context to determine if the input is compatible with it.

Parameters:
  `principals` - principal(s) to evaluate
Returns:
  true iff the input is compatible with the requested authentication preferences

### isAcceptable

public <T extends Principal> boolean isAcceptable(@Nonnull T principal)
Helper method that evaluates a `Principal` object against this context to determine if the input is compatible with it.

Type Parameters:
  `T` - type of principal
Parameters:
  `principal` - principal to evaluate
Returns:
  true iff the input is compatible with the requested authentication preferences