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
010     * trunk/opends/resource/legal-notices/OpenDS.LICENSE
011     * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
012     * See the License for the specific language governing permissions
013     * and limitations under the License.
014     *
015     * When distributing Covered Code, include this CDDL HEADER in each
016     * file and include the License file at
017     * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
018     * add the following below this CDDL HEADER, with the fields enclosed
019     * by brackets "[]" replaced with your own identifying information:
020     *      Portions Copyright [yyyy] [name of copyright owner]
021     *
022     * CDDL HEADER END
023     *
024     *
025     *      Copyright 2008 Sun Microsystems, Inc.
026     */
027    
028    package org.opends.server.authorization.dseecompat;
029    
030    /**
031     * This class provides an enumeration of the allowed bind rule
032     * keyword types.
033     */
034    public 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    
082        /*
083         * The keyword name.
084         */
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    }