| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.authorization.dseecompat; |
| | | |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | |
| | | /** |
| | | * This class implements the dns bind rule keyword. |
| | | */ |
| | | /** This class implements the dns bind rule keyword. */ |
| | | public class DNS implements KeywordBindRule { |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** List of patterns to match against. */ |
| | | private List<String> patterns; |
| | | |
| | | private final List<String> patterns; |
| | | /** The enumeration representing the bind rule type of the DNS rule. */ |
| | | private EnumBindRuleType type; |
| | | private final EnumBindRuleType type; |
| | | |
| | | /** 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 + |
| | |
| | | String hn=valueMatcher.group(valuePos); |
| | | String[] hnArray=hn.split("\\.", -1); |
| | | for(int i=1, n=hnArray.length; i < n; i++) { |
| | | if(hnArray[i].equals("*")) { |
| | | if ("*".equals(hnArray[i])) { |
| | | LocalizableMessage message = |
| | | WARN_ACI_SYNTAX_INVALID_DNS_WILDCARD.get(expr); |
| | | throw new AciException(message); |
| | |
| | | String canonicalName = addr.getCanonicalHostName(); |
| | | if (! hn.equalsIgnoreCase(canonicalName)) |
| | | { |
| | | if (hn.equalsIgnoreCase("localhost") |
| | | if ("localhost".equalsIgnoreCase(hn) |
| | | && !dns.contains(canonicalName)) |
| | | { |
| | | dns.add(canonicalName); |
| | |
| | | * @return True if the remote hostname matches the pattern. |
| | | */ |
| | | boolean evalHostName(String[] remoteHostName, String[] pat) { |
| | | boolean wildCard=pat[0].equals("*"); |
| | | boolean wildCard = "*".equals(pat[0]); |
| | | //Check if there is a single wild-card. |
| | | if(pat.length == 1 && wildCard) { |
| | | return true; |
| | |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder sb = new StringBuilder(); |
| | |
| | | return sb.toString(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final void toString(StringBuilder buffer) { |
| | | buffer.append(super.toString()); |
| | | } |
| | | |
| | | } |