/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2014-2015 ForgeRock AS. All rights reserved.
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*/
/*
* Default mapping script for processing effectiveAssignments
* Assignment and unassignment operations are configured as scripts.
* An example operation configuration is:
* {
* "file" : "roles/replaceTarget.js",
* "type" : "text/javascript"
* };
*/
// The result map
var map = { "result" : true },
// Default operations
// A map of operation aliases to their corresponding script configurations
var operations = {
"replaceTarget" : {
"file" : "roles/replaceTarget.js",
"type" : "text/javascript"
},
"mergeWithTarget" : {
"file" : "roles/mergeWithTarget.js",
"type" : "text/javascript"
},
"removeFromTarget" : {
"file" : "roles/removeFromTarget.js",
"type" : "text/javascript"
},
"noOp" : {
"type" : "text/javascript"
}
}
/**
* Returns the script configuration with the necessary scope fields added.
*
* @param script a script configuration or a script alias
*/
var config;
var scope = {};
// Check if the script is an alias or a full configuration
if (script instanceof Object) {
// Full configuration
// Alias
} else {
throw "Unsupported operation alias " + script;
}
}
// Add additional scope fields
}
return scope;
}
/**
* Executes a script from the given configurations.
*
* @param scriptConfig the script configuration
*/
}
}
}
/**
* Searches the given list for an assignment relationship matching the given assignment relationship.
* Returns the fetched assignment or null if no matching assignment is found.
*
* @param assignment the assignment to search for
* @param listOfAssignments a list of assignments
*/
return listOfAssignments[i];
}
}
return null;
}
// Check for any assignments that have been removed or modified
var unassigned = [];
// Loop through old assignments
var oldAssignment = oldAssignments[x];
// Check that this assignment is relevant to this mapping
var assignmentRemoved = false;
// Get the Current assignment, may be null if it has been removed/unassigned
if (currentAssignment === null) {
// This assignment has been unassigned
// Check if an onUnassignment script is configured
}
assignmentRemoved = true;
}
// Get the Old assignment's attributes
// Loop through old attributes and execute the unassignmentOperation on any that were removed or updated
var oldAttribute = oldAttributes[i];
var removedOrUpdated = true;
// If the assignment has not been removed, then we need to check if the attribute has been removed or updated.
if (!assignmentRemoved && currentAssignment !== null) {
var currentAttribute = currentAttributes[j];
// attribute was found and not updated
removedOrUpdated = false;
}
break;
}
}
}
// Check if the old attribute has been removed
if (removedOrUpdated) {
if (unassignmentOperation == null) {
// Default to replace and use the entire value
}
// Update the target (working copy)
// Update the existingTarget, in order to carry changes over to additional operations that may use the existingTarget
}
}
}
}
}
}
}
}
// Process effective assignments, if any
if (effectiveAssignments != null) {
// Used to carry information across different assignmentOperations
var attibutesInfo; attributesInfoMap = {};
// Check that this assignment is relevant to this mapping
// Only map if no linkQualifiers were specified or the current linkQualifier is in the list of linkQualifiers specified in the assignment
// Check if an onAssignment script is configured
}
// Loop through attributes, performing the assignmentOperations
var attribute = attributes[i];
// Initialize if it has not already been defined for this attribute
attributesInfo = {};
}
if (assignmentOperation == null) {
// Default to replace and use the entire value
}
// Process the assignmentOperation
// The result of this call should be an object with a field "value" containing the updated target field's value
// Set the new target field's value
// Update any passed back attributesInfo
}
}
}
}
}
}
// Return the resulting map
map;