Class ScriptedStorageMappingStrategy
- java.lang.Object
-
- net.shibboleth.utilities.java.support.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
StorageMappingStrategythat 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
Fields Modifier and Type Field Description private org.slf4j.LoggerlogClass logger.static StringRESULTS_STRINGThe id of the object where the results go.-
Fields inherited from class net.shibboleth.utilities.java.support.scripting.AbstractScriptEvaluator
DEFAULT_ENGINE
-
-
Constructor Summary
Constructors Modifier Constructor Description privateScriptedStorageMappingStrategy(EvaluableScript theScript)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private 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<String,IdPAttribute>map(StorageRecord<?> results)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.utilities.java.support.scripting.AbstractScriptEvaluator
evaluate, getCustomObject, getHideExceptions, getLogPrefix, getOutputType, getReturnOnError, setCustomObject, setHideExceptions, setLogPrefix, setOutputType, setReturnOnError
-
-
-
-
Field Detail
-
RESULTS_STRING
@Nonnull public static final String RESULTS_STRING
The id of the object where the results go.- See Also:
- Constant Field Values
-
log
@Nonnull private final org.slf4j.Logger log
Class logger.
-
-
Constructor Detail
-
ScriptedStorageMappingStrategy
private ScriptedStorageMappingStrategy(@Nonnull EvaluableScript theScript)Constructor.- Parameters:
theScript- the script to run
-
-
Method Detail
-
map
@Nonnull public Map<String,IdPAttribute> map(@Nonnull StorageRecord<?> results) throws ResolutionException
- Specified by:
mapin interfaceMappingStrategy<StorageRecord<?>>- Throws:
ResolutionException
-
prepareContext
protected void prepareContext(@Nonnull ScriptContext scriptContext, @Nullable Object... input)- Specified by:
prepareContextin classAbstractScriptEvaluator
-
finalizeContext
@Nullable protected Object finalizeContext(@Nonnull ScriptContext scriptContext, @Nullable Object scriptResult) throws ScriptException
- Overrides:
finalizeContextin classAbstractScriptEvaluator- Throws:
ScriptException
-
checkValues
private void checkValues(IdPAttribute attribute)
Ensure that all the values in the attribute are of the correct type.- Parameters:
attribute- the attribute to look at
-
resourceScript
@Nonnull static ScriptedStorageMappingStrategy resourceScript(@Nonnull @NotEmpty String engineName, @Nonnull Resource resource) throws ScriptException, IOException
Factory to createScriptedStorageMappingStrategyfrom aResource.- Parameters:
engineName- the languageresource- the resource to look at- Returns:
- the function
- Throws:
ScriptException- if the compile failsIOException- if the file doesn't exist.
-
resourceScript
@Nonnull static ScriptedStorageMappingStrategy resourceScript(@Nonnull Resource resource) throws ScriptException, IOException
Factory to createScriptedStorageMappingStrategyfrom aResource.- Parameters:
resource- the resource to look at- Returns:
- the function
- Throws:
ScriptException- if the compile failsIOException- if the file doesn't exist.
-
inlineScript
@Nonnull static ScriptedStorageMappingStrategy inlineScript(@Nonnull @NotEmpty String engineName, @Nonnull @NotEmpty String scriptSource) throws ScriptException
Factory to createScriptedStorageMappingStrategyfrom inline data.- Parameters:
scriptSource- the script, as a stringengineName- the language- Returns:
- the function
- Throws:
ScriptException- if the compile fails
-
inlineScript
@Nonnull static ScriptedStorageMappingStrategy inlineScript(@Nonnull @NotEmpty String scriptSource) throws ScriptException
Factory to createScriptedStorageMappingStrategyfrom inline data.- Parameters:
scriptSource- the script, as a string- Returns:
- the function
- Throws:
ScriptException- if the compile fails
-
-