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 valid ACI target keywords. 032 */ 033 public enum EnumTargetKeyword { 034 035 /** 036 * This enumeration is returned when the target keyword is 037 * "target". 038 */ 039 KEYWORD_TARGET ("target"), 040 /** 041 * This enumeration is returned when the target keyword is 042 * "targetattr". 043 */ 044 KEYWORD_TARGETATTR ("targetattr"), 045 /** 046 * This enumeration is returned when the target keyword is 047 * "targetscope". 048 */ 049 KEYWORD_TARGETSCOPE ("targetscope"), 050 /** 051 * This enumeration is returned when the target keyword is 052 * "targetfilter". 053 */ 054 KEYWORD_TARGETFILTER ("targetfilter"), 055 /** 056 * This enumeration is returned when the target keyword is 057 * "targattrfilters". 058 */ 059 KEYWORD_TARGATTRFILTERS ("targattrfilters"), 060 /** 061 * This enumeration is returned when the target keyword is 062 * "targetcontrol". 063 */ 064 KEYWORD_TARGETCONTROL ("targetcontrol"), 065 /** 066 * This enumeration is returned when the target keyword is 067 * "extop". 068 */ 069 KEYWORD_EXTOP ("extop"); 070 071 /* 072 * The target keyword name. 073 */ 074 private final String keyword; 075 076 /** 077 * Create a target keyword enumeration of the specified name. 078 * @param keyword The keyword name. 079 */ 080 EnumTargetKeyword(String keyword){ 081 this.keyword = keyword; 082 } 083 084 /** 085 * Checks if the keyword name is equal to the enumeration name. 086 * @param keyword The keyword name to check. 087 * @return True if the keyword name is equal to the enumeration. 088 */ 089 public boolean isKeyword(String keyword){ 090 return keyword.equalsIgnoreCase(this.keyword); 091 } 092 093 /** 094 * Create an enumeration of the provided keyword name. 095 * @param keyword The keyword name to create. 096 * @return An enumeration of the specified keyword name or null 097 * if the keyword name is invalid. 098 */ 099 public static EnumTargetKeyword createKeyword(String keyword){ 100 if (keyword != null){ 101 for (EnumTargetKeyword t : EnumTargetKeyword.values()){ 102 if (t.isKeyword(keyword)){ 103 return t; 104 } 105 } 106 } 107 return null; 108 } 109 110 /** 111 * Return the enumeration keyword name. 112 * @return The keyword name. 113 */ 114 public String getKeyword() { 115 return keyword; 116 } 117 }