Fix being able to negate permissions/parents/meta in specific contexts
This commit is contained in:
parent
fae49096f3
commit
030fb1262e
@ -489,8 +489,9 @@ public abstract class PermissionHolder {
|
|||||||
List<LocalizedNode> finalAccumulator = accumulator;
|
List<LocalizedNode> finalAccumulator = accumulator;
|
||||||
|
|
||||||
// this allows you to negate parent permissions lower down the inheritance tree.
|
// 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.
|
// there's no way to distinct the stream below based on a custom comparator.
|
||||||
NodeTools.removeIgnoreValue(nodes.iterator());
|
NodeTools.removeSamePermission(nodes.iterator());
|
||||||
|
|
||||||
nodes.stream()
|
nodes.stream()
|
||||||
.filter(Node::getValue)
|
.filter(Node::getValue)
|
||||||
@ -612,6 +613,12 @@ public abstract class PermissionHolder {
|
|||||||
|
|
||||||
// get and add the objects own nodes
|
// get and add the objects own nodes
|
||||||
List<Node> nodes = flattenAndMergeNodesToList(context.getContextSet());
|
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()
|
nodes.stream()
|
||||||
.filter(Node::getValue)
|
.filter(Node::getValue)
|
||||||
.filter(n -> n.isMeta() || n.isPrefix() || n.isSuffix())
|
.filter(n -> n.isMeta() || n.isPrefix() || n.isSuffix())
|
||||||
@ -623,10 +630,6 @@ public abstract class PermissionHolder {
|
|||||||
accumulator.accumulateWeight(w.getAsInt());
|
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()
|
nodes.stream()
|
||||||
.filter(Node::getValue)
|
.filter(Node::getValue)
|
||||||
.filter(Node::isGroupNode)
|
.filter(Node::isGroupNode)
|
||||||
|
@ -39,11 +39,11 @@ public class LogicParser {
|
|||||||
public static boolean parse(String s, PermissionHolder holder, Tristate tristate) throws IllegalArgumentException {
|
public static boolean parse(String s, PermissionHolder holder, Tristate tristate) throws IllegalArgumentException {
|
||||||
try {
|
try {
|
||||||
ScriptEngine engine = Scripting.getScriptEngine();
|
ScriptEngine engine = Scripting.getScriptEngine();
|
||||||
|
|
||||||
String expression = generateExpression(s, s1 -> holder.hasPermission(NodeFactory.fromSerializedNode(s1, true)) == tristate);
|
|
||||||
if (engine == null) {
|
if (engine == null) {
|
||||||
throw new NullPointerException("script engine");
|
throw new NullPointerException("script engine");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String expression = generateExpression(s, s1 -> holder.hasPermission(NodeFactory.fromSerializedNode(s1, true)) == tristate);
|
||||||
String result = engine.eval(expression).toString();
|
String result = engine.eval(expression).toString();
|
||||||
|
|
||||||
if (!result.equals("true") && !result.equals("false")) {
|
if (!result.equals("true") && !result.equals("false")) {
|
||||||
|
Loading…
Reference in New Issue
Block a user