d1d86cce199bac0cae2564859cdce940fc674efcomebold/**
d1d86cce199bac0cae2564859cdce940fc674efcomebold * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
d1d86cce199bac0cae2564859cdce940fc674efcomebold *
d1d86cce199bac0cae2564859cdce940fc674efcomebold * Copyright (c) 2014 ForgeRock AS. All rights reserved.
d1d86cce199bac0cae2564859cdce940fc674efcomebold *
d1d86cce199bac0cae2564859cdce940fc674efcomebold * The contents of this file are subject to the terms
d1d86cce199bac0cae2564859cdce940fc674efcomebold * of the Common Development and Distribution License
d1d86cce199bac0cae2564859cdce940fc674efcomebold * (the License). You may not use this file except in
d1d86cce199bac0cae2564859cdce940fc674efcomebold * compliance with the License.
d1d86cce199bac0cae2564859cdce940fc674efcomebold *
d1d86cce199bac0cae2564859cdce940fc674efcomebold * You can obtain a copy of the License at
d1d86cce199bac0cae2564859cdce940fc674efcomebold * http://forgerock.org/license/CDDLv1.0.html
d1d86cce199bac0cae2564859cdce940fc674efcomebold * See the License for the specific language governing
d1d86cce199bac0cae2564859cdce940fc674efcomebold * permission and limitations under the License.
d1d86cce199bac0cae2564859cdce940fc674efcomebold *
d1d86cce199bac0cae2564859cdce940fc674efcomebold * When distributing Covered Code, include this CDDL
d1d86cce199bac0cae2564859cdce940fc674efcomebold * Header Notice in each file and include the License file
d1d86cce199bac0cae2564859cdce940fc674efcomebold * at http://forgerock.org/license/CDDLv1.0.html
d1d86cce199bac0cae2564859cdce940fc674efcomebold * If applicable, add the following below the CDDL Header,
d1d86cce199bac0cae2564859cdce940fc674efcomebold * with the fields enclosed by brackets [] replaced by
d1d86cce199bac0cae2564859cdce940fc674efcomebold * your own identifying information:
d1d86cce199bac0cae2564859cdce940fc674efcomebold * "Portions Copyrighted [year] [name of copyright owner]"
d1d86cce199bac0cae2564859cdce940fc674efcomebold */
d1d86cce199bac0cae2564859cdce940fc674efcomebold
d1d86cce199bac0cae2564859cdce940fc674efcomebold/**
d1d86cce199bac0cae2564859cdce940fc674efcomebold * Calculates the effective roles
d1d86cce199bac0cae2564859cdce940fc674efcomebold */
d1d86cce199bac0cae2564859cdce940fc674efcomebold
d1d86cce199bac0cae2564859cdce940fc674efcomebold/*global object */
d1d86cce199bac0cae2564859cdce940fc674efcomebold
d1d86cce199bac0cae2564859cdce940fc674efcomeboldlogger.debug("Invoked effectiveRoles script on {} value: ", propertyName, object);
d1d86cce199bac0cae2564859cdce940fc674efcomebold// Allow for configuration in virtual attribute config, but default
d1d86cce199bac0cae2564859cdce940fc674efcomeboldif (rolesPropName === undefined) {
d1d86cce199bac0cae2564859cdce940fc674efcomebold var rolesPropName = "roles";
d1d86cce199bac0cae2564859cdce940fc674efcomebold}
d1d86cce199bac0cae2564859cdce940fc674efcomeboldlogger.trace("Configured rolesPropName: {}", rolesPropName);
d1d86cce199bac0cae2564859cdce940fc674efcomebold
d1d86cce199bac0cae2564859cdce940fc674efcomeboldvar directRoles = object[rolesPropName];
e7eb3ca682d7f080b1fb33cd54f56e880cdc9176Jason Vincentvar effectiveRoles = directRoles == null ? [] : directRoles;
d1d86cce199bac0cae2564859cdce940fc674efcomebold
d1d86cce199bac0cae2564859cdce940fc674efcomebold// This is the location to expand to dynamic roles,
d1d86cce199bac0cae2564859cdce940fc674efcomebold// project role script return values can then be added via
d1d86cce199bac0cae2564859cdce940fc674efcomebold// effectiveRoles = effectiveRoles.concat(dynamicRolesArray);
d1d86cce199bac0cae2564859cdce940fc674efcomeboldif (object.department === 'Human Resources') {
c1bed58d59da76132e7b960e74825f038c282555Jon Branch effectiveRoles = effectiveRoles.concat([{"_ref":"managed/role/human-resources"}]);
d1d86cce199bac0cae2564859cdce940fc674efcomebold}
d1d86cce199bac0cae2564859cdce940fc674efcomeboldif (object.department === 'Production Planning') {
c1bed58d59da76132e7b960e74825f038c282555Jon Branch effectiveRoles = effectiveRoles.concat([{"_ref":"managed/role/production-planning"}]);
d1d86cce199bac0cae2564859cdce940fc674efcomebold}
d1d86cce199bac0cae2564859cdce940fc674efcomeboldif (object.department === 'Sales & Distribution') {
c1bed58d59da76132e7b960e74825f038c282555Jon Branch effectiveRoles = effectiveRoles.concat([{"_ref":"managed/role/sales-distribution"}]);
d1d86cce199bac0cae2564859cdce940fc674efcomebold}
d1d86cce199bac0cae2564859cdce940fc674efcomeboldif (object.department === 'Treasury & Payments') {
c1bed58d59da76132e7b960e74825f038c282555Jon Branch effectiveRoles = effectiveRoles.concat([{"_ref":"managed/role/treasury-payments"}]);
d1d86cce199bac0cae2564859cdce940fc674efcomebold}
d1d86cce199bac0cae2564859cdce940fc674efcomebold
d1d86cce199bac0cae2564859cdce940fc674efcomeboldeffectiveRoles;