policy.js revision 7e5743eba4787b2af8f31fbbb1f7d529d36196b5
/*! @license
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright © 2011-2012 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]"
*/
//var params;
//var value;
//var fullObject;
var returnObject = {};
var failedPolicies = new Array();
var policyConfig = {
"policies" : [
{ "policyId" : "minimum-length",
"policyExec" : "propertyMinLength",
"policyRequirements" : ["MIN_LENGTH"]
},
{ "policyId" : "at-least-one-capital",
"policyExec" : "atLeastOneCapitalLetter",
"policyRequirements" : ["AT_LEAST_ONE_CAPITAL_LETTER"]
},
{ "policyId" : "at-least-one-number",
"policyExec" : "atLeastOneNumber",
"policyRequirements" : ["AT_LEAST_ONE_NUMBER"]
}
]
};
return policyConfig.policies[i];
}
}
return null;
}
}
return [];
}
reg = /[(A-Z)]+/;
return [ { "policyRequirement" : "AT_LEAST_ONE_CAPITAL_LETTER" } ];
}
return [];
}
return [ { "policyRequirement" : "AT_LEAST_ONE_NUMBER" } ];
}
return [];
}
var tmpObject = requestObject;
return null;
}
}
return tmpObject;
}
return prop;
}
}
return null;
}
if (components != null) {
var component = components[i];
return component;
}
}
}
return null;
}
// Loop through the properties for this component
var propPolicyReqs = new Array();
var reqs;
// loop through the policies of each property
// loop through the requirements for each policy
// Add the requirement if it hasen't been added yet
}
}
}
// Add the requirements array to the property object
}
// Return all property configs for this component
return component;
}
var retObj = {};
var policyRequirements = new Array();
if (policy == null) {
}
}
}
}
}
}
function processRequest() {
if (method == "read") {
var compArray = new Array();
var comp = components[i];
}
returnObject = {};
} else {
}
} else if (method == "action") {
var failedPolicyRequirements = new Array();
var component;
returnObject = {};
throw "No component specified";
} else {
// Get the policy configuration for the specified component
}
if (component == null) {
// There is no configured policies for this component (nothing to verify)
returnObject.result = true;
} else {
// Perform the validation
if (action == "validateObject") {
// Validate
}
} else if (action == "validateProperty") {
// Validate
}
} else {
throw "Unsupported action: " + action;
}
// Set the result to true if no failedPolicyRequirements (failures), false otherwise
// Set the return failedPolicyRequirements
}
} else {
throw "Unsupported method: " + method;
}
}