Import a mapping rule from another mapping rule

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

When you want to create a new mapping rule, or customize an existing mapping rule, you can reuse JavaScript code from a previously defined mapping rule. With this feature, you 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, you can define a mapping rule that is called Utility.js that contains functions for obtaining an HTTP header and an HTTP cookie.


function getHeader(name) { 
          // function for getting HTTP header
} 

function getCookie(name) { 
         // function for getting HTTP cookie
} 

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


importMappingRule("Utility"); 
var host = getHeader("Host");
// do something with the host header 
var sessionID = getHeader("PD-SESSION-ID");
// do something with the session ID

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

importMappingRule("Utility","Credential","UserIdentity");

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

importMappingRule("Utility");
importMappingRule("Credential");
importMappingRule("UserIdentity");

The JavaScript engine throws an error if you 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 that are defined on your system. Select Federation > Global Settings > Mapping Rules, or AAC > Global Settings > Mapping Rules.

Note:

On the LMI menu, the icon Import is for importing mapping rules into IBM® Verify Identity 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.