Package net.shibboleth.idp.attribute.transcoding.impl

# Class AttributeTranscoderRegistryImpl

java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent
net.shibboleth.idp.attribute.transcoding.impl.AttributeTranscoderRegistryImpl

All Implemented Interfaces:
  `AttributeTranscoderRegistry`, `Component`, `DestructableComponent`, `IdentifiableComponent`, `IdentifiedComponent`, `InitializableComponent`, `Aware`, `ApplicationContextAware`

@ThreadSafe public class AttributeTranscoderRegistryImpl extends AbstractIdentifiableInitializableComponent implements AttributeTranscoderRegistry, ApplicationContextAware
Service implementation of the `AttributeTranscoderRegistry` interface.

## Nested Class Summary

## Nested classes/interfaces inherited from interface net.shibboleth.idp.attribute.transcoding.AttributeTranscoderRegistry

`AttributeTranscoderRegistry.NamingFunction<T>`

## Field Summary

Fields
Modifier and Type
Field
Description
`private ApplicationContext`
`applicationContext`
The context used to load this bean.
`private final Map<String,Map<Locale,String>>`
`descriptionRegistry`
Registry of description mappings associated with internal attribute IDs.
`private final Map<String,Map<Locale,String>>`
`displayNameRegistry`
Registry of display name mappings associated with internal attribute IDs.
`private Function<Map<String,Object>,Predicate<ProfileRequestContext>>`
`extendedConditionFactory`
Optional factory function for building extended activation conditions.
`private final org.slf4j.Logger`
`log`
Class logger.
`private final Map<Class<?>,Function<?,String>>`
`namingFunctionRegistry`
Registry of naming functions for supported object types.
`private final Map<String,Multimap<Class<?>,TranscodingRule>>`
`transcodingRegistry`
Registry of transcoding instructions for a given "name" and type of object.

### Fields inherited from interface net.shibboleth.idp.attribute.transcoding.AttributeTranscoderRegistry

`PROP_CONDITION, PROP_DECODER, PROP_DESCRIPTION, PROP_DISPLAY_NAME, PROP_ENCODER, PROP_ID, PROP_RELYINGPARTIES, PROP_TRANSCODER`

## Constructor Summary

Constructors
Constructor
Description
`AttributeTranscoderRegistryImpl()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`private void`
`addMapping(String id, AttributeTranscoder<?> transcoder, Map<String,Object> ruleset)`
Add a mapping between an `IdPAttribute` name and a set of transcoding rules.
`private Predicate<ProfileRequestContext>`
`buildActivationCondition(Map<String,Object> ruleset)`
Build an appropriate `Predicate` to use as an activation condition within the ruleset.
`ApplicationContext`
`getApplicationContext()`
Get the context used to load this bean.
`private Collection<AttributeTranscoder<?>>`
`getAttributeTranscoders(TranscodingRule rule)`
Get the appropriate `AttributeTranscoder` objects to use.
`Map<Locale,String>`
`getDescriptions(IdPAttribute attribute)`
Get the localized descriptions for an `IdPAttribute`.
`Map<Locale,String>`
`getDisplayNames(IdPAttribute attribute)`
Get the localized display names for an `IdPAttribute`.
`private Class<?>`
`getEffectiveType(Class<?> inputType)`
Convert an input type into the appropriate type (possibly itself) to use in looking up rules in the registry.
`Collection<TranscodingRule>`
`getTranscodingRules(IdPAttribute from, Class<?> to)`
Obtains a set of instructions for encoding an input `IdPAttribute` into a target type.
`<T> Collection<TranscodingRule>`
`getTranscodingRules(T from)`
Obtains a set of instructions for decoding an input object into an `IdPAttribute`.
`void`
`setApplicationContext(ApplicationContext context)`
`void`
`setExtendedConditionFactory(Function<Map<String,Object>,Predicate<ProfileRequestContext>> factory)`
Set a factory function to call to consume a rule set and produce an optional "extended" activation condition `Predicate`.
`void`
`setNamingRegistry(Collection<AttributeTranscoderRegistry.NamingFunction<?>> registry)`
Installs registry of naming functions mapped against the types of objects they support.
`void`
`setTranscoderRegistry(Collection<TranscodingRule> mappings)`
Installs the transcoder mappings en masse.

### Methods inherited from class net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent

`setId`

### Methods inherited from class net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent

`doInitialize, ensureId, getId, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentException`

### Methods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent

`checkComponentActive, checkSetterPreconditions, destroy, doDestroy, 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.shared.component.IdentifiedComponent

`getId`

## Field Details

### log

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

### transcodingRegistry

@Nonnull private final Map<String,Multimap<Class<?>,TranscodingRule>> transcodingRegistry
Registry of transcoding instructions for a given "name" and type of object.

### displayNameRegistry

@Nonnull private final Map<String,Map<Locale,String>> displayNameRegistry
Registry of display name mappings associated with internal attribute IDs.

### descriptionRegistry

@Nonnull private final Map<String,Map<Locale,String>> descriptionRegistry
Registry of description mappings associated with internal attribute IDs.

### namingFunctionRegistry

@Nonnull private final Map<Class<?>,Function<?,String>> namingFunctionRegistry
Registry of naming functions for supported object types.

### extendedConditionFactory

@Nullable private Function<Map<String,Object>,Predicate<ProfileRequestContext>> extendedConditionFactory
Optional factory function for building extended activation conditions.

### applicationContext

@Nullable private ApplicationContext applicationContext
The context used to load this bean.

## Constructor Details

### AttributeTranscoderRegistryImpl

public AttributeTranscoderRegistryImpl()
Constructor.

## Method Details

### setApplicationContext

public void setApplicationContext(@Nullable ApplicationContext context)

Specified by:
  `setApplicationContext` in interface `ApplicationContextAware`

### getApplicationContext

@Nullable public ApplicationContext getApplicationContext()
Get the context used to load this bean.

Returns:
  the context.

### setNamingRegistry

public void setNamingRegistry(@Nullable Collection<AttributeTranscoderRegistry.NamingFunction<?>> registry)
Installs registry of naming functions mapped against the types of objects they support.

Parameters:
  `registry` - collection of naming functions for indexing

### setTranscoderRegistry

public void setTranscoderRegistry(@Nonnull Collection<TranscodingRule> mappings)
Installs the transcoder mappings en masse.

Each map connects an `IdPAttribute` name to the rules for transcoding to/from it.

The rules MUST contain at least:

- `AttributeTranscoderRegistry.PROP_ID` - internal attribute ID to map to/from
- `AttributeTranscoderRegistry.PROP_TRANSCODER` - an `AttributeTranscoder` instance supporting the type

Transcoders will generally require particular properties in their own right to function.

Parameters:
  `mappings` - transcoding rulesets

### setExtendedConditionFactory

public void setExtendedConditionFactory(@Nullable Function<Map<String,Object>,Predicate<ProfileRequestContext>> factory)
Set a factory function to call to consume a rule set and produce an optional "extended" activation condition `Predicate`.

This allows deployments to define extended property names that represent condition types not known to this layer of the code base.

Parameters:
  `factory` - factory function

### getDisplayNames

@Nonnull @NotLive @Unmodifiable public Map<Locale,String> getDisplayNames(@Nonnull IdPAttribute attribute)
Get the localized display names for an `IdPAttribute`.

Specified by:
  `getDisplayNames` in interface `AttributeTranscoderRegistry`
Parameters:
  `attribute` - input attribute
Returns:
  map of locale-based names

### getDescriptions

@Nonnull @NotLive @Unmodifiable public Map<Locale,String> getDescriptions(@Nonnull IdPAttribute attribute)
Get the localized descriptions for an `IdPAttribute`.

Specified by:
  `getDescriptions` in interface `AttributeTranscoderRegistry`
Parameters:
  `attribute` - input attribute
Returns:
  map of locale-based descriptions

### getTranscodingRules

@Nonnull @Unmodifiable @NotLive public Collection<TranscodingRule> getTranscodingRules(@Nonnull IdPAttribute from, @Nonnull Class<?> to)
Obtains a set of instructions for encoding an input `IdPAttribute` into a target type.

The principal property useful to a caller is `AttributeTranscoderRegistry.PROP_TRANSCODER` to obtain an instance of the appropriate `AttributeTranscoder` to call, passing in the properties to drive that call.

Specified by:
  `getTranscodingRules` in interface `AttributeTranscoderRegistry`
Parameters:
  `from` - the input object to encode
  `to` - class of object being encoded
Returns:
  a collection of `TranscodingRule` objects, possibly empty

### getTranscodingRules

@Nonnull @Unmodifiable @NotLive public <T> Collection<TranscodingRule> getTranscodingRules(@Nonnull T from)
Obtains a set of instructions for decoding an input object into an `IdPAttribute`.

The principal property useful to a caller is `AttributeTranscoderRegistry.PROP_TRANSCODER` to obtain an instance of the appropriate `AttributeTranscoder` to call, passing in the properties to drive that call.

Specified by:
  `getTranscodingRules` in interface `AttributeTranscoderRegistry`
Type Parameters:
  `T` - the type of object to decode
Parameters:
  `from` - object to decode
Returns:
  a collection of `TranscodingRule` objects, possibly empty

### getAttributeTranscoders

@Nonnull private Collection<AttributeTranscoder<?>> getAttributeTranscoders(@Nonnull TranscodingRule rule)
Get the appropriate `AttributeTranscoder` objects to use.

Parameters:
  `rule` - transcoding rule
Returns:
  transcoders to install under a copy of each ruleset's `AttributeTranscoderRegistry.PROP_TRANSCODER` property

### addMapping

private void addMapping(@Nonnull @NotEmpty String id, @Nonnull AttributeTranscoder<?> transcoder, @Nonnull Map<String,Object> ruleset)
Add a mapping between an `IdPAttribute` name and a set of transcoding rules.

Parameters:
  `id` - name of the `IdPAttribute` to map to/from
  `transcoder` - the transcoder for this rule
  `ruleset` - transcoding rules

### buildActivationCondition

@Nullable private Predicate<ProfileRequestContext> buildActivationCondition(@Nonnull Map<String,Object> ruleset)
Build an appropriate `Predicate` to use as an activation condition within the ruleset.

Parameters:
  `ruleset` - transcoding rules
Returns:
  a predicate to install under the ruleset's `AttributeTranscoderRegistry.PROP_CONDITION`

### getEffectiveType

@Nullable private Class<?> getEffectiveType(@Nonnull Class<?> inputType)
Convert an input type into the appropriate type (possibly itself) to use in looking up rules in the registry.

Parameters:
  `inputType` - the type passed into the registry operation
Returns:
  the appropriate type to use subsequently or null if not found