mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

dugan
07.56.2007 14c5f3996a46c1281cb133de439f25492c97530a
opends/src/server/org/opends/server/authorization/dseecompat/DNS.java
@@ -28,6 +28,7 @@
package org.opends.server.authorization.dseecompat;
import static org.opends.server.authorization.dseecompat.AciMessages.*;
import static org.opends.server.authorization.dseecompat.Aci.*;
import static org.opends.server.messages.MessageHandler.getMessage;
import java.util.LinkedList;
import java.util.regex.Matcher;
@@ -38,9 +39,28 @@
 */
public class DNS implements KeywordBindRule {
    /*
     * List of patterns to match against.
     */
    LinkedList<String> patterns=null;
    /*
     * The enumeration representing the bind rule type of the DNS rule.
     */
    private EnumBindRuleType type=null;
    /*
     *  Regular expression group used to match a dns rule.
     */
    private static final String valueRegex = "([a-zA-Z0-9\\.\\-\\*]+)";
    /*
     * Regular expression group used to match one or more DNS values.
     */
    private static final String valuesRegExGroup =
            valueRegex + ZERO_OR_MORE_WHITESPACE +
            "(," +  ZERO_OR_MORE_WHITESPACE  +  valueRegex  +  ")*";
    /**
     * Create a class representing a dns bind rule keyword.
     * @param patterns List of dns patterns to match against.
@@ -62,9 +82,7 @@
    public static DNS decode(String expr,  EnumBindRuleType type)
    throws AciException
    {
        String valueRegex = "([a-zA-Z0-9\\.\\-\\*]+)";
        String valuesRegex = valueRegex + "\\s*(,\\s*" + valueRegex + ")*";
        if (!Pattern.matches(valuesRegex, expr)) {
        if (!Pattern.matches(valuesRegExGroup, expr)) {
            int msgID = MSGID_ACI_SYNTAX_INVALID_DNS_EXPRESSION;
            String message = getMessage(msgID, expr);
            throw new AciException(msgID, message);