Import a mapping rule from another mapping rule

We can reuse mapping rules by importing a mapping rule from another mapping rule.

To create a new mapping rule, or customize an existing mapping rule, we can reuse JavaScript code from a previously defined mapping rule. With this feature, we can define a mapping rule once and then reuse it in other mapping rules.

Use the function importMappingRule() to specify a mapping rule to import. For example, we can define a mapping rule called Utility.js that contains functions for obtaining an HTTP header and an HTTP cookie.

If we have another mapping rule called Credential.js, which also needs to obtain HTTP headers, use the following code to include the functions from the Utility.js mapping rule:

The function importMappingRule() accepts a list of mapping rule names and imports each of the mapping rules. For example:

Alternatively, we can also make multiple calls to importMappingRule() within one script. For example:

The JavaScript engine throws an error if we do not specify a mapping rule name, or if you specify the name of a mapping rule that does not exist.

Use the Local Management Interface (LMI) to view existing mapping rules defined on your system. Select Federation > Global Settings > Mapping Rules, or AAC > Global Settings > Mapping Rules.

On the LMI menu, the icon Import is for importing mapping rules into IBM Security Verify Access, not for importing a mapping rule into an existing mapping rule. Use the Edit icon to add the importMappingRule() function to an existing mapping rule.

Parent topic: Manage JavaScript mapping rules