From a036cff9de96bad3f2b1131c2b4e311d13a3507d Mon Sep 17 00:00:00 2001
From: Christophe Sovant <christophe.sovant@forgerock.com>
Date: Sat, 31 May 2008 11:59:35 +0000
Subject: [PATCH] Update SNMP user list, enable encryption in the SNMP managers and  add news functions in snmp.xml

---
 opendj-sdk/opends/tests/functional-tests/shared/data/snmp/manager.security |    9 
 opendj-sdk/opends/tests/functional-tests/shared/data/snmp/agent.security   |    6 
 opendj-sdk/opends/tests/shared/java/snmp/SNMPSet.java                      |    5 
 opendj-sdk/opends/tests/shared/functions/snmp.xml                          |  445 +++++++++++++++++++++++++--------
 opendj-sdk/opends/tests/shared/java/snmp/SNMPGet.java                      |  279 +++++++++++++--------
 5 files changed, 523 insertions(+), 221 deletions(-)

diff --git a/opendj-sdk/opends/tests/functional-tests/shared/data/snmp/agent.security b/opendj-sdk/opends/tests/functional-tests/shared/data/snmp/agent.security
index 824c5c3..d85a592 100644
--- a/opendj-sdk/opends/tests/functional-tests/shared/data/snmp/agent.security
+++ b/opendj-sdk/opends/tests/functional-tests/shared/data/snmp/agent.security
@@ -44,8 +44,10 @@
 ## BEGIN: Test users ##
 #######################
 
-userEntry=localEngineID,myUser,,usmHMACMD5AuthProtocol,mypasswd
-userEntry=localEngineID,myUser2,,usmHMACMD5AuthProtocol,mypasswd2
+userEntry=localEngineID,myUser1,,usmNoAuthProtocol
+userEntry=localEngineID,myUser2,,usmHMACMD5AuthProtocol,mypasswd
+userEntry=localEngineID,myUser3,,usmHMACMD5AuthProtocol,mypasswd,usmDESPrivProtocol,mypasswd
+userEntry=localEngineID,myUser4,,usmHMACMD5AuthProtocol,mypasswd2
 
 #######################
 ## END: Test users   ##
diff --git a/opendj-sdk/opends/tests/functional-tests/shared/data/snmp/manager.security b/opendj-sdk/opends/tests/functional-tests/shared/data/snmp/manager.security
index 9760790..cb81071 100644
--- a/opendj-sdk/opends/tests/functional-tests/shared/data/snmp/manager.security
+++ b/opendj-sdk/opends/tests/functional-tests/shared/data/snmp/manager.security
@@ -31,6 +31,9 @@
 
 # User and security configuration
 userEntry=0x8000002a017f000001000000a1,snmpAdmin,null,usmHMACMD5AuthProtocol,passadmin
-userEntry=0x8000002a017f000001000000a1,defaultUser,,usmHMACMD5AuthProtocol,password
-userEntry=0x8000002a017f000001000000a1,myUser,,usmHMACMD5AuthProtocol,mypasswd
-userEntry=0x8000002a017f000001000000a1,myUser2,,usmHMACMD5AuthProtocol,mypasswd2
+userEntry=0x8000002a017f000001000000a1,defaultUser,,usmHMACMD5AuthProtocol,password,,,3,true
+
+userEntry=0x8000002a017f000001000000a1,myUser1,,usmNoAuthProtocol
+userEntry=0x8000002a017f000001000000a1,myUser2,,usmHMACMD5AuthProtocol,mypasswd
+userEntry=0x8000002a017f000001000000a1,myUser3,,usmHMACMD5AuthProtocol,mypasswd,usmDESPrivProtocol,mypasswd
+userEntry=0x8000002a017f000001000000a1,myUser4,,usmHMACMD5AuthProtocol,mypasswd2
diff --git a/opendj-sdk/opends/tests/shared/functions/snmp.xml b/opendj-sdk/opends/tests/shared/functions/snmp.xml
index bb7000b..d044dba 100755
--- a/opendj-sdk/opends/tests/shared/functions/snmp.xml
+++ b/opendj-sdk/opends/tests/shared/functions/snmp.xml
@@ -57,48 +57,54 @@
       <function-arg-def name="snmpPort" type="required">
         <function-arg-description>
           Directory server SNMP port number
-        </function-arg-description>      
+        </function-arg-description>
         <function-arg-property name="type" value="Port number"/>
       </function-arg-def>
       <function-arg-def name="snmpOIDs" type="optional">
         <function-arg-description>
-          Bind password
+          SNMP OID to query
         </function-arg-description>
         <function-arg-property name="type" value="string"/>
-      </function-arg-def>      
+      </function-arg-def>
       <function-arg-def name="snmpCommunity" type="required">
         <function-arg-description>
-          Bind DN
+          SNMP community/context
         </function-arg-description>
-        <function-arg-property name="type" value="DN"/>
+        <function-arg-property name="type" value="string"/>
       </function-arg-def>
       <function-arg-def name="snmpUser" type="optional">
         <function-arg-description>
