| | |
| | | import org.opends.server.workflowelement.WorkflowElementConfigManager; |
| | | import org.opends.server.workflowelement.localbackend.*; |
| | | |
| | | |
| | | /** |
| | | * This class defines the core of the Directory Server. It manages the startup |
| | | * and shutdown processes and coordinates activities between all other |
| | |
| | | |
| | | /** |
| | | * Indicates whether the server currently holds an exclusive lock on the |
| | | * server lock fiie. |
| | | * server lock file. |
| | | */ |
| | | private static boolean serverLocked = false; |
| | | |
| | |
| | | |
| | | // Determine whether or not we should start the connection handlers. |
| | | boolean startConnectionHandlers = |
| | | (! environmentConfig.disableConnectionHandlers()); |
| | | !environmentConfig.disableConnectionHandlers(); |
| | | |
| | | |
| | | // Initialize all the schema elements. |
| | |
| | | */ |
| | | public static boolean mailServerConfigured() |
| | | { |
| | | return ((directoryServer.mailServerPropertySets != null) && |
| | | (! directoryServer.mailServerPropertySets.isEmpty())); |
| | | return directoryServer.mailServerPropertySets != null |
| | | && !directoryServer.mailServerPropertySets.isEmpty(); |
| | | } |
| | | |
| | | |
| | |
| | | Map<String, List<ConfigChangeListener>> changeListeners) |
| | | { |
| | | List<ConfigAddListener> cfgAddListeners = configEntry.getAddListeners(); |
| | | if ((cfgAddListeners != null) && (cfgAddListeners.size() > 0)) |
| | | if (cfgAddListeners != null && cfgAddListeners.size() > 0) |
| | | { |
| | | addListeners.put(configEntry.getDN().toString(), cfgAddListeners); |
| | | } |
| | | |
| | | List<ConfigDeleteListener> cfgDeleteListeners = |
| | | configEntry.getDeleteListeners(); |
| | | if ((cfgDeleteListeners != null) && (cfgDeleteListeners.size() > 0)) |
| | | if (cfgDeleteListeners != null && cfgDeleteListeners.size() > 0) |
| | | { |
| | | deleteListeners.put(configEntry.getDN().toString(), cfgDeleteListeners); |
| | | } |
| | | |
| | | List<ConfigChangeListener> cfgChangeListeners = |
| | | configEntry.getChangeListeners(); |
| | | if ((cfgChangeListeners != null) && (cfgChangeListeners.size() > 0)) |
| | | if (cfgChangeListeners != null && cfgChangeListeners.size() > 0) |
| | | { |
| | | changeListeners.put(configEntry.getDN().toString(), cfgChangeListeners); |
| | | } |
| | |
| | | // we might want to configure several workflows handling the same |
| | | // baseDN through different network groups. So a mix of both |
| | | // backendID and baseDN should be ok. |
| | | String workflowID = backend.getBackendID() + "#" + baseDN.toString(); |
| | | String workflowID = backend.getBackendID() + "#" + baseDN; |
| | | |
| | | // Create the workflow for the base DN and register the workflow with |
| | | // the server. |
| | |
| | | WorkflowConfigurationMode oldMode, |
| | | WorkflowConfigurationMode newMode) |
| | | { |
| | | if ((oldMode == WorkflowConfigurationMode.AUTO) |
| | | && (newMode == WorkflowConfigurationMode.MANUAL)) |
| | | if (oldMode == WorkflowConfigurationMode.AUTO |
| | | && newMode == WorkflowConfigurationMode.MANUAL) |
| | | { |
| | | // move to manual mode |
| | | try |
| | |
| | | } |
| | | } |
| | | } |
| | | else if ((oldMode == WorkflowConfigurationMode.MANUAL) |
| | | && (newMode == WorkflowConfigurationMode.AUTO)) |
| | | else if (oldMode == WorkflowConfigurationMode.MANUAL |
| | | && newMode == WorkflowConfigurationMode.AUTO) |
| | | { |
| | | // move to auto mode |
| | | try |
| | |
| | | boolean returnDefault) |
| | | { |
| | | ObjectClass oc = directoryServer.schema.getObjectClass(lowerName); |
| | | if (returnDefault && (oc == null)) |
| | | if (returnDefault && oc == null) |
| | | { |
| | | oc = getDefaultObjectClass(lowerName); |
| | | } |
| | |
| | | boolean returnDefault) |
| | | { |
| | | AttributeType type = directoryServer.schema.getAttributeType(lowerName); |
| | | if (returnDefault && (type == null)) |
| | | if (returnDefault && type == null) |
| | | { |
| | | type = getDefaultAttributeType(lowerName); |
| | | } |
| | |
| | | boolean allowDefault) |
| | | { |
| | | AttributeSyntax syntax = directoryServer.schema.getSyntax(oid); |
| | | if ((syntax == null) && allowDefault) |
| | | if (syntax == null && allowDefault) |
| | | { |
| | | return getDefaultAttributeSyntax(); |
| | | } |
| | |
| | | String alertType, |
| | | Message alertMessage) |
| | | { |
| | | if ((directoryServer.alertHandlers == null) || |
| | | directoryServer.alertHandlers.isEmpty()) |
| | | if (directoryServer.alertHandlers == null |
| | | || directoryServer.alertHandlers.isEmpty()) |
| | | { |
| | | // If the Directory Server is still in the process of starting up, then |
| | | // create a JMX alert handler to use for this notification. |
| | |
| | | AlertHandlerCfg config = alertHandler.getAlertHandlerConfiguration(); |
| | | Set<String> enabledAlerts = config.getEnabledAlertType(); |
| | | Set<String> disabledAlerts = config.getDisabledAlertType(); |
| | | if ((enabledAlerts == null) || enabledAlerts.isEmpty()) |
| | | if (enabledAlerts == null || enabledAlerts.isEmpty()) |
| | | { |
| | | if ((disabledAlerts != null) && disabledAlerts.contains(alertType)) |
| | | if (disabledAlerts != null && disabledAlerts.contains(alertType)) |
| | | { |
| | | continue; |
| | | } |
| | |
| | | { |
| | | if (enabledAlerts.contains(alertType)) |
| | | { |
| | | if ((disabledAlerts != null) && disabledAlerts.contains(alertType)) |
| | | if (disabledAlerts != null && disabledAlerts.contains(alertType)) |
| | | { |
| | | continue; |
| | | } |
| | |
| | | .get(directoryServer.defaultPasswordPolicyDN) : |
| | | "Internal Error: no default password policy defined."; |
| | | |
| | | if ((directoryServer.defaultPasswordPolicy == null) |
| | | && (directoryServer.defaultPasswordPolicyDN != null)) |
| | | if (directoryServer.defaultPasswordPolicy == null |
| | | && directoryServer.defaultPasswordPolicyDN != null) |
| | | { |
| | | // The correct policy type is enforced by the core config manager. |
| | | directoryServer.defaultPasswordPolicy = (PasswordPolicy) |
| | |
| | | DN existingRootEntryDN = |
| | | directoryServer.alternateRootBindDNs.putIfAbsent(alternateRootBindDN, |
| | | actualRootEntryDN); |
| | | if ((existingRootEntryDN != null) && |
| | | (! existingRootEntryDN.equals(actualRootEntryDN))) |
| | | if (existingRootEntryDN != null |
| | | && !existingRootEntryDN.equals(actualRootEntryDN)) |
| | | { |
| | | Message message = ERR_CANNOT_REGISTER_DUPLICATE_ALTERNATE_ROOT_BIND_DN. |
| | | get(String.valueOf(alternateRootBindDN), |
| | |
| | | // When a new baseDN is registered with the server we have to create |
| | | // a new workflow to handle the base DN. We do not need to create |
| | | // the workflow in manual mode because in that case the workflows |
| | | // are created explicitely. |
| | | if (workflowConfigurationModeIsAuto()) |
| | | // are created explicitly. |
| | | if (workflowConfigurationModeIsAuto() |
| | | && !baseDN.equals(DN.decode("cn=config"))) |
| | | { |
| | | // Now create a workflow for the registered baseDN and register |
| | | // the workflow with the default network group, but don't register |
| | | // the workflow if the backend happens to be the configuration |
| | | // backend because it's too soon for the config backend. |
| | | if (! baseDN.equals(DN.decode("cn=config"))) |
| | | { |
| | | WorkflowImpl workflowImpl = createWorkflow(baseDN, backend); |
| | | registerWorkflowWithInternalNetworkGroup(workflowImpl); |
| | | registerWorkflowWithAdminNetworkGroup(workflowImpl); |
| | | registerWorkflowWithDefaultNetworkGroup(workflowImpl); |
| | | } |
| | | WorkflowImpl workflowImpl = createWorkflow(baseDN, backend); |
| | | registerWorkflowWithInternalNetworkGroup(workflowImpl); |
| | | registerWorkflowWithAdminNetworkGroup(workflowImpl); |
| | | registerWorkflowWithDefaultNetworkGroup(workflowImpl); |
| | | } |
| | | } |
| | | } |
| | |
| | | return true; |
| | | } |
| | | |
| | | // Figure out which backend should be used for the entry. If it isn't |
| | | // appropriate for any backend, then return false. |
| | | Backend backend = getBackend(entryDN); |
| | | if (backend == null) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | // Ask the appropriate backend if the entry exists. |
| | | return backend.entryExists(entryDN); |
| | | // If it is not appropriate for any backend, then return false. |
| | | Backend backend = getBackend(entryDN); |
| | | return backend != null && backend.entryExists(entryDN); |
| | | } |
| | | |
| | | |
| | |
| | | case EXTENDED: |
| | | ExtendedOperationBasis extOp = (ExtendedOperationBasis) operation; |
| | | String requestOID = extOp.getRequestOID(); |
| | | if (!((requestOID != null) && |
| | | requestOID.equals(OID_START_TLS_REQUEST))) |
| | | if (!OID_START_TLS_REQUEST.equals(requestOID)) |
| | | { |
| | | if (directoryServer.lockdownMode) |
| | | { |
| | |
| | | // If it did, then add a corresponding response control. |
| | | for (Control c : operation.getRequestControls()) |
| | | { |
| | | if (c.getOID().equals(OID_PASSWORD_POLICY_CONTROL)) |
| | | if (OID_PASSWORD_POLICY_CONTROL.equals(c.getOID())) |
| | | { |
| | | operation.addResponseControl(new PasswordPolicyResponseControl( |
| | | null, 0, PasswordPolicyErrorType.CHANGE_AFTER_RESET)); |
| | |
| | | // operations. |
| | | ExtendedOperationBasis extOp = (ExtendedOperationBasis) operation; |
| | | String requestOID = extOp.getRequestOID(); |
| | | if ((requestOID == null) || |
| | | ((! requestOID.equals(OID_PASSWORD_MODIFY_REQUEST)) && |
| | | (! requestOID.equals(OID_START_TLS_REQUEST)))) |
| | | if (!OID_PASSWORD_MODIFY_REQUEST.equals(requestOID) |
| | | && !OID_START_TLS_REQUEST.equals(requestOID)) |
| | | { |
| | | // See if the request included the password policy request control. |
| | | // If it did, then add a corresponding response control. |
| | | for (Control c : operation.getRequestControls()) |
| | | { |
| | | if (c.getOID().equals(OID_PASSWORD_POLICY_CONTROL)) |
| | | if (OID_PASSWORD_POLICY_CONTROL.equals(c.getOID())) |
| | | { |
| | | operation.addResponseControl(new PasswordPolicyResponseControl( |
| | | null, 0, PasswordPolicyErrorType.CHANGE_AFTER_RESET)); |
| | |
| | | if (directoryServer.lockdownMode) |
| | | { |
| | | InetAddress remoteAddress = clientConnection.getRemoteAddress(); |
| | | if ((remoteAddress != null) && (! remoteAddress.isLoopbackAddress())) |
| | | if (remoteAddress != null && !remoteAddress.isLoopbackAddress()) |
| | | { |
| | | return -1; |
| | | } |
| | | } |
| | | |
| | | if ((directoryServer.maxAllowedConnections > 0) && |
| | | (directoryServer.currentConnections >= |
| | | directoryServer.maxAllowedConnections)) |
| | | final long maxAllowed = directoryServer.maxAllowedConnections; |
| | | if (0 < maxAllowed && maxAllowed <= directoryServer.currentConnections) |
| | | { |
| | | return -1; |
| | | } |
| | |
| | | public static boolean allowNewPersistentSearch() |
| | | { |
| | | //-1 indicates that there is no limit. |
| | | if(directoryServer.maxPSearches ==-1 || |
| | | directoryServer.activePSearches.get() < |
| | | directoryServer.maxPSearches) |
| | | { |
| | | return true; |
| | | } |
| | | return false; |
| | | return directoryServer.maxPSearches == -1 |
| | | || directoryServer.activePSearches.get() < directoryServer.maxPSearches; |
| | | } |
| | | |
| | | |
| | |
| | | List<String> newArgList = new LinkedList<String>(); |
| | | for (String arg : args) |
| | | { |
| | | if (! arg.equalsIgnoreCase("--checkstartability")) |
| | | if (!"--checkstartability".equalsIgnoreCase(arg)) |
| | | { |
| | | newArgList.add(arg); |
| | | } |
| | |
| | | new FileOutputStream(new File(logDir, "server.out"), true); |
| | | serverOutStream = new PrintStream(fos); |
| | | |
| | | if (noDetach.isPresent()) |
| | | if (noDetach.isPresent() && !quietMode.isPresent()) |
| | | { |
| | | if (! quietMode.isPresent()) |
| | | { |
| | | MultiOutputStream multiStream = |
| | | new MultiOutputStream(System.out, serverOutStream); |
| | | serverOutStream = new PrintStream(multiStream); |
| | | } |
| | | MultiOutputStream multiStream = |
| | | new MultiOutputStream(System.out, serverOutStream); |
| | | serverOutStream = new PrintStream(multiStream); |
| | | } |
| | | |
| | | System.setOut(serverOutStream); |
| | |
| | | */ |
| | | public static boolean workflowConfigurationModeIsAuto() |
| | | { |
| | | boolean isAuto = |
| | | (directoryServer.workflowConfigurationMode |
| | | == WorkflowConfigurationMode.AUTO); |
| | | return isAuto; |
| | | return directoryServer.workflowConfigurationMode |
| | | == WorkflowConfigurationMode.AUTO; |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return the associated workflow element or null |
| | | */ |
| | | public static WorkflowElement getWorkflowElement(String workflowElementID) { |
| | | return(directoryServer.workflowElements.get(workflowElementID)); |
| | | return directoryServer.workflowElements.get(workflowElementID); |
| | | } |
| | | |
| | | /** |
| | |
| | | loadAndRegisterWorkflowElement(workflowElementID); |
| | | } |
| | | |
| | | return (we); |
| | | return we; |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return boolean indicating if workflow element is already registered |
| | | */ |
| | | public static boolean isWorkflowElementRegistered(String workflowElementID) { |
| | | return (directoryServer.workflowElements.containsKey(workflowElementID)); |
| | | return directoryServer.workflowElements.containsKey(workflowElementID); |
| | | } |
| | | |
| | | /** |
| | | * Print messages for start-ds "-F" option (full version information). |
| | | */ |
| | | |
| | | private static |
| | | void printFullVersionInformation() { |
| | | private static void printFullVersionInformation() { |
| | | /** |
| | | * This option is used by the upgrade to identify the server build and it |
| | | * can eventually also be used to be sent to the support in case of an |