Package org.opensaml.saml.common.profile.impl

# Class ChainingNameIdentifierGenerator<NameIdType extends SAMLObject>

java.lang.Object
org.opensaml.saml.common.profile.impl.ChainingNameIdentifierGenerator<NameIdType>

Type Parameters:
  `NameIdType` - the type of identifier object supported

All Implemented Interfaces:
  `NameIdentifierGenerator<NameIdType>`

Direct Known Subclasses:
  `ChainingSAML1NameIdentifierGenerator`, `ChainingSAML2NameIDGenerator`

public class ChainingNameIdentifierGenerator<NameIdType extends SAMLObject> extends Object implements NameIdentifierGenerator<NameIdType>
A compound implementation of the `NameIdentifierGenerator` interface that wraps a sequence of candidate generators along with a default to try if no format-specific options are available.

## Field Summary

Fields
Modifier and Type
Field
Description
`private NameIdentifierGenerator<NameIdType>`
`defaultNameIdGenerator`
Fallback generator, generally for legacy support.
`private final org.slf4j.Logger`
`log`
Class logger.
`private ListMultimap<String,NameIdentifierGenerator<NameIdType>>`
`nameIdGeneratorMap`
Map of formats to generators.

## Constructor Summary

Constructors
Constructor
Description
`ChainingNameIdentifierGenerator()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`NameIdType`
`generate(ProfileRequestContext profileRequestContext, String format)`
Generate an identifier object.
`void`
`setDefaultGenerator(NameIdentifierGenerator<NameIdType> generator)`
Set the generator to try if no generator(s) are mapped to a desired format.
`void`
`setGenerators(List<NameIdentifierGenerator<NameIdType>> generators)`
Set the format-specific generators to use.

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

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

## Field Details

### log

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

### nameIdGeneratorMap

@Nonnull private ListMultimap<String,NameIdentifierGenerator<NameIdType extends SAMLObject>> nameIdGeneratorMap
Map of formats to generators.

### defaultNameIdGenerator

@Nullable private NameIdentifierGenerator<NameIdType extends SAMLObject> defaultNameIdGenerator
Fallback generator, generally for legacy support.

## Constructor Details

### ChainingNameIdentifierGenerator

public ChainingNameIdentifierGenerator()
Constructor.

## Method Details

### setGenerators

public void setGenerators(@Nonnull List<NameIdentifierGenerator<NameIdType>> generators)
Set the format-specific generators to use.

Only generators that support the `FormatSpecificNameIdentifierGenerator` interface are installed, and the generators are prioritized for a given format by the order they are supplied.

Parameters:
  `generators` - generators to use

### setDefaultGenerator

public void setDefaultGenerator(@Nullable NameIdentifierGenerator<NameIdType> generator)
Set the generator to try if no generator(s) are mapped to a desired format.

Parameters:
  `generator` - a fallback default generator, if any

### generate

@Nullable public NameIdType generate(@Nonnull ProfileRequestContext profileRequestContext, @Nonnull @NotEmpty String format) throws SAMLException
Generate an identifier object.

Specified by:
  `generate` in interface `NameIdentifierGenerator<NameIdType extends SAMLObject>`
Parameters:
  `profileRequestContext` - the current profile request context
  `format` - the identifier format to generate
Returns:
  the identifier object, or null
Throws:
  `SAMLException` - if an error occurs generating an identifier