001/*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License").  You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
010 * or http://forgerock.org/license/CDDLv1.0.html.
011 * See the License for the specific language governing permissions
012 * and limitations under the License.
013 *
014 * When distributing Covered Code, include this CDDL HEADER in each
015 * file and include the License file at legal-notices/CDDLv1_0.txt.
016 * If applicable, add the following below this CDDL HEADER, with the
017 * fields enclosed by brackets "[]" replaced with your own identifying
018 * information:
019 *      Portions Copyright [yyyy] [name of copyright owner]
020 *
021 * CDDL HEADER END
022 *
023 *
024 *      Copyright 2008 Sun Microsystems, Inc.
025 *      Portions Copyright 2015 ForgeRock AS.
026 */
027
028package org.opends.server.authorization.dseecompat;
029
030/**
031 * This class provides an enumeration of the allowed bind rule
032 * keyword types.
033 */
034public enum EnumBindRuleKeyword {
035
036    /**
037     * The enumeration type when the bind rule has specified keyword of
038     * userdn.
039     */
040    USERDN     ("userdn"),
041    /**
042     * The enumeration type when the bind rule has specified keyword of
043     * groupdn.
044     */
045    GROUPDN    ("groupdn"),
046    /**
047     * The enumeration type when the bind rule has specified keyword of
048     * roledn.
049     */
050    ROLEDN     ("roledn"),
051    /**
052     * The enumeration type when the bind rule has specified keyword of
053     * ip.
054     */
055    IP         ("ip"),
056    /**
057     * The enumeration type when the bind rule has specified keyword of
058     * dns.
059     */
060    DNS        ("dns"),
061    /**
062     * The enumeration type when the bind rule has specified keyword of
063     * dayofweek.
064     */
065    DAYOFWEEK  ("dayofweek"),
066    /**
067     * The enumeration type when the bind rule has specified keyword of
068     * timeofday.
069     */
070    TIMEOFDAY  ("timeofday"),
071    /**
072     * The enumeration type when the bind rule has specified keyword of
073     * userattr.
074     */
075    USERATTR ("userattr"),
076    /**
077     * The enumeration type when the bind rule has specified keyword of
078     * authmethod.
079     */
080    AUTHMETHOD ("authmethod"),
081    /** The enumeration type when the bind rule has specified keyword of ssf. */
082    SSF("ssf");
083
084    /** The keyword name. */
085    private final String keyword;
086
087    /**
088     * Creates a new enumeration type for the specified keyword.
089     * @param keyword The keyword name.
090     */
091    EnumBindRuleKeyword(String keyword){
092        this.keyword = keyword;
093    }
094
095    /**
096     * Checks to see if the keyword string is equal to the enumeration.
097     * @param keywordStr   The keyword name to check equality for.
098     * @return  True if the keyword is equal to the specified name.
099     */
100    public boolean isBindRuleKeyword(String keywordStr){
101        return keywordStr.equalsIgnoreCase(this.keyword);
102    }
103
104    /**
105     * Create a new enumeration type for the specified keyword name.
106     * @param keywordStr The name of the enumeration to create.
107     * @return A new enumeration type for the name or null if the name is
108     * not valid.
109     */
110    public static EnumBindRuleKeyword createBindRuleKeyword(String keywordStr){
111        if (keywordStr != null){
112            for (EnumBindRuleKeyword t : EnumBindRuleKeyword.values()){
113                if (t.isBindRuleKeyword(keywordStr)){
114                    return t;
115                }
116            }
117        }
118        return null;
119    }
120}