Class ScriptedStorageMappingStrategy
java.lang.Object
net.shibboleth.shared.scripting.AbstractScriptEvaluator
net.shibboleth.idp.attribute.resolver.dc.storage.impl.ScriptedStorageMappingStrategy
- All Implemented Interfaces:
MappingStrategy<StorageRecord<?>>,StorageMappingStrategy
public final class ScriptedStorageMappingStrategy
extends AbstractScriptEvaluator
implements StorageMappingStrategy
StorageMappingStrategy that relies on a script to map the record to the
attribute set.
Well-suited to JSON output formats that can be parsed by the scripting engine.
- Since:
- 4.1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final org.slf4j.LoggerClass logger.static final StringThe id of the object where the results go.Fields inherited from class net.shibboleth.shared.scripting.AbstractScriptEvaluator
DEFAULT_ENGINE -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateScriptedStorageMappingStrategy(EvaluableScript theScript) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcheckValues(IdPAttribute attribute) Ensure that all the values in the attribute are of the correct type.protected ObjectfinalizeContext(ScriptContext scriptContext, Object scriptResult) (package private) static ScriptedStorageMappingStrategyinlineScript(String scriptSource) Factory to createScriptedStorageMappingStrategyfrom inline data.(package private) static ScriptedStorageMappingStrategyinlineScript(String engineName, String scriptSource) Factory to createScriptedStorageMappingStrategyfrom inline data.map(StorageRecord<?> results) Maps the given results to a collection ofIdPAttributeindexed by the attribute's ID.protected voidprepareContext(ScriptContext scriptContext, Object... input) (package private) static ScriptedStorageMappingStrategyresourceScript(String engineName, Resource resource) Factory to createScriptedStorageMappingStrategyfrom aResource.(package private) static ScriptedStorageMappingStrategyresourceScript(Resource resource) Factory to createScriptedStorageMappingStrategyfrom aResource.Methods inherited from class net.shibboleth.shared.scripting.AbstractScriptEvaluator
evaluate, getCustomObject, getHideExceptions, getLogPrefix, getOutputType, getReturnOnError, setContextExtenders, setCustomObject, setHideExceptions, setLogPrefix, setOutputType, setReturnOnError
-
Field Details
-
RESULTS_STRING
The id of the object where the results go.- See Also:
-
log
@Nonnull private final org.slf4j.Logger logClass logger.
-
-
Constructor Details
-
Method Details
-
map
@Nonnull @Unmodifiable @NotLive public Map<String,IdPAttribute> map(@Nonnull StorageRecord<?> results) throws ResolutionException Maps the given results to a collection ofIdPAttributeindexed by the attribute's ID.- Specified by:
mapin interfaceMappingStrategy<StorageRecord<?>>- Parameters:
results- to map- Returns:
- the mapped attributes or null if none exist
- Throws:
ResolutionException- thrown if there is a problem reading data or mapping it
-
prepareContext
- Specified by:
prepareContextin classAbstractScriptEvaluator
-
finalizeContext
@Nullable protected Object finalizeContext(@Nonnull ScriptContext scriptContext, @Nullable Object scriptResult) throws ScriptException - Overrides:
finalizeContextin classAbstractScriptEvaluator- Throws:
ScriptException
-
checkValues
Ensure that all the values in the attribute are of the correct type.- Parameters:
attribute- the attribute to look at
-
inlineScript
@Nonnull static ScriptedStorageMappingStrategy inlineScript(@Nonnull @NotEmpty @ParameterName(name="engineName") String engineName, @Nonnull @NotEmpty @ParameterName(name="scriptSource") String scriptSource) throws ScriptException, ComponentInitializationException Factory to createScriptedStorageMappingStrategyfrom inline data.- Parameters:
scriptSource- the script, as a stringengineName- the language- Returns:
- the function
- Throws:
ScriptException- if the compile failsComponentInitializationException- if the script object fails to initialize
-
inlineScript
@Nonnull static ScriptedStorageMappingStrategy inlineScript(@Nonnull @NotEmpty @ParameterName(name="scriptSource") String scriptSource) throws ScriptException, ComponentInitializationException Factory to createScriptedStorageMappingStrategyfrom inline data.- Parameters:
scriptSource- the script, as a string- Returns:
- the function
- Throws:
ScriptException- if the compile failsComponentInitializationException- if the script object fails to initialize
-