-          Bind DN
+          SNMP user used for v3 requests
         </function-arg-description>
-        <function-arg-property name="type" value="DN"/>
+        <function-arg-property name="type" value="string"/>
       </function-arg-def>
       <function-arg-def name="snmpSecurityLevel" type="optional">
         <function-arg-description>
-          Bind DN
+          SNMP security level used for v3 requests
         </function-arg-description>
-        <function-arg-property name="type" value="DN"/>
-      </function-arg-def>      
+        <function-arg-property name="type" value="string"/>
+      </function-arg-def>
       <function-arg-def name="snmpSecurityFile" type="optional">
         <function-arg-description>
-          Bind password
+          Path to the SNMP security file
         </function-arg-description>
         <function-arg-property name="type" value="string"/>
       </function-arg-def>
       <function-arg-def name="snmpStatus" type="required">
         <function-arg-description>
-          Bind password
+          Expected status of the SNMP request
         </function-arg-description>
         <function-arg-property name="type" value="string"/>
       </function-arg-def>
       <function-arg-def name="snmpValidOIDs" type="optional">
         <function-arg-description>
-          Bind password
+          Check if the values returned for the OIDs are correct
+        </function-arg-description>
+        <function-arg-property name="type" value="string"/>
+      </function-arg-def>
+      <function-arg-def name="snmpWalk" type="optional">
+        <function-arg-description>
+          Perform a walk request
         </function-arg-description>
         <function-arg-property name="type" value="string"/>
       </function-arg-def>
@@ -107,70 +113,79 @@
           Expected return code value. Default value is 0
           Wildcard 'noCheck' to not check the RC
         </function-arg-description>
-        <function-arg-property name="type" value="integer"/>      
+        <function-arg-property name="type" value="integer"/>
       </function-arg-def>
     </function-map-args>
-    
+
     <sequence>
       <!-- Build the command -->
       <script>
         STAFCmdParamsList=[]
         STAFCmdParams=''
-        
+
         if snmpVersion:
-          STAFCmdParamsList.append('-v %s' % snmpVersion)          
-        
-        if snmpHost:          
+          STAFCmdParamsList.append('-v %s' % snmpVersion)
+
+        if snmpHost:
           STAFCmdParamsList.append('-h %s' % snmpHost)
-        
+
         if snmpPort:
           STAFCmdParamsList.append('-p %s' % snmpPort)
-          
+
         if snmpOIDs:
           STAFCmdParamsList.append('-o %s' % snmpOIDs)
-        
+
         if snmpCommunity:
-          STAFCmdParamsList.append('-c %s' % snmpCommunity)          
-          
+          STAFCmdParamsList.append('-c %s' % snmpCommunity)
+
         if snmpUser:
           STAFCmdParamsList.append('-u %s' % snmpUser)
 
         if snmpSecurityLevel:
-          STAFCmdParamsList.append('-l %s' % snmpSecurityLevel)  
-          
+          STAFCmdParamsList.append('-l %s' % snmpSecurityLevel)
+
         if snmpSecurityFile:
           STAFCmdParamsList.append('-f %s' % snmpSecurityFile)
-        
+
         if snmpStatus:
           STAFCmdParamsList.append('-s %s' % snmpStatus)
-        
+
         if snmpValidOIDs:
           STAFCmdParamsList.append('-n %s' % snmpValidOIDs)
-        
+
+        if snmpWalk:
+          STAFCmdParamsList.append('-w %s' % snmpWalk)
+
         STAFCmdParams=' '.join(STAFCmdParamsList)
-        
+
         STAFCmd='SNMPGet'
-        
+
         if is_windows_platform(location):
           separator=';'
         else:
           separator=':'
-        
+
         opends_jarfile='%s/%s' % (DIRECTORY_INSTANCE_DIR,SNMP_OPENDS_JARFILE)
         snmpPath='%s/%s/snmp' % (DIRECTORY_INSTANCE_DIR, relativeJavaDir)
         jdmk_jarfile='%s/jdmkrt.jar' % snmpPath
-        cp = 'CLASSPATH=%s%s%s%s.' \
-        % (opends_jarfile,separator,jdmk_jarfile,separator)
-        
-        env = ['JAVA_HOME=%s' % JAVA_HOME, '%s' % cp] 
+
+        emma_jarfile='%s/%s/lib/emma.jar' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME)
+        if os.path.exists(emma_jarfile):
+          cp = 'CLASSPATH=%s%s%s%s%s%s.' \
+          % (opends_jarfile,separator,jdmk_jarfile,separator,emma_jarfile,separator)
+        else:
+          cp = 'CLASSPATH=%s%s%s%s.' \
+          % (opends_jarfile,separator,jdmk_jarfile,separator)
+
+        env = ['JAVA_HOME=%s' % JAVA_HOME, '%s' % cp]
       </script>
-      
+
       <message>
         '%s %s' % (STAFCmd, STAFCmdParams)
       </message>
-      
+
       <call function="'runCommand'" >
-        { 
+        {
         'name'       : 'SNMP Get' ,
         'command'    : '%s/bin/java' % JAVA_HOME ,
         'arguments'  : '%s %s' % (STAFCmd, STAFCmdParams) ,
@@ -180,11 +195,11 @@
         'expectedRC' : expectedRC
         }
       </call>
-      
+
       <return>
         STAXResult
       </return>
-      
+
     </sequence>
   </function>
 
@@ -219,48 +234,48 @@
       <function-arg-def name="snmpPort" type="required">
         <function-arg-description>
           Directory server SNMP port number
-        </function-arg-description>      
+        </function-arg-description>
         <function-arg-property name="type" value="Port number"/>
-      </function-arg-def>  
+      </function-arg-def>
       <function-arg-def name="snmpOIDs" type="optional">
         <function-arg-description>
-          Bind password
+          SNMP OID to query
         </function-arg-description>
         <function-arg-property name="type" value="string"/>
       </function-arg-def>
       <function-arg-def name="snmpCommunity" type="required">
         <function-arg-description>
-          Bind DN
+          SNMP community/context
         </function-arg-description>
-        <function-arg-property name="type" value="DN"/>
+        <function-arg-property name="type" value="string"/>
       </function-arg-def>
       <function-arg-def name="snmpUser" type="optional">
         <function-arg-description>
-          Bind DN
+          SNMP user used for v3 requests
         </function-arg-description>
-        <function-arg-property name="type" value="DN"/>
+        <function-arg-property name="type" value="string"/>
       </function-arg-def>
       <function-arg-def name="snmpSecurityLevel" type="optional">
         <function-arg-description>
-          Bind DN
+          SNMP security level used for v3 requests
         </function-arg-description>
-        <function-arg-property name="type" value="DN"/>
-      </function-arg-def>  
+        <function-arg-property name="type" value="string"/>
+      </function-arg-def>
       <function-arg-def name="snmpSecurityFile" type="optional">
         <function-arg-description>
-          Bind password
+          Path to the SNMP security file
         </function-arg-description>
         <function-arg-property name="type" value="string"/>
       </function-arg-def>
       <function-arg-def name="snmpStatus" type="required">
         <function-arg-description>
-          Bind password
+          Expected status of the SNMP request
         </function-arg-description>
         <function-arg-property name="type" value="string"/>
       </function-arg-def>
       <function-arg-def name="snmpValidOIDs" type="optional">
         <function-arg-description>
-          Bind password
+          Check if the values returned for the OIDs are correct
         </function-arg-description>
         <function-arg-property name="type" value="string"/>
       </function-arg-def>
@@ -269,28 +284,28 @@
           Expected return code value. Default value is 0
           Wildcard 'noCheck' to not check the RC
         </function-arg-description>
-        <function-arg-property name="type" value="integer"/>      
+        <function-arg-property name="type" value="integer"/>
       </function-arg-def>
     </function-map-args>
-    
+
     <sequence>
       <!-- Build the command -->
       <script>
         STAFCmdParamsList=[]
         STAFCmdParams=''
-        
+
         if snmpVersion:
-          STAFCmdParamsList.append('-v %s' % snmpVersion)          
-        
-        if snmpHost:          
+          STAFCmdParamsList.append('-v %s' % snmpVersion)
+
+        if snmpHost:
           STAFCmdParamsList.append('-h %s' % snmpHost)
-        
+
         if snmpPort:
           STAFCmdParamsList.append('-p %s' % snmpPort)
 
         if snmpOIDs:
           STAFCmdParamsList.append('-o %s' % snmpOIDs)
-          
+
         if snmpCommunity:
           STAFCmdParamsList.append('-c %s' % snmpCommunity)
 
@@ -298,41 +313,47 @@
           STAFCmdParamsList.append('-u %s' % snmpUser)
 
         if snmpSecurityLevel:
-          STAFCmdParamsList.append('-l %s' % snmpSecurityLevel)  
-          
+          STAFCmdParamsList.append('-l %s' % snmpSecurityLevel)
+
         if snmpSecurityFile:
-          STAFCmdParamsList.append('-f %s' % snmpSecurityFile)  
-        
+          STAFCmdParamsList.append('-f %s' % snmpSecurityFile)
+
         if snmpStatus:
           STAFCmdParamsList.append('-s %s' % snmpStatus)
-        
+
         if snmpValidOIDs:
           STAFCmdParamsList.append('-n %s' % snmpValidOIDs)
-        
+
         STAFCmdParams=' '.join(STAFCmdParamsList)
-        
+
         STAFCmd='SNMPSet'
-        
+
         if is_windows_platform(location):
           separator=';'
         else:
           separator=':'
-          
+
         opends_jarfile='%s/%s' % (DIRECTORY_INSTANCE_DIR,SNMP_OPENDS_JARFILE)
         snmpPath='%s/%s/snmp' % (DIRECTORY_INSTANCE_DIR, relativeJavaDir)
         jdmk_jarfile='%s/jdmkrt.jar' % snmpPath
-        cp = 'CLASSPATH=%s%s%s%s.' \
-        % (opends_jarfile,separator,jdmk_jarfile,separator)
-        
-        env = ['JAVA_HOME=%s' % JAVA_HOME, '%s' % cp] 
+
+        emma_jarfile='%s/%s/lib/emma.jar' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME)
+        if os.path.exists(emma_jarfile):
+          cp = 'CLASSPATH=%s%s%s%s%s%s.' \
+          % (opends_jarfile,separator,jdmk_jarfile,separator,emma_jarfile,separator)
+        else:
+          cp = 'CLASSPATH=%s%s%s%s.' \
+          % (opends_jarfile,separator,jdmk_jarfile,separator)
+
+        env = ['JAVA_HOME=%s' % JAVA_HOME, '%s' % cp]
       </script>
-      
+
       <message>
         '%s %s' % (STAFCmd, STAFCmdParams)
       </message>
-      
+
       <call function="'runCommand'" >
-        { 
+        {
         'name'       : 'SNMP Set' ,
         'command'    : '%s/bin/java' % JAVA_HOME ,
         'arguments'  : '%s %s' % (STAFCmd, STAFCmdParams) ,
@@ -342,11 +363,11 @@
         'expectedRC' : expectedRC
         }
       </call>
-      
+
       <return>
         STAXResult
       </return>
-      
+
     </sequence>
   </function>
 
@@ -367,24 +388,24 @@
       <function-arg-def name="snmpHost" type="required">
         <function-arg-description>
           Directory server SNMP port number
-        </function-arg-description>      
+        </function-arg-description>
         <function-arg-property name="type" value="hostname"/>
-      </function-arg-def>        
+      </function-arg-def>
       <function-arg-def name="snmpTrapPort" type="required">
         <function-arg-description>
           Directory server SNMP port number
-        </function-arg-description>      
+        </function-arg-description>
         <function-arg-property name="type" value="Port number"/>
-      </function-arg-def>  
+      </function-arg-def>
       <function-arg-def name="snmpTrapCommunity" type="required">
         <function-arg-description>
-          Bind DN
+          SNMP trap community
         </function-arg-description>
-        <function-arg-property name="type" value="DN"/>
-      </function-arg-def>  
+        <function-arg-property name="type" value="string"/>
+      </function-arg-def>
       <function-arg-def name="snmpTrapNumber" type="required">
         <function-arg-description>
-          Bind password
+          Number of expected traps
         </function-arg-description>
         <function-arg-property name="type" value="string"/>
       </function-arg-def>
@@ -393,61 +414,61 @@
           Expected return code value. Default value is 0
           Wildcard 'noCheck' to not check the RC
         </function-arg-description>
-        <function-arg-property name="type" value="integer"/>      
+        <function-arg-property name="type" value="integer"/>
       </function-arg-def>
     </function-map-args>
-    
+
     <sequence>
       <call function="'ResolveVar'" >
-        { 
+        {
         'location' : location ,
         'type'     : 'STRING',
         'name'     : 'STAF/Config/STAFRoot'
         }
-      </call>                                                       
-      <script>jstaf_jarfile = '%s/lib/JSTAF.jar' % STAFResult</script> 
-      
+      </call>
+      <script>jstaf_jarfile = '%s/lib/JSTAF.jar' % STAFResult</script>
+
       <!-- Build the command -->
       <script>
         STAFCmdParamsList=[]
         STAFCmdParams=''
-        
+
         if snmpHost:
-          STAFCmdParamsList.append('-h %s' % snmpHost)          
-        
+          STAFCmdParamsList.append('-h %s' % snmpHost)
+
         if snmpTrapPort:
           STAFCmdParamsList.append('-p %s' % snmpTrapPort)
-          
+
         if snmpTrapCommunity:
           STAFCmdParamsList.append('-c %s' % snmpTrapCommunity)
-          
+
         if snmpTrapNumber:
           STAFCmdParamsList.append('-t %s' % snmpTrapNumber)
-          
+
         STAFCmdParams=' '.join(STAFCmdParamsList)
-        
+
         STAFCmd='SNMPTrapListener'
-        
+
         if is_windows_platform(location):
           separator=';'
         else:
           separator=':'
-          
+
         opends_jarfile='%s/%s' % (DIRECTORY_INSTANCE_DIR,SNMP_OPENDS_JARFILE)
         snmpPath='%s/%s/snmp' % (DIRECTORY_INSTANCE_DIR, relativeJavaDir)
         jdmk_jarfile='%s/jdmkrt.jar' % snmpPath
         cp = 'CLASSPATH=%s%s%s%s%s%s.' \
         % (opends_jarfile,separator,jdmk_jarfile,separator,jstaf_jarfile,separator)
-        
-        env = ['JAVA_HOME=%s' % JAVA_HOME, '%s' % cp] 
+
+        env = ['JAVA_HOME=%s' % JAVA_HOME, '%s' % cp]
       </script>
-      
+
       <message>
         '%s %s' % (STAFCmd, STAFCmdParams)
       </message>
-      
+
       <call function="'runCommand'" >
-        { 
+        {
         'name'       : 'SNMP Trap Listener' ,
         'command'    : '%s/bin/java' % JAVA_HOME ,
         'arguments'  : '%s %s' % (STAFCmd, STAFCmdParams) ,
@@ -457,11 +478,215 @@
         'expectedRC' : expectedRC
         }
       </call>
-      
+
       <return>
         STAXResult
       </return>
-      
+
     </sequence>
   </function>
+
+  <!-- Restart SNMP Connection Handler -->
+  <function name="restartSNMPConnectionHandler" scope="local">
+    <function-prolog>
+      This function restart the SNMP Connection Handler using dsconfig
+    </function-prolog>
+    <function-map-args>
+      <function-arg-def name="location"
+                        type="optional"
+                        default="STAF_REMOTE_HOSTNAME">
+        <function-arg-description>
+          Location of target host
+        </function-arg-description>
+        <function-arg-property name="type" value="hostname" />
+      </function-arg-def>
+      <function-arg-def name="dsPath"
+                        type="optional"
+                        default="'%s/%s' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME)">
+        <function-arg-description>
+          Pathname to installation root
+        </function-arg-description>
+        <function-arg-property name="type" value="filepath" />
+      </function-arg-def>
+      <function-arg-def name="dsInstanceHost"
+                        type="optional"
+                        default="STAF_REMOTE_HOSTNAME">
+        <function-arg-description>
+          Directory server hostname or IP address
+        </function-arg-description>
+        <function-arg-property name="type" value="hostname" />
+      </function-arg-def>
+      <function-arg-def name="dsInstancePort" type="required">
+        <function-arg-description>
+          Directory server port number
+        </function-arg-description>
+        <function-arg-property name="type" value="Port number" />
+      </function-arg-def>
+
+      <function-arg-def name="dsInstanceDn" type="required">
+        <function-arg-description>
+          Bind DN
+        </function-arg-description>
+        <function-arg-property name="type" value="DN" />
+      </function-arg-def>
+      <function-arg-def name="dsInstancePswd" type="required">
+        <function-arg-description>
+          Bind password
+        </function-arg-description>
+        <function-arg-property name="type" value="string" />
+      </function-arg-def>
+      <function-arg-def name="expectedRC" type="optional" default="0">
+        <function-arg-description>
+          Expected return code value. Default value is 0.
+          Wildcard 'noCheck' to not check the RC
+        </function-arg-description>
+        <function-arg-property name="type" value="string" />
+      </function-arg-def>
+    </function-map-args>
+
+    <sequence>
+      <!-- Build the command -->
+      <script>
+        STAFCmdParamsList=[]
+        STAFCmdParams=''
+
+        if dsPath:
+          dsBinPath='%s/%s' % (dsPath,fileFolder)
+
+        if dsInstanceHost:
+          STAFCmdParamsList.append('-h %s' % dsInstanceHost)
+
+        if dsInstancePort:
+          STAFCmdParamsList.append('-p %s' % dsInstancePort)
+
+        if dsInstanceDn:
+          STAFCmdParamsList.append('-D "%s"' % dsInstanceDn)
+
+        if dsInstancePswd:
+          STAFCmdParamsList.append('-w "%s"' % dsInstancePswd)
+
+        STAFCmdParamsList.append('-n')
+
+        STAFCmdParamsList.append('set-connection-handler-prop')
+        STAFCmdParamsList.append('--handler-name "SNMP Connection Handler"')
+
+        STAFCmdParams=' '.join(STAFCmdParamsList)
+
+        STAFCmd='%s/%s%s' % (dsBinPath,DSCONFIG,fileExt)
+      </script>
+
+      <call function="'runCommand'">
+        {
+        'name'      : 'Disable the SNMP Connection Handler' ,
+        'location'  : location ,
+        'command'   : STAFCmd ,
+        'arguments' : '%s --set enabled:false' % STAFCmdParams ,
+        'expectedRC': expectedRC
+        }
+      </call>
+
+      <call function="'runCommand'">
+        {
+        'name'      : 'Enable the SNMP Connection Handler' ,
+        'location'  : location ,
+        'command'   : STAFCmd ,
+        'arguments' : '%s --set enabled:true' % STAFCmdParams ,
+        'expectedRC': expectedRC
+        }
+      </call>
+
+      <return>
+        STAXResult
+      </return>
+
+    </sequence>
+  </function>
+
+  <!-- Compare SNMP values -->
+  <function name="compareSNMPValues" scope="local">
+    <function-prolog>
+      This function compare SNMP Values
+    </function-prolog>
+    <function-map-args>
+      <function-arg-def name="location"
+                        type="optional"
+                        default="STAF_REMOTE_HOSTNAME">
+        <function-arg-description>
+          Location of target host
+        </function-arg-description>
+        <function-arg-property name="type" value="hostname" />
+      </function-arg-def>
+      <function-arg-def name="snmpHost"
+                        type="optional"
+                        default="STAF_REMOTE_HOSTNAME">
+        <function-arg-description>
+          Directory server hostname or IP address
+        </function-arg-description>
+        <function-arg-property name="type" value="hostname" />
+      </function-arg-def>
+      <function-arg-def name="snmpPort" type="required">
+        <function-arg-description>
+          Directory server SNMP port number
+        </function-arg-description>
+        <function-arg-property name="type" value="Port number"/>
+      </function-arg-def>
+      <function-arg-def name="snmpCommunity" type="required">
+        <function-arg-description>
+          SNMP community/context
+        </function-arg-description>
+        <function-arg-property name="type" value="string"/>
+      </function-arg-def>
+      <function-arg-def name="expectedRC" type="optional" default="0">
+        <function-arg-description>
+          Expected return code value. Default value is 0
+          Wildcard 'noCheck' to not check the RC
+        </function-arg-description>
+        <function-arg-property name="type" value="integer"/>
+      </function-arg-def>
+    </function-map-args>
+    
+    <sequence>
+      <message>
+        'get the current mib values'
+      </message>
+
+      <call function="'SNMPGet'">
+        {
+        'location'      : location ,
+        'snmpVersion'   : '1',
+        'snmpHost'      : snmpHost ,
+        'snmpPort'      : snmpPort ,
+        'snmpCommunity' : snmpCommunity ,
+        'snmpOIDs'      : '' ,
+        'snmpStatus'    : 'noError' ,
+        'snmpWalk'      : 'True' ,
+        'expectedRC'    : expectedRC
+        }
+      </call>
+
+      <script>
+        CURRENT_VALUES = {}
+        CURRENT_VALUES = create_table_fromoutput(STAXResult[0][1])
+
+        result = compare_snmp_values(DEFAULT_VALUES, CURRENT_VALUES)
+      </script>
+
+      <message>
+        'result: %s' % result
+      </message>
+
+      <call function="'checktestStringNotPresent'">
+        {
+        'returnString' : result ,
+        'testString'   : 'ERROR'
+        }
+      </call>
+
+      <return>
+        STAXResult
+      </return>
+
+    </sequence>
+  </function>
+
 </stax>
diff --git a/opendj-sdk/opends/tests/shared/java/snmp/SNMPGet.java b/opendj-sdk/opends/tests/shared/java/snmp/SNMPGet.java
index 6f29ccf..893d0d7 100644
--- a/opendj-sdk/opends/tests/shared/java/snmp/SNMPGet.java
+++ b/opendj-sdk/opends/tests/shared/java/snmp/SNMPGet.java
@@ -73,7 +73,8 @@
               " -l <securityLevel>" +
               " -f <securityFile>" +
               " -s <connectionStatus>" +
-              " -n <checkOIDs>");
+              " -n <checkOIDs>" +
+              " -w <snmpwalk>");
       rc = 1;
     } else {
       for (int i = 0; i < args.length; i++) {
@@ -121,6 +122,9 @@
           case 'n':
             validOIDs = new Boolean(val).booleanValue();
             break;
+          case 'w':
+            walk = new Boolean(val).booleanValue();
+            break;
           default:
             System.out.println("Unknown option -" + opt.charAt(1) + ".");
             rc = 1;
@@ -207,6 +211,11 @@
           // Custom engine parameters
           final SnmpEngineParameters engineParameters =
                   new SnmpEngineParameters();
+
+          // Activate encryption
+          engineParameters.activateEncryption();
+
+          // Set the security file
           engineParameters.setSecurityFile(securityFile);
 
           // Create the session
@@ -257,30 +266,32 @@
           agentV3.setMaxTries(maxRetries);
           agentV3.setParams(paramsV3);
 
-          // Discover timeliness of creation and boot
-          //
-         try {
-            agentV3.processUsmTimelinessDiscovery();
-         } catch (SnmpStatusException e) {
-           if (connectStatus.compareTo("SnmpStatusException") == 0) {
-             System.out.println(
-                     "connect() of SNMPGet catched as expected a " +
-                     "SNMP status exception: " + e.getMessage() + "\"");
-           } else {
-             System.out.println(
-                     "connect() of SNMPGet should not catch a " +
-                     "SNMP status exception: " + e.getMessage() + "\"");
+          if (securityLevel != SnmpDefinitions.noAuthNoPriv) {
+            // Discover timeliness of creation and boot
+            //
+            try {
+              agentV3.processUsmTimelinessDiscovery();
+            } catch (SnmpStatusException e) {
+              if (connectStatus.compareTo("SnmpStatusException") == 0) {
+                System.out.println(
+                        "connect() of SNMPGet catched as expected a " +
+                        "SNMP status exception: " + e.getMessage() + "\"");
+              } else {
+                System.out.println(
+                        "connect() of SNMPGet should not catch a " +
+                        "SNMP status exception: " + e.getMessage() + "\"");
+                
+                rc = 1;
+              }
+            } catch (Exception e) {
+              System.out.println(
+                      "connect() of SNMPGet catched an unexpected exception: " +
+                      e.getMessage() + "\"");
 
-             rc = 1;
-           }
-          } catch (Exception e) {
-            System.out.println(
-                    "connect() of SNMPGet catched an unexpected exception: " +
-                    e.getMessage() + "\"");
-
-            rc = 1;
+              rc = 1;
+            }
           }
-
+          
           if (rc == 0) {
             // Set the default peer (agent) to a SnmpSession
             //
@@ -318,15 +329,25 @@
    */
   public int getRequest() {
     int rc = 0;
+    String previousOID = "";
 
     try {
       // Build the list of variables you want to query
       //
       final SnmpVarBindList list = new SnmpVarBindList("Get varbind list");
 
-      // Read all TEST-MIB variables.
+      // Read specific OIDs
       //
-      list.addVarBind(oids);
+      if (walk) {
+        // Walk request
+        //
+         list.addVarBind("0.0");
+         previousOID = "0.0";
+      } else {
+        // Get request
+        //
+        list.addVarBind(oids);
+      }
 
       // Make the SNMP get request
       //
@@ -335,103 +356,148 @@
               " GET request for SNMP agent on \"" + remoteHost +
               "\" at port \"" + port + "\".");
 
-      // Get request
-      //
-      SnmpRequest request = session.snmpGetRequest(null, list);
-
-      // Check for a timeout of the request
-      //
-      boolean completed = request.waitForCompletion((maxRetries + 1) * timeOut);
-      if (completed == false) {
-        System.out.println(
-                "getRequest() of SNMPGet: Request timed out, " +
-                "check reachability of agent.");
-
-        // Print request
-        //
-        System.out.println(
-                "getRequest() of SNMPGet: Request= " +
-                request.toString() + ".");
-
-        rc = 1;
-      }
-
-      if (rc == 0) {
-        System.out.println(
-                "getRequest() of SNMPGet: Finish SNMP V" +
-                version + " GET request.");
-
-        // Now we have a response. Check if the response contains an error
-        //
-        String errorStatus = SnmpRequest.snmpErrorToString(
-                request.getErrorStatus());
-        if (errorStatus.compareTo("noError") != 0) {
-          System.out.println(
-                  "getRequest() of SNMPGet: Error status= " +
-                  errorStatus + ".");
-
-          System.out.println(
-                  "getRequest() of SNMPGet: Error index= " +
-                  request.getErrorIndex() + ".");
-
-          if (errorStatus.compareTo(connectStatus) == 0) {
-            System.out.println(
-                    "getRequest() of SNMPGet: Get request failed as " +
-                    "expected with " + connectStatus + " status.");
-          } else {
-            System.out.println(
-                    "getRequest() of SNMPGet: Get request should " +
-                    "fail with " + connectStatus + " status.");
-
-            rc = 1;
-          }
-        } else {
-          // Now we shall display the content of the result
+      while (previousOID.compareTo("end") != 0) {
+        SnmpRequest request = null;
+        if (walk) {
+          // Walk request
           //
-          SnmpVarBindList resp = request.getResponseVarBindList();
+          request = session.snmpGetNextRequest(null, list);
+        } else {
+          // Get request
+          //
+          request = session.snmpGetRequest(null, list);
+        }
 
-          System.out.println("getRequest() of SNMPGet: Result=");
+        // Check for a timeout of the request
+        //
+        boolean completed =
+                request.waitForCompletion((maxRetries + 1) * timeOut);
+        if (completed == false) {
+          if (connectStatus.compareTo("reqTimeout") != 0) {
+            System.out.println(
+                    "getRequest() of SNMPGet: Request timed out, " +
+                    "check reachability of agent.");
 
-          for (int i = 0; i < resp.getVarBindCount(); i++) {
-            System.out.println(resp.getVarBindAt(i));
-          }
-
-          if (connectStatus.compareTo("noError") != 0) {
-            // Request should failed
+            // Print request
             //
             System.out.println(
-                    "getRequest() of SNMPGet: Get request should " +
-                    "fail with " + connectStatus + " status.");
+                    "getRequest() of SNMPGet: Request= " +
+                    request.toString() + ".");
 
             rc = 1;
           } else {
-            if (validOIDs) {
-              // Check that we obtain correct values for the OIDs
-              //
-              if (resp.checkForValidValues()) {
+            System.out.println(
+                    "getRequest() of SNMPGet: Request timed out as expected.");
+          }
+        }
+
+        if (rc == 0 && completed) {
+          System.out.println(
+                  "getRequest() of SNMPGet: Finish SNMP V" +
+                  version + " GET request.");
+
+          // Now we have a response. Check if the response contains an error
+          //
+          String errorStatus = SnmpRequest.snmpErrorToString(
+                  request.getErrorStatus());
+          if (errorStatus.compareTo("noError") != 0) {
+            System.out.println(
+                    "getRequest() of SNMPGet: Error status= " +
+                    errorStatus + ".");
+
+            System.out.println(
+                    "getRequest() of SNMPGet: Error index= " +
+                    request.getErrorIndex() + ".");
+
+            if (errorStatus.compareTo(connectStatus) == 0) {
+              System.out.println(
+                      "getRequest() of SNMPGet: Get request failed as " +
+                      "expected with " + connectStatus + " status.");
+            } else {
+              if (walk && errorStatus.compareTo("noSuchName") == 0) {
                 System.out.println(
-                        "getRequest() of SNMPGet: Returned values for" +
-                        " OIDs are correct.");
+                        "getRequest() of SNMPGet: Get request failed as " +
+                        "expected with " + connectStatus + " status.");
               } else {
                 System.out.println(
-                        "getRequest() of SNMPGet: Returned values for" +
-                        " OIDs are not correct.");
+                        "getRequest() of SNMPGet: Get request should " +
+                        "fail with " + connectStatus + " status.");
 
                 rc = 1;
               }
-            } else {
-              // Check that we obtain incorrect values for the OIDs
-              //
-              if (resp.checkForValidValues()) {
-                System.out.println(
-                        "getRequest() of SNMPGet: Returned values for" +
-                        " OIDs should not be correct.");
+            }
 
-                rc = 1;
+            previousOID = "end";
+          } else {
+            // Now we shall display the content of the result
+            //
+            SnmpVarBindList resp = request.getResponseVarBindList();
+
+            System.out.println("getRequest() of SNMPGet: Result=");
+
+            String tmpOID = "";
+            String realOID = "";
+            for (int i = 0; i < resp.getVarBindCount(); i++) {
+              tmpOID = resp.getVarBindAt(i).getOid().toString();
+              int endIndex = tmpOID.lastIndexOf(".");
+              String indexOID = tmpOID.substring(endIndex, tmpOID.length());
+
+              realOID = tmpOID.substring(0, endIndex);
+              if (realOID.startsWith("1.3.6.1.2.1.66.2")) {
+                endIndex = realOID.lastIndexOf(".");
+                realOID = realOID.substring(0, endIndex);
+              }
+
+              String name = resp.getVarBindAt(i).resolveVarName(realOID).getName();
+              String value = resp.getVarBindAt(i).getStringValue();
+              System.out.println(name + indexOID + "=" + value);
+
+              if (walk) {
+                list.removeVarBind(previousOID);
+                list.addVarBind(tmpOID);
+                previousOID = tmpOID;
               } else {
-                System.out.println(
-                        "getRequest() of SNMPGet: Returned values for" +
-                        " OIDs are not correct as expected.");
+                previousOID = "end";
+              }
+            }
+
+            if (connectStatus.compareTo("noError") != 0) {
+              // Request should failed
+              //
+              System.out.println(
+                      "getRequest() of SNMPGet: Get request should " +
+                      "fail with " + connectStatus + " status.");
+
+              rc = 1;
+            } else {
+              if (validOIDs) {
+                // Check that we obtain correct values for the OIDs
+                //
+                if (resp.checkForValidValues()) {
+                  System.out.println(
+                          "getRequest() of SNMPGet: Returned values for" +
+                          " OIDs are correct.");
+                } else {
+                  System.out.println(
+                          "getRequest() of SNMPGet: Returned values for" +
+                          " OIDs are not correct.");
+
+                  rc = 1;
+                }
+              } else {
+                // Check that we obtain incorrect values for the OIDs
+                //
+                if (resp.checkForValidValues()) {
+                  System.out.println(
+                          "getRequest() of SNMPGet: Returned values for" +
+                          " OIDs should not be correct.");
+
+                  rc = 1;
+                } else {
+                  System.out.println(
+                          "getRequest() of SNMPGet: Returned values for" +
+                          " OIDs are not correct as expected.");
+                }
               }
             }
           }
@@ -511,6 +577,7 @@
   String securityFile = null;
   static String connectStatus = null;
   boolean validOIDs = true;
+  boolean walk = false;
 
   // SnmpSession
   SnmpSession session = null;
diff --git a/opendj-sdk/opends/tests/shared/java/snmp/SNMPSet.java b/opendj-sdk/opends/tests/shared/java/snmp/SNMPSet.java
index aa0325e..4fac0d4 100644
--- a/opendj-sdk/opends/tests/shared/java/snmp/SNMPSet.java
+++ b/opendj-sdk/opends/tests/shared/java/snmp/SNMPSet.java
@@ -207,6 +207,11 @@
           // Custom engine parameters
           final SnmpEngineParameters engineParameters =
                   new SnmpEngineParameters();
+          
+          // Activate encryption
+          engineParameters.activateEncryption();
+          
+          // Set the security file
           engineParameters.setSecurityFile(securityFile);
 
           // Create the session

--
Gitblit v1.10.0