| | |
| | | * 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 static org.opends.messages.AccessControlMessages.*; |
| | | import org.opends.server.util.TimeThread; |
| | | |
| | | import java.util.regex.Pattern; |
| | | |
| | | /** |
| | | * This class represents the timeofday keyword in a bind rule. |
| | | */ |
| | | public class TimeOfDay implements KeywordBindRule { |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.server.util.TimeThread; |
| | | |
| | | /** |
| | | * Regular expression matching a valid timeofday rule value (0-2359). |
| | | */ |
| | | private static final String timeofdayRegex = "[0-2]\\d[0-5]\\d"; |
| | | /** This class represents the timeofday keyword in a bind rule. */ |
| | | public class TimeOfDay implements KeywordBindRule { |
| | | /** Regular expression matching a valid timeofday rule value (0-2359). */ |
| | | private static final Pattern timeofdayRegex = Pattern.compile("[0-2]\\d[0-5]\\d"); |
| | | |
| | | /** Enumeration representing the bind rule operation type. */ |
| | | private EnumBindRuleType type; |
| | |
| | | public static TimeOfDay decode(String expr, EnumBindRuleType type) |
| | | throws AciException { |
| | | int valueAsInt = 0; |
| | | if (!Pattern.matches(timeofdayRegex, expr)) |
| | | if (!timeofdayRegex.matcher(expr).matches()) |
| | | { |
| | | LocalizableMessage message = WARN_ACI_SYNTAX_INVALID_TIMEOFDAY.get(expr); |
| | | throw new AciException(message); |
| | |
| | | * @return An enumeration result representing the result of the |
| | | * evaluation. |
| | | */ |
| | | @Override |
| | | public EnumEvalResult evaluate(AciEvalContext evalCtx) { |
| | | EnumEvalResult matched=EnumEvalResult.FALSE; |
| | | |
| | |
| | | return matched.getRet(type, false); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() |
| | | { |
| | |
| | | return sb.toString(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final void toString(StringBuilder buffer) |
| | | { |
| | | buffer.append(super.toString()); |
| | | } |
| | | |
| | | } |