Script Transformer Action

A script transformer action transforms the input attribute names and values. The script transformer allows for any transformations imaginable as the incoming attributes is transformed programmatically through custom script procedures.

Transforming values using script procedures

A procedure is basically a function providing a scripting context in which the incoming attributes are contained. These attributes may be transformed in any possible way, either statically or even by looking up data in external data sources or whatever other helpers are provided in the context.

Like other actions, this one is also able exclude certain attributes if so configured (see below).

Note

See the Common Procedure Objects page for some pointers on what’s made available in procedure contexts.

In its simplest form, a script transformer action procedure looks like the following:

Listing 153 Structure of a script transformer action
1
2
3
4
5
6
7
function result(transformationContext) {
    var attributes = transformationContext.attributeMap;

    // .. do something with the incoming attributes here before returning them

    return attributes;
}

In the previous example, the source of the attributes in transformationContext.attributeMap and the destination for the returned attributes is defined by the attributes-location configuration setting. By default the location is the subject attributes, contained inside the authentication attributes. The other two possible locations are the context attributes, also contained inside the authentication attributes, and the action attributes.

The procedure used by a Script Transformer Action also has access to the complete subject attributes, context attributes, and action attributes, via the following additional properties on the transformation script context.

Transformation context property Description
subjectAttributeMap The action’s input SubjectAttributes.
contextAttributeMap The action’s input ContextAttributes.
actionAttributeMap The action’s input AuthenticationActionAttributes.
These extra properties contain the full non-filtered attributes, represented as maps. Any changes made to these maps are not reflected in the action’s output attributes. Only the script’s return is used to change the action’s output attributes, controlled by the attributes-location configuration setting.

Configuration

Adding script procedures is easily done from the Admin UI. Simply click to add a new script transformer and then choose to reference an existing one or create a new one with the help of the provided editor.

../../_images/example-script.png

The following configuration options are available:

Configuration Mandatory Description
transformation-procedure yes A reference to the actual procedure that should run
excluded-attributes no Optional list of attributes that should be removed
attributes-location no The source and destination location for the transformed attributes (subject-attributes, context-attributes, or action-attributes).