* Some additional work on ACS

This commit is contained in:
Bryan Ashby 2015-11-12 20:47:34 -07:00
parent da460dfc7b
commit a2f8101821
3 changed files with 188 additions and 169 deletions

View File

@ -59,11 +59,11 @@ module.exports = (function() {
peg$c20 = "]",
peg$c21 = { type: "literal", value: "]", description: "\"]\"" },
peg$c22 = function(n, a) { return checkAccess(n, a); },
peg$c23 = /^[A-Z=]/,
peg$c24 = { type: "class", value: "[A-Z\\=]", description: "[A-Z\\=]" },
peg$c25 = /^[A-Z]/,
peg$c26 = { type: "class", value: "[A-Z]", description: "[A-Z]" },
peg$c27 = function(c) { return c.join(''); },
peg$c23 = /^[A-Z]/,
peg$c24 = { type: "class", value: "[A-Z]", description: "[A-Z]" },
peg$c25 = function(c) { return c.join(''); },
peg$c26 = /^[A-Z=]/,
peg$c27 = { type: "class", value: "[A-Z\\=]", description: "[A-Z\\=]" },
peg$c28 = /^[A-Za-z0-9\-_+]/,
peg$c29 = { type: "class", value: "[A-Za-z0-9\\-_\\+]", description: "[A-Za-z0-9\\-_\\+]" },
peg$c30 = function(a) { return a.join('') },
@ -567,15 +567,12 @@ module.exports = (function() {
if (peg$silentFails === 0) { peg$fail(peg$c24); }
}
if (s2 !== peg$FAILED) {
if (peg$c25.test(input.charAt(peg$currPos))) {
if (peg$c23.test(input.charAt(peg$currPos))) {
s3 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c26); }
}
if (s3 === peg$FAILED) {
s3 = null;
if (peg$silentFails === 0) { peg$fail(peg$c24); }
}
if (s3 !== peg$FAILED) {
s2 = [s2, s3];
@ -590,9 +587,18 @@ module.exports = (function() {
}
if (s1 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c27(s1);
s1 = peg$c25(s1);
}
s0 = s1;
if (s0 === peg$FAILED) {
if (peg$c26.test(input.charAt(peg$currPos))) {
s0 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c27); }
}
}
return s0;
}
@ -799,6 +805,7 @@ module.exports = (function() {
var _ = require('lodash');
function checkAccess(name, value) {
try {
return {
'=' : function isLocalConnection() {
return client.isLocal();
@ -880,7 +887,11 @@ module.exports = (function() {
// :TODO: return true if value is >= minutes past midnight sys time
return false;
}
}[name](value) || false;
}[name](value);
} catch (e) {
client.log.warn( { name : name, value : value }, 'Invalid ACS string!');
return false;
}
}

View File

@ -14,8 +14,10 @@ function getConditionalValue(client, condArray, memberName) {
assert(_.isArray(condArray));
assert(_.isString(memberName));
console.log(condArray)
condArray.forEach(function cond(c) {
if(acsParser.parse( { client : client }, c.acs)) {
if(acsParser.parse(c.acs, { client : client })) {
return c[memberName];
}
});

View File

@ -6,6 +6,7 @@
var _ = require('lodash');
function checkAccess(name, value) {
try {
return {
'=' : function isLocalConnection() {
return client.isLocal();
@ -87,7 +88,11 @@
// :TODO: return true if value is >= minutes past midnight sys time
return false;
}
}[name](value) || false;
}[name](value);
} catch (e) {
client.log.warn( { name : name, value : value }, 'Invalid ACS string!');
return false;
}
}
}
@ -147,7 +152,8 @@ acsCheck
= n:name a:arg { return checkAccess(n, a); }
name
= c:([A-Z\=][A-Z]?) { return c.join(''); }
= c:([A-Z][A-Z]) { return c.join(''); }
/ c:[A-Z\=]
argVar
= a:[A-Za-z0-9\-_\+]+ { return a.join('') }