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 valid ACI target keywords. 032 */ 033public 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 /** The target keyword name. */ 072 private final String keyword; 073 074 /** 075 * Create a target keyword enumeration of the specified name. 076 * @param keyword The keyword name. 077 */ 078 EnumTargetKeyword(String keyword){ 079 this.keyword = keyword; 080 } 081 082 /** 083 * Checks if the keyword name is equal to the enumeration name. 084 * @param keyword The keyword name to check. 085 * @return True if the keyword name is equal to the enumeration. 086 */ 087 public boolean isKeyword(String keyword){ 088 return keyword.equalsIgnoreCase(this.keyword); 089 } 090 091 /** 092 * Create an enumeration of the provided keyword name. 093 * @param keyword The keyword name to create. 094 * @return An enumeration of the specified keyword name or null 095 * if the keyword name is invalid. 096 */ 097 public static EnumTargetKeyword createKeyword(String keyword){ 098 if (keyword != null){ 099 for (EnumTargetKeyword t : EnumTargetKeyword.values()){ 100 if (t.isKeyword(keyword)){ 101 return t; 102 } 103 } 104 } 105 return null; 106 } 107 108 /** 109 * Return the enumeration keyword name. 110 * @return The keyword name. 111 */ 112 public String getKeyword() { 113 return keyword; 114 } 115}