diff options
| author | Robert Gemmell <robbie@apache.org> | 2010-01-06 22:03:39 +0000 |
|---|---|---|
| committer | Robert Gemmell <robbie@apache.org> | 2010-01-06 22:03:39 +0000 |
| commit | 23a64e9e8dab5829da0b1bfa9a501124f95667b9 (patch) | |
| tree | 049432768847393c4a7872053aa6c40e922541fc /java | |
| parent | dd4acef7f90f2351aa8ceace566521b807505614 (diff) | |
| download | qpid-python-23a64e9e8dab5829da0b1bfa9a501124f95667b9.tar.gz | |
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.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@896692 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java')
2 files changed, 48 insertions, 2 deletions
diff --git a/java/broker/src/main/java/org/apache/qpid/server/management/MBeanInvocationHandlerImpl.java b/java/broker/src/main/java/org/apache/qpid/server/management/MBeanInvocationHandlerImpl.java index 0ee5763d91..74ca0399a1 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/management/MBeanInvocationHandlerImpl.java +++ b/java/broker/src/main/java/org/apache/qpid/server/management/MBeanInvocationHandlerImpl.java @@ -38,6 +38,7 @@ import javax.management.MBeanOperationInfo; 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 @@ public class MBeanInvocationHandlerImpl implements InvocationHandler, Notificati Principal principal = principals.iterator().next(); String identity = principal.getName(); + + checkCompatibility(proxy, method, args); if (isAdminMethod(args)) { @@ -168,6 +171,49 @@ public class MBeanInvocationHandlerImpl implements InvocationHandler, Notificati 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) diff --git a/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/UserManagement.java b/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/UserManagement.java index 474012bf12..4a43071c3b 100644 --- a/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/UserManagement.java +++ b/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/UserManagement.java @@ -54,7 +54,7 @@ public interface UserManagement @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 @@ public interface UserManagement @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); |
