[jboss-cvs] JBossAS SVN: r111505 - in branches/snmp4j-int/varia/src: main/java/org/jboss/jmx/adaptor/snmp/config/attribute and 5 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jun 1 17:35:02 EDT 2011


Author: thauser at redhat.com
Date: 2011-06-01 17:35:01 -0400 (Wed, 01 Jun 2011)
New Revision: 111505

Added:
   branches/snmp4j-int/varia/src/resources/services/snmp/deploy/validator.class
   branches/snmp4j-int/varia/src/resources/services/snmp/deploy/validator.java
Modified:
   branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/AttributeMappingsBinding.java
   branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/RequestHandlerImpl.java
   branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/SnmpAgentService.java
   branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/TrapEmitter.java
   branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/TrapFactory.java
   branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/TrapFactorySupport.java
   branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/config/attribute/MIBGenerator.java
   branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/config/attribute/MappedAttribute.java
   branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/config/manager/Manager.java
   branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/config/notification/Mapping.java
   branches/snmp4j-int/varia/src/resources/services/snmp/config/Attributes.xsd
   branches/snmp4j-int/varia/src/resources/services/snmp/config/Manager.xsd
   branches/snmp4j-int/varia/src/resources/services/snmp/config/Notification.xsd
   branches/snmp4j-int/varia/src/resources/services/snmp/deploy/META-INF/jboss-service.xml
   branches/snmp4j-int/varia/src/resources/services/snmp/deploy/attributes.xml
   branches/snmp4j-int/varia/src/resources/services/snmp/deploy/managers.xml
   branches/snmp4j-int/varia/src/resources/services/snmp/deploy/notifications.xml
   branches/snmp4j-int/varia/src/resources/services/snmp/deploy/users.xml
Log:
changes made to traps. V3 support available. modifications to the xml files / schemas. MIBGenerator development continues.

Modified: branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/AttributeMappingsBinding.java
===================================================================
--- branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/AttributeMappingsBinding.java	2011-06-01 20:36:48 UTC (rev 111504)
+++ branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/AttributeMappingsBinding.java	2011-06-01 21:35:01 UTC (rev 111505)
@@ -112,11 +112,13 @@
 			String oid = attrs.getValue("oid");
 			String name = attrs.getValue("name");
 			String mode = attrs.getValue("mode");
+			String snmpType = attrs.getValue("snmp-type");
 			attribute = new MappedAttribute();
 			if ("rw".equalsIgnoreCase(mode))
             attribute.setReadWrite(true);
 			attribute.setName(name);
 			attribute.setOid(oid);
+			attribute.setSnmpType(snmpType);
 		}
 		return attribute;
 	}

Modified: branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/RequestHandlerImpl.java
===================================================================
--- branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/RequestHandlerImpl.java	2011-06-01 20:36:48 UTC (rev 111504)
+++ branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/RequestHandlerImpl.java	2011-06-01 21:35:01 UTC (rev 111505)
@@ -657,21 +657,24 @@
 			  String oid;
 			  if (oidPrefix != null){
 				  oid = oidPrefix + ma.getOid();
+				  ma.setOidPrefix(oidPrefix);
 				  addObjectEntry(new OID(oidPrefix));
 			  }
 			  else{
 				  oid = ma.getOid();
 				  OID objectOID = new OID(oid);
+				  //ma.setOidPrefix(objectOID.trim());
       			  addObjectEntry(objectOID.trim());
 			  }
 			  // for the MIB Generator
+			  ma.setMbean(mmb.getName());
 			  maList.add(ma);
 			  addBindEntry(oid, mmb.getName(), ma.getName(),ma.isReadWrite());			  
   		   }
       }
 	//last step, to be indicated in choice somewhere. 
 	//if (genMib) -- check to be added; don't want to always gen the MIB
-		generateMib(mibResName, mappings, maList);
+		generateMib(mibResName, maList, mappings, server);
 		
    }
 	
@@ -680,9 +683,9 @@
 	 * @param ArrayList<MBeanAttributeInfo[]> information about the attributes gathered during initialization
 	 * @param ArrayList<MappedAttribute> information about the attributes in the .xml, namely the desired OID value and r/w perms
 	 */
-	private void generateMib(String mibResName, AttributeMappings attrList, ArrayList<MappedAttribute> maList){
-		this.mibGenerator = new MIBGenerator(mibResName, attrList, maList);
-		mibGenerator.writeMib();
+	private void generateMib(String mibResName, ArrayList<MappedAttribute> maList, AttributeMappings attrList, MBeanServer server){
+		this.mibGenerator = new MIBGenerator(mibResName, maList, attrList, server);
+		mibGenerator.writeFile();
 	}
 	
 	/** This method adds a new ObjectEntry to the set of Object OIDs.
@@ -830,7 +833,6 @@
         {
         	// the SNMP4J class TimeTicks default toString method is formatted horribly. This 
         	// call emulates the joesnmp SnmpTimeTicks display.
-        	//result = new OctetString(((TimeTicks)val).toString("{0} d {1} h {2} m {3} s {4} hs"));
         	result = (TimeTicks) val;
         }
         else if (val instanceof Counter32)

Modified: branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/SnmpAgentService.java
===================================================================
--- branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/SnmpAgentService.java	2011-06-01 20:36:48 UTC (rev 111504)
+++ branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/SnmpAgentService.java	2011-06-01 21:35:01 UTC (rev 111505)
@@ -43,10 +43,6 @@
 import org.snmp4j.mp.MPv2c;
 import org.snmp4j.mp.MPv3;
 import org.snmp4j.security.Priv3DES;
-import org.snmp4j.security.PrivAES128;
-import org.snmp4j.security.PrivAES192;
-import org.snmp4j.security.PrivAES256;
-import org.snmp4j.security.PrivDES;
 import org.snmp4j.security.SecurityModels;
 import org.snmp4j.security.SecurityProtocols;
 import org.snmp4j.security.USM;
@@ -782,5 +778,33 @@
 	public Map<String, User> getUserMap() {
 		return userMap;
 	}
+	
+	/**
+	 * @return the session
+	 */
+	public Snmp getSession() {
+		return session;
+	}
 
+	/**
+	 * @return the responder
+	 */
+	public SnmpRequest getResponder() {
+		return responder;
+	}
+
+	/**
+	 * @return the requestHandler
+	 */
+	public RequestHandler getRequestHandler() {
+		return requestHandler;
+	}
+
+	/**
+	 * @return the transportMappings
+	 */
+	public TransportMapping[] getTransportMappings() {
+		return transportMappings;
+	}
+
 }

Modified: branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/TrapEmitter.java
===================================================================
--- branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/TrapEmitter.java	2011-06-01 20:36:48 UTC (rev 111504)
+++ branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/TrapEmitter.java	2011-06-01 21:35:01 UTC (rev 111505)
@@ -28,28 +28,37 @@
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
 
 import javax.management.Notification;
 
 import org.jboss.bootstrap.api.as.config.JBossASServerConfig;
 import org.jboss.jmx.adaptor.snmp.config.manager.Manager;
+import org.jboss.jmx.adaptor.snmp.config.notification.Mapping;
+import org.jboss.jmx.adaptor.snmp.config.notification.VarBind;
+import org.jboss.jmx.adaptor.snmp.config.notification.VarBindList;
 import org.jboss.jmx.adaptor.snmp.config.user.User;
 import org.jboss.logging.Logger;
+import org.jboss.xb.binding.GenericObjectModelFactory;
 import org.jboss.xb.binding.MappingObjectModelFactory;
+import org.jboss.xb.binding.ObjectModelFactory;
 import org.jboss.xb.binding.Unmarshaller;
 import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.UnmarshallingContext;
 import org.snmp4j.CommunityTarget;
+import org.snmp4j.MessageDispatcherImpl;
 import org.snmp4j.PDU;
 import org.snmp4j.PDUv1;
 import org.snmp4j.ScopedPDU;
 import org.snmp4j.Snmp;
 import org.snmp4j.Target;
 import org.snmp4j.UserTarget;
+import org.snmp4j.mp.MPv2c;
+import org.snmp4j.mp.MPv3;
 import org.snmp4j.mp.SnmpConstants;
-import org.snmp4j.security.Priv3DES;
-import org.snmp4j.security.SecurityLevel;
 import org.snmp4j.security.SecurityModel;
-import org.snmp4j.security.SecurityModels;
 import org.snmp4j.security.SecurityProtocols;
 import org.snmp4j.security.USM;
 import org.snmp4j.security.UsmUser;
@@ -60,6 +69,7 @@
 import org.snmp4j.transport.AbstractTransportMapping;
 import org.snmp4j.transport.DefaultTcpTransportMapping;
 import org.snmp4j.transport.DefaultUdpTransportMapping;
+import org.xml.sax.Attributes;
 
 /**
  * <tt>TrapEmitter</tt> is a class that manages SNMP trap emission.
@@ -86,6 +96,15 @@
    /** Holds the manager subscriptions. Accessed through synch'd wrapper */
    private Set managers = Collections.synchronizedSet(new HashSet());  
     
+   /** Contains the read in mappings */
+   private ArrayList notificationMapList = null;
+    
+   /** Contains the compiled regular expression type specifications */
+   private ArrayList mappingRegExpCache = null;
+   
+   /** Contains instances of the notification wrappers */
+   private ArrayList notificationWrapperCache = null;
+   
    /**
     * Builds a TrapEmitter object for sending SNMP V1 or V2 traps. <P>
    **/
@@ -108,8 +127,7 @@
                                                      this.getClass().getClassLoader()).newInstance();
       
       // Initialise
-      this.trapFactory.set(this.snmpAgentService.getNotificationMapResName(),
-                           this.snmpAgentService.getClock(),
+      this.trapFactory.set(this.snmpAgentService.getClock(),
                            this.snmpAgentService.getTrapCounter());
       
       // Start the trap factory
@@ -151,13 +169,25 @@
       PDU v2cTrapPdu = null; 
       ScopedPDU v3TrapPdu = null;
       
-      //The snmp session
-      Snmp snmp = null;
-      
-      //The target to send to
-      Target t = null;
-      
       if(managers.size() > 0) {
+    	  // Locate mapping for incomming event
+          int index = -1;
+            
+          try
+          {
+             index = findMappingIndex(n);
+          }
+          catch (IndexOutOfBoundsException e)
+          {
+             throw new MappingFailedException("No mapping found for notification type: '" + 
+                        n.getType() + "'");
+          }
+            
+          Mapping m = (Mapping)this.notificationMapList.get(index);
+          // Get the coresponding wrapper to get access to notification payload
+          NotificationWrapper wrapper =
+             (NotificationWrapper)this.notificationWrapperCache.get(index);
+          
 	      // Send trap. Synchronise on the subscription collection while 
 	      // iterating 
 	      synchronized(this.managers) {     	  
@@ -165,40 +195,30 @@
 	         Iterator i = this.managers.iterator();
 	         while (i.hasNext()) {
 	            //ManagerRecord t = (ManagerRecord)i.next();
-	        	 t = (Target)i.next();
-	        	 
-	            try {  
-	            	snmp = createSnmpSession(t.getAddress());
+	        	Target t = (Target)i.next();	        		        	
+	        	
+	            try {  	            	
 	            	switch (t.getVersion()) {
 	            		case SnmpConstants.version1:
 		                    if (v1TrapPdu == null)
-		                    	v1TrapPdu = this.trapFactory.generateV1Trap(n);
+		                    	v1TrapPdu = this.trapFactory.generateV1Trap(n, m, wrapper);
 		                     
 		                    //Should work, but need to upgrade to snmp4j v.1.10.2
 //		                    v1TrapPdu.setAgentAddress((IpAddress)t.getAddress());
 		                   
-		                    // Advance the trap counter
-		                    this.snmpAgentService.getTrapCounter().advance();
-		                            
-		                    // Send
-		                    log.debug("Sending trap: "+v1TrapPdu.toString() + "\n to target: "+ t.toString());
-		                    snmp.send(v1TrapPdu, t);
+		                    sendTrap(v1TrapPdu, t, m.getSecurityName());
 		                    break;
 		                  
 	               		case SnmpConstants.version2c:
 	               			if (v2cTrapPdu == null)
-	               				v2cTrapPdu = this.trapFactory.generateV2cTrap(n);
+	               				v2cTrapPdu = this.trapFactory.generateV2cTrap(n, m, wrapper);
 	                     
-	               			// Advance the trap counter
-	               			this.snmpAgentService.getTrapCounter().advance();
-	                            
-	               			// Send
-	               			snmp.send(v2cTrapPdu, t);
+	               			sendTrap(v2cTrapPdu, t, m.getSecurityName());
 	               			break;
 	                     
 	               		case SnmpConstants.version3:
 	                        if (v3TrapPdu == null)
-	                            v3TrapPdu = this.trapFactory.generateV3Trap(n);
+	                            v3TrapPdu = this.trapFactory.generateV3Trap(n, m, wrapper);
 	                        
 	//                      if (contextEngineID != null) {
 	//                    	trapPdu.setContextEngineID(contextEngineID);
@@ -207,19 +227,13 @@
 	//                    	  trapPdu.setContextName(contextName);
 	//                      }
 	                        
-	                         // Advance the trap counter
-	                        this.snmpAgentService.getTrapCounter().advance();
-	                                
-	                        // Send
-	                        snmp.send(v3TrapPdu, t);
+	                        sendTrap(v3TrapPdu, t, m.getSecurityName());
+	                        
 	                	 break;
 	                     
 	                  default:    
 	                     log.error("Skipping session: Unknown SNMP version found");    
 	               }        
-	               if (snmp != null){
-	            	   snmp.close();
-	               }
 	            } 
 	            catch(MappingFailedException e) {
 	              log.error("Translating notification - " + e.getMessage());
@@ -236,6 +250,84 @@
     	 log.warn("No SNMP managers to send traps to");
       }
    }
+   
+   void sendTrap(PDU trap, Target target, String securityName) throws IOException {
+	   // Advance the trap counter
+       this.snmpAgentService.getTrapCounter().advance();
+       
+	   if(target instanceof UserTarget) {
+		   if(securityName != null) {
+			   if(snmpAgentService.getUserMap().get(securityName) == null) {
+		        	 throw new IllegalArgumentException("Notification Security Name " +securityName + " doesn't match any user defined in users.xml");
+		       } else {			   
+				   OctetString userSecurityName = new OctetString(securityName);
+				   
+				   ((UserTarget)target).setSecurityName(userSecurityName);
+				   ((UserTarget)target).setSecurityLevel(snmpAgentService.getUserMap().get(securityName).getSecurityLevel());
+				   ((UserTarget)target).setSecurityModel(SecurityModel.SECURITY_MODEL_USM);	
+				   
+				   if(trap.getType() == PDU.INFORM) { 
+					   User user = snmpAgentService.getUserMap().get(securityName);        	 
+					   UsmUser usmUser = new UsmUser(userSecurityName,
+			                 user.getAuthenticationProtocolID(),
+			                 new OctetString(user.getAuthenticationPassphrase()),
+			                 user.getPrivacyProtocolID(),
+			                 new OctetString(user.getPrivacyPassphrase()));
+					   Snmp snmp = createSnmpSession(target.getAddress());
+					   byte[] authorativeEngine = snmp.discoverAuthoritativeEngineID(target.getAddress(), 8000);
+					   if(authorativeEngine != null) {		      
+						   OctetString authorativeEngineID = new OctetString(authorativeEngine);
+						   snmp.getUSM().addUser(usmUser.getSecurityName(), authorativeEngineID, usmUser);
+						   ((UserTarget)target).setAuthoritativeEngineID(authorativeEngine);					   
+						   
+						   snmp.send(trap, target);	    		
+			    	  } else {
+			    		  log.warn("Couldn't discover the AuthoritativeEngineID for INFORM notification " + trap);
+			    	  }
+			    	  snmp.close();
+			    	  return;
+				   }
+			   }
+		   }
+	   }
+	   // Send v2 traps or inform without users
+	   snmpAgentService.getSession().send(trap, target);
+   }
+   
+   
+   /**
+    * Locate mapping applicable for the incoming notification. Key is the
+    * notification's type
+    *
+    * @param n the notification to be examined
+    * @return the index of the mapping
+    * @throws IndexOutOfBoundsException if no mapping found
+   **/ 
+   private int findMappingIndex(Notification n)
+      throws IndexOutOfBoundsException
+   {
+      // Sequentially check the notification type against the compiled 
+      // regular expressions. On first match return the coresponding mapping
+      // index
+      for (int i = 0; i < notificationMapList.size(); i++)
+      {
+         Pattern p = (Pattern) this.mappingRegExpCache.get(i);
+            
+         if (p != null)
+         {
+            Matcher m = p.matcher(n.getType());
+            
+            if (m.matches())
+            {
+               if (log.isTraceEnabled())
+                  log.trace("Match for '" + n.getType() + "' on mapping " + i);
+               return i;
+            }
+         }
+      }
+      // Signal "no mapping found"
+      throw new IndexOutOfBoundsException();
+   }
 
    /**
     * Load manager subscriptions
@@ -284,10 +376,7 @@
       {
          // Read the monitoring manager's particulars
          Manager m = (Manager)i.next();
-         fixManagerVersion(m);
-         if(m.getVersion() == 3 && m.getSecurityName() != null && snmpAgentService.getUserMap().get(m.getSecurityName()) == null) {
-        	 throw new IllegalArgumentException("Manager Security Name " + m.getSecurityName() + " doesn't match any user defined in users.xml");
-         }
+         fixManagerVersion(m);                
          
     	 Target target = createTarget(m);
     	 if (target == null){
@@ -302,6 +391,91 @@
            log.warn("Ignoring duplicate manager: " + m);  
     	 }            
       }
+      
+      log.debug("Reading resource: '" + snmpAgentService.getNotificationMapResName() + "'");
+      
+      ObjectModelFactory omf = new NotificationBinding();
+      try
+      {
+         // locate notifications.xml
+         final String resName = snmpAgentService.getNotificationMapResName();
+         is = SecurityActions.getThreadContextClassLoaderResource(resName);
+         
+         // create unmarshaller
+         Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+
+         // let JBossXB do it's magic using the MappingObjectModelFactory
+         this.notificationMapList = (ArrayList)unmarshaller.unmarshal(is, omf, null);         
+      }
+      catch (Exception e)
+      {
+         log.error("Accessing resource '" + snmpAgentService.getNotificationMapResName() + "'");
+         throw e;
+      }
+      finally
+      {
+         if (is != null)
+         {
+            // close the XML stream
+            is.close();            
+         }
+      }
+      log.debug("Found " + notificationMapList.size() + " notification mappings");   
+      
+      // Initialise the cache with the compiled regular expressions denoting 
+      // notification type specifications
+      this.mappingRegExpCache = 
+         new ArrayList(notificationMapList.size());
+        
+      // Initialise the cache with the instantiated notification wrappers
+      this.notificationWrapperCache =
+         new ArrayList(notificationMapList.size());
+        
+      for (Iterator i = notificationMapList.iterator(); i.hasNext(); )
+      {
+         Mapping mapping = (Mapping)i.next();
+         
+         // Compile and add the regular expression
+         String notificationType = mapping.getNotificationType();
+         
+         try
+         {
+            Pattern re = Pattern.compile(notificationType);
+            this.mappingRegExpCache.add(re);
+         }
+         catch (PatternSyntaxException e)
+         {
+            // Fill the slot to keep index count correct
+            this.mappingRegExpCache.add(null);
+                
+            log.warn("Error compiling notification mapping for type: " + notificationType, e); 
+         }
+            
+         // Instantiate and add the wrapper
+         // Read wrapper class name 
+         String wrapperClassName = mapping.getVarBindList().getWrapperClass();
+                
+         log.debug("notification wrapper class: " + wrapperClassName);
+         
+         try
+         {
+            NotificationWrapper wrapper =
+               (NotificationWrapper)Class.forName(wrapperClassName, true, this.getClass().getClassLoader()).newInstance();
+                
+            // Initialise it
+            wrapper.set(snmpAgentService.getClock(), snmpAgentService.getTrapCounter());
+            
+            // Add the wrapper to the cache
+            this.notificationWrapperCache.add(wrapper);
+         }
+         catch (Exception e)
+         {
+            // Fill the slot to keep index count correct
+            this.notificationWrapperCache.add(null);
+                
+            log.warn("Error compiling notification mapping for type: " + notificationType, e);  
+         }
+      }
    }
    
    /**
@@ -356,21 +530,18 @@
 			   }
 		   }
 		   else if (version == SnmpConstants.version3) {
-			   //won't be used at the moment
 			   target = new UserTarget();
 			   target.setRetries(1);
 			   target.setTimeout(8000);
-			   target.setAddress(new UdpAddress(InetAddress.getByName(m.getAddress()), m.getPort()));
-			   ((UserTarget)target).setSecurityName(new OctetString(m.getSecurityName()));
-			   ((UserTarget)target).setSecurityLevel(snmpAgentService.getUserMap().get(m.getSecurityName()).getSecurityLevel());
-			   ((UserTarget)target).setSecurityModel(SecurityModel.SECURITY_MODEL_USM);
+			   target.setAddress(new UdpAddress(InetAddress.getByName(m.getAddress()), m.getPort()));			   
 		   }
 		   else {
 			   //unrecognized version
 			   throw new IllegalArgumentException("version " + version + " is not supported in managers.xml, only 1, 2 and 3 are valid values");
 		   }
-	   
-	   } catch (UnknownHostException e) {} //something goes here
+	   } catch (UnknownHostException e) {
+		   log.error("A problem occured creating the target towards " + m.getAddress() + ":" + m.getPort(), e);
+	   } //something goes here
 	   if (target != null){
 		   target.setVersion(version);
 	   }
@@ -388,26 +559,129 @@
 	    // Could save some CPU cycles:
 	    // transport.setAsyncMsgProcessingSupported(false);
 	    
-	    Snmp snmp =  new Snmp(transport);
-	    OctetString localEngineID =new OctetString(snmp.getLocalEngineID());
-	    USM usm = new USM(SecurityProtocols.getInstance(), localEngineID, 0);	    	   
-	    SecurityProtocols.getInstance().addDefaultProtocols();
-	    // all other privacy and authentication protocols are provided by the above method
-	    SecurityProtocols.getInstance().addPrivacyProtocol(new Priv3DES());	   		   
-	    SecurityModels.getInstance().addSecurityModel(usm);
-	    
-	    for (Iterator<User> userIt = snmpAgentService.getUserMap().values().iterator(); userIt.hasNext(); ) {
-	    	  User user = userIt.next();
-	        	 
-	    	  UsmUser usmUser = new UsmUser(new OctetString(user.getSecurityName()),
-	               user.getAuthenticationProtocolID(),
-	               new OctetString(user.getAuthenticationPassphrase()),
-	               user.getPrivacyProtocolID(),
-	               new OctetString(user.getPrivacyPassphrase()));
-	    	  usm.addUser(usmUser.getSecurityName(), usm.getLocalEngineID(),usmUser);
-	      }
-	       
+	   	MessageDispatcherImpl dispatcher = new MessageDispatcherImpl();
+	    Snmp snmp =  new Snmp(dispatcher, transport);
+	    OctetString localEngineID= new OctetString(MPv3.createLocalEngineID());	    
+	    USM usm = new USM(SecurityProtocols.getInstance(), localEngineID, 0);
+	    MPv3 mpv3 = new MPv3(usm);			   		   	    
+		dispatcher.addMessageProcessingModel(new MPv2c());
+		dispatcher.addMessageProcessingModel(mpv3);		
+		
+		snmp.listen();
+		
 	    return snmp;
 	  }
-   
+
+	/**
+	 * Utility class used by JBossXB to help parse notifications.xml
+	 */
+	private static class NotificationBinding implements
+			GenericObjectModelFactory {
+		// GenericObjectModelFactory implementation ----------------------
+
+		public Object completeRoot(Object root, UnmarshallingContext ctx,
+				String uri, String name) {
+			return root;
+		}
+
+		public Object newRoot(Object root, UnmarshallingContext navigator,
+				String namespaceURI, String localName, Attributes attrs) {
+			ArrayList notifList;
+
+			if (root == null) {
+				root = notifList = new ArrayList();
+			} else {
+				notifList = (ArrayList) root;
+			}
+			return root;
+		}
+
+		public Object newChild(Object parent, UnmarshallingContext navigator,
+				String namespaceURI, String localName, Attributes attrs) {
+			Object child = null;
+
+			if ("mapping".equals(localName)) {
+				Mapping m = new Mapping();
+				child = m;
+			} else if ("var-bind-list".equals(localName)) {
+				VarBindList vblist = new VarBindList();
+				child = vblist;
+				if (attrs.getLength() > 0) {
+					for (int i = 0; i < attrs.getLength(); i++) {
+						if ("wrapper-class".equals(attrs.getLocalName(i))) {
+							vblist.setWrapperClass(attrs.getValue(i));
+						}
+					}
+				}
+				// check that wrapper-class is set
+				if (vblist.getWrapperClass() == null) {
+					throw new RuntimeException(
+							"'wrapper-class' must be set at 'var-bind-list' element");
+				}
+			} else if ("var-bind".equals(localName)) {
+				VarBind vb = new VarBind();
+				child = vb;
+			}
+			return child;
+		}
+
+		public void addChild(Object parent, Object child,
+				UnmarshallingContext navigator, String namespaceURI,
+				String localName) {
+			if (parent instanceof ArrayList) {
+				ArrayList notifList = (ArrayList) parent;
+
+				if (child instanceof Mapping) {
+					notifList.add(child);
+				}
+			} else if (parent instanceof Mapping) {
+				Mapping m = (Mapping) parent;
+
+				if (child instanceof VarBindList) {
+					m.setVarBindList((VarBindList) child);
+				}
+			} else if (parent instanceof VarBindList) {
+				VarBindList vblist = (VarBindList) parent;
+
+				if (child instanceof VarBind) {
+					vblist.addVarBind((VarBind) child);
+				}
+			}
+		}
+
+		public void setValue(Object o, UnmarshallingContext navigator,
+				String namespaceURI, String localName, String value) {
+			if (o instanceof Mapping) {
+				Mapping m = (Mapping) o;
+
+				if ("notification-type".equals(localName)) {
+					m.setNotificationType(value);
+				} else if ("generic".equals(localName)) {
+					m.setGeneric(Integer.parseInt(value));
+				} else if ("specific".equals(localName)) {
+					m.setSpecific(Integer.parseInt(value));
+				} else if ("enterprise".equals(localName)) {
+					m.setEnterprise(value);
+				} else if ("inform".equals(localName)) {
+					m.setInform(Boolean.parseBoolean(value));
+				} else if ("security-name".equals(localName)) {
+					m.setSecurityName(value);
+				}
+			} else if (o instanceof VarBind) {
+				VarBind vb = (VarBind) o;
+
+				if ("tag".equals(localName)) {
+					vb.setTag(value);
+				} else if ("oid".equals(localName)) {
+					vb.setOid(value);
+				}
+			}
+		}
+
+		public Object completedRoot(Object root,
+				UnmarshallingContext navigator, String namespaceURI,
+				String localName) {
+			return root;
+		}
+	}
 } // class TrapEmitter

Modified: branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/TrapFactory.java
===================================================================
--- branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/TrapFactory.java	2011-06-01 20:36:48 UTC (rev 111504)
+++ branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/TrapFactory.java	2011-06-01 21:35:01 UTC (rev 111505)
@@ -21,6 +21,7 @@
 
 import javax.management.Notification;
 
+import org.jboss.jmx.adaptor.snmp.config.notification.Mapping;
 import org.snmp4j.PDUv1;
 import org.snmp4j.PDU;
 import org.snmp4j.ScopedPDU;
@@ -69,7 +70,7 @@
     * Sets the name of the file containing the notification/trap mappings,
     * the uptime clock and the trap counter
    **/ 
-   public void set(String notificationMapResName, Clock uptime, Counter count);
+   public void set(Clock uptime, Counter count);
    
    /**
     * Performs all the required initialisation in order for the mapper to 
@@ -84,7 +85,7 @@
     *
     * @param the notification to be translated
    **/
-   public PDUv1 generateV1Trap(Notification n) 
+   public PDUv1 generateV1Trap(Notification n, Mapping m, NotificationWrapper wrapper) 
    throws MappingFailedException;
    
    /**
@@ -94,7 +95,7 @@
    **/
 //   public SnmpPduPacket generateV2Trap(Notification n) 
 //      throws MappingFailedException;
-   public PDU generateV2cTrap(Notification n) 
+   public PDU generateV2cTrap(Notification n, Mapping m, NotificationWrapper wrapper) 
    throws MappingFailedException;
 
    /**
@@ -102,7 +103,7 @@
     *
     * @param the notification to be translated
    **/
-   public ScopedPDU generateV3Trap(Notification n) 
+   public ScopedPDU generateV3Trap(Notification n, Mapping m, NotificationWrapper wrapper) 
    throws MappingFailedException;
           
 } // TrapFactory

Modified: branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/TrapFactorySupport.java
===================================================================
--- branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/TrapFactorySupport.java	2011-06-01 20:36:48 UTC (rev 111504)
+++ branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/TrapFactorySupport.java	2011-06-01 21:35:01 UTC (rev 111505)
@@ -19,13 +19,8 @@
 **/
 package org.jboss.jmx.adaptor.snmp.agent;
 
-import java.io.InputStream;
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.regex.PatternSyntaxException;
 
 import javax.management.Notification;
 
@@ -34,9 +29,6 @@
 import org.jboss.jmx.adaptor.snmp.config.notification.VarBindList;
 import org.jboss.logging.Logger;
 import org.jboss.xb.binding.GenericObjectModelFactory;
-import org.jboss.xb.binding.ObjectModelFactory;
-import org.jboss.xb.binding.Unmarshaller;
-import org.jboss.xb.binding.UnmarshallerFactory;
 import org.jboss.xb.binding.UnmarshallingContext;
 import org.snmp4j.PDU;
 import org.snmp4j.PDUv1;
@@ -93,24 +85,12 @@
    /** Reference to SNMP variable binding factory */
    private SnmpVarBindFactory snmpVBFactory = null;
    
-   /** File that contains notification mappings */
-   private String notificationMapResName = null;
-   
    /** Uptime clock */
    private Clock clock = null;
    
    /** Trap counter */
-   private Counter trapCount = null;
+   private Counter trapCount = null;   
    
-   /** Contains the read in mappings */
-   private ArrayList notificationMapList = null;
-    
-   /** Contains the compiled regular expression type specifications */
-   private ArrayList mappingRegExpCache = null;
-   
-   /** Contains instances of the notification wrappers */
-   private ArrayList notificationWrapperCache = null;
-   
    /**
     * Create TrapFactorySupport
    **/
@@ -123,9 +103,8 @@
     * Sets the name of the file containing the notification/trap mappings,
     * the uptime clock and the trap counter
    **/ 
-   public void set(String notificationMapResName, Clock clock, Counter count)
+   public void set(Clock clock, Counter count)
    {
-      this.notificationMapResName = notificationMapResName;
       this.clock = clock;
       this.trapCount = count;
    }
@@ -142,152 +121,19 @@
    public void start()
       throws Exception
    {
-      log.debug("Reading resource: '" + notificationMapResName + "'");
       
-      ObjectModelFactory omf = new NotificationBinding();
-      InputStream is = null;
-      try
-      {
-         // locate notifications.xml
-         final String resName = notificationMapResName;
-         is = SecurityActions.getThreadContextClassLoaderResource(resName);
-         
-         // create unmarshaller
-         Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
-
-         // let JBossXB do it's magic using the MappingObjectModelFactory
-         this.notificationMapList = (ArrayList)unmarshaller.unmarshal(is, omf, null);         
-      }
-      catch (Exception e)
-      {
-         log.error("Accessing resource '" + notificationMapResName + "'");
-         throw e;
-      }
-      finally
-      {
-         if (is != null)
-         {
-            // close the XML stream
-            is.close();            
-         }
-      }
-      log.debug("Found " + notificationMapList.size() + " notification mappings");   
-      
-      // Initialise the cache with the compiled regular expressions denoting 
-      // notification type specifications
-      this.mappingRegExpCache = 
-         new ArrayList(notificationMapList.size());
-        
-      // Initialise the cache with the instantiated notification wrappers
-      this.notificationWrapperCache =
-         new ArrayList(notificationMapList.size());
-        
-      for (Iterator i = notificationMapList.iterator(); i.hasNext(); )
-      {
-         Mapping mapping = (Mapping)i.next();
-         
-         // Compile and add the regular expression
-         String notificationType = mapping.getNotificationType();
-         
-         try
-         {
-            Pattern re = Pattern.compile(notificationType);
-            this.mappingRegExpCache.add(re);
-         }
-         catch (PatternSyntaxException e)
-         {
-            // Fill the slot to keep index count correct
-            this.mappingRegExpCache.add(null);
-                
-            log.warn("Error compiling notification mapping for type: " + notificationType, e); 
-         }
-            
-         // Instantiate and add the wrapper
-         // Read wrapper class name 
-         String wrapperClassName = mapping.getVarBindList().getWrapperClass();
-                
-         log.debug("notification wrapper class: " + wrapperClassName);
-         
-         try
-         {
-            NotificationWrapper wrapper =
-               (NotificationWrapper)Class.forName(wrapperClassName, true, this.getClass().getClassLoader()).newInstance();
-                
-            // Initialise it
-            wrapper.set(this.clock, this.trapCount);
-            
-            // Add the wrapper to the cache
-            this.notificationWrapperCache.add(wrapper);
-         }
-         catch (Exception e)
-         {
-            // Fill the slot to keep index count correct
-            this.notificationWrapperCache.add(null);
-                
-            log.warn("Error compiling notification mapping for type: " + notificationType, e);  
-         }
-      }
       log.debug("Trap factory going active");                                                       
    }
     
    /**
-    * Locate mapping applicable for the incoming notification. Key is the
-    * notification's type
-    *
-    * @param n the notification to be examined
-    * @return the index of the mapping
-    * @throws IndexOutOfBoundsException if no mapping found
-   **/ 
-   private int findMappingIndex(Notification n)
-      throws IndexOutOfBoundsException
-   {
-      // Sequentially check the notification type against the compiled 
-      // regular expressions. On first match return the coresponding mapping
-      // index
-      for (int i = 0; i < notificationMapList.size(); i++)
-      {
-         Pattern p = (Pattern) this.mappingRegExpCache.get(i);
-            
-         if (p != null)
-         {
-            Matcher m = p.matcher(n.getType());
-            
-            if (m.matches())
-            {
-               if (log.isTraceEnabled())
-                  log.trace("Match for '" + n.getType() + "' on mapping " + i);
-               return i;
-            }
-         }
-      }
-      // Signal "no mapping found"
-      throw new IndexOutOfBoundsException();
-   }
-    
-   /**
     * Traslates a Notification to an SNMP V1 trap.
    **/
-   public PDUv1 generateV1Trap(Notification n) 
+   public PDUv1 generateV1Trap(Notification n, Mapping m, NotificationWrapper wrapper) 
       throws MappingFailedException
    {
       if (log.isTraceEnabled())
-         log.trace("generateV1Trap");
+         log.trace("generateV1Trap");             
         
-      // Locate mapping for incomming event
-      int index = -1;
-        
-      try
-      {
-         index = findMappingIndex(n);
-      }
-      catch (IndexOutOfBoundsException e)
-      {
-         throw new MappingFailedException("No mapping found for notification type: '" + 
-                    n.getType() + "'");
-      }
-        
-      Mapping m = (Mapping)this.notificationMapList.get(index);
-        
       // Create trap
       PDUv1 trapPdu = new PDUv1();
         
@@ -301,11 +147,7 @@
         
       // Append the specified varbinds. Get varbinds from mapping and for
       // each one of the former use the wrapper to get the corresponding
-      // values
-
-      // Get the coresponding wrapper to get access to notification payload
-      NotificationWrapper wrapper =
-         (NotificationWrapper)this.notificationWrapperCache.get(index);
+      // values      
         
       if(wrapper != null)
       {
@@ -343,35 +185,20 @@
     *
     * TODO: how do you get timestamp, generic, and specific stuff in the trap
    **/
-   public PDU generateV2cTrap(Notification n) 
+   public PDU generateV2cTrap(Notification n, Mapping m, NotificationWrapper wrapper) 
       throws MappingFailedException
    {
       if (log.isTraceEnabled())
          log.trace("generateV2cTrap");
-        
-      // Locate mapping for incomming event
-      int index = -1;
-        
-      try
-      {
-         index = findMappingIndex(n);
-      }
-      catch (IndexOutOfBoundsException e)
-      {
-         throw new MappingFailedException(
-            "No mapping found for notification type: '" + n.getType() + "'");
-      }
-        
-      Mapping m = (Mapping)this.notificationMapList.get(index);
       
       // Create trap
       PDU trapPdu = new PDU();
-      trapPdu.setType(PDU.TRAP);
+      if(m.isInform()) {
+      	trapPdu.setType(ScopedPDU.INFORM);    	
+      } else {
+      	trapPdu.setType(ScopedPDU.TRAP);
+      }
         
-      // Get the coresponding wrapper
-      NotificationWrapper wrapper =
-         (NotificationWrapper)this.notificationWrapperCache.get(index);
-      
       // Those 2 Variable Bindings are mandatory for v2c and v3 traps and inform
       trapPdu.add(new VariableBinding(SnmpConstants.sysUpTime, new TimeTicks(this.clock.uptime())));
       // For generic traps, values are defined in RFC 1907, for vendor specific traps snmpTrapOID is essentially a concatenation of the SNMPv1 Enterprise parameter and two additional sub-identifiers, '0', and the SNMPv1 Specific trap code parameter.
@@ -413,34 +240,19 @@
     *
     * TODO: how do you get timestamp, generic, and specific stuff in the trap
    **/
-   public ScopedPDU generateV3Trap(Notification n) 
+   public ScopedPDU generateV3Trap(Notification n, Mapping m, NotificationWrapper wrapper) 
       throws MappingFailedException
    {
 	   if (log.isTraceEnabled())
        log.trace("generateV3Trap");
-      
-    // Locate mapping for incomming event
-    int index = -1;
-      
-    try
-    {
-       index = findMappingIndex(n);
-    }
-    catch (IndexOutOfBoundsException e)
-    {
-       throw new MappingFailedException(
-          "No mapping found for notification type: '" + n.getType() + "'");
-    }
-      
-    Mapping m = (Mapping)this.notificationMapList.get(index);
     
     // Create trap
     ScopedPDU trapPdu = new ScopedPDU();
-    trapPdu.setType(ScopedPDU.TRAP);    
-
-    // Get the coresponding wrapper
-    NotificationWrapper wrapper =
-       (NotificationWrapper)this.notificationWrapperCache.get(index);
+    if(m.isInform()) {
+    	trapPdu.setType(ScopedPDU.INFORM);    	
+    } else {
+    	trapPdu.setType(ScopedPDU.TRAP);
+    }
       
     // Those 2 Variable Bindings are mandatory for v2c and v3 traps and inform
     trapPdu.add(new VariableBinding(SnmpConstants.sysUpTime, new TimeTicks(this.clock.uptime())));
@@ -474,148 +286,4 @@
     return trapPdu;
    }
    
-   /**
-    * Utility class used by JBossXB to help parse notifications.xml 
-    */
-   private static class NotificationBinding implements GenericObjectModelFactory
-   {
-      // GenericObjectModelFactory implementation ----------------------
-
-      public Object completeRoot(Object root, UnmarshallingContext ctx,
-            String uri, String name)
-      {
-         return root;
-      }
-
-      public Object newRoot(Object root, UnmarshallingContext navigator, String namespaceURI,
-                            String localName, Attributes attrs)
-      {
-         ArrayList notifList;
-         
-         if (root == null)
-         {
-            root = notifList = new ArrayList();
-         }
-         else
-         {
-            notifList = (ArrayList) root;
-         }
-         return root;
-      }
-      
-      public Object newChild(Object parent, UnmarshallingContext navigator, String namespaceURI,
-                             String localName, Attributes attrs)
-      {
-         Object child = null;
-
-         if ("mapping".equals(localName))
-         {
-            Mapping m = new Mapping();
-            child = m;
-         }
-         else if ("var-bind-list".equals(localName))
-         {
-            VarBindList vblist = new VarBindList();
-            child = vblist;
-            if (attrs.getLength() > 0)
-            {
-               for (int i = 0; i < attrs.getLength(); i++)
-               {
-                  if ("wrapper-class".equals(attrs.getLocalName(i)))
-                  {
-                     vblist.setWrapperClass(attrs.getValue(i));
-                  }
-               }
-            }
-            // check that wrapper-class is set
-            if (vblist.getWrapperClass() == null)
-            {
-               throw new RuntimeException("'wrapper-class' must be set at 'var-bind-list' element");
-            }
-         }
-         else if ("var-bind".equals(localName))
-         {
-            VarBind vb = new VarBind();
-            child = vb;
-         }
-         return child;
-      }
-
-      public void addChild(Object parent, Object child, UnmarshallingContext navigator,
-                           String namespaceURI, String localName)
-      {
-         if (parent instanceof ArrayList)
-         {
-            ArrayList notifList = (ArrayList)parent;
-            
-            if (child instanceof Mapping)
-            {
-               notifList.add(child);
-            }
-         }
-         else if (parent instanceof Mapping)
-         {
-            Mapping m = (Mapping)parent;
-            
-            if (child instanceof VarBindList)
-            {
-               m.setVarBindList((VarBindList)child);
-            }
-         }
-         else if (parent instanceof VarBindList)
-         {
-            VarBindList vblist = (VarBindList)parent;
-            
-            if (child instanceof VarBind)
-            {
-               vblist.addVarBind((VarBind)child);
-            }
-         }
-      }
-      
-      public void setValue(Object o, UnmarshallingContext navigator, String namespaceURI,
-                           String localName, String value)
-      {
-         if (o instanceof Mapping)
-         {
-            Mapping m = (Mapping)o;
-            
-            if ("notification-type".equals(localName))
-            {
-               m.setNotificationType(value);
-            }
-            else if ("generic".equals(localName))
-            {
-               m.setGeneric(Integer.parseInt(value));
-            }
-            else if ("specific".equals(localName))
-            {
-               m.setSpecific(Integer.parseInt(value));
-            }
-            else if ("enterprise".equals(localName))
-            {
-               m.setEnterprise(value);
-            }
-         }
-         else if (o instanceof VarBind)
-         {
-            VarBind vb = (VarBind)o;
-            
-            if ("tag".equals(localName))
-            {
-               vb.setTag(value);
-            }
-            else if ("oid".equals(localName))
-            {
-               vb.setOid(value);
-            }
-         }
-      }
-
-      public Object completedRoot(Object root, UnmarshallingContext navigator, String namespaceURI, String localName)
-      {
-         return root;
-      }      
-   }
-   
 } // class TrapFactorySupport

Modified: branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/config/attribute/MIBGenerator.java
===================================================================
--- branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/config/attribute/MIBGenerator.java	2011-06-01 20:36:48 UTC (rev 111504)
+++ branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/config/attribute/MIBGenerator.java	2011-06-01 21:35:01 UTC (rev 111505)
@@ -25,50 +25,70 @@
 import java.io.*;
 import java.util.ArrayList;
 import java.util.Iterator;
+import java.util.StringTokenizer;
+import java.util.HashMap;
 
 import org.jboss.jmx.adaptor.snmp.config.attribute.MappedAttribute;
+import org.jboss.jmx.adaptor.snmp.config.attribute.AttributeMappings;
+import org.jboss.jmx.adaptor.snmp.config.attribute.ManagedBean;
 
 import javax.management.MBeanAttributeInfo;
 import javax.management.MBeanServer;
+import javax.management.MBeanServerConnection;
 import javax.management.MBeanInfo;
 import javax.management.ObjectName;
 
+import org.snmp4j.smi.TimeTicks;
+import org.snmp4j.smi.Counter32;
+import org.snmp4j.smi.OID;
 
+
 /** 
-* The goal of this class is to be able to, from information gathered from attributes.xml(s), 
-* generate an MIB that is able to be loaded by external managers.
+* This class will be able to generate MIBs or XMLs, depending on the invocation by the user. 
+* It will utilize mibble libraries to parse MIBs to generate xmls from them, and will use 
+* objects gathered from the parsing of XMLs to generate MIBs. Types are determined by either an
+* attribute in the attributes.xml (snmp-type), or, if missing, a check on the attribute's type after 
+* querying the server. 
 * 
+* 
 *  @author <a href="mailto:tom.hauser at gmail.com">Tom Hauser</a>
 **/
 
 public class MIBGenerator {
-	private String mibResName; // the name of the output MIB file
-	private AttributeMappings attrInfo;
-	private ArrayList<MappedAttribute> maList; // a list of all mapped attributes algamated from all attributes.xml
+	private String outputResName; // the name of the output file (.mib or .xml)
+	private AttributeMappings mbList;
 	private ArrayList<MIBObject> miboList; //internal list of MIBObjects
 	private MBeanServer server; // reference to the MBeanServer, which we will use to query attribute types and other such things
+	private ArrayList<MappedAttribute> maList;
+	private HashMap<String, OIDDef> oidDefMap;
 	
+	// need some way to prevent collisions
+		
+	
 	public MIBGenerator(){
-		mibResName = null;
-		this.attrInfo = null;
+		this.outputResName = null;
+		this.mbList = null;
+		this.miboList = null;
 		this.maList = null;
-		this.miboList = null;
 	}
 	
-	public MIBGenerator(String mibResName, AttributesMapping attrInfo, ArrayList<MappedAttribute> maList, MBeanServer server){
-		this.mibResName = mibResName;
+	public MIBGenerator(String outputResName, ArrayList<MappedAttribute> maList, AttributeMappings mbList, MBeanServer server){
+		this.outputResName = outputResName;
+		this.mbList = mbList;
+		this.miboList = new ArrayList<MIBObject>();
 		this.maList = maList;
-		this.attrInfo = attrInfo;
-		this.miboList = new ArrayList<MIBObject>();
+		this.server = server;
+		this.oidDefMap = new HashMap<String, OIDDef>();
+		
 	}
 	
 	//mutators
-	public String getMibResName(){
-		return this.mibResName;
+	public String getOutputResName(){
+		return this.outputResName;
 	}
 	
-	public void setMibResName(String mrn){
-		this.mibResName = mrn;
+	public void setOutputResName(String outputResName){
+		this.outputResName = outputResName;
 	}
 	
 	public ArrayList<MappedAttribute> getMaList(){
@@ -79,14 +99,14 @@
 		this.maList = maList;
 	}
 	
-	public ArrayList<MBeanAttributeInfo> getAttrInfo(){
-		return this.attrInfo;
+	public AttributeMappings getMbList(){
+		return this.mbList;
 	}
 	
-	public void setAttrInfo(ArrayList<MBeanAttributeInfo> attrInfo){
-		this.attrInfo = attrInfo;
+	public void setMbList(AttributeMappings mbList){
+		this.mbList = mbList;
 	}
-	
+		
 	public MBeanServer getMBeanServer(){
 		return this.server;
 	}
@@ -94,93 +114,117 @@
 	public void setMBeanServer(MBeanServer server){
 		this.server = server;
 	}
+	
+	public HashMap<String, OIDDef> getOidDefMap(){
+		return this.oidDefMap;
+	}
+	
+	public void setOidDefMap(HashMap<String, OIDDef> oidDefMap){
+		this.oidDefMap = oidDefMap;
+	}
 	//we're done gathering attributes. write the MIB.
-	public void writeMib() throws Exception{
+	public void writeFile(){
 		try{
-		PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(mibResName)));
-		writeHeader(out);
-		//writeDefinitions(out);
-		writeObjects(miboList, out);
-		out.println();
-		out.println("END");
-		out.close();
+			PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(outputResName)));
+			if (outputResName.contains(".mib")){
+				createMibObjects();
+				createOidDefinitions();
+				writeMibHeader(out);
+				writeMibImports(out);
+				writeMibDefinitions(out);
+				writeMibObjects(out);
+			}
+			else if (outputResName.contains(".xml")){
+				writeXmlHeader(out);
+				writeXmlDefinitions(out);
+			}
+			out.close();
 		}
-		catch (Exception e){throw e;}
+		catch (Exception e){e.printStackTrace();}
 	}
 	
-/*	private void addDescriptions(){
-		Iterator<MappedAttribute> maIt = this.maList.iterator();
-		while (maIt.hasNext()){
-			MappedAttribute tempMa = maIt.next();
-			Iterator<MBeanAttributeInfo> mbaIt = attrInfo.iterator();
-			while (mbaIt.hasNext()){
-				MBeanAttributeInfo tempMba = mbaIt.next();
-				if (tempMba.getName() == tempMa.getName()){
-					tempMa.setDesc(tempMba.getDescription());
-				}
-			}
-		}	
-	}*/
 	
-/*	private ArrayList<MBeanAttributeInfo> processMBeanInfo(ArrayList<MBeanAttributeInfo[]> attrInfo){
-		ArrayList<MBeanAttributeInfo> retval = new ArrayList<MBeanAttributeInfo>(10);
-		Iterator<MBeanAttributeInfo[]> mbaIt = attrInfo.iterator();
-		while (mbaIt.hasNext()){
-			MBeanAttributeInfo[] temp = mbaIt.next();
-			for (int i=0;i<temp.length;i++){
-				retval.add(temp[i]);//add all entries of all attributes to the list.
-			}
-		}
-		//done adding all MBeanAttributeInfos
-		return retval;
-	}*/
-	
-	private void writeHeader(PrintWriter out){
+	private void writeMibHeader(PrintWriter out){
 		out.println("-- This MIB Generated by the SNMP MIB Generator");
 		out.println();
 		out.println("JBOSS-AS-MIB DEFINITIONS ::=BEGIN");
 		out.println();
-		// maybe add more here, if not we don't need this to be a seperate method.
+		// maybe add more here, if notrrayList we don't need this to be a seperate method.
 	}
 	
+	private void writeMibImports(PrintWriter out){
+		out.println("IMPORTS");
+		out.println("\tOBJECT-TYPE,");
+		out.println("\tNOTIFICATION-TYPE,");
+		out.println("\tCounter32,");
+		out.println("\tGauge32,");
+		out.println("\tCounter64,");
+		out.println("\tTimeTicks");
+		out.println("\t\tFROM SNMPv2-SMI");
+		out.println("\tDisplayString,");
+		out.println("\tTruthValue");
+		out.println("\t\tFROM SNMPv2-TC;");	
+		out.println();
+	}
+	
 	/** This method is used to write the definitions of our SYNTAX inside the JBoss MIB
 	 *  For use when we figure out what OIDs we want our metrics to be. 
 	 * @param attrList list of MBeans that we're interested in
 	 * @param out The PrintWriter that writes to the file we need it to
 	 * @author Tom Hauser
 	 */	
-	private void writeDefinitions(PrintWriter out){
-		out.println("-- Tree Roots");
-		out.println("org\tOBJECT IDENTIFIER ::= { iso 3 }");
-		out.println("dod\tOBJECT IDENTIFIER ::= { org 6 }");
-		out.println("internet\tOBJECT IDENTIFIER ::= { dod 1 }");
-		out.println("private\tOBJECT IDENTIFIER ::= { internet 4 }");
-		out.println("enterprise\tOBJECT IDENTIFIER ::= { private 1 }");
-		out.println("redhat\tOBJECT IDENTIFIER ::= { enterprise 2312 }");
-		out.println("jboss\tOBJECT IDENTIFIER ::= { redhat 100 }");
-		out.println();
+	private void writeMibDefinitions(PrintWriter out){
+		/*org             OBJECT IDENTIFIER ::= { iso 3 }
+		dod             OBJECT IDENTIFIER ::= { org 6 }
+		internet        OBJECT IDENTIFIER ::= { dod 1 }
+
+		private         OBJECT IDENTIFIER ::= { internet 4 }
+		enterprise      OBJECT IDENTIFIER ::= { private 1 }
+		redhat          OBJECT IDENTIFIER ::= { enterprise 2312 }
+		jboss           OBJECT IDENTIFIER ::= { redhat 100 }
+		as              OBJECT IDENTIFIER ::= { jboss 1 }*/
+		Iterator<OIDDef> oidIt = oidDefMap.iterator();
+		while (oidIt.hasNext()){
+			out.println(oidIt.next());
+		}
 	}
 	
-	private void writeObjects(ArrayList<MIBObject>miboList, PrintWriter out){
-		createMIBObjects(this.maList);
+	private void writeMibObjects(PrintWriter out){
 		Iterator<MIBObject> aIt = miboList.iterator();
 		while (aIt.hasNext()){
 			out.println(aIt.next());
 		}
+		out.println("END");
 	}
 	
-	private void createMIBObjects(ArrayList<MappedAttribute> maList){
+	private void createMibObjects(){
 		Iterator<MappedAttribute> aIt = maList.iterator();
 		while (aIt.hasNext()){
 			MIBObject mibO = new MIBObject(aIt.next());
 			miboList.add(mibO);
-		}		
+		}
+	}		
+	
+	private void createOidDefinitions(){
+		// expansion: make a way to discover these, rather than hardcoding them. 
+		// suggestion: add a map of oid-prefixes from the attributes.xml and create OIDDefs out of those.
+		// then how do we get names? :( 
+		// create ones we know about first
+		String as = "1.3.6.1.4.1.2312.100.1";
+		String system = "1.3.6.1.2.1.1";
+		OIDDef jbossas = new OIDDef("as", as);
+		OIDDef mib2system = new OIDDef("system", system);
+		this.oidDefMap.put(as, jbossas);
+		this.oidDefMap.put(system, mib2system);
 	}
+	
+	private void writeXmlHeader(PrintWriter out){}
+	private void writeXmlDefinitions(PrintWriter out){}
 	/* Internal Classes ----- */
 	
-	private class MIBNotification{
-		MIBNotification(){} // this will model a NOTIFICATION-TYPE for the generated MIB
-	}
+//	private class MIBNotification{
+//		MIBNotification(){} // this will model a NOTIFICATION-TYPE for the generated MIB
+//	}
 	
 	private class MIBObject{
 		private String name;
@@ -189,33 +233,70 @@
 		private String status;
 		private String description;
 		private String objectId; 
-		private String oidPrefix; 
+		private OIDDef oidDef;
 				
 		//need to modify the information saved in mapped attribute maybe.
 		//or just make a new class to hold this info in, instead of an internal one.
 		//we need to get the information out of the MappedAttribute and format it 
 		//correctly for use in an MIB.
-		MIBObject(MappedAttribute ma, String oidPrefix){
-			MIBObject(ma);
-			this.oidPrefix = oidPrefix;
-		}
-		
+			
 		MIBObject(MappedAttribute ma){
-			this.name = ma.getName();
-			this.syntax = "OCTET STRING (SIZE (0..255))"; // definitely need a better way to find this out.
-			// maybe need to parse notifications.xml to find out trap objects
-		
+			this.name = ma.getName().substring(0,1).toLowerCase() + ma.getName().substring(1);
+			
+			if (ma.getSnmpType()!= null)
+				this.syntax = ma.getSnmpType();
+			else
+				this.syntax = findType(ma);
+					
 			if (ma.isReadWrite()) // since we only have "rw" and "ro", this needs expansion.
 				maxAccess = "read-write";
 			else
 				maxAccess = "read-only";
 			
-			this.status = "mandatory"; // need expansions to attributes.xml to account for this
-			this.description = ""; // see above.
+			this.status = "current"; 
+			this.description = ""; 
 			this.objectId = ma.getOid(); // this will contain the full numerical OID.
-			this.oidPrefix = "";
+			
+			if (oidDefMap.containsKey(ma.getOidPrefix())){
+				this.oidDef = oidDefMap.get(oidDefMap.get(ma.getOidPrefix()));
+			}
+			//we don't ever want this to fail :( 
+			else{
+				OIDDef newOidDef = new OIDDef("unknown", ma.getOidPrefix());
+				oidDefMap.put(ma.getOidPrefix(), newOidDef);
+			}
 		}
-	
+		
+		public String findType(MappedAttribute ma){
+			Object o = null;
+			try{
+			o = server.getAttribute(new ObjectName(ma.getMbean()), ma.getName());
+			}catch (Exception e){e.printStackTrace();}				
+
+			if (o instanceof Long){
+				return "DisplayString";
+			}
+			else if (o instanceof String){
+				return "DisplayString";
+			}
+			else if (o instanceof Integer){
+				return "INTEGER";
+			}
+			else if (o instanceof OID){
+				return "OBJECT IDENTIFIER";
+			}
+			else if (o instanceof TimeTicks){
+				return "TimeTicks";
+			}
+			else if (o instanceof Counter32){
+				return "Counter32";
+			}
+			else{
+				return "OCTET STRING (SIZE(0..255))";
+			}
+		}
+
+		@Override
 		public String toString(){
 			StringBuffer buf = new StringBuffer();
 			buf.append(this.name+" OBJECT-TYPE\n");
@@ -227,15 +308,76 @@
 			buf.append("\n");
 			buf.append("\tDESCRIPTION ");
 			buf.append("\n\t\t");
-			buf.append(\"this.description\");
+			buf.append("\""+this.description+"\"");
 			buf.append("\n");
 			buf.append("::= {").append(" ");
-			buf.append(oidPrefix + objectId + " }");
+			buf.append("as " + objectId.charAt(1)+ " }");
+			buf.append("\n");
 			return buf.toString();
 		}
+	}
 	
+		private class OIDDef{
+			private String name;
+			private String definition;
+			private String rawOid;
+			
+			public OIDDef(String name, String oid){
+				this.name = name;
+				this.rawOid = oid;
+				this.definition = parseDefinition(oid);
+			}
+			
+			public String getName(){
+				return this.name;	
+			}
+			
+			public void setName(String name){
+				this.name = name;
+			}
+			
+			public String getDefinition(){
+				return this.definition;
+			}
+			 
+			public void setDefinition(String def){
+				this.definition = def;
+			}
+			
+			public String parseDefinition(String oid){
+				String[] tokens = oid.split(".");
+				String temp = "{ ";
+				for (int i = 0; i < tokens.length;i++){
+					temp += tokens[i];
+				}
+				temp += " }";
+				return temp;
+			}
+			
+			@Override
+			public String toString(){
+				StringBuffer buf = new StringBuffer();
+				buf.append(this.name);
+				buf.append("\t\tOBJECT IDENTIFIER ::= ");
+				buf.append(this.definition);
+				return buf.toString();
+			}
+			
+			@Override
+			public boolean equals(Object other){
+			    if (other == null) return false;
+			    if (other == this) return true;
+			    if (this.getClass() != other.getClass())return false;
+			    OIDDef otherDef = (OIDDef)other;
+			    if(otherDef.rawOid == this.rawOid)
+			    	return true;
+			    else
+			    	return false;
+			}
+
+
+		}//end OIDDef
 	
-	
-	}//end MIBObject
 
+
 }// end MIB Generator
\ No newline at end of file

Modified: branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/config/attribute/MappedAttribute.java
===================================================================
--- branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/config/attribute/MappedAttribute.java	2011-06-01 20:36:48 UTC (rev 111504)
+++ branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/config/attribute/MappedAttribute.java	2011-06-01 21:35:01 UTC (rev 111505)
@@ -32,7 +32,10 @@
 	private String name;
 	private String oid;
 	private boolean isReadWrite = false;
-	private String desc = "";
+	private String type = "";
+	private String mbName = ""; //the name of the mBean this MappedAttribute is associated with
+	private String snmpType = ""; //the type for the MIB we should use, if provided
+	private String oidPrefix = "";
 	
 	/** Attribute name */
 	public String getName()
@@ -56,14 +59,38 @@
 		this.oid = oid;
 	}
 	
-	public String getDesc(){
-		return desc;
+	public String getType(){
+		return type;
 	}
-
-	public void setDesc(String desc){
-		this.desc = desc;
+	
+	public void setType(String type){
+		this.type = type;
 	}
 	
+	public String getMbean(){
+		return this.mbName;
+	}
+	
+	public void setMbean(String mbName){
+		this.mbName = mbName;
+	}
+	
+	public String getSnmpType(){
+		return this.snmpType;
+	}
+	
+	public void setSnmpType(String snmpType){
+		this.snmpType=snmpType;
+	}
+	
+	public String getOidPrefix(){
+		return this.oidPrefix;
+	}
+	
+	public void setOidPrefix(String oidPrefix){
+		this.oidPrefix = oidPrefix;
+	}
+	
    /** Attribute mode (ro/rw) */
    public boolean isReadWrite()
    {

Modified: branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/config/manager/Manager.java
===================================================================
--- branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/config/manager/Manager.java	2011-06-01 20:36:48 UTC (rev 111504)
+++ branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/config/manager/Manager.java	2011-06-01 21:35:01 UTC (rev 111505)
@@ -41,8 +41,7 @@
    private String  localAddress;
    private int     localPort;
    private int     version;
-   private String  communityString;
-   private String  securityName;
+   private String  communityString;   
 
    // Constructors -------------------------------------------------
     
@@ -178,22 +177,8 @@
    public void setCommunityString(String communityString)
    {
       this.communityString = communityString;
-   }
+   }   
    
-   /**
-    * @param securityName the securityName to set
-    */
-   public void setSecurityName(String securityName) {
-   	this.securityName = securityName;
-   }
-
-   /**
-    * @return the securityName
-    */
-   public String getSecurityName() {
-   	return securityName;
-   }
-   
    // Object overrides ----------------------------------------------
    
    public String toString()

Modified: branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/config/notification/Mapping.java
===================================================================
--- branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/config/notification/Mapping.java	2011-06-01 20:36:48 UTC (rev 111504)
+++ branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/config/notification/Mapping.java	2011-06-01 21:35:01 UTC (rev 111505)
@@ -36,6 +36,8 @@
    private int         generic;
    private int         specific;
    private String      enterprise;
+   private boolean 	   inform;
+   private String  securityName;
    private VarBindList varBindList;
 
    // Constructors -------------------------------------------------
@@ -100,6 +102,34 @@
       this.varBindList = varBindList;
    }
    
+   /**
+    * @param inform the inform to set
+    */
+   public void setInform(boolean inform) {
+	   	this.inform = inform;
+   }
+	
+   /**
+    * @return the inform
+    */
+   public boolean isInform() {
+	   	return inform;
+   }
+   
+   /**
+    * @param securityName the securityName to set
+    */
+   public void setSecurityName(String securityName) {
+   	this.securityName = securityName;
+   }
+
+   /**
+    * @return the securityName
+    */
+   public String getSecurityName() {
+   	return securityName;
+   }
+   
    // Object overrides ----------------------------------------------
    
    public String toString()

Modified: branches/snmp4j-int/varia/src/resources/services/snmp/config/Attributes.xsd
===================================================================
--- branches/snmp4j-int/varia/src/resources/services/snmp/config/Attributes.xsd	2011-06-01 20:36:48 UTC (rev 111504)
+++ branches/snmp4j-int/varia/src/resources/services/snmp/config/Attributes.xsd	2011-06-01 21:35:01 UTC (rev 111505)
@@ -25,6 +25,7 @@
           <xsd:attribute name="name"/>
           <xsd:attribute name="oid" use="required" type="xsd:string"/>
           <xsd:attribute name="mode" use="optional" type="xsd:string"/>
+          <xsd:attribute name="snmp-type" use="optional" type="xsd:string"/>
         </xsd:complexType>
       </xsd:element>
       </xsd:sequence> 

Modified: branches/snmp4j-int/varia/src/resources/services/snmp/config/Manager.xsd
===================================================================
--- branches/snmp4j-int/varia/src/resources/services/snmp/config/Manager.xsd	2011-06-01 20:36:48 UTC (rev 111504)
+++ branches/snmp4j-int/varia/src/resources/services/snmp/config/Manager.xsd	2011-06-01 21:35:01 UTC (rev 111505)
@@ -33,6 +33,7 @@
                      <xsd:element name="local-address" type="xsd:string" />
                      <xsd:element name="local-port"    type="xsd:integer" />
                      <xsd:element name="version"       type="xsd:integer" />
+                     <xsd:element name="community-string"       type="xsd:string" />                     
                   </xsd:sequence>
                </xsd:complexType>
             </xsd:element>

Modified: branches/snmp4j-int/varia/src/resources/services/snmp/config/Notification.xsd
===================================================================
--- branches/snmp4j-int/varia/src/resources/services/snmp/config/Notification.xsd	2011-06-01 20:36:48 UTC (rev 111504)
+++ branches/snmp4j-int/varia/src/resources/services/snmp/config/Notification.xsd	2011-06-01 21:35:01 UTC (rev 111505)
@@ -34,6 +34,8 @@
                      <xsd:element name="generic" type="xsd:integer" />
                      <xsd:element name="specific" type="xsd:integer" />
                      <xsd:element name="enterprise" type="xsd:string" />
+                     <xsd:element name="inform" type="xsd:boolean" />
+                     <xsd:element name="securityName" type="xsd:string" />
                      <xsd:element name="var-bind-list">
                         <xsd:complexType>
                            <xsd:sequence>
@@ -46,7 +48,7 @@
                                  </xsd:complexType>
                               </xsd:element>
                            </xsd:sequence>
-                           <xsd:attribute name="wrapper-class" type="string" use="required"/>
+                           <xsd:attribute name="wrapper-class" type="xsd:string" use="required"/>
                         </xsd:complexType>
                      </xsd:element>
                   </xsd:sequence>

Modified: branches/snmp4j-int/varia/src/resources/services/snmp/deploy/META-INF/jboss-service.xml
===================================================================
--- branches/snmp4j-int/varia/src/resources/services/snmp/deploy/META-INF/jboss-service.xml	2011-06-01 20:36:48 UTC (rev 111504)
+++ branches/snmp4j-int/varia/src/resources/services/snmp/deploy/META-INF/jboss-service.xml	2011-06-01 21:35:01 UTC (rev 111505)
@@ -15,13 +15,14 @@
   to SNMP traps.
   
   SnmpAgentService is the main MBean that implements the SNMP agent.
-  It is configured by means of 3 different configuration files, plus
+  It is configured by means of 4 different configuration files, plus
   an inline notification subscription specification:
   
   - attributes.xml, maps SNMP oids to MBean attribute get/set
   - managers.xml, configures where to send traps
   - notifications.xml, specifies the exact mapping of each notification type
     to a corresponding SNMP trap
+  - users.xml, specifies the User names and passwords for v3 SNMP communication
     
   For more information, see
   http://www.jboss.org/wiki/Wiki.jsp?page=JBossSNMPAdapter
@@ -144,8 +145,12 @@
   	     name="jboss.jmx:name=SnmpAgent,service=MIB2SystemGroup">
     
     <attribute name="SysLocation">In The Matrix</attribute>
-    <attribute name="SysDescr">Central Computer</attribute>
-    <attribute name="SysContact">Agent Smith</attribute>
+    <attribute name="SysDescr">Mobicents Sip Servlets</attribute>
+    <attribute name="SysContact">Red Hat</attribute>
+    <!-- EAP IS 1, EPP is 2, SOAP is 3, ... JBCP is 9, JBCP Sip Servlets is 9.1 -->
+    <attribute name="Product">.1</attribute>
+    <!-- product version, MSS 1.6 here -->
+    <attribute name="Version">.5.1.1</attribute>
     <!-- attribute name="SysName"></attribute> set internally to serverConfig at hostAddress-->
     <depends optional-attribute-name="SnmpAgent">
   	   jboss.jmx:name=SnmpAgent,service=snmp,type=adaptor

Modified: branches/snmp4j-int/varia/src/resources/services/snmp/deploy/attributes.xml
===================================================================
--- branches/snmp4j-int/varia/src/resources/services/snmp/deploy/attributes.xml	2011-06-01 20:36:48 UTC (rev 111504)
+++ branches/snmp4j-int/varia/src/resources/services/snmp/deploy/attributes.xml	2011-06-01 21:35:01 UTC (rev 111505)
@@ -19,9 +19,9 @@
    </mbean>
 
    <!-- tomcat global http request processing -->
-   <!--<mbean name="jboss.web:name=http-0.0.0.0-8080,type=GlobalRequestProcessor">
+   <mbean name="jboss.web:name=http-0.0.0.0-8080,type=GlobalRequestProcessor">
       <attribute name="requestCount" oid=".1.2.3.4.1.5"/>
-   </mbean>-->
+   </mbean>
    
    <!-- Tx Manager statistics -->
    <mbean name="jboss:service=TransactionManager">
@@ -45,6 +45,6 @@
       <attribute name="SysName" oid=".5"/>
       <attribute name="SysLocation" oid=".6"/>
       <attribute name="SysServices" oid=".7"/>
-   </mbean>-->
+   </mbean>
    
 </attribute-mappings>

Modified: branches/snmp4j-int/varia/src/resources/services/snmp/deploy/managers.xml
===================================================================
--- branches/snmp4j-int/varia/src/resources/services/snmp/deploy/managers.xml	2011-06-01 20:36:48 UTC (rev 111504)
+++ branches/snmp4j-int/varia/src/resources/services/snmp/deploy/managers.xml	2011-06-01 21:35:01 UTC (rev 111505)
@@ -26,12 +26,30 @@
     "jboss.jmx:name=SnmpAgent,service=trapd,type=logger" MBean that
     simply outputs received traps as log4j DEBUG messages
   -->
+  <!-- v1 manager -->
   <manager>
     <address>localhost</address>
-    <port>1162</port>
+    <port>162</port>
     <local-address></local-address>
     <local-port></local-port>
     <version>1</version>
     <community-string>public</community-string>
   </manager>
+  <!-- v2c manager -->
+  <manager>
+    <address>localhost</address>
+    <port>162</port>
+    <local-address></local-address>
+    <local-port></local-port>
+    <version>2</version>
+    <community-string>public</community-string>
+  </manager>
+  <!-- v3 manager -->
+  <manager>
+    <address>localhost</address>
+    <port>162</port>
+    <local-address></local-address>
+    <local-port></local-port>
+    <version>3</version>    
+  </manager>  
 </manager-list>

Modified: branches/snmp4j-int/varia/src/resources/services/snmp/deploy/notifications.xml
===================================================================
--- branches/snmp4j-int/varia/src/resources/services/snmp/deploy/notifications.xml	2011-06-01 20:36:48 UTC (rev 111504)
+++ branches/snmp4j-int/varia/src/resources/services/snmp/deploy/notifications.xml	2011-06-01 21:35:01 UTC (rev 111505)
@@ -52,6 +52,8 @@
     <generic>0</generic>
     <specific>0</specific>
     <enterprise>1.2.3.4.5.6.7</enterprise>
+    <!--inform>true</inform-->
+    <security-name>TEST</security-name>    
     <var-bind-list wrapper-class="org.jboss.jmx.adaptor.snmp.agent.NotificationWrapperSupport">
       <var-bind>
         <tag>a:startTime</tag>

Modified: branches/snmp4j-int/varia/src/resources/services/snmp/deploy/users.xml
===================================================================
--- branches/snmp4j-int/varia/src/resources/services/snmp/deploy/users.xml	2011-06-01 20:36:48 UTC (rev 111504)
+++ branches/snmp4j-int/varia/src/resources/services/snmp/deploy/users.xml	2011-06-01 21:35:01 UTC (rev 111505)
@@ -24,4 +24,11 @@
     <privacyProtocol>DES</privacyProtocol>
     <privacyPassphrase>maplesyrup</privacyPassphrase>
   </user>
+  <user>
+    <securityName>myuser</securityName>
+    <authenticationProtocol>MD5</authenticationProtocol>
+    <authenticationPassphrase>password</authenticationPassphrase>
+    <privacyProtocol>DES</privacyProtocol>
+    <privacyPassphrase>password</privacyPassphrase>
+  </user>
 </user-list>

Added: branches/snmp4j-int/varia/src/resources/services/snmp/deploy/validator.class
===================================================================
(Binary files differ)


Property changes on: branches/snmp4j-int/varia/src/resources/services/snmp/deploy/validator.class
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: branches/snmp4j-int/varia/src/resources/services/snmp/deploy/validator.java
===================================================================
--- branches/snmp4j-int/varia/src/resources/services/snmp/deploy/validator.java	                        (rev 0)
+++ branches/snmp4j-int/varia/src/resources/services/snmp/deploy/validator.java	2011-06-01 21:35:01 UTC (rev 111505)
@@ -0,0 +1,41 @@
+import java.io.File;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import javax.xml.validation.Validator;
+import javax.xml.XMLConstants;
+import org.w3c.dom.Document;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+// ...
+// Exception handling is not shown.
+// The ErrorHandler implementation which could just do System.err dumps is not shown.
+public class validator {
+
+public static void main(String [] args) throws Exception {
+// build an XSD-aware SchemaFactory
+SchemaFactory schemaFactory = SchemaFactory.newInstance( XMLConstants.W3C_XML_SCHEMA_NS_URI );
+
+// hook up org.xml.sax.ErrorHandler implementation.
+//schemaFactory.setErrorHandler( myErrorHandler );
+
+// get the custom xsd schema describing the required format for my XML files.
+Schema schemaXSD = schemaFactory.newSchema( new File (args[0] ) );
+
+// Create a Validator capable of validating XML files according to my custom schema.
+Validator validator = schemaXSD.newValidator();
+
+// Get a parser capable of parsing vanilla XML into a DOM tree
+DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+
+// parse the XML purely as XML and get a DOM tree represenation.
+Document document = parser.parse( new File( args[1] ) );
+
+// parse the XML DOM tree againts the stricter XSD schema
+validator.validate( new DOMSource( document ) );
+System.out.println("Valid.");
+}
+}



More information about the jboss-cvs-commits mailing list