mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jean-Noel Rouvignac
22.08.2014 572030bbcfc173d5d0a022e958360551c4453987
opendj3-server-dev/src/server/org/opends/server/core/DirectoryServer.java
@@ -9130,30 +9130,6 @@
  }
  /**
   * Return the WorkflowElement associated with a name and try to
   * create it if it does not exists yet.
   *
   * @param workflowElementID the name of the requested workflow element
   * @return the associated workflow element
   * @throws ConfigException if the configuration is invalid
   * @throws InitializationException if the initialization failed
   */
  public static WorkflowElement getOrCreateWorkflowElement(
          String workflowElementID)
    throws ConfigException, InitializationException {
    WorkflowElement we = directoryServer.workflowElements.get(
      workflowElementID);
    if (we == null) {
      we = directoryServer.workflowElementConfigManager.
        loadAndRegisterWorkflowElement(workflowElementID);
    }
    return we;
  }
  /**
   * Registers the provided workflow element from the Directory Server.
   *
   * @param  we  The workflow element to register. It must not be
@@ -9199,16 +9175,6 @@
  }
  /**
   * Verifies if the provided workflow element ID is already registered.
   *
   * @param workflowElementID workflow element identifier
   * @return boolean indicating if workflow element is already registered
   */
  public static boolean isWorkflowElementRegistered(String workflowElementID) {
    return directoryServer.workflowElements.containsKey(workflowElementID);
  }
  /**
   * Print messages for start-ds "-F" option (full version information).
   */
  private static void printFullVersionInformation() {
opendj3-server-dev/src/server/org/opends/server/core/networkgroups/BindDNConnectionCriteria.java
@@ -22,11 +22,10 @@
 *
 *
 *      Copyright 2009 Sun Microsystems, Inc.
 *      Portions copyright 2014 ForgeRock AS.
 */
package org.opends.server.core.networkgroups;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -37,8 +36,6 @@
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
/**
 * A connection criteria which matches connections authenticated using a
 * permitted bind DN.
@@ -48,23 +45,6 @@
  /**
   * Creates a new bind DN connection criteria using the provided DN
   * patterns.
   *
   * @param patterns
   *          The DN patterns.
   * @return The new bind DN connection criteria.
   */
  public static BindDNConnectionCriteria create(
      Collection<PatternDN> patterns)
  {
    return new BindDNConnectionCriteria(new ArrayList<PatternDN>(
        patterns));
  }
  /**
   * Creates a new bind DN connection criteria using the provided DN
   * pattern string representations.
   *
   * @param patternStrings
@@ -94,8 +74,13 @@
  // Private constructor.
  private BindDNConnectionCriteria(List<PatternDN> patterns)
  /**
   * Creates a new bind DN connection criteria using the provided DN patterns.
   *
   * @param patterns
   *          The DN patterns.
   */
  BindDNConnectionCriteria(List<PatternDN> patterns)
  {
    this.patterns = patterns;
  }
@@ -105,6 +90,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public boolean matches(ClientConnection connection)
  {
    DN dn = connection.getAuthenticationInfo().getAuthenticationDN();
@@ -116,6 +102,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public boolean willMatchAfterBind(ClientConnection connection,
      DN bindDN, AuthenticationType authType, boolean isSecure)
  {
opendj3-server-dev/src/server/org/opends/server/core/networkgroups/NetworkGroup.java
@@ -26,11 +26,6 @@
 */
package org.opends.server.core.networkgroups;
import static org.opends.messages.ConfigMessages.*;
import static org.opends.messages.CoreMessages.*;
import static org.opends.server.util.StaticUtils.*;
import static org.forgerock.util.Reject.*;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collection;
@@ -45,6 +40,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.admin.ClassPropertyDefinition;
import org.opends.server.admin.server.ConfigurationAddListener;
@@ -56,13 +52,11 @@
import org.opends.server.api.ClientConnection;
import org.opends.server.api.QOSPolicy;
import org.opends.server.api.QOSPolicyFactory;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.RootDseWorkflowTopology;
import org.opends.server.core.Workflow;
import org.opends.server.core.WorkflowImpl;
import org.opends.server.core.WorkflowTopologyNode;
import org.opends.server.protocols.ldap.LDAPMessage;
import org.opends.server.types.AuthenticationType;
import org.opends.server.types.ConfigChangeResult;
import org.opends.server.types.DN;
@@ -71,6 +65,11 @@
import org.opends.server.types.operation.PreParseOperation;
import org.opends.server.workflowelement.WorkflowElement;
import static org.forgerock.util.Reject.*;
import static org.opends.messages.ConfigMessages.*;
import static org.opends.messages.CoreMessages.*;
import static org.opends.server.util.StaticUtils.*;
/**
 * This class defines the network group. A network group is used to
 * categorize client connections. A network group is defined by a set of
@@ -299,7 +298,7 @@
      new TreeMap<String, NetworkGroup>();
  // A lock to protect concurrent access to the registeredNetworkGroups.
  private static Object registeredNetworkGroupsLock = new Object();
  private static final Object registeredNetworkGroupsLock = new Object();
  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
@@ -799,11 +798,6 @@
  // is not stored in the list of registered workflow nodes.
  private RootDseWorkflowTopology rootDSEWorkflowNode = null;
  // The network group statistics.
  private final NetworkGroupStatistics statistics;
  /**
   * Creates a new system network group using the provided ID.
   *
@@ -819,7 +813,6 @@
        ADMIN_NETWORK_GROUP_NAME.equals(networkGroupID);
    this.isDefaultNetworkGroup =
        DEFAULT_NETWORK_GROUP_NAME.equals(networkGroupID);
    this.statistics = new NetworkGroupStatistics(this);
    this.configuration = null;
    this.changeListener = null;
    this.policyListener = null;
@@ -836,7 +829,6 @@
    this.isInternalNetworkGroup = false;
    this.isAdminNetworkGroup = false;
    this.isDefaultNetworkGroup = false;
    this.statistics = new NetworkGroupStatistics(this);
    this.configuration = configuration;
    this.changeListener = new ChangeListener();
    this.policyListener = new QOSPolicyListener();
@@ -1073,8 +1065,6 @@
    resourceLimitsPolicy = null;
    criteria = ConnectionCriteria.TRUE;
    policies.clear();
    // Remove the stats
    statistics.finalizeStatistics();
  }
@@ -1278,21 +1268,6 @@
    }
  }
  /**
   * Updates the operations statistics.
   *
   * @param message
   *          The LDAP message being processed
   */
  public void updateMessageRead(LDAPMessage message)
  {
    statistics.updateMessageRead(message);
  }
  /**
   * Deregisters the current network group (this) with the server. The
   * method also decrements the reference counter of the workflows so
@@ -1478,46 +1453,6 @@
    }
  }
  /**
   * Dumps info from the current network group for debug purpose.
   * <p>
   * This method is intended for testing only.
   *
   * @param leftMargin
   *          white spaces used to indent traces
   * @return a string buffer that contains trace information
   */
  StringBuilder toString(String leftMargin)
  {
    StringBuilder sb = new StringBuilder();
    String newMargin = leftMargin + "   ";
    sb.append(leftMargin + "Networkgroup (" + networkGroupID + "\n");
    sb.append(leftMargin + "List of registered workflows:\n");
    for (WorkflowTopologyNode node : registeredWorkflowNodes.values())
    {
      sb.append(node.toString(newMargin));
    }
    namingContexts.toString(leftMargin);
    sb.append(leftMargin + "rootDSEWorkflow:\n");
    if (rootDSEWorkflowNode == null)
    {
      sb.append(newMargin + "null\n");
    }
    else
    {
      sb.append(rootDSEWorkflowNode.toString(newMargin));
    }
    return sb;
  }
  /**
   * Checks whether the base DN of a new workflow to register is present
   * in a workflow already registered with the network group.
opendj3-server-dev/src/server/org/opends/server/core/networkgroups/NetworkGroupStatistics.java
File was deleted
opendj3-server-dev/src/server/org/opends/server/protocols/ldap/LDAPClientConnection.java
@@ -26,8 +26,6 @@
 */
package org.opends.server.protocols.ldap;
import java.io.Closeable;
import java.io.IOException;
import java.net.InetAddress;
@@ -52,6 +50,7 @@
import org.forgerock.opendj.io.ASN1Writer;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.api.ClientConnection;
import org.opends.server.api.ConnectionHandler;
import org.opends.server.core.*;
@@ -61,7 +60,6 @@
import org.opends.server.extensions.TLSByteChannel;
import org.opends.server.extensions.TLSCapableConnection;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.util.StaticUtils;
import org.opends.server.util.TimeThread;
@@ -73,7 +71,6 @@
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
/**
 * This class defines an LDAP client connection, which is a type of
 * client connection that will be accepted by an instance of the LDAP
@@ -1624,7 +1621,6 @@
    if (keepStats)
    {
      statTracker.updateMessageRead(message);
      this.getNetworkGroup().updateMessageRead(message);
    }
    operationsPerformed.getAndIncrement();
opendj3-server-dev/src/server/org/opends/server/workflowelement/LeafWorkflowElement.java
File was deleted
opendj3-server-dev/src/server/org/opends/server/workflowelement/ObservableWorkflowElement.java
File was deleted
opendj3-server-dev/src/server/org/opends/server/workflowelement/ObservableWorkflowElementState.java
@@ -22,9 +22,11 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions copyright 2014 ForgeRock AS.
 */
package org.opends.server.workflowelement;
import java.util.Observable;
/**
 * This class implements an observable workflow element state.
@@ -32,13 +34,13 @@
 * state of the workflow element has changed. Typically, observers are
 * notified when a workflow element is enabled or disabled.
 */
public class ObservableWorkflowElementState
    extends ObservableWorkflowElement
public class ObservableWorkflowElementState extends Observable
{
  // The "enabled" state of the observed workflow element.
  // By default, a workflow element is enabled (otherwise this
  // instance of workflow element state would not exist).
  private boolean enabled = true;
  private final WorkflowElement<?> observedWorkflowElement;
  /**
@@ -48,10 +50,9 @@
   * @param  observedWorkflowElement
   *         The workflow element to observe.
   */
  public ObservableWorkflowElementState(
      WorkflowElement<?> observedWorkflowElement)
  ObservableWorkflowElementState(WorkflowElement<?> observedWorkflowElement)
  {
    super(observedWorkflowElement);
    this.observedWorkflowElement = observedWorkflowElement;
  }
@@ -61,8 +62,7 @@
   *
   * @param enabled  the new "enabled" state of the observed workflow element
   */
  public void setWorkflowElementEnabled(
      boolean enabled)
  public void setWorkflowElementEnabled(boolean enabled)
  {
    if (this.enabled != enabled)
    {
@@ -81,4 +81,15 @@
  {
    return enabled;
  }
  /**
   * Gets the observed workflow element.
   *
   * @return the observed workflow element.
   */
  public WorkflowElement<?> getObservedWorkflowElement()
  {
    return observedWorkflowElement;
  }
}
opendj3-server-dev/src/server/org/opends/server/workflowelement/ObservableWorkflowElementStatus.java
File was deleted
opendj3-server-dev/src/server/org/opends/server/workflowelement/WorkflowElement.java
@@ -22,25 +22,20 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions copyright 2013 ForgeRock AS.
 *      Portions copyright 2013-2014 ForgeRock AS.
 */
package org.opends.server.workflowelement;
import java.util.List;
import java.util.Observable;
import java.util.Observer;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CopyOnWriteArrayList;
import org.opends.server.admin.std.server.MonitorProviderCfg;
import org.opends.server.admin.std.server.WorkflowElementCfg;
import org.opends.server.api.MonitorProvider;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.Operation;
import org.opends.server.types.CanceledOperationException;
import org.opends.server.types.Operation;
/**
 * This class defines the super class for all the workflow elements. A workflow
@@ -82,16 +77,6 @@
    newWorkflowElementNotificationList =
      new ConcurrentHashMap<String, List<Observer>>();
  // The observable status of the workflow element.
  // The status contains the health indicator (aka saturation index)
  // of the workflow element.
  private ObservableWorkflowElementStatus observableStatus =
    new ObservableWorkflowElementStatus(this);
  // The statistics exported by the workflow element
  private MonitorProvider<MonitorProviderCfg> statistics;
  /**
   * Provides the observable state of the workflow element.
   * This method is intended to be called by the WorkflowElementConfigManager
@@ -105,18 +90,6 @@
    return observableState;
  }
  /**
   * Provides the observable status of the workflow element.
   *
   * @return the observable status of the workflow element.
   */
  protected ObservableWorkflowElementStatus getObservableStatus()
  {
    return observableStatus;
  }
  /**
   * Registers with a specific workflow element to be notified when the
   * workflow element state has changed. This notification system is
@@ -280,16 +253,13 @@
  {
    this.workflowElementID = workflowElementID;
    this.workflowElementTypeInfo = workflowElementTypeInfo;
    this.statistics = this.createStatistics();
    if (this.statistics != null) {
      DirectoryServer.registerMonitorProvider(this.statistics);
    }
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public void update(Observable o, Object arg)
  {
    // By default, do nothing when notification hits the workflow element.
@@ -340,10 +310,6 @@
   */
  public void finalizeWorkflowElement()
  {
    // Deregister the monitor provider.
    if (statistics != null) {
      DirectoryServer.deregisterMonitorProvider(statistics);
    }
  }
  /**
@@ -393,96 +359,4 @@
  {
    return workflowElementID;
  }
  /**
   * Modifies the saturation index of the workflow element.
   *
   * @param  newValue
   *         The new value of the saturation index of the workflow element.
   */
  public void setSaturationIndex(int newValue)
  {
    observableStatus.setSaturationIndex(newValue);
  }
  /**
   * Gets the saturation index of the workflow element.
   *
   * @return  the value of the saturation index of the workflow element.
   */
  public int getSaturationIndex()
  {
    return observableStatus.getSaturationIndex();
  }
  /**
   * Registers an observer with the saturation index of the workflow
   * element. The observer will be notified when the saturation index
   * is updated.
   *
   * @param  observer
   *         The observer to notify when the saturation index is modified.
   */
  public void registerForSaturationIndexUpdate(Observer observer)
  {
    observableStatus.addObserver(observer);
  }
  /**
   * Deregisters an observer with the saturation index of the workflow
   * element.
   *
   * @param  observer
   *         The observer to deregister.
   */
  public void deregisterForSaturationIndexUpdate(Observer observer)
  {
    observableStatus.deleteObserver(observer);
  }
  /**
   * Retrieves the list of child workflow elements, ie the
   * WorkflowElements below this one in the topology tree.
   *
   * @return child workflow elements
   */
  public abstract List<WorkflowElement<?>> getChildWorkflowElements();
  /**
   * Checks whether the tree of workflow elements below this one
   * contains the provided workflow element.
   *
   * @param element The WorkflowElement we are looking for in the topology
   *        below this object.
   * @return boolean
   */
  public boolean hasChildWorkflowElement(WorkflowElement<?> element) {
    if (this.getChildWorkflowElements().size() == 0) {
      return (this.equals(element));
    }
    for (WorkflowElement<?> subElement : this.getChildWorkflowElements()) {
      if (subElement.equals(element) ||
          subElement.hasChildWorkflowElement(element)) {
        return true;
      }
    }
    return false;
  }
  /**
   * Creates the statistics exposed by the workflow element. By default,
   * workflow elements do not expose anything but specific implementations
   * can override this method and provide their own stats.
   * @return the statistics exposed by the workflow element.
   */
  public MonitorProvider<MonitorProviderCfg> createStatistics() {
    // by default, no stats are created;
    // This method should be overriden if necessary
    return null;
  }
}
opendj3-server-dev/src/server/org/opends/server/workflowelement/WorkflowElementConfigManager.java
@@ -32,6 +32,8 @@
import java.util.List;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.util.Utils;
import org.opends.server.admin.ClassPropertyDefinition;
import org.opends.server.admin.server.ConfigurationAddListener;
@@ -41,13 +43,11 @@
import org.opends.server.admin.std.meta.WorkflowElementCfgDefn;
import org.opends.server.admin.std.server.RootCfg;
import org.opends.server.admin.std.server.WorkflowElementCfg;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ServerContext;
import org.opends.server.types.ConfigChangeResult;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.InitializationException;
import org.forgerock.opendj.ldap.ResultCode;
import static org.opends.messages.ConfigMessages.*;
@@ -65,8 +65,6 @@
{
  private final ServerContext serverContext;
  /**
   * Creates a new instance of this workflow config manager.
   *
@@ -75,7 +73,6 @@
   */
  public WorkflowElementConfigManager(ServerContext serverContext)
  {
    this.serverContext = serverContext;
  }
  /**
@@ -144,6 +141,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public boolean isConfigurationAddAcceptable(
      WorkflowElementCfg configuration,
      List<LocalizableMessage> unacceptableReasons)
@@ -175,6 +173,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public ConfigChangeResult applyConfigurationAdd(
      WorkflowElementCfg configuration)
  {
@@ -215,6 +214,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public boolean isConfigurationDeleteAcceptable(
      WorkflowElementCfg configuration,
      List<LocalizableMessage> unacceptableReasons)
@@ -229,6 +229,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public ConfigChangeResult applyConfigurationDelete(
      WorkflowElementCfg configuration)
  {
@@ -263,6 +264,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public boolean isConfigurationChangeAcceptable(
      WorkflowElementCfg configuration,
      List<LocalizableMessage> unacceptableReasons)
@@ -294,6 +296,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public ConfigChangeResult applyConfigurationChange(
      WorkflowElementCfg configuration)
  {
@@ -418,7 +421,6 @@
      // I cannot use the parameterized type WorflowElement<?>
      // because it would break the line WorkflowElement.class below.
      // Use SuppressWarning because we know the cast is safe.
      @SuppressWarnings("unchecked")
      Class<? extends WorkflowElement>    workflowElementClass;
      definition = WorkflowElementCfgDefn.getInstance();
opendj3-server-dev/src/server/org/opends/server/workflowelement/WorkflowElementStatistics.java
File was deleted
opendj3-server-dev/src/server/org/opends/server/workflowelement/localbackend/LocalBackendWorkflowElement.java
@@ -33,22 +33,22 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizableMessageDescriptor;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.server.ServerManagementContext;
import org.opends.server.admin.std.server.BackendCfg;
import org.opends.server.admin.std.server.LocalBackendWorkflowElementCfg;
import org.opends.server.admin.std.server.RootCfg;
import org.opends.server.api.Backend;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.controls.LDAPPostReadRequestControl;
import org.opends.server.controls.LDAPPostReadResponseControl;
import org.opends.server.controls.LDAPPreReadRequestControl;
import org.opends.server.controls.LDAPPreReadResponseControl;
import org.opends.server.core.*;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.workflowelement.LeafWorkflowElement;
import org.opends.server.workflowelement.WorkflowElement;
import static org.opends.messages.CoreMessages.*;
import static org.opends.server.config.ConfigConstants.*;
@@ -58,7 +58,7 @@
 * handle the processing of an operation against a local backend.
 */
public class LocalBackendWorkflowElement extends
    LeafWorkflowElement<LocalBackendWorkflowElementCfg>
    WorkflowElement<LocalBackendWorkflowElementCfg>
    implements ConfigurationChangeListener<LocalBackendWorkflowElementCfg>
{
  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/core/networkgroups/BindDNConnectionCriteriaTest.java
@@ -26,8 +26,7 @@
 */
package org.opends.server.core.networkgroups;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
@@ -39,12 +38,11 @@
import org.opends.server.authorization.dseecompat.PatternDN;
import org.opends.server.types.AuthenticationType;
import org.opends.server.types.DN;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.testng.Assert.*;
/**
 * Unit tests for BindDNConnectionCriteria.
@@ -118,9 +116,8 @@
        new MockClientConnection(12345, false, clientBindDN,
            AllowedAuthMethod.SIMPLE);
    BindDNConnectionCriteria criteria =
        BindDNConnectionCriteria.create(allowedDNPatterns);
    Assert.assertEquals(criteria.matches(client), expectedResult);
    BindDNConnectionCriteria criteria = new BindDNConnectionCriteria(new ArrayList<PatternDN>(allowedDNPatterns));
    assertEquals(criteria.matches(client), expectedResult);
  }
@@ -146,10 +143,8 @@
        new MockClientConnection(12345, false, DN.rootDN(),
            AllowedAuthMethod.ANONYMOUS);
    BindDNConnectionCriteria criteria =
        BindDNConnectionCriteria.create(allowedDNPatterns);
    Assert
        .assertEquals(criteria.willMatchAfterBind(client, clientBindDN,
    BindDNConnectionCriteria criteria = new BindDNConnectionCriteria(new ArrayList<PatternDN>(allowedDNPatterns));
    assertEquals(criteria.willMatchAfterBind(client, clientBindDN,
            AuthenticationType.SIMPLE, false), expectedResult);
  }