Class TranscodingRule
java.lang.Object
net.shibboleth.idp.attribute.transcoding.TranscodingRule
public final class TranscodingRule extends Object
Wrapper around a
Map
representing a rule for transcoding, used to
detect and load the rules at runtime from a Spring context.-
Field Summary
-
Constructor Summary
Constructors Constructor Description TranscodingRule(Map<String,Object> map)
Constructor.TranscodingRule(Properties properties)
Constructor. -
Method Summary
Modifier and Type Method Description static TranscodingRule
fromResource(Resource resource)
Build a new rule from a property set resource.<T> T
get(String key, Class<T> type)
Get the value of a property key in the rule.Map<Locale,String>
getDescriptions()
Get the descriptions to attach to anyIdPAttribute
objects created by this transcoder.Map<Locale,String>
getDisplayNames()
Get the display names to attach to anyIdPAttribute
objects created by this transcoder.Map<String,Object>
getMap()
Access the underlying mapping rule.<T> T
getOrDefault(String key, Class<T> type, T defValue)
Get the value of a property key in the rule or a default value if no property exists.private void
processDescriptions()
Process any properties that start withAttributeTranscoderRegistry.PROP_DESCRIPTION
and create a Locale map around them.private void
processDisplayNames()
Process any properties that start withAttributeTranscoderRegistry.PROP_DISPLAY_NAME
and create a Locale map around them.
-
Field Details
-
rule
Underlying map containing the rule. -
displayNames
Map of locale-specific display names. -
descriptions
Map of locale-specific descriptions.
-
-
Constructor Details
-
TranscodingRule
public TranscodingRule(@Nonnull @NonnullElements @ParameterName(name="map") Map<String,Object> map)Constructor.- Parameters:
map
- a map containing the ruleThe rule MUST contain at least:
-
AttributeTranscoderRegistry.PROP_ID
- internal attribute ID to map to/from -
AttributeTranscoderRegistry.PROP_TRANSCODER
-AttributeTranscoder
instance supporting the type
-
-
TranscodingRule
public TranscodingRule(@Nonnull @NonnullElements @ParameterName(name="properties") Properties properties)Constructor.- Parameters:
properties
- a property set to initialize the mapThe rule MUST contain at least:
-
AttributeTranscoderRegistry.PROP_ID
- internal attribute ID to map to/from -
AttributeTranscoderRegistry.PROP_TRANSCODER
-AttributeTranscoder
class name
-
-
-
Method Details
-
getMap
Access the underlying mapping rule.- Returns:
- the map representing the rule
-
get
Get the value of a property key in the rule.- Type Parameters:
T
- type of property value- Parameters:
key
- key of propertytype
- class type of property- Returns:
- the mapped value, or null
-
getOrDefault
@Nullable public <T> T getOrDefault(@Nonnull @NotEmpty String key, @Nonnull Class<T> type, @Nullable T defValue)Get the value of a property key in the rule or a default value if no property exists.- Type Parameters:
T
- type of property value- Parameters:
key
- key of propertytype
- class type of propertydefValue
- default value- Returns:
- the mapped value, or the default
-
getDisplayNames
Get the display names to attach to anyIdPAttribute
objects created by this transcoder.- Returns:
- map of locale-based names
-
getDescriptions
Get the descriptions to attach to anyIdPAttribute
objects created by this transcoder.- Returns:
- map of locale-based descriptions
-
processDisplayNames
private void processDisplayNames()Process any properties that start withAttributeTranscoderRegistry.PROP_DISPLAY_NAME
and create a Locale map around them. -
processDescriptions
private void processDescriptions()Process any properties that start withAttributeTranscoderRegistry.PROP_DESCRIPTION
and create a Locale map around them. -
fromResource
@Nonnull public static TranscodingRule fromResource(@Nonnull @ParameterName(name="resource") Resource resource) throws IOExceptionBuild a new rule from a property set resource.- Parameters:
resource
- a property set to initialize the map- Returns:
- the new rule
- Throws:
IOException
- if an error occurs
-