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
FieldsModifier and TypeFieldDescriptionprivate ApplicationContextThe context used to load this bean.Registry of description mappings associated with internal attribute IDs.Registry of display name mappings associated with internal attribute IDs.Optional factory function for building extended activation conditions.private final org.slf4j.LoggerClass logger.Registry of naming functions for supported object types.private final Map<String,Multimap<Class<?>, TranscodingRule>> 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 -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddMapping(String id, AttributeTranscoder<?> transcoder, Map<String, Object> ruleset) Add a mapping between anIdPAttributename and a set of transcoding rules.private Predicate<ProfileRequestContext>buildActivationCondition(Map<String, Object> ruleset) Build an appropriatePredicateto use as an activation condition within the ruleset.Get the context used to load this bean.private Collection<AttributeTranscoder<?>>Get the appropriateAttributeTranscoderobjects to use.getDescriptions(IdPAttribute attribute) Get the localized descriptions for anIdPAttribute.getDisplayNames(IdPAttribute attribute) Get the localized display names for anIdPAttribute.private Class<?>getEffectiveType(Class<?> inputType) Convert an input type into the appropriate type (possibly itself) to use in looking up rules in the registry.getTranscodingRules(IdPAttribute from, Class<?> to) Obtains a set of instructions for encoding an inputIdPAttributeinto a target type.getTranscodingRules(T from) Obtains a set of instructions for decoding an input object into anIdPAttribute.voidsetApplicationContext(ApplicationContext context) voidSet a factory function to call to consume a rule set and produce an optional "extended" activation conditionPredicate.voidInstalls registry of naming functions mapped against the types of objects they support.voidsetTranscoderRegistry(Collection<TranscodingRule> mappings) Installs the transcoder mappings en masse.Methods inherited from class net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent
setIdMethods inherited from class net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent
doInitialize, ensureId, getId, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentExceptionMethods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent
checkComponentActive, checkSetterPreconditions, destroy, doDestroy, initialize, isDestroyed, isInitializedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.shibboleth.shared.component.IdentifiedComponent
getId
-
Field Details
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
transcodingRegistry
Registry of transcoding instructions for a given "name" and type of object. -
displayNameRegistry
Registry of display name mappings associated with internal attribute IDs. -
descriptionRegistry
Registry of description mappings associated with internal attribute IDs. -
namingFunctionRegistry
Registry of naming functions for supported object types. -
extendedConditionFactory
@Nullable private Function<Map<String,Object>, extendedConditionFactoryPredicate<ProfileRequestContext>> Optional factory function for building extended activation conditions. -
applicationContext
The context used to load this bean.
-
-
Constructor Details
-
AttributeTranscoderRegistryImpl
public AttributeTranscoderRegistryImpl()Constructor.
-
-
Method Details
-
setApplicationContext
- Specified by:
setApplicationContextin interfaceApplicationContextAware
-
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
Installs the transcoder mappings en masse.Each map connects an
IdPAttributename to the rules for transcoding to/from it.The rules MUST contain at least:
AttributeTranscoderRegistry.PROP_ID- internal attribute ID to map to/fromAttributeTranscoderRegistry.PROP_TRANSCODER- anAttributeTranscoderinstance supporting the type
- 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 conditionPredicate.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 anIdPAttribute.- Specified by:
getDisplayNamesin interfaceAttributeTranscoderRegistry- 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 anIdPAttribute.- Specified by:
getDescriptionsin interfaceAttributeTranscoderRegistry- 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 inputIdPAttributeinto a target type.The principal property useful to a caller is
AttributeTranscoderRegistry.PROP_TRANSCODERto obtain an instance of the appropriateAttributeTranscoderto call, passing in the properties to drive that call.- Specified by:
getTranscodingRulesin interfaceAttributeTranscoderRegistry- Parameters:
from- the input object to encodeto- class of object being encoded- Returns:
- a collection of
TranscodingRuleobjects, 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 anIdPAttribute.The principal property useful to a caller is
AttributeTranscoderRegistry.PROP_TRANSCODERto obtain an instance of the appropriateAttributeTranscoderto call, passing in the properties to drive that call.- Specified by:
getTranscodingRulesin interfaceAttributeTranscoderRegistry- Type Parameters:
T- the type of object to decode- Parameters:
from- object to decode- Returns:
- a collection of
TranscodingRuleobjects, possibly empty
-
getAttributeTranscoders
@Nonnull private Collection<AttributeTranscoder<?>> getAttributeTranscoders(@Nonnull TranscodingRule rule) Get the appropriateAttributeTranscoderobjects to use.- Parameters:
rule- transcoding rule- Returns:
- transcoders to install under a copy of each ruleset's
AttributeTranscoderRegistry.PROP_TRANSCODERproperty
-
addMapping
private void addMapping(@Nonnull @NotEmpty String id, @Nonnull AttributeTranscoder<?> transcoder, @Nonnull Map<String, Object> ruleset) Add a mapping between anIdPAttributename and a set of transcoding rules.- Parameters:
id- name of theIdPAttributeto map to/fromtranscoder- the transcoder for this ruleruleset- transcoding rules
-
buildActivationCondition
@Nullable private Predicate<ProfileRequestContext> buildActivationCondition(@Nonnull Map<String, Object> ruleset) Build an appropriatePredicateto 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
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
-