001/* 002 * The contents of this file are subject to the terms of the Common Development and 003 * Distribution License (the License). You may not use this file except in compliance with the 004 * License. 005 * 006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the 007 * specific language governing permission and limitations under the License. 008 * 009 * When distributing Covered Software, include this CDDL Header Notice in each file and include 010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL 011 * Header, with the fields enclosed by brackets [] replaced by your own identifying 012 * information: "Portions Copyright [year] [name of copyright owner]". 013 * 014 * Copyright 2006-2009 Sun Microsystems, Inc. 015 * Portions Copyright 2013-2016 ForgeRock AS. 016 */ 017package org.opends.server.types; 018 019import java.util.Set; 020 021import org.forgerock.i18n.LocalizableMessage; 022import org.forgerock.opendj.ldap.DN; 023import org.forgerock.opendj.ldap.ResultCode; 024import org.opends.server.api.AlertGenerator; 025import org.opends.server.api.ExtendedOperationHandler; 026import org.opends.server.api.SASLMechanismHandler; 027import org.opends.server.api.ServerShutdownListener; 028import org.opends.server.core.DirectoryServer; 029 030import com.forgerock.opendj.util.OperatingSystem; 031 032/** 033 * This interface defines a set of methods that may be used by 034 * third-party code to obtain information about the core Directory 035 * Server configuration and the instances of various kinds of 036 * components that have registered themselves with the server. 037 * <BR><BR> 038 * Note that this interface is not intended to be implemented by any 039 * third-party code. It is merely used to control which elements are 040 * intended for use by external classes. 041 */ 042@org.opends.server.types.PublicAPI( 043 stability=org.opends.server.types.StabilityLevel.VOLATILE, 044 mayInstantiate=false, 045 mayExtend=false, 046 mayInvoke=true) 047public final class DirectoryConfig 048{ 049 /** 050 * Retrieves a reference to the Directory Server crypto manager. 051 * 052 * @return A reference to the Directory Server crypto manager. 053 */ 054 public static CryptoManager getCryptoManager() 055 { 056 return DirectoryServer.getCryptoManager(); 057 } 058 059 /** 060 * Retrieves the operating system on which the Directory Server is 061 * running. 062 * 063 * @return The operating system on which the Directory Server is 064 * running. 065 */ 066 public static OperatingSystem getOperatingSystem() 067 { 068 return DirectoryServer.getOperatingSystem(); 069 } 070 071 /** 072 * Retrieves the path to the root directory for this instance of the 073 * Directory Server. 074 * 075 * @return The path to the root directory for this instance of the 076 * Directory Server. 077 */ 078 public static String getServerRoot() 079 { 080 return DirectoryServer.getServerRoot(); 081 } 082 083 /** 084 * Retrieves the time that the Directory Server was started, in 085 * milliseconds since the epoch. 086 * 087 * @return The time that the Directory Server was started, in 088 * milliseconds since the epoch. 089 */ 090 public static long getStartTime() 091 { 092 return DirectoryServer.getStartTime(); 093 } 094 095 /** 096 * Retrieves the time that the Directory Server was started, 097 * formatted in UTC. 098 * 099 * @return The time that the Directory Server was started, 100 * formatted in UTC. 101 */ 102 public static String getStartTimeUTC() 103 { 104 return DirectoryServer.getStartTimeUTC(); 105 } 106 107 /** 108 * Retrieves a reference to the Directory Server schema. 109 * 110 * @return A reference to the Directory Server schema. 111 */ 112 public static Schema getSchema() 113 { 114 return DirectoryServer.getSchema(); 115 } 116 117 /** 118 * Registers the provided alert generator with the Directory Server. 119 * 120 * @param alertGenerator The alert generator to register. 121 */ 122 public static void registerAlertGenerator( 123 AlertGenerator alertGenerator) 124 { 125 DirectoryServer.registerAlertGenerator(alertGenerator); 126 } 127 128 /** 129 * Deregisters the provided alert generator with the Directory 130 * Server. 131 * 132 * @param alertGenerator The alert generator to deregister. 133 */ 134 public static void deregisterAlertGenerator( 135 AlertGenerator alertGenerator) 136 { 137 DirectoryServer.deregisterAlertGenerator(alertGenerator); 138 } 139 140 /** 141 * Sends an alert notification with the provided information. 142 * 143 * @param generator The alert generator that created the alert. 144 * @param alertType The alert type name for this alert. 145 * @param alertMessage A message (possibly <CODE>null</CODE>) that 146 * can provide more information about this 147 * alert. 148 */ 149 public static void 150 sendAlertNotification(AlertGenerator generator, 151 String alertType, 152 LocalizableMessage alertMessage) 153 { 154 DirectoryServer.sendAlertNotification(generator, alertType, 155 alertMessage); 156 } 157 158 /** 159 * Retrieves the result code that should be used when the Directory 160 * Server encounters an internal server error. 161 * 162 * @return The result code that should be used when the Directory 163 * Server encounters an internal server error. 164 */ 165 public static ResultCode getServerErrorResultCode() 166 { 167 return DirectoryServer.getServerErrorResultCode(); 168 } 169 170 /** 171 * Retrieves the entry with the requested DN. It will first 172 * determine which backend should be used for this DN and will then 173 * use that backend to retrieve the entry. The caller must already 174 * hold the appropriate lock on the specified entry. 175 * 176 * @param entryDN The DN of the entry to retrieve. 177 * 178 * @return The requested entry, or <CODE>null</CODE> if it does not 179 * exist. 180 * 181 * @throws DirectoryException If a problem occurs while attempting 182 * to retrieve the entry. 183 */ 184 public static Entry getEntry(DN entryDN) 185 throws DirectoryException 186 { 187 return DirectoryServer.getEntry(entryDN); 188 } 189 190 /** 191 * Indicates whether the specified entry exists in the Directory 192 * Server. The caller is not required to hold any locks when 193 * invoking this method. 194 * 195 * @param entryDN The DN of the entry for which to make the 196 * determination. 197 * 198 * @return <CODE>true</CODE> if the specified entry exists in one 199 * of the backends, or <CODE>false</CODE> if it does not. 200 * 201 * @throws DirectoryException If a problem occurs while attempting 202 * to make the determination. 203 */ 204 public static boolean entryExists(DN entryDN) 205 throws DirectoryException 206 { 207 return DirectoryServer.entryExists(entryDN); 208 } 209 210 /** 211 * Retrieves the set of OIDs for the supported controls registered 212 * with the Directory Server. 213 * 214 * @return The set of OIDS for the supported controls registered 215 * with the Directory Server. 216 */ 217 public static Set<String> getSupportedControls() 218 { 219 return DirectoryServer.getSupportedControls(); 220 } 221 222 /** 223 * Indicates whether the specified OID is registered with the 224 * Directory Server as a supported control. 225 * 226 * @param controlOID The OID of the control for which to make the 227 * determination. 228 * 229 * @return <CODE>true</CODE> if the specified OID is registered 230 * with the server as a supported control, or 231 * <CODE>false</CODE> if not. 232 */ 233 public static boolean isSupportedControl(String controlOID) 234 { 235 return DirectoryServer.isSupportedControl(controlOID); 236 } 237 238 /** 239 * Registers the provided OID as a supported control for the 240 * Directory Server. This will have no effect if the specified 241 * control OID is already present in the list of supported controls. 242 * 243 * @param controlOID The OID of the control to register as a 244 * supported control. 245 */ 246 public static void registerSupportedControl(String controlOID) 247 { 248 DirectoryServer.registerSupportedControl(controlOID); 249 } 250 251 /** 252 * Deregisters the provided OID as a supported control for the 253 * Directory Server. This will have no effect if the specified 254 * control OID is not present in the list of supported controls. 255 * 256 * @param controlOID The OID of the control to deregister as a 257 * supported control. 258 */ 259 public static void 260 deregisterSupportedControl(String controlOID) 261 { 262 DirectoryServer.deregisterSupportedControl(controlOID); 263 } 264 265 /** 266 * Retrieves the set of OIDs for the supported features registered 267 * with the Directory Server. 268 * 269 * @return The set of OIDs for the supported features registered 270 * with the Directory Server. 271 */ 272 public static Set<String> getSupportedFeatures() 273 { 274 return DirectoryServer.getSupportedFeatures(); 275 } 276 277 /** 278 * Indicates whether the specified OID is registered with the 279 * Directory Server as a supported feature. 280 * 281 * @param featureOID The OID of the feature for which to make the 282 * determination. 283 * 284 * @return <CODE>true</CODE> if the specified OID is registered 285 * with the server as a supported feature, or 286 * <CODE>false</CODE> if not. 287 */ 288 public static boolean isSupportedFeature(String featureOID) 289 { 290 return DirectoryServer.isSupportedFeature(featureOID); 291 } 292 293 /** 294 * Registers the provided OID as a supported feature for the 295 * Directory Server. This will have no effect if the specified 296 * feature OID is already present in the list of supported features. 297 * 298 * @param featureOID The OID of the feature to register as a 299 * supported feature. 300 */ 301 public static void registerSupportedFeature(String featureOID) 302 { 303 DirectoryServer.registerSupportedFeature(featureOID); 304 } 305 306 /** 307 * Deregisters the provided OID as a supported feature for the 308 * Directory Server. This will have no effect if the specified 309 * feature OID is not present in the list of supported features. 310 * 311 * @param featureOID The OID of the feature to deregister as a 312 * supported feature. 313 */ 314 public static void 315 deregisterSupportedFeature(String featureOID) 316 { 317 DirectoryServer.deregisterSupportedFeature(featureOID); 318 } 319 320 /** 321 * Retrieves the handler for the extended operation for the provided 322 * extended operation OID. 323 * 324 * @param oid The OID of the extended operation to retrieve. 325 * 326 * @return The handler for the specified extended operation, or 327 * <CODE>null</CODE> if there is none. 328 */ 329 public static ExtendedOperationHandler<?> getExtendedOperationHandler(String oid) 330 { 331 return DirectoryServer.getExtendedOperationHandler(oid); 332 } 333 334 /** 335 * Registers the provided extended operation handler with the 336 * Directory Server. 337 * 338 * @param oid The OID for the extended operation to register. 339 * @param handler The extended operation handler to register with 340 * the Directory Server. 341 */ 342 public static void registerSupportedExtension(String oid, ExtendedOperationHandler<?> handler) 343 { 344 DirectoryServer.registerSupportedExtension(oid, handler); 345 } 346 347 /** 348 * Deregisters the provided extended operation handler with the 349 * Directory Server. 350 * 351 * @param oid The OID for the extended operation to deregister. 352 */ 353 public static void deregisterSupportedExtension(String oid) 354 { 355 DirectoryServer.deregisterSupportedExtension(oid); 356 } 357 358 /** 359 * Retrieves the handler for the specified SASL mechanism. 360 * 361 * @param name The name of the SASL mechanism to retrieve. 362 * 363 * @return The handler for the specified SASL mechanism, or 364 * <CODE>null</CODE> if there is none. 365 */ 366 public static SASLMechanismHandler<?> getSASLMechanismHandler(String name) 367 { 368 return DirectoryServer.getSASLMechanismHandler(name); 369 } 370 371 /** 372 * Registers the provided SASL mechanism handler with the Directory 373 * Server. 374 * 375 * @param name The name of the SASL mechanism to be registered. 376 * @param handler The SASL mechanism handler to register with the 377 * Directory Server. 378 */ 379 public static void registerSASLMechanismHandler(String name, SASLMechanismHandler<?> handler) 380 { 381 DirectoryServer.registerSASLMechanismHandler(name, handler); 382 } 383 384 /** 385 * Deregisters the provided SASL mechanism handler with the 386 * Directory Server. 387 * 388 * @param name The name of the SASL mechanism to be deregistered. 389 */ 390 public static void deregisterSASLMechanismHandler(String name) 391 { 392 DirectoryServer.deregisterSASLMechanismHandler(name); 393 } 394 395 /** 396 * Registers the provided shutdown listener with the Directory 397 * Server so that it will be notified when the server shuts down. 398 * 399 * @param listener The shutdown listener to register with the 400 * Directory Server. 401 */ 402 public static void 403 registerShutdownListener(ServerShutdownListener listener) 404 { 405 DirectoryServer.registerShutdownListener(listener); 406 } 407 408 /** 409 * Deregisters the provided shutdown listener with the Directory 410 * Server. 411 * 412 * @param listener The shutdown listener to deregister with the 413 * Directory Server. 414 */ 415 public static void 416 deregisterShutdownListener(ServerShutdownListener listener) 417 { 418 DirectoryServer.deregisterShutdownListener(listener); 419 } 420 421 /** 422 * Retrieves the full version string for the Directory Server. 423 * 424 * @return The full version string for the Directory Server. 425 */ 426 public static String getVersionString() 427 { 428 return DirectoryServer.getVersionString(); 429 } 430}