001/* 002 * Copyright 2013-2020 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright 2013-2020 Ping Identity Corporation 007 * 008 * Licensed under the Apache License, Version 2.0 (the "License"); 009 * you may not use this file except in compliance with the License. 010 * You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, software 015 * distributed under the License is distributed on an "AS IS" BASIS, 016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 017 * See the License for the specific language governing permissions and 018 * limitations under the License. 019 */ 020/* 021 * Copyright (C) 2015-2020 Ping Identity Corporation 022 * 023 * This program is free software; you can redistribute it and/or modify 024 * it under the terms of the GNU General Public License (GPLv2 only) 025 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only) 026 * as published by the Free Software Foundation. 027 * 028 * This program is distributed in the hope that it will be useful, 029 * but WITHOUT ANY WARRANTY; without even the implied warranty of 030 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 031 * GNU General Public License for more details. 032 * 033 * You should have received a copy of the GNU General Public License 034 * along with this program; if not, see <http://www.gnu.org/licenses>. 035 */ 036package com.unboundid.ldap.sdk.unboundidds.extensions; 037 038 039 040import com.unboundid.util.StaticUtils; 041import com.unboundid.util.ThreadSafety; 042import com.unboundid.util.ThreadSafetyLevel; 043 044 045 046/** 047 * This enum defines the types of configurations that may be obtained using the 048 * get configuration extended operation. 049 * <BR> 050 * <BLOCKQUOTE> 051 * <B>NOTE:</B> This class, and other classes within the 052 * {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only 053 * supported for use against Ping Identity, UnboundID, and 054 * Nokia/Alcatel-Lucent 8661 server products. These classes provide support 055 * for proprietary functionality or for external specifications that are not 056 * considered stable or mature enough to be guaranteed to work in an 057 * interoperable way with other types of LDAP servers. 058 * </BLOCKQUOTE> 059 */ 060@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 061public enum GetConfigurationType 062{ 063 /** 064 * The type used to specify the current active configuration. 065 */ 066 ACTIVE(GetConfigurationType.ACTIVE_BER_TYPE, 0), 067 068 069 070 /** 071 * The type used to specify the baseline configuration for the current server 072 * version. 073 */ 074 BASELINE(GetConfigurationType.BASELINE_BER_TYPE, 1), 075 076 077 078 /** 079 * The type used to specify an archived configuration that was previously 080 * in effect. 081 */ 082 ARCHIVED(GetConfigurationType.ARCHIVED_BER_TYPE, 2); 083 084 085 086 /** 087 * The BER type used to designate the active type. 088 */ 089 static final byte ACTIVE_BER_TYPE = (byte) 0x80; 090 091 092 093 /** 094 * The BER type used to designate the baseline type. 095 */ 096 static final byte BASELINE_BER_TYPE = (byte) 0x81; 097 098 099 100 /** 101 * The BER type used to designate the archived type. 102 */ 103 static final byte ARCHIVED_BER_TYPE = (byte) 0x82; 104 105 106 107 // The BER type that should be used when this configuration type needs to be 108 // encoded in a get configuration request. 109 private final byte berType; 110 111 // The integer value that should be used when this configuration type needs to 112 // be encoded as an enumerated element in a get configuration result. 113 private final int intValue; 114 115 116 117 /** 118 * Creates a new get configuration type value with the specified information. 119 * 120 * @param berType The BER type that should be used when this configuration 121 * type needs to be encoded in a get configuration request. 122 * @param intValue The integer value that should be used when this 123 * configuration type needs to be encoded as an enumerated 124 * element in a get configuration result. 125 */ 126 GetConfigurationType(final byte berType, final int intValue) 127 { 128 this.berType = berType; 129 this.intValue = intValue; 130 } 131 132 133 134 /** 135 * Retrieves the BER type that should be used when this configuration type 136 * needs to be encoded in a get configuration request. 137 * 138 * @return The BER type that should be used when this configuration type 139 * needs to be encoded in a get configuration request. 140 */ 141 public byte getBERType() 142 { 143 return berType; 144 } 145 146 147 148 /** 149 * Retrieves the integer value that should be used when this configuration 150 * type needs to be encoded as an enumerated element in a get configuration 151 * result. 152 * 153 * @return The integer value that should be used when this configuration 154 * type needs to be encoded as an enumerated element in a get 155 * configuration result. 156 */ 157 public int getIntValue() 158 { 159 return intValue; 160 } 161 162 163 164 /** 165 * Retrieves the get configuration type value that has the specified BER type. 166 * 167 * @param berType The BER type for the get configuration type value to 168 * retrieve. 169 * 170 * @return The get configuration type value for the specified BER type, or 171 * {@code null} if there is no enum value with the specified BER 172 * type. 173 */ 174 public static GetConfigurationType forBERType(final byte berType) 175 { 176 for (final GetConfigurationType t : values()) 177 { 178 if (t.berType == berType) 179 { 180 return t; 181 } 182 } 183 184 return null; 185 } 186 187 188 189 /** 190 * Retrieves the get configuration type value that has the specified integer 191 * value. 192 * 193 * @param intValue The integer value for the get configuration type value 194 * to retrieve. 195 * 196 * @return The get configuration type value for the specified integer value, 197 * or {@code null} if there is no enum value with the specified 198 * integer value. 199 */ 200 public static GetConfigurationType forIntValue(final int intValue) 201 { 202 for (final GetConfigurationType t : values()) 203 { 204 if (t.intValue == intValue) 205 { 206 return t; 207 } 208 } 209 210 return null; 211 } 212 213 214 215 /** 216 * Retrieves the get configuration type value with the specified name. 217 * 218 * @param name The name of the get configuration type value to retrieve. It 219 * must not be {@code null}. 220 * 221 * @return The requested get configuration type value, or {@code null} if no 222 * such value is defined. 223 */ 224 public static GetConfigurationType forName(final String name) 225 { 226 switch (StaticUtils.toLowerCase(name)) 227 { 228 case "active": 229 return ACTIVE; 230 case "baseline": 231 return BASELINE; 232 case "archived": 233 return ARCHIVED; 234 default: 235 return null; 236 } 237 } 238}