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