From 282288d61ff6180e6798948e3aaa49271e306e70 Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Mon, 30 Jul 2007 06:26:11 +0000
Subject: [PATCH] Update the server to provide an idle time limit configuration option that can be used to terminate client connections that have been idle for too long.  This can be controlled on a server-wide default level using the ds-cfg-idle-time-limit configuration attribute in the cn=config entry, but it can also be overridden on a per-user level with the ds-rlim-idle-time-limit operational attribute in the user's entry.

---
 opends/src/server/org/opends/server/api/ClientConnection.java |   55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 55 insertions(+), 0 deletions(-)

diff --git a/opends/src/server/org/opends/server/api/ClientConnection.java b/opends/src/server/org/opends/server/api/ClientConnection.java
index 1c268df..8c0fc8e 100644
--- a/opends/src/server/org/opends/server/api/ClientConnection.java
+++ b/opends/src/server/org/opends/server/api/ClientConnection.java
@@ -108,6 +108,9 @@
   // The time that this client connection was established.
   private long connectTime;
 
+  // The idle time limit for this client connection.
+  private long idleTimeLimit;
+
   // The opaque information used for storing intermediate state
   // information needed across multi-stage SASL binds.
   private Object saslAuthState;
@@ -138,6 +141,7 @@
     persistentSearches = new CopyOnWriteArrayList<PersistentSearch>();
     sizeLimit          = DirectoryServer.getSizeLimit();
     timeLimit          = DirectoryServer.getTimeLimit();
+    idleTimeLimit      = DirectoryServer.getIdleTimeLimit();
     lookthroughLimit   = DirectoryServer.getLookthroughLimit();
     finalized          = false;
     privileges         = new HashSet<Privilege>();
@@ -1274,6 +1278,39 @@
 
 
   /**
+   * Retrieves the maximum length of time in milliseconds that this
+   * client connection will be allowed to remain idle before it should
+   * be disconnected.
+   *
+   * @return  The maximum length of time in milliseconds that this
+   *          client connection will be allowed to remain idle before
+   *          it should be disconnected.
+   */
+  public final long getIdleTimeLimit()
+  {
+    return idleTimeLimit;
+  }
+
+
+
+  /**
+   * Specifies the maximum length of time in milliseconds that this
+   * client connection will be allowed to remain idle before it should
+   * be disconnected.
+   *
+   * @param  idleTimeLimit  The maximum length of time in milliseconds
+   *                        that this client connection will be
+   *                        allowed to remain idle before it should be
+   *                        disconnected.
+   */
+  public void setIdleTimeLimit(long idleTimeLimit)
+  {
+    this.idleTimeLimit = idleTimeLimit;
+  }
+
+
+
+  /**
    * Retrieves the default maximum number of entries that should
    * checked for matches during a search.
    *
@@ -1575,5 +1612,23 @@
     this.networkGroup = networkGroup;
   }
 
+
+
+  /**
+   * Retrieves the length of time in milliseconds that this client
+   * connection has been idle.
+   * <BR><BR>
+   * Note that the default implementation will always return zero.
+   * Subclasses associated with connection handlers should override
+   * this method if they wish to provided idle time limit
+   * functionality.
+   *
+   * @return  The length of time in milliseconds that this client
+   *          connection has been idle.
+   */
+  public long getIdleTime()
+  {
+    return 0L;
+  }
 }
 

--
Gitblit v1.10.0