You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ro...@apache.org on 2010/01/06 23:03:40 UTC

svn commit: r896692 - in /qpid/trunk/qpid/java: broker/src/main/java/org/apache/qpid/server/management/MBeanInvocationHandlerImpl.java management/common/src/main/java/org/apache/qpid/management/common/mbeans/UserManagement.java

Author: robbie
Date: Wed Jan  6 22:03:39 2010
New Revision: 896692

URL: http://svn.apache.org/viewvc?rev=896692&view=rev
Log:
QPID-2322: change the JMX parameter name for the password parameter to prevent the 0.5 management console from sending an MD5-hashed password to the once again versionless UserManagement MBean. Add compatibility check to alert users of the old console they should upgrade to a newer release.

Modified:
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/management/MBeanInvocationHandlerImpl.java
    qpid/trunk/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/UserManagement.java

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/management/MBeanInvocationHandlerImpl.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/management/MBeanInvocationHandlerImpl.java?rev=896692&r1=896691&r2=896692&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/management/MBeanInvocationHandlerImpl.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/management/MBeanInvocationHandlerImpl.java Wed Jan  6 22:03:39 2010
@@ -38,6 +38,7 @@
 import javax.management.JMException;
 import javax.management.NotificationListener;
 import javax.management.Notification;
+import javax.management.OperationsException;
 import javax.security.auth.Subject;
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Proxy;
@@ -139,6 +140,8 @@
 
         Principal principal = principals.iterator().next();
         String identity = principal.getName();
+        
+        checkCompatibility(proxy, method, args);
 
         if (isAdminMethod(args))
         {
@@ -168,6 +171,49 @@
         throw new SecurityException("Access denied");
     }
 
+    private void checkCompatibility(final Object proxy, final Method method, final Object[] args) throws Throwable
+    {
+        if (args[0] instanceof ObjectName && method.getName().equals("invoke"))
+        {        
+            //get the ObjectName and invoked Method name
+            final ObjectName objectName = (ObjectName) args[0];
+            
+            final String mbeanMethod = (args.length > 1) ? (String) args[1] : null;
+            if (mbeanMethod == null)
+            {
+                return;
+            }
+            
+            //UserManagement MBean compatibility checks
+            if(objectName.getKeyProperty("type").equals(UserManagement.TYPE))
+            {
+                if (mbeanMethod.equals("createUser") || mbeanMethod.equals("setPassword"))
+                {
+                    //get the provided argument values and types for the method
+                    if( args.length > 2 && args[2] != null && args[2] instanceof Object[] &&
+                        args.length > 3 && args[3] != null && args[3] instanceof String[])
+                    {
+                        //check the 2nd argument value is a char[]
+                        final Object[] argValues = (Object[]) args[2];
+                        final String[] argTypes = (String[]) args[3];
+                        
+                        final Object actualValue = (argValues.length > 1) ? argValues[1] : null;
+                        final String expectedType = (argTypes.length > 1) ? (String) argTypes[1] : null;
+                        
+                        if (expectedType != null && expectedType.equals("[C"))
+                        {     
+                            if (actualValue != null && actualValue instanceof String)
+                            {
+                                throw new OperationsException("Incorrect parameter type provided.\n" +
+                                "Please upgrade to a newer management console release to correct this issue.");
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+
     private boolean isAdminMethod(Object[] args)
     {
         if (args[0] instanceof ObjectName)

Modified: qpid/trunk/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/UserManagement.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/UserManagement.java?rev=896692&r1=896691&r2=896692&view=diff
==============================================================================
--- qpid/trunk/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/UserManagement.java (original)
+++ qpid/trunk/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/UserManagement.java Wed Jan  6 22:03:39 2010
@@ -54,7 +54,7 @@
     @MBeanOperation(name = "setPassword", description = "Set password for user.",
                     impact = MBeanOperationInfo.ACTION)
     boolean setPassword(@MBeanOperationParameter(name = "username", description = "Username")String username,
-                        @MBeanOperationParameter(name = "password", description = "Password")char[] password);
+                        @MBeanOperationParameter(name = "passwd", description = "Password")char[] password);
 
     /**
      * set rights for users with given details
@@ -89,7 +89,7 @@
     @MBeanOperation(name = "createUser", description = "Create new user from system.",
                     impact = MBeanOperationInfo.ACTION)
     boolean createUser(@MBeanOperationParameter(name = "username", description = "Username")String username,
-                       @MBeanOperationParameter(name = "password", description = "Password")char[] password,
+                       @MBeanOperationParameter(name = "passwd", description = "Password")char[] password,
                        @MBeanOperationParameter(name = "read", description = "Administration read")boolean read,
                        @MBeanOperationParameter(name = "readAndWrite", description = "Administration write")boolean write,
                        @MBeanOperationParameter(name = "admin", description = "Administration rights")boolean admin);



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org