Fix being able to negate permissions/parents/meta in specific contexts

This commit is contained in:
Luck 2017-05-08 22:27:46 +01:00
parent fae49096f3
commit 030fb1262e
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
2 changed files with 10 additions and 7 deletions

View File

@ -489,8 +489,9 @@ public abstract class PermissionHolder {
List<LocalizedNode> finalAccumulator = accumulator;
// this allows you to negate parent permissions lower down the inheritance tree.
// we can negate parent groups in a specific context at this level and prevent them from being applied.
// there's no way to distinct the stream below based on a custom comparator.
NodeTools.removeIgnoreValue(nodes.iterator());
NodeTools.removeSamePermission(nodes.iterator());
nodes.stream()
.filter(Node::getValue)
@ -612,6 +613,12 @@ public abstract class PermissionHolder {
// get and add the objects own nodes
List<Node> nodes = flattenAndMergeNodesToList(context.getContextSet());
// this allows you to negate parent permissions lower down the inheritance tree.
// it also allows you to negate meta in specific contexts and have it override.
// there's no way to distinct the stream below based on a custom comparator.
NodeTools.removeSamePermission(nodes.iterator());
nodes.stream()
.filter(Node::getValue)
.filter(n -> n.isMeta() || n.isPrefix() || n.isSuffix())
@ -623,10 +630,6 @@ public abstract class PermissionHolder {
accumulator.accumulateWeight(w.getAsInt());
}
// this allows you to negate parent permissions lower down the inheritance tree.
// there's no way to distinct the stream below based on a custom comparator.
NodeTools.removeIgnoreValue(nodes.iterator());
nodes.stream()
.filter(Node::getValue)
.filter(Node::isGroupNode)

View File

@ -39,11 +39,11 @@ public class LogicParser {
public static boolean parse(String s, PermissionHolder holder, Tristate tristate) throws IllegalArgumentException {
try {
ScriptEngine engine = Scripting.getScriptEngine();
String expression = generateExpression(s, s1 -> holder.hasPermission(NodeFactory.fromSerializedNode(s1, true)) == tristate);
if (engine == null) {
throw new NullPointerException("script engine");
}
String expression = generateExpression(s, s1 -> holder.hasPermission(NodeFactory.fromSerializedNode(s1, true)) == tristate);
String result = engine.eval(expression).toString();
if (!result.equals("true") && !result.equals("false")) {