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 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 Map<String,Map<Locale,String>>
descriptionRegistry
Registry of description mappings associated with internal attribute IDs.private Map<String,Map<Locale,String>>
displayNameRegistry
Registry of display name mappings associated with internal attribute IDs.private org.slf4j.Logger
log
Class logger.private Map<Class<?>,Function<?,String>>
namingFunctionRegistry
Registry of naming functions for supported object types.private 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 anIdPAttribute
name and a set of transcoding rules.private Predicate<ProfileRequestContext>
buildActivationCondition(Map<String,Object> ruleset)
Build an appropriatePredicate
to use as an activation condition within the ruleset.private Collection<AttributeTranscoder<?>>
getAttributeTranscoders(TranscodingRule rule)
Get the appropriateAttributeTranscoder
objects to use.AttributeTranscoderRegistry
getComponent()
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 inputIdPAttribute
into a target type.<T> Collection<TranscodingRule>
getTranscodingRules(T from)
Obtains a set of instructions for decoding an input object into anIdPAttribute
.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.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 Details
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
transcodingRegistry
@Nonnull @NonnullElements private final Map<String,Multimap<Class<?>,TranscodingRule>> transcodingRegistryRegistry 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.
-
-
Constructor Details
-
AttributeTranscoderRegistryImpl
public AttributeTranscoderRegistryImpl()Constructor.
-
-
Method Details
-
getComponent
- Specified by:
getComponent
in interfaceServiceableComponent<AttributeTranscoderRegistry>
- Specified by:
getComponent
in 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
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/fromAttributeTranscoderRegistry.PROP_TRANSCODER
- anAttributeTranscoder
instance 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:
getDisplayNames
in 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:
getDescriptions
in 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 inputIdPAttribute
into a target type.The principal property useful to a caller is
AttributeTranscoderRegistry.PROP_TRANSCODER
to obtain an instance of the appropriateAttributeTranscoder
to call, passing in the properties to drive that call.- Specified by:
getTranscodingRules
in interfaceAttributeTranscoderRegistry
- Parameters:
from
- the input object to encodeto
- class of object being encoded- Returns:
- a collection of
TranscodingRule
objects, 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_TRANSCODER
to obtain an instance of the appropriateAttributeTranscoder
to call, passing in the properties to drive that call.- Specified by:
getTranscodingRules
in interfaceAttributeTranscoderRegistry
- Type Parameters:
T
- the type of object to decode- Parameters:
from
- object to decode- Returns:
- a collection of
TranscodingRule
objects, possibly empty
-
getAttributeTranscoders
@Nonnull @NonnullElements private Collection<AttributeTranscoder<?>> getAttributeTranscoders(@Nonnull TranscodingRule rule)Get the appropriateAttributeTranscoder
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 anIdPAttribute
name and a set of transcoding rules.- Parameters:
id
- name of theIdPAttribute
to map to/fromtranscoder
- the transcoder for this ruleruleset
- transcoding rules
-
buildActivationCondition
@Nullable private Predicate<ProfileRequestContext> buildActivationCondition(@Nonnull Map<String,Object> ruleset)Build an appropriatePredicate
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
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
-