From 56e752193bfb90d11cfe73c35a24e576b9b18c87 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Wed, 03 Jul 2013 11:03:06 +0000
Subject: [PATCH] First stab at having debuggable ACIs.
---
opends/src/server/org/opends/server/authorization/dseecompat/BindRule.java | 84 ++++++++++++++++++++++-------------------
1 files changed, 45 insertions(+), 39 deletions(-)
diff --git a/opends/src/server/org/opends/server/authorization/dseecompat/BindRule.java b/opends/src/server/org/opends/server/authorization/dseecompat/BindRule.java
index 18e3611..79cb912 100644
--- a/opends/src/server/org/opends/server/authorization/dseecompat/BindRule.java
+++ b/opends/src/server/org/opends/server/authorization/dseecompat/BindRule.java
@@ -23,16 +23,18 @@
*
*
* Copyright 2008 Sun Microsystems, Inc.
+ * Portions Copyright 2013 ForgeRock AS
*/
-
package org.opends.server.authorization.dseecompat;
-import org.opends.messages.Message;
import static org.opends.messages.AccessControlMessages.*;
import static org.opends.server.authorization.dseecompat.Aci.*;
-import java.util.regex.Pattern;
-import java.util.regex.Matcher;
+
import java.util.HashMap;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.opends.messages.Message;
/**
* This class represents a single bind rule of an ACI permission-bind rule
@@ -40,78 +42,58 @@
*/
public class BindRule {
- /*
- * This hash table holds the keyword bind rule mapping.
- */
- private HashMap<String, KeywordBindRule> keywordRuleMap =
+ /** This hash table holds the keyword bind rule mapping. */
+ private final HashMap<String, KeywordBindRule> keywordRuleMap =
new HashMap<String, KeywordBindRule>();
- /*
- * True is a boolean "not" was seen.
- */
+ /** True is a boolean "not" was seen. */
private boolean negate=false;
- /*
- * Complex bind rules have left and right values.
- */
+ /** Complex bind rules have left and right values. */
private BindRule left = null;
private BindRule right = null;
- /*
+ /**
* Enumeration of the boolean type of the complex bind rule ("and" or "or").
*/
private EnumBooleanTypes booleanType = null;
- /*
- * The keyword of a simple bind rule.
- */
+ /** The keyword of a simple bind rule. */
private EnumBindRuleKeyword keyword = null;
- /*
- * Regular expression group position of a bind rule keyword.
- */
+ /** Regular expression group position of a bind rule keyword. */
private static final int keywordPos = 1;
- /*
- * Regular expression group position of a bind rule operation.
- */
+ /** Regular expression group position of a bind rule operation. */
private static final int opPos = 2;
- /*
- * Regular expression group position of a bind rule expression.
- */
+ /** Regular expression group position of a bind rule expression. */
private static final int expressionPos = 3;
- /*
+ /**
* Regular expression group position of the remainder part of an operand.
*/
private static final int remainingOperandPos = 1;
- /*
- * Regular expression group position of the remainder of the bind rule.
- */
+ /** Regular expression group position of the remainder of the bind rule. */
private static final int remainingBindrulePos = 2;
- /*
- * Regular expression for valid bind rule operator group.
- */
+ /** Regular expression for valid bind rule operator group. */
private static final String opRegGroup = "([!=<>]+)";
- /*
+ /**
* Regular expression for the expression part of a partially parsed
* bind rule.
*/
private static final String expressionRegex =
"\"([^\"]+)\"" + ZERO_OR_MORE_WHITESPACE;
- /*
- * Regular expression for a single bind rule.
- */
+ /** Regular expression for a single bind rule. */
private static final String bindruleRegex =
WORD_GROUP_START_PATTERN + ZERO_OR_MORE_WHITESPACE +
opRegGroup + ZERO_OR_MORE_WHITESPACE + expressionRegex;
- /*
+ /**
* Regular expression of the remainder part of a partially parsed bind rule.
*/
private static final String remainingBindruleRegex =
@@ -588,4 +570,28 @@
ret=evalComplex(left.evaluate(evalCtx),right.evaluate(evalCtx));
return EnumEvalResult.negateIfNeeded(ret, negate);
}
+
+ /** {@inheritDoc} */
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ toString(sb);
+ return sb.toString();
+ }
+
+ /**
+ * Appends a string representation of this object to the provided buffer.
+ *
+ * @param buffer
+ * The buffer into which a string representation of this object
+ * should be appended.
+ */
+ public final void toString(StringBuilder buffer) {
+ if (this.keywordRuleMap != null) {
+ for (KeywordBindRule rule : this.keywordRuleMap.values()) {
+ rule.toString(buffer);
+ buffer.append(";");
+ }
+ }
+ }
}
--
Gitblit v1.10.0