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

jcduff
23.04.2008 b4f8838b15342670c31753a484abf0129e3c9653
opendj-sdk/opends/src/server/org/opends/server/api/ClientConnection.java
@@ -43,7 +43,7 @@
import org.opends.server.core.PersistentSearch;
import org.opends.server.core.PluginConfigManager;
import org.opends.server.core.SearchOperation;
import org.opends.server.core.NetworkGroup;
import org.opends.server.core.networkgroups.NetworkGroup;
import org.opends.server.loggers.debug.DebugTracer;
import org.opends.server.types.AbstractOperation;
import org.opends.server.types.Attribute;
@@ -131,6 +131,8 @@
  // The network group to which the connection belongs to.
  private NetworkGroup networkGroup;
  /** Need to evaluate the network group for the first operation. */
  protected boolean mustEvaluateNetworkGroup;
  /**
@@ -152,6 +154,18 @@
    finalized          = false;
    privileges         = new HashSet<Privilege>();
    networkGroup       = NetworkGroup.getDefaultNetworkGroup();
    networkGroup.addConnection(this);
    mustEvaluateNetworkGroup = true;
    if (debugEnabled())
      {
        Message message =
                INFO_CHANGE_NETWORK_GROUP.get(
                  getConnectionID(),
                  "null",
                  networkGroup.getID());
        TRACER.debugMessage(DebugLogLevel.INFO, message.toString());
      }
  }
@@ -206,6 +220,8 @@
           authZEntry.getDN(), this);
    }
    networkGroup.removeConnection(this);
    try
    {
      finalizeClientConnection();
@@ -313,6 +329,40 @@
  /**
   * Retrieves the port number for this connection on the client
   * system if available.
   *
   * @return The port number for this connection on the client system
   *         or -1 if there is no client port associated with this
   *         connection (e.g. internal client).
   */
  public abstract int getClientPort();
  /**
   * Retrieves the address and port (if available) of the client
   * system, separated by a colon.
   *
   * @return The address and port of the client system, separated by a
   *         colon.
   */
  public final String getClientHostPort()
  {
    int port = getClientPort();
    if (port >= 0)
    {
      return getClientAddress() + ":" + port;
    }
    else
    {
      return getClientAddress();
    }
  }
  /**
   * Retrieves a string representation of the address on the server to
   * which the client connected.
   *
@@ -323,6 +373,41 @@
  /**
   * Retrieves the port number for this connection on the server
   * system if available.
   *
   * @return The port number for this connection on the server system
   *         or -1 if there is no server port associated with this
   *         connection (e.g. internal client).
   */
  public abstract int getServerPort();
  /**
   * Retrieves the address and port of the server system, separated by
   * a colon.
   *
   * @return The address and port of the server system, separated by a
   *         colon.
   */
  public final String getServerHostPort()
  {
    int port = getServerPort();
    if (port >= 0)
    {
      return getServerAddress() + ":" + port;
    }
    else
    {
      return getServerAddress();
    }
  }
  /**
   * Retrieves the {@code java.net.InetAddress} associated with the
   * remote client system.
@@ -445,6 +530,34 @@
  /**
   * Retrieves the total number of operations performed
   * on this connection.
   *
   * @return The total number of operations performed
   * on this connection.
   */
  public abstract long getNumberOfOperations();
  /**
   * Indicates whether the network group must be evaluated for
   * the next connection.
   * @return boolean indicating if the network group must be evaluated
   */
  public boolean mustEvaluateNetworkGroup() {
    return mustEvaluateNetworkGroup;
  }
  /**
   * Indicates that the network group will have to be evaluated
   * for the next connection.
   *
   * @param bool true if the network group must be evaluated
   */
  public void mustEvaluateNetworkGroup(boolean bool) {
      mustEvaluateNetworkGroup = bool;
  }
  /**
   * Indicates that the data in the provided buffer has been read from
   * the client and should be processed.  The contents of the provided
   * buffer will be in clear-text (the data may have been passed
@@ -1180,7 +1293,7 @@
    {
      for (Attribute a : attrList)
      {
        for (AttributeValue v : a.getValues())
        for (AttributeValue v : a)
        {
          String privName = toLowerCase(v.getStringValue());
@@ -1640,7 +1753,29 @@
   */
  public final void setNetworkGroup (NetworkGroup networkGroup)
  {
    this.networkGroup = networkGroup;
    if (this.networkGroup != networkGroup) {
      if (debugEnabled())
      {
        Message message =
                INFO_CHANGE_NETWORK_GROUP.get(
                  getConnectionID(),
                  this.networkGroup.getID(),
                  networkGroup.getID());
        TRACER.debugMessage(DebugLogLevel.INFO, message.toString());
      }
      // If there is a change, first remove this connection
      // from the current network group
      this.networkGroup.removeConnection(this);
      // Then set the new network group
      this.networkGroup = networkGroup;
      // And add the connection to the new ng
      this.networkGroup.addConnection(this);
      // The client connection inherits the resource limits
      sizeLimit = networkGroup.getSearchSizeLimit();
      timeLimit = networkGroup.getSearchDurationLimit();
    }
  }