From 1815f3ff74b2898b8c41a79a4e0466381d85a56e Mon Sep 17 00:00:00 2001
From: fguigues <fguigues@localhost>
Date: Wed, 23 Apr 2008 15:47:10 +0000
Subject: [PATCH] Fixes :

---
 opendj-sdk/opends/src/snmp/src/org/opends/server/snmp/SNMPClassLoaderProvider.java                  |   30 --
 opendj-sdk/opends/src/snmp/src/org/opends/server/snmp/SNMPUserAcl.java                              |   23 +-
 opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ListenerDescriptor.java              |    4 
 opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ConfigFromLDAP.java                  |   16 +
 opendj-sdk/opends/src/snmp/src/org/opends/server/snmp/DIRECTORY_SERVER_MIBImpl.java                 |  181 ++++++++++----------
 opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ConfigFromFile.java                  |   18 ++
 opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/SNMPConnectionHandlerConfiguration.xml |  157 ----------------
 opendj-sdk/opends/src/snmp/src/org/opends/server/snmp/DsMIBImpl.java                                |    3 
 opendj-sdk/opends/src/snmp/src/org/opends/server/snmp/SNMPInetAddressAcl.java                       |   11 
 opendj-sdk/opends/resource/schema/02-config.ldif                                                    |   54 +-----
 opendj-sdk/opends/src/messages/messages/admin_tool.properties                                       |    1 
 11 files changed, 166 insertions(+), 332 deletions(-)

diff --git a/opendj-sdk/opends/resource/schema/02-config.ldif b/opendj-sdk/opends/resource/schema/02-config.ldif
index 395e073..ea3c10a 100644
--- a/opendj-sdk/opends/resource/schema/02-config.ldif
+++ b/opendj-sdk/opends/resource/schema/02-config.ldif
@@ -2182,72 +2182,42 @@
   SINGLE-VALUE
   X-ORIGIN 'OpenDS Directory Server' )
 attributeTypes: ( 1.3.6.1.4.1.26027.1.1.449
-  NAME 'ds-cfg-version'
-  SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
-  SINGLE-VALUE
-  X-ORIGIN 'OpenDS Directory Server' )
-attributeTypes: ( 1.3.6.1.4.1.26027.1.1.450
   NAME 'ds-cfg-community'
   SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
   X-ORIGIN 'OpenDS Directory Server' )
-attributeTypes: ( 1.3.6.1.4.1.26027.1.1.451
+attributeTypes: ( 1.3.6.1.4.1.26027.1.1.450
   NAME 'ds-cfg-allowed-manager'
   SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
   X-ORIGIN 'OpenDS Directory Server' )
-attributeTypes: ( 1.3.6.1.4.1.26027.1.1.452
+attributeTypes: ( 1.3.6.1.4.1.26027.1.1.451
   NAME 'ds-cfg-allowed-user'
   SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
   X-ORIGIN 'OpenDS Directory Server' )
-attributeTypes: ( 1.3.6.1.4.1.26027.1.1.453
+attributeTypes: ( 1.3.6.1.4.1.26027.1.1.452
   NAME 'ds-cfg-security-level'
   SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
   SINGLE-VALUE
   X-ORIGIN 'OpenDS Directory Server' )
-attributeTypes: ( 1.3.6.1.4.1.26027.1.1.454
+attributeTypes: ( 1.3.6.1.4.1.26027.1.1.453
   NAME 'ds-cfg-traps-community'
   SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
   SINGLE-VALUE
   X-ORIGIN 'OpenDS Directory Server' )
-attributeTypes: ( 1.3.6.1.4.1.26027.1.1.455
+attributeTypes: ( 1.3.6.1.4.1.26027.1.1.454
   NAME 'ds-cfg-traps-destination'
   SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
   X-ORIGIN 'OpenDS Directory Server' )
-attributeTypes: ( 1.3.6.1.4.1.26027.1.1.456
+attributeTypes: ( 1.3.6.1.4.1.26027.1.1.455
   NAME 'ds-cfg-security-agent-file'
   SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
   SINGLE-VALUE
   X-ORIGIN 'OpenDS Directory Server' )
-attributeTypes: ( 1.3.6.1.4.1.26027.1.1.457
+attributeTypes: ( 1.3.6.1.4.1.26027.1.1.456
   NAME 'ds-cfg-registered-mbean'
   SYNTAX 1.3.6.1.4.1.1466.115.121.1.7
   SINGLE-VALUE
   X-ORIGIN 'OpenDS Directory Server' )
-attributeTypes: ( 1.3.6.1.4.1.26027.1.1.458
-  NAME 'ds-cfg-template-username'
-  SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
-  SINGLE-VALUE
-  X-ORIGIN 'OpenDS Directory Server' )
-attributeTypes: ( 1.3.6.1.4.1.26027.1.1.459
-  NAME 'ds-cfg-template-auth-algorithm'
-  SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
-  SINGLE-VALUE
-  X-ORIGIN 'OpenDS Directory Server' )
-attributeTypes: ( 1.3.6.1.4.1.26027.1.1.460
-  NAME 'ds-cfg-template-authkey'
-  SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
-  SINGLE-VALUE
-  X-ORIGIN 'OpenDS Directory Server' )
-attributeTypes: ( 1.3.6.1.4.1.26027.1.1.461
-  NAME 'ds-cfg-template-priv-algorithm'
-  SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
-  SINGLE-VALUE
-  X-ORIGIN 'OpenDS Directory Server' )
-attributeTypes: ( 1.3.6.1.4.1.26027.1.1.462
-  NAME 'ds-cfg-template-privkey'
-  SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
-  SINGLE-VALUE
-  X-ORIGIN 'OpenDS Directory Server' )
-attributeTypes: ( 1.3.6.1.4.1.26027.1.1.463
+attributeTypes: ( 1.3.6.1.4.1.26027.1.1.457
   NAME 'ds-cfg-opendmk-jarfile'
   SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
   SINGLE-VALUE
@@ -3764,8 +3734,7 @@
   STRUCTURAL
   MUST ( ds-cfg-listen-port $
          ds-cfg-trap-port )
-  MAY ( ds-cfg-version $
-        ds-cfg-traps-destination $
+  MAY ( ds-cfg-traps-destination $
         ds-cfg-registered-mbean $
         ds-cfg-community $
         ds-cfg-allowed-manager $
@@ -3773,10 +3742,5 @@
         ds-cfg-security-level $
         ds-cfg-traps-community $
         ds-cfg-security-agent-file $
-        ds-cfg-template-username $
-        ds-cfg-template-auth-algorithm $
-        ds-cfg-template-authkey $
-        ds-cfg-template-priv-algorithm $ 
-        ds-cfg-template-privkey $
         ds-cfg-opendmk-jarfile )
   X-ORIGIN 'OpenDS Directory Server' )
diff --git a/opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/SNMPConnectionHandlerConfiguration.xml b/opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/SNMPConnectionHandlerConfiguration.xml
index a360576..19d11d3 100644
--- a/opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/SNMPConnectionHandlerConfiguration.xml
+++ b/opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/SNMPConnectionHandlerConfiguration.xml
@@ -35,7 +35,7 @@
         The
         <adm:user-friendly-name />
         can be used to process SNMP requests to retrieve monitoring information
-        described by the MIB 2605.
+        described by the MIB 2605. Supported protocol are SNMP V1, V2c and V3.
     </adm:synopsis>
     <adm:description>
         The SNMP connection handler will process SNMP requests sent by SNMP 
@@ -77,29 +77,12 @@
         </adm:profile>
     </adm:property>
     <!-- SNMP Version  -->
-    <adm:property name="version">
-        <adm:synopsis>
-            Specifies Supported SNMP Version : v1, v2, v3.
-        </adm:synopsis>
-        <adm:default-behavior>
-            <adm:defined>
-                <adm:value>v2</adm:value>
-            </adm:defined>
-        </adm:default-behavior>
-        <adm:syntax>
-            <adm:string />
-        </adm:syntax>
-        <adm:profile name="ldap">
-            <ldap:attribute>
-                <ldap:name>ds-cfg-version</ldap:name>
-            </ldap:attribute>
-        </adm:profile>
-    </adm:property>
     <!-- SNMP Community or Context Name  -->
-    <adm:property name="community" multi-valued="true">
+    <adm:property name="community">
         <adm:synopsis>
             Specifies the v1,v2 community or the v3 context name allowed to 
-            access the MIB 2605 monitoring information or the USM MIB.
+            access the MIB 2605 monitoring information or the USM MIB. The
+            mapping between "community" and "context name" is set.
         </adm:synopsis>
         <adm:default-behavior>
             <adm:defined>
@@ -124,7 +107,7 @@
         <adm:default-behavior>
             <adm:alias>
                 <adm:synopsis>
-                    If the list is empty, no access control is done.
+                    An empty list opens access to all managers.
                 </adm:synopsis>
             </adm:alias>
         </adm:default-behavior>
@@ -287,135 +270,7 @@
             </ldap:attribute>
         </adm:profile>
     </adm:property>
-    <!--User Template definitions -->
-    <!--User Name -->
-    <adm:property name="template-username">
-        <adm:synopsis>
-            Indicates the user name for the template definitions.
-        </adm:synopsis>
-        <adm:default-behavior>
-            <adm:defined>
-                <adm:value>defaultUser</adm:value>
-            </adm:defined>
-        </adm:default-behavior>
-        <adm:syntax>
-            <adm:string />
-        </adm:syntax>
-        <adm:profile name="ldap">
-            <ldap:attribute>
-                <ldap:name>ds-cfg-template-username</ldap:name>
-            </ldap:attribute>
-        </adm:profile>
-    </adm:property>
-    <!-- Authentication Algoritm -->
-    <adm:property name="template-auth-algorithm">
-        <adm:synopsis>
-            Specifies the type of Authentication algorithm that must be used for
-            SNMP V3 request for the specified user.
-        </adm:synopsis>
-        <adm:default-behavior>
-            <adm:defined>
-                <adm:value>usmhmacmd5authprotocol</adm:value>
-            </adm:defined>
-        </adm:default-behavior>
-        <adm:syntax>
-            <adm:enumeration>
-                <adm:value name="usmhmacmd5authprotocol">
-                    <adm:synopsis>
-                        usmHMACMD5AuthProtocol Authentication algorithm.
-                    </adm:synopsis>
-                </adm:value>
-                <adm:value name="usmhmacshaauthprotocol">
-                    <adm:synopsis>
-                        usmHMACSHAAuthProtocol Authentication algorithm.
-                    </adm:synopsis>
-                </adm:value>
-                <adm:value name="usmnoauthprotocol">
-                    <adm:synopsis>
-                        usmNoAuthProtocol Authentication algorithm.
-                    </adm:synopsis>
-                </adm:value>
-            </adm:enumeration>
-        </adm:syntax>
-        <adm:profile name="ldap">
-            <ldap:attribute>
-                <ldap:name>ds-cfg-template-auth-algorithm</ldap:name>
-            </ldap:attribute>
-        </adm:profile>
-    </adm:property>
-    <!-- Authentication key -->
-    <adm:property name="template-authkey">
-        <adm:synopsis>
-            Any text password or any hexadecimal key starting with 0x; for 
-            example, 0x0098768905AB67EFAA855A453B665B12, of size: 0 to 32 
-            inclusive for HMACMD5 or 0 to 40 inclusive for HMACSHA.
-        </adm:synopsis>
-        <adm:default-behavior>
-            <adm:defined>
-                <adm:value>password</adm:value>
-            </adm:defined>
-        </adm:default-behavior>
-        <adm:syntax>
-            <adm:string />
-        </adm:syntax>
-        <adm:profile name="ldap">
-            <ldap:attribute>
-                <ldap:name>ds-cfg-template-authkey</ldap:name>
-            </ldap:attribute>
-        </adm:profile>
-    </adm:property>
-    <!-- Privacy Algorithm -->
-    <adm:property name="template-priv-algorithm">
-        <adm:synopsis>
-            Specifies the type of Privacy algorithm that must be used for
-            SNMP V3 request for the specified user.
-        </adm:synopsis>
-        <adm:default-behavior>
-            <adm:defined>
-                <adm:value>usmdesprivprotocol</adm:value>
-            </adm:defined>
-        </adm:default-behavior>
-        <adm:syntax>
-            <adm:enumeration>
-                <adm:value name="usmdesprivprotocol">
-                    <adm:synopsis>
-                        usmDESPrivProtocol Privacy algorithm.
-                    </adm:synopsis>
-                </adm:value>
-                <adm:value name="usmnoprivprotocol">
-                    <adm:synopsis>
-                        usmNoPrivProtocol Privacy algorithm.
-                    </adm:synopsis>
-                </adm:value>
-            </adm:enumeration>
-        </adm:syntax>
-        <adm:profile name="ldap">
-            <ldap:attribute>
-                <ldap:name>ds-cfg-template-priv-algorithm</ldap:name>
-            </ldap:attribute>
-        </adm:profile>
-    </adm:property>
-    <!-- Privacy key -->
-    <adm:property name="template-privkey">
-        <adm:synopsis>
-            Any text password or any hexadecimal key starting with 0x; 
-            for example, 0x0098768905AB67EFAA855A453B665B12, of size: 0 to 32 
-            inclusive for HMACMD5 or 0 to 40 inclusive for HMACSHA.
-        </adm:synopsis>
-        <adm:default-behavior>
-            <adm:defined>
-                <adm:value>password</adm:value>
-            </adm:defined>
-        </adm:default-behavior>
-        <adm:syntax>
-            <adm:string />
-        </adm:syntax>
-        <adm:profile name="ldap">
-            <ldap:attribute>
-                <ldap:name>ds-cfg-template-privkey</ldap:name>
-            </ldap:attribute>
-        </adm:profile>
-    </adm:property>
+  
       <adm:property name="opendmk-jarfile">
         <adm:synopsis>
             Indicates the OpenDMK runtime jar file location
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ConfigFromFile.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ConfigFromFile.java
index 7f640d9..91e637f 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ConfigFromFile.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ConfigFromFile.java
@@ -73,6 +73,8 @@
     DirectoryServer.getObjectClass("ds-cfg-jmx-connection-handler", true);
   private final ObjectClass ldifConnectionHandlerOc =
     DirectoryServer.getObjectClass("ds-cfg-ldif-connection-handler", true);
+  private final ObjectClass snmpConnectionHandlerOc =
+    DirectoryServer.getObjectClass("ds-cfg-snmp-connection-handler", true);
   private final ObjectClass backendOc =
     DirectoryServer.getObjectClass("ds-cfg-backend", true);
   private final ObjectClass administrativeUserOc =
@@ -580,6 +582,22 @@
         state = ListenerDescriptor.State.DISABLED;
       }
     }
+    else if (entry.hasObjectClass(snmpConnectionHandlerOc))
+    {
+      addressPort = addressPort = "0.0.0.0:"+port;
+      protocol = ListenerDescriptor.Protocol.SNMP;
+      protocolDescription = INFO_SNMP_PROTOCOL_LABEL.get();
+      boolean enabled = "true".equalsIgnoreCase(
+          getFirstValue(entry, "ds-cfg-connection-handler-enabled"));
+      if (enabled)
+      {
+        state = ListenerDescriptor.State.ENABLED;
+      }
+      else
+      {
+        state = ListenerDescriptor.State.DISABLED;
+      }
+    }
     else
     {
       addressPort = INFO_UNKNOWN_LABEL.get().toString();
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ConfigFromLDAP.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ConfigFromLDAP.java
index 8187f02..4e3418d 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ConfigFromLDAP.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ConfigFromLDAP.java
@@ -915,6 +915,22 @@
         state = ListenerDescriptor.State.DISABLED;
       }
     }
+    else if (hasObjectClass(entry, "ds-cfg-snmp-connection-handler"))
+    {
+      addressPort = "0.0.0.0:"+port;
+      protocolDescription = INFO_SNMP_PROTOCOL_LABEL.get();
+      protocol = ListenerDescriptor.Protocol.SNMP;
+      boolean enabled = "true".equalsIgnoreCase(
+          getFirstValue(entry, "ds-cfg-enabled"));
+      if (enabled)
+      {
+        state = ListenerDescriptor.State.ENABLED;
+      }
+      else
+      {
+        state = ListenerDescriptor.State.DISABLED;
+      }
+    }
     else
     {
       addressPort = INFO_UNKNOWN_LABEL.get().toString();
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ListenerDescriptor.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ListenerDescriptor.java
index 36b1378..7a1c0e2 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ListenerDescriptor.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ListenerDescriptor.java
@@ -81,6 +81,10 @@
      */
     LDIF,
     /**
+     * SNMP protocol.
+     */
+    SNMP,
+    /**
      * Other protocol.
      */
     OTHER
diff --git a/opendj-sdk/opends/src/messages/messages/admin_tool.properties b/opendj-sdk/opends/src/messages/messages/admin_tool.properties
index b60723b..502408d 100644
--- a/opendj-sdk/opends/src/messages/messages/admin_tool.properties
+++ b/opendj-sdk/opends/src/messages/messages/admin_tool.properties
@@ -211,6 +211,7 @@
 INFO_LDAP_PROTOCOL_LABEL=LDAP
 INFO_LDAPS_PROTOCOL_LABEL=LDAPS
 INFO_LDIF_PROTOCOL_LABEL=LDIF
+INFO_SNMP_PROTOCOL_LABEL=SNMP
 INFO_LISTENERS_TITLE=Connection Handlers
 INFO_LOGIN_CANCEL_BUTTON_TOOLTIP=Close Login Dialog
 INFO_LOGIN_DIALOG_MSG=You must provide an Administrative User DN and password \
diff --git a/opendj-sdk/opends/src/snmp/src/org/opends/server/snmp/DIRECTORY_SERVER_MIBImpl.java b/opendj-sdk/opends/src/snmp/src/org/opends/server/snmp/DIRECTORY_SERVER_MIBImpl.java
index ed1818a..2cd7640 100644
--- a/opendj-sdk/opends/src/snmp/src/org/opends/server/snmp/DIRECTORY_SERVER_MIBImpl.java
+++ b/opendj-sdk/opends/src/snmp/src/org/opends/server/snmp/DIRECTORY_SERVER_MIBImpl.java
@@ -36,103 +36,104 @@
  */
 public class DIRECTORY_SERVER_MIBImpl extends DIRECTORY_SERVER_MIB {
 
-  /**
-   * The serial version identifier required to satisfy the compiler because
-   * this class implements the <CODE>java.io.Serializable</CODE> interface.
-   * This value was generated using the <CODE>serialver</CODE> command-line
-   * utility included with the Java SDK.
-   */
-  private static final long serialVersionUID = 1420660265781848102L;
-  /**
-   * The debug log tracer for this class.
-   */
-  private static final DebugTracer TRACER = DebugLogger.getTracer();
-  /**
-   * Indicates if the SNMP Mbeans have to be registered or not.
-   */
-  private boolean registeredSnmpMBean = false;
-  /**
-   * The Current Directory Server MIB.
-   */
-  private DsMIBImpl dsMib = null;
-  /**
-   * ObjectName of the Current Direcotry Server MIB.
-   */
-  private ObjectName mibObName;
-  /**
-   * ObjectName of the dsMIB group in the Directory Server MIB.
-   */
-  private ObjectName groupObjName;
+    /**
+     * The serial version identifier required to satisfy the compiler because
+     * this class implements the <CODE>java.io.Serializable</CODE> interface.
+     * This value was generated using the <CODE>serialver</CODE> command-line
+     * utility included with the Java SDK.
+     */
+    private static final long serialVersionUID = 1420660265781848102L;
+    /**
+     * The debug log tracer for this class.
+     */
+    private static final DebugTracer TRACER = DebugLogger.getTracer();
+    /**
+     * Indicates if the SNMP Mbeans have to be registered or not.
+     */
+    private boolean registeredSnmpMBean = false;
+    /**
+     * The Current Directory Server MIB.
+     */
+    private DsMIBImpl dsMibGroup = null;
+    /**
+     * ObjectName of the Current Direcotry Server MIB.
+     */
+    private ObjectName mibObName;
+    /**
+     * ObjectName of the dsMIB group in the Directory Server MIB.
+     */
+    private ObjectName groupObjName;
 
-  /**
-   * Creates the Current Directory Server MIB.
-   * @param registeredMBean indicates if the SNMP MBean has to register
-   * in the Direcotry Server MBeanServer
-   * @param mibName of the Directory Server MIB
-   */
-  public DIRECTORY_SERVER_MIBImpl(boolean registeredMBean, ObjectName mibName) {
-    super();
-    this.registeredSnmpMBean = registeredMBean;
-    this.mibObName = mibName;
-    if (DebugLogger.debugEnabled()) {
-      TRACER.debugVerbose("DIRECTORY_SERVER_MIB=" + this.mibObName +
-              " created with registerMBean=" + this.registeredSnmpMBean);
+    /**
+     * Creates the Current Directory Server MIB.
+     * @param registeredMBean indicates if the SNMP MBean has to register
+     * in the Direcotry Server MBeanServer
+     * @param mibName of the Directory Server MIB
+     */
+    public DIRECTORY_SERVER_MIBImpl(boolean registeredMBean,
+            ObjectName mibName) {
+        super();
+        this.registeredSnmpMBean = registeredMBean;
+        this.mibObName = mibName;
+        if (DebugLogger.debugEnabled()) {
+            TRACER.debugVerbose("DIRECTORY_SERVER_MIB=" + this.mibObName +
+                    " created with registerMBean=" + this.registeredSnmpMBean);
+        }
     }
-  }
 
-  /**
-   * {@inheritDoc}
-   * @throws java.lang.Exception if the DsMib Group couls not be initialized
-   */
-  @Override
-  protected void initDsMIB(MBeanServer server)
-          throws Exception {
+    /**
+     * {@inheritDoc}
+     * @throws java.lang.Exception if the DsMib Group couls not be initialized
+     */
+    @Override
+    protected void initDsMIB(MBeanServer server)
+            throws Exception {
 
-    final String oid = getGroupOid("DsMIB", "1.3.6.1.2.1.66");
-    if (server != null) {
-      groupObjName = new ObjectName(
-              SNMPConnectionHandlerDefinitions.SNMP_DOMAIN +
-              "type=group,name=DsMib");
+        final String oid = getGroupOid("DsMIB", "1.3.6.1.2.1.66");
+        if (server != null) {
+            groupObjName = new ObjectName(
+                    SNMPConnectionHandlerDefinitions.SNMP_DOMAIN +
+                    "type=group,name=DsMib");
+        }
+        final DsMIBMeta meta = createDsMIBMetaNode("DsMIB", oid, groupObjName,
+                server);
+        if (meta != null) {
+            meta.registerTableNodes(this, server);
+
+            // Note that when using standard metadata,
+            // the returned object must implement the "DsMIBMBean"
+            // interface.
+            //
+            final DsMIBMBean group = (DsMIBMBean) createDsMIBMBean("DsMIB", oid,
+                    groupObjName, server);
+            meta.setInstance(group);
+            registerGroupNode("DsMIB", oid, groupObjName, meta, group, server);
+        }
     }
-    final DsMIBMeta meta = createDsMIBMetaNode("DsMIB", oid, groupObjName,
-            server);
-    if (meta != null) {
-      meta.registerTableNodes(this, server);
 
-      // Note that when using standard metadata,
-      // the returned object must implement the "DsMIBMBean"
-      // interface.
-      //
-      final DsMIBMBean group = (DsMIBMBean) createDsMIBMBean("DsMIB", oid,
-              groupObjName, server);
-      meta.setInstance(group);
-      registerGroupNode("DsMIB", oid, groupObjName, meta, group, server);
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected Object createDsMIBMBean(String groupName,
+            String groupOid, ObjectName groupObjname, MBeanServer server) {
+        this.dsMibGroup = new DsMIBImpl(this, server, this.registeredSnmpMBean);
+        return this.dsMibGroup;
     }
-  }
 
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  protected Object createDsMIBMBean(String groupName,
-          String groupOid, ObjectName groupObjname, MBeanServer server) {
-    this.dsMib = new DsMIBImpl(this, server, this.registeredSnmpMBean);
-    return this.dsMib;
-  }
+    /**
+     * Returns the created dsMIB group.
+     * @return the DsMIBImpl
+     */
+    protected DsMIBImpl getMib() {
+        return this.dsMibGroup;
+    }
 
-  /**
-   * Returns the created dsMIB group.
-   * @return the DsMIBImpl
-   */
-  protected DsMIBImpl getMib() {
-    return this.dsMib;
-  }
-
-  /**
-   * Returns the ObjectName of the dsMIB group.
-   * @return the ObjectName of the created dsMIB group
-   */
-  protected ObjectName getObjectName() {
-    return this.groupObjName;
-  }
+    /**
+     * Returns the ObjectName of the dsMIB group.
+     * @return the ObjectName of the created dsMIB group
+     */
+    protected ObjectName getObjectName() {
+        return this.groupObjName;
+    }
 }
diff --git a/opendj-sdk/opends/src/snmp/src/org/opends/server/snmp/DsMIBImpl.java b/opendj-sdk/opends/src/snmp/src/org/opends/server/snmp/DsMIBImpl.java
index 9274588..dd1c92b 100644
--- a/opendj-sdk/opends/src/snmp/src/org/opends/server/snmp/DsMIBImpl.java
+++ b/opendj-sdk/opends/src/snmp/src/org/opends/server/snmp/DsMIBImpl.java
@@ -123,9 +123,6 @@
     this.dsTableEntries.clear();
     this.dsApplIfOpsTableEntries.clear();
     this.dsIntTableEntries.clear();
-    this.applIndex = 1;
-    this.applIfOpsIndex = 1;
-    this.intIndex = 1;
     // Initialize the MIB
     initDsTables();
 
diff --git a/opendj-sdk/opends/src/snmp/src/org/opends/server/snmp/SNMPClassLoaderProvider.java b/opendj-sdk/opends/src/snmp/src/org/opends/server/snmp/SNMPClassLoaderProvider.java
index 47b64a8..8c6dfe8 100644
--- a/opendj-sdk/opends/src/snmp/src/org/opends/server/snmp/SNMPClassLoaderProvider.java
+++ b/opendj-sdk/opends/src/snmp/src/org/opends/server/snmp/SNMPClassLoaderProvider.java
@@ -98,11 +98,6 @@
      */
     private int snmpTrapPort = 162;
 
-    /**
-     * Default SNMP Version.
-     */
-    private String snmpVersion =
-      SNMPConnectionHandlerDefinitions.SNMP_VERSION_V3;
 
     /**
      * Registration of the SNMP MBeans.
@@ -228,12 +223,6 @@
         this.snmpTrapPort = this.currentConfig.getTrapPort();
         this.registeredSNMPMBeans = this.currentConfig.isRegisteredMbean();
 
-        this.snmpVersion = this.currentConfig.getVersion().trim().toLowerCase();
-        if (!SNMPConnectionHandlerDefinitions.SUPPORTED_SNMP_VERSION.contains(
-                this.snmpVersion)) {
-            this.snmpVersion = SNMPConnectionHandlerDefinitions.SNMP_VERSION_V3;
-        }
-
         // Creates all the required objects for SNMP MIB 2605 Support
         try {
 
@@ -246,8 +235,7 @@
             this.snmpAdaptor = this.getSnmpAdaptor(this.currentConfig);
 
             // Create the Usm MIB to allow user management
-            if ((this.registeredSNMPMBeans) && (this.snmpVersion.equals(
-                    SNMPConnectionHandlerDefinitions.SNMP_VERSION_V3))) {
+            if (this.registeredSNMPMBeans) {
 
                 this.UsmObjName = new ObjectName(
                         SNMPConnectionHandlerDefinitions.SNMP_DOMAIN +
@@ -273,10 +261,10 @@
 
             this.dsMib = new DIRECTORY_SERVER_MIBImpl(
                     this.registeredSNMPMBeans, this.mibObjName);
+            this.dsMib.preRegister(this.server, this.mibObjName);
             this.dsMib.setSnmpAdaptor(snmpAdaptor);
 
             this.server.registerMBean(this.snmpAdaptor, snmpObjName);
-            this.server.registerMBean(this.dsMib, this.mibObjName);
 
         } catch (Exception ex) {
             if (debugEnabled()) {
@@ -310,11 +298,7 @@
             // Unregister the created SNMP MBeans
             if (this.registeredSNMPMBeans) {
                 this.unregisterSnmpMBeans();
-
-                if (this.snmpVersion.equals(
-                        SNMPConnectionHandlerDefinitions.SNMP_VERSION_V3)) {
-                    this.server.unregisterMBean(this.UsmObjName);
-                }
+                this.server.unregisterMBean(this.UsmObjName);
             }
         } catch (Exception ex) {
             if (debugEnabled()) {
@@ -345,13 +329,7 @@
             // Set the USM security file
             String usmConfigPath = configuration.getSecurityAgentFile();
             File file = StaticUtils.getFileForPath(usmConfigPath);
-
-            if (configuration.getVersion().toLowerCase().equals(
-                    SNMPConnectionHandlerDefinitions.SNMP_VERSION_V3)) {
-                System.setProperty("jdmk.security.file",
-                    file.getAbsolutePath());
-            }
-
+            System.setProperty("jdmk.security.file",file.getAbsolutePath());
             // Create the Security Parameters for the engine
             SnmpEngineParameters engineParameters = new SnmpEngineParameters();
 
diff --git a/opendj-sdk/opends/src/snmp/src/org/opends/server/snmp/SNMPInetAddressAcl.java b/opendj-sdk/opends/src/snmp/src/org/opends/server/snmp/SNMPInetAddressAcl.java
index 5cf9d0b..669d545 100644
--- a/opendj-sdk/opends/src/snmp/src/org/opends/server/snmp/SNMPInetAddressAcl.java
+++ b/opendj-sdk/opends/src/snmp/src/org/opends/server/snmp/SNMPInetAddressAcl.java
@@ -59,7 +59,7 @@
     private SortedSet<String> trapsDestinations;
     private String trapsCommunity;
 
-    private SortedSet<String> communitiesList;
+    private String communities;
 
 
     /**
@@ -68,6 +68,7 @@
      */
     public SNMPInetAddressAcl(SNMPConnectionHandlerCfg configuration) {
         super();
+        // Get the current configuration
         this.currentConfig = configuration;
 
         // hostsList
@@ -85,10 +86,12 @@
             }
         }
 
+        // Get the list of trap destinations
         this.trapsDestinations = this.currentConfig.getTrapsDestination();
-        this.communitiesList = this.currentConfig.getCommunity();
+        // Get the community string to accept
+        this.communities = this.currentConfig.getCommunity();
+        // Get the community string to set in the traps
         this.trapsCommunity = this.currentConfig.getTrapsCommunity();
-
     }
 
     /**
@@ -140,7 +143,7 @@
      * {@inheritDoc}
      */
     public boolean checkCommunity(String community) {
-        return this.communitiesList.contains(community);
+        return this.communities.equals(community);
     }
 
     /**
diff --git a/opendj-sdk/opends/src/snmp/src/org/opends/server/snmp/SNMPUserAcl.java b/opendj-sdk/opends/src/snmp/src/org/opends/server/snmp/SNMPUserAcl.java
index 2ed86a8..d51b9d0 100644
--- a/opendj-sdk/opends/src/snmp/src/org/opends/server/snmp/SNMPUserAcl.java
+++ b/opendj-sdk/opends/src/snmp/src/org/opends/server/snmp/SNMPUserAcl.java
@@ -48,6 +48,10 @@
      */
     private static final String ALL_USERS_ALLOWED = "*";
     /**
+     * Default User for cloning mechanism.
+     */
+    private static final String DEFAULT_USER = "defaultUser";
+    /**
      * Current Security Configuration for the SNMP Connection Handler.
      */
     private SNMPConnectionHandlerCfg currentConfig;
@@ -60,18 +64,13 @@
      */
     private SortedSet trapDestinations;
     /**
-     * Configured communities string.
+     * Configured context name.
      */
-    private SortedSet communityList;
+    private String contextName;
     /**
      * Configured Security level.
      */
     private SecurityLevel securityLevel;
-    /**
-     * User Name template - the only user getting the write access
-     * on the USM MIB . Allowed to add user clones
-     */
-    private String templateUsername;
 
     /**
      * {@inheritDoc}
@@ -81,15 +80,13 @@
         // Keep the configuration
         this.currentConfig = configuration;
         // Get the community/context string to accept
-        this.communityList = this.currentConfig.getCommunity();
+        this.contextName = this.currentConfig.getCommunity();
         // Get the list of allowed users (SNMPV3)
         this.usersList = this.currentConfig.getAllowedUser();
         // Get the traps destinations
         this.trapDestinations = this.currentConfig.getTrapsDestination();
         // Get the min security level to accept
         this.securityLevel = this.currentConfig.getSecurityLevel();
-        // Get the user name template allowed to add users in the USM MIB
-        this.templateUsername = this.currentConfig.getTemplateUsername();
     }
 
     /**
@@ -118,7 +115,7 @@
             int securityLevel) {
 
         // Special check for the defaultUser
-        if ((user.equals(this.templateUsername))
+        if ((user.equals(DEFAULT_USER))
             && (contextName.equals("null"))
             && ((this.securityLevel.ordinal() + 1) >= securityLevel)) {
             return true;
@@ -136,14 +133,14 @@
      * {@inheritDoc}
      */
     public boolean checkContextName(String contextName) {
-        return this.communityList.contains(contextName);
+        return this.contextName.equals(contextName);
     }
 
     /**
      * {@inheritDoc}
      */
     public boolean checkWritePermission(String user) {
-        if (user.equals(this.templateUsername)) {
+        if (user.equals(DEFAULT_USER)) {
             return true;
         }
         return false;

--
Gitblit v1.10.0