Class AttributeTranscoderRegistryImpl
- java.lang.Object
-
- net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
-
- net.shibboleth.utilities.java.support.component.AbstractIdentifiedInitializableComponent
-
- net.shibboleth.utilities.java.support.component.AbstractIdentifiableInitializableComponent
-
- net.shibboleth.ext.spring.service.AbstractServiceableComponent<AttributeTranscoderRegistry>
-
- net.shibboleth.idp.attribute.transcoding.impl.AttributeTranscoderRegistryImpl
-
- All Implemented Interfaces:
AttributeTranscoderRegistry,Component,DestructableComponent,IdentifiableComponent,IdentifiedComponent,InitializableComponent,ServiceableComponent<AttributeTranscoderRegistry>,Aware,ApplicationContextAware
@ThreadSafe public class AttributeTranscoderRegistryImpl extends AbstractServiceableComponent<AttributeTranscoderRegistry> implements AttributeTranscoderRegistry
Service implementation of theAttributeTranscoderRegistryinterface.
-
-
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 Map<String,Map<Locale,String>>descriptionRegistryRegistry of description mappings associated with internal attribute IDs.private Map<String,Map<Locale,String>>displayNameRegistryRegistry of display name mappings associated with internal attribute IDs.private org.slf4j.LoggerlogClass logger.private Map<Class<?>,Function<?,String>>namingFunctionRegistryRegistry of naming functions for supported object types.private Map<String,Multimap<Class<?>,TranscodingRule>>transcodingRegistryRegistry 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private 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.private Collection<AttributeTranscoder<?>>getAttributeTranscoders(TranscodingRule rule)Get the appropriateAttributeTranscoderobjects to use.AttributeTranscoderRegistrygetComponent()Map<Locale,String>getDescriptions(IdPAttribute attribute)Get the localized descriptions for anIdPAttribute.Map<Locale,String>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.Collection<TranscodingRule>getTranscodingRules(IdPAttribute from, Class<?> to)Obtains a set of instructions for encoding an inputIdPAttributeinto a target type.<T> Collection<TranscodingRule>getTranscodingRules(T from)Obtains a set of instructions for decoding an input object into anIdPAttribute.voidsetNamingRegistry(Collection<AttributeTranscoderRegistry.NamingFunction<?>> registry)Installs 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.ext.spring.service.AbstractServiceableComponent
doDestroy, doInitialize, getApplicationContext, pinComponent, setApplicationContext, unloadComponent, unpinComponent
-
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractIdentifiableInitializableComponent
setId
-
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractIdentifiedInitializableComponent
getId
-
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
destroy, 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.utilities.java.support.component.IdentifiedComponent
getId
-
-
-
-
Field Detail
-
log
@Nonnull private final org.slf4j.Logger log
Class logger.
-
transcodingRegistry
@Nonnull @NonnullElements private final Map<String,Multimap<Class<?>,TranscodingRule>> transcodingRegistry
Registry of transcoding instructions for a given "name" and type of object.
-
displayNameRegistry
@Nonnull @NonnullElements private final Map<String,Map<Locale,String>> displayNameRegistry
Registry of display name mappings associated with internal attribute IDs.
-
descriptionRegistry
@Nonnull @NonnullElements private final Map<String,Map<Locale,String>> descriptionRegistry
Registry of description mappings associated with internal attribute IDs.
-
namingFunctionRegistry
@Nonnull @NonnullElements private final Map<Class<?>,Function<?,String>> namingFunctionRegistry
Registry of naming functions for supported object types.
-
-
Method Detail
-
getComponent
@Nonnull public AttributeTranscoderRegistry getComponent()
- Specified by:
getComponentin interfaceServiceableComponent<AttributeTranscoderRegistry>- Specified by:
getComponentin classAbstractServiceableComponent<AttributeTranscoderRegistry>
-
setNamingRegistry
public void setNamingRegistry(@Nullable @NonnullElements 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 @NonnullElements Collection<TranscodingRule> mappings)
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
-
getDisplayNames
@Nonnull @NonnullElements @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 @NonnullElements @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 @NonnullElements @Unmodifiable 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 @NonnullElements @Unmodifiable 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 @NonnullElements 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
@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
-
-