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 */ 027package org.opends.server.authorization.dseecompat; 028 029/** 030 * This class provides an enumeration of the allowed bind rule boolean types. 031 */ 032public enum EnumBooleanTypes { 033 034 /** 035 * The enumeration type when the bind rule has specified boolean type of 036 * "AND". 037 */ 038 AND_BOOLEAN_TYPE ("and"), 039 /** 040 * The enumeration type when the bind rule has specified boolean type of 041 * "OR". 042 */ 043 OR_BOOLEAN_TYPE ("or"), 044 /** 045 * The enumeration type when the bind rule has specified boolean type of 046 * "NOT". 047 */ 048 NOT_BOOLEAN_TYPE ("not"); 049 050 /** The bind rule boolean type name. */ 051 private final String booleanType; 052 053 /** 054 * Creates a new enumeration type for the specified bind rule boolean type. 055 * @param booleanType The boolean type name. 056 */ 057 EnumBooleanTypes(String booleanType){ 058 this.booleanType = booleanType; 059 } 060 061 /** 062 * Checks to see if the boolean type string is equal to the enumeration type 063 * name. 064 * @param booleanType The type name to check equality for. 065 * @return True if the keyword is equal to the specified name. 066 */ 067 public boolean isBindRuleBooleanOperand(String booleanType){ 068 return booleanType.equalsIgnoreCase(this.booleanType); 069 } 070 071 /** 072 * Create a new enumeration type for the specified boolean type name. 073 * @param booleanType The name of the enumeration to create. 074 * @return A new enumeration type for the name or null if the name is 075 * not valid. 076 */ 077 public static 078 EnumBooleanTypes createBindruleOperand(String booleanType) { 079 if (booleanType != null){ 080 for (EnumBooleanTypes t : EnumBooleanTypes.values()) { 081 if (t.isBindRuleBooleanOperand(booleanType)) { 082 return t; 083 } 084 } 085 } 086 return null; 087 } 088}