You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by bh...@apache.org on 2007/04/24 17:49:04 UTC

svn commit: r531989 - in /incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui: ./ actions/ jmx/ views/

Author: bhupendrab
Date: Tue Apr 24 08:49:03 2007
New Revision: 531989

URL: http://svn.apache.org/viewvc?view=rev&rev=531989
Log:
Added connection exception handling and refactored the action classes

Removed:
    incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ICommandIds.java
Modified:
    incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AbstractAction.java
    incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java
    incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/CloseConnection.java
    incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/EditAttribute.java
    incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java
    incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/Refresh.java
    incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/RemoveServer.java
    incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java
    incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java

Modified: incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AbstractAction.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AbstractAction.java?view=diff&rev=531989&r1=531988&r2=531989
==============================================================================
--- incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AbstractAction.java (original)
+++ incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AbstractAction.java Tue Apr 24 08:49:03 2007
@@ -26,15 +26,24 @@
 import org.apache.qpid.management.ui.ApplicationWorkbenchAdvisor;
 import org.apache.qpid.management.ui.Constants;
 import org.apache.qpid.management.ui.jmx.MBeanUtility;
+import org.apache.qpid.management.ui.views.NavigationView;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.action.IAction;
 import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.IWorkbenchWindowActionDelegate;
 
 public class AbstractAction
 {
+    private NavigationView _navigationView;
+    
     protected IWorkbenchWindow _window;
+    
+    public static final String RMI_SASL_ERROR = "non-JRMP server";
+    public static final String SECURITY_FAILURE = "User authentication has failed";   
+    public static final String SERVER_UNAVAILABLE = "Qpid server is not running";
    
     /**
      * We will cache window object in order to
@@ -48,8 +57,19 @@
         {
             _window.getShell().setImage(ApplicationRegistry.getImage(Constants.CONSOLE_IMAGE));
         }
+    }   
+
+    protected NavigationView getNavigationView()
+    {
+        if (_navigationView == null)
+        {
+            _navigationView = (NavigationView)_window.getActivePage().findView(NavigationView.ID);
+        }
+        
+        return _navigationView;
     }
     
+    
     protected void handleException(Throwable ex, String title, String msg)
     {
         MBeanUtility.printStackTrace(ex);
@@ -74,5 +94,22 @@
         IStatus status = new Status(IStatus.ERROR, ApplicationWorkbenchAdvisor.PERSPECTIVE_ID,
                                     IStatus.OK, msg, null); 
         ErrorDialog.openError(_window.getShell(), "Error", title, status);
+    }
+    
+
+    /**
+     * Selection in the workbench has been changed. We can change the state of the 'real' action here
+     * if we want, but this can only happen after  the delegate has been created.
+     * @see IWorkbenchWindowActionDelegate#selectionChanged
+     */
+    public void selectionChanged(IAction action, ISelection selection) {
+    }
+
+    /**
+     * We can use this method to dispose of any system resources we previously allocated.
+     * @see IWorkbenchWindowActionDelegate#dispose
+     */
+    public void dispose() {
+        
     }
 }

Modified: incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java?view=diff&rev=531989&r1=531988&r2=531989
==============================================================================
--- incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java (original)
+++ incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java Tue Apr 24 08:49:03 2007
@@ -22,13 +22,13 @@
 
 import static org.apache.qpid.management.ui.Constants.*;
 
+import java.io.IOException;
+
 import org.apache.qpid.management.ui.ApplicationRegistry;
 import org.apache.qpid.management.ui.exceptions.InfoRequiredException;
-import org.apache.qpid.management.ui.views.NavigationView;
 import org.apache.qpid.management.ui.views.NumberVerifyListener;
 import org.apache.qpid.management.ui.views.ViewUtility;
 import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
@@ -47,7 +47,6 @@
 {
     private static final String[] _domains ={"org.apache.qpid"};
     
-    private NavigationView _navigationView;
     private String _transport = DEFAULT_PROTOCOL;
     private String _host;
     private String _port;
@@ -62,19 +61,6 @@
         
     }
     
-    /*
-	public AddServer(IWorkbenchWindow window)//, String label)
-	{
-		_window = window;
-        //setText(label);
-        // The id is used to refer to the action in a menu or toolbar
-		setId(ICommandIds.CMD_ADD_SERVER);
-        // Associate the action with a pre-defined command, to allow key bindings.
-		setActionDefinitionId(ICommandIds.CMD_ADD_SERVER);
-		//setImageDescriptor(org.apache.qpid.management.ui.Activator.getImageDescriptor("/icons/add.gif"));
-	}
-	*/
-    
     public void run(IAction action)
     {
         if(_window != null)
@@ -92,6 +78,17 @@
             {
                 ViewUtility.popupInfoMessage(ACTION_ADDSERVER, ex.getMessage());
             }
+            catch (IOException ex)
+            {
+                if ((ex.getMessage() != null) && (ex.getMessage().indexOf(RMI_SASL_ERROR) != -1))
+                {
+                    handleException(ex, null, SECURITY_FAILURE);
+                }
+                else
+                {
+                    handleException(ex, null, SERVER_UNAVAILABLE);
+                }
+            }
             catch (Exception ex)
             {
                 handleException(ex, null, null);
@@ -108,45 +105,6 @@
         _user = null;
         _password = null;
     }
-    
-    /**
-     * Selection in the workbench has been changed. We 
-     * can change the state of the 'real' action here
-     * if we want, but this can only happen after 
-     * the delegate has been created.
-     * @see IWorkbenchWindowActionDelegate#selectionChanged
-     */
-    public void selectionChanged(IAction action, ISelection selection) {
-    }
-
-    /**
-     * We can use this method to dispose of any system
-     * resources we previously allocated.
-     * @see IWorkbenchWindowActionDelegate#dispose
-     */
-    public void dispose() {
-        
-    }
-    
-    private NavigationView getNavigationView()
-    {
-        if (_navigationView == null)
-        {
-            _navigationView = (NavigationView)_window.getActivePage().findView(NavigationView.ID);
-        }
-        
-        return _navigationView;
-    }
-    
-    /*
-	public void run()
-    {
-		if(_window != null)
-        {	
-            createWidgets();
-		}
-	}
-    */
     
     /**
      * Creates the shell and then opens the popup where user can enter new connection details.

Modified: incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/CloseConnection.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/CloseConnection.java?view=diff&rev=531989&r1=531988&r2=531989
==============================================================================
--- incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/CloseConnection.java (original)
+++ incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/CloseConnection.java Tue Apr 24 08:49:03 2007
@@ -25,7 +25,6 @@
 import org.apache.qpid.management.ui.views.NavigationView;
 import org.apache.qpid.management.ui.views.ViewUtility;
 import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.ui.IWorkbenchWindowActionDelegate;
 
 public class CloseConnection extends AbstractAction implements IWorkbenchWindowActionDelegate
@@ -53,24 +52,5 @@
                 handleException(ex, null, null);
             }
         }
-    }
-    
-    /**
-     * Selection in the workbench has been changed. We 
-     * can change the state of the 'real' action here
-     * if we want, but this can only happen after 
-     * the delegate has been created.
-     * @see IWorkbenchWindowActionDelegate#selectionChanged
-     */
-    public void selectionChanged(IAction action, ISelection selection) {
-    }
-
-    /**
-     * We can use this method to dispose of any system
-     * resources we previously allocated.
-     * @see IWorkbenchWindowActionDelegate#dispose
-     */
-    public void dispose() {
-        
-    }    
+    }   
 }

Modified: incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/EditAttribute.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/EditAttribute.java?view=diff&rev=531989&r1=531988&r2=531989
==============================================================================
--- incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/EditAttribute.java (original)
+++ incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/EditAttribute.java Tue Apr 24 08:49:03 2007
@@ -25,7 +25,6 @@
 import org.apache.qpid.management.ui.views.MBeanView;
 import org.apache.qpid.management.ui.views.ViewUtility;
 import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.ui.IWorkbenchWindowActionDelegate;
 
 public class EditAttribute extends AbstractAction implements IWorkbenchWindowActionDelegate
@@ -48,24 +47,5 @@
                 handleException(ex, "Attribute could not be edited", null);
             }
         }
-    }
-    
-    /**
-     * Selection in the workbench has been changed. We 
-     * can change the state of the 'real' action here
-     * if we want, but this can only happen after 
-     * the delegate has been created.
-     * @see IWorkbenchWindowActionDelegate#selectionChanged
-     */
-    public void selectionChanged(IAction action, ISelection selection) {
-    }
-
-    /**
-     * We can use this method to dispose of any system
-     * resources we previously allocated.
-     * @see IWorkbenchWindowActionDelegate#dispose
-     */
-    public void dispose() {
-        
     }
 }

Modified: incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java?view=diff&rev=531989&r1=531988&r2=531989
==============================================================================
--- incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java (original)
+++ incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java Tue Apr 24 08:49:03 2007
@@ -27,14 +27,14 @@
 import static org.apache.qpid.management.ui.Constants.PASSWORD;
 import static org.apache.qpid.management.ui.Constants.USERNAME;
 
+import java.io.IOException;
+
 import org.apache.qpid.management.ui.ApplicationRegistry;
 import org.apache.qpid.management.ui.Constants;
 import org.apache.qpid.management.ui.exceptions.InfoRequiredException;
-import org.apache.qpid.management.ui.views.NavigationView;
 import org.apache.qpid.management.ui.views.TreeObject;
 import org.apache.qpid.management.ui.views.ViewUtility;
 import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
@@ -50,45 +50,12 @@
 
 public class ReconnectServer extends AbstractAction implements IWorkbenchWindowActionDelegate
 {
-    private NavigationView _navigationView;
     private String _title;
     private String _serverName;
     private String _user;
     private String _password;
     private boolean _connect;
     
-    /**
-     * Selection in the workbench has been changed. We 
-     * can change the state of the 'real' action here
-     * if we want, but this can only happen after 
-     * the delegate has been created.
-     * @see IWorkbenchWindowActionDelegate#selectionChanged
-     */
-    public void selectionChanged(IAction action, ISelection selection)
-    {
-        
-    }
-
-    /**
-     * We can use this method to dispose of any system
-     * resources we previously allocated.
-     * @see IWorkbenchWindowActionDelegate#dispose
-     */
-    public void dispose()
-    {
-        
-    }
-    
-    private NavigationView getNavigationView()
-    {
-        if (_navigationView == null)
-        {
-            _navigationView = (NavigationView)_window.getActivePage().findView(NavigationView.ID);
-        }
-        
-        return _navigationView;
-    }
-    
     public void run(IAction action)
     {
         if(_window != null)
@@ -113,6 +80,17 @@
             catch(InfoRequiredException ex)
             {
                 ViewUtility.popupInfoMessage("Reconnect Qpid server", ex.getMessage());
+            }
+            catch (IOException ex)
+            {
+                if ((ex.getMessage() != null) && (ex.getMessage().indexOf(RMI_SASL_ERROR) != -1))
+                {
+                    handleException(ex, null, SECURITY_FAILURE);
+                }
+                else
+                {
+                    handleException(ex, null, SERVER_UNAVAILABLE);
+                }
             }
             catch (Exception ex)
             {

Modified: incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/Refresh.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/Refresh.java?view=diff&rev=531989&r1=531988&r2=531989
==============================================================================
--- incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/Refresh.java (original)
+++ incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/Refresh.java Tue Apr 24 08:49:03 2007
@@ -24,7 +24,6 @@
 import org.apache.qpid.management.ui.views.MBeanView;
 import org.apache.qpid.management.ui.views.NavigationView;
 import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.ui.IWorkbenchWindowActionDelegate;
 
 /**
@@ -32,29 +31,7 @@
  * @author Bhupendra Bhardwaj
  */
 public class Refresh extends AbstractAction implements IWorkbenchWindowActionDelegate
-{
-    /**
-     * Selection in the workbench has been changed. We 
-     * can change the state of the 'real' action here
-     * if we want, but this can only happen after 
-     * the delegate has been created.
-     * @see IWorkbenchWindowActionDelegate#selectionChanged
-     */
-    public void selectionChanged(IAction action, ISelection selection)
-    {
-        
-    }
-
-    /**
-     * We can use this method to dispose of any system
-     * resources we previously allocated.
-     * @see IWorkbenchWindowActionDelegate#dispose
-     */
-    public void dispose()
-    {
-        
-    }
-    
+{    
     public void run(IAction action)
     {
         if(_window != null)

Modified: incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/RemoveServer.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/RemoveServer.java?view=diff&rev=531989&r1=531988&r2=531989
==============================================================================
--- incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/RemoveServer.java (original)
+++ incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/RemoveServer.java Tue Apr 24 08:49:03 2007
@@ -24,33 +24,10 @@
 import org.apache.qpid.management.ui.views.NavigationView;
 import org.apache.qpid.management.ui.views.ViewUtility;
 import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.ui.IWorkbenchWindowActionDelegate;
 
 public class RemoveServer extends AbstractAction implements IWorkbenchWindowActionDelegate
-{    
-    /**
-     * Selection in the workbench has been changed. We 
-     * can change the state of the 'real' action here
-     * if we want, but this can only happen after 
-     * the delegate has been created.
-     * @see IWorkbenchWindowActionDelegate#selectionChanged
-     */
-    public void selectionChanged(IAction action, ISelection selection)
-    {
-        
-    }
-
-    /**
-     * We can use this method to dispose of any system
-     * resources we previously allocated.
-     * @see IWorkbenchWindowActionDelegate#dispose
-     */
-    public void dispose()
-    {
-        
-    }
-    
+{       
     public void run(IAction action)
     {
         if(_window != null)

Modified: incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java?view=diff&rev=531989&r1=531988&r2=531989
==============================================================================
--- incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java (original)
+++ incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java Tue Apr 24 08:49:03 2007
@@ -39,6 +39,7 @@
 import javax.management.remote.JMXConnector;
 import javax.management.remote.JMXConnectorFactory;
 import javax.management.remote.JMXServiceURL;
+import javax.security.auth.callback.CallbackHandler;
 import javax.security.sasl.SaslClientFactory;
 
 import org.apache.qpid.management.ui.ApplicationRegistry;
@@ -58,6 +59,8 @@
 public class JMXServerRegistry extends ServerRegistry
 {
     private ObjectName _serverObjectName = null;
+    private Map<String, Object> _env = null;
+    private JMXServiceURL _jmxUrl = null;
     private JMXConnector _jmxc = null;
     private MBeanServerConnection _mbsc = null;
     
@@ -92,59 +95,27 @@
     public JMXServerRegistry(ManagedServer server) throws Exception
     {
         super(server);
-        JMXServiceURL jmxUrl = new JMXServiceURL(server.getUrl());
-        Map<String, Object> env = null;
         String securityMechanism = ApplicationRegistry.getSecurityMechanism();
+        boolean saslPluginAvailable = false;
        
         if (securityMechanism != null)
-        {    
-            // Check if the JMXMP connector is available
-            Class klass = Class.forName("javax.management.remote.jmxmp.JMXMPConnector");
-
-            jmxUrl = new JMXServiceURL("jmxmp", server.getHost(), server.getPort());
-            env = new HashMap<String, Object>();
-
-            if (MECH_CRAMMD5.equals(securityMechanism))
+        { 
+            try
             {
-                // For SASL/CRAM-MD5
-                Map<String, Class<? extends SaslClientFactory>> map = new HashMap<String, Class<? extends SaslClientFactory>>();
-                Class<?> clazz = Class.forName("org.apache.qpid.management.ui.sasl.CRAMMD5HashedSaslClientFactory");
-                map.put("CRAM-MD5-HASHED", (Class<? extends SaslClientFactory>) clazz);
-
-                Security.addProvider(new JCAProvider(map));
-                env.put("jmx.remote.profiles", SASL_CRAMMD5); 
-                env.put("jmx.remote.sasl.callback.handler",
-                        new UsernameHashedPasswordCallbackHandler(server.getUser(), server.getPassword()));
+                createSASLConnector(securityMechanism);
+                saslPluginAvailable = true;
             }
-            else if (MECH_PLAIN.equals(securityMechanism))
+            catch (Exception ex)
             {
-                // For SASL/PLAIN
-                Security.addProvider(new SaslProvider());
-                env.put("jmx.remote.profiles", SASL_PLAIN);
-                env.put("jmx.remote.sasl.callback.handler",
-                        new UserPasswordCallbackHandler(server.getUser(), server.getPassword())); 
+                ex.printStackTrace();
+                saslPluginAvailable = false;
             }
-            else
-            {
-                String text = "Security mechanism " + securityMechanism + " is not supported.";
-                MBeanUtility.printOutput(text);
-                throw new Exception(text);
-            }
-            // Now create the instance of JMXMPConnector                                               
-            Class[] paramTypes = {JMXServiceURL.class, Map.class};                           
-            Constructor cons = klass.getConstructor(paramTypes);
-
-            Object[] args = {jmxUrl, env};           
-            Object theObject = cons.newInstance(args);
-
-            _jmxc = (JMXConnector)theObject;
-            _jmxc.connect();
-            MBeanUtility.printOutput("Starting JMXConnector with SASL. Server=" + server.getName());
         }
-        else
+        
+        if (!saslPluginAvailable)
         {
-            jmxUrl = new JMXServiceURL(server.getUrl());
-            _jmxc = JMXConnectorFactory.connect(jmxUrl, null);
+            _jmxUrl = new JMXServiceURL(server.getUrl());
+            _jmxc = JMXConnectorFactory.connect(_jmxUrl, null);
         }
         
         _mbsc = _jmxc.getMBeanServerConnection();
@@ -160,6 +131,53 @@
     public MBeanServerConnection getServerConnection()
     {
         return _mbsc;
+    }
+    
+    private void createSASLConnector(String mech) throws Exception
+    {
+        String text = "Security mechanism " + mech + " is not supported.";
+        // Check if the JMXMP connector is available
+        Class klass = Class.forName("javax.management.remote.jmxmp.JMXMPConnector");
+
+        _jmxUrl = new JMXServiceURL("jmxmp", getManagedServer().getHost(), getManagedServer().getPort());
+        _env = new HashMap<String, Object>();
+        CallbackHandler handler;
+        if (MECH_CRAMMD5.equals(mech))
+        {
+            // For SASL/CRAM-MD5
+            Map<String, Class<? extends SaslClientFactory>> map = new HashMap<String, Class<? extends SaslClientFactory>>();
+            Class<?> clazz = Class.forName("org.apache.qpid.management.ui.sasl.CRAMMD5HashedSaslClientFactory");
+            map.put("CRAM-MD5-HASHED", (Class<? extends SaslClientFactory>) clazz);
+
+            Security.addProvider(new JCAProvider(map));
+            handler = new UsernameHashedPasswordCallbackHandler(getManagedServer().getUser(),
+                                                                getManagedServer().getPassword());
+            _env.put("jmx.remote.profiles", SASL_CRAMMD5); 
+            _env.put("jmx.remote.sasl.callback.handler", handler);
+                    
+        }
+        else if (MECH_PLAIN.equals(mech))
+        {
+            // For SASL/PLAIN
+            Security.addProvider(new SaslProvider());
+            handler = new UserPasswordCallbackHandler(getManagedServer().getUser(), getManagedServer().getPassword());
+            _env.put("jmx.remote.profiles", SASL_PLAIN);
+            _env.put("jmx.remote.sasl.callback.handler", handler); 
+        }
+        else
+        {
+            MBeanUtility.printOutput(text);
+            throw new Exception(text);
+        }
+        // Now create the instance of JMXMPConnector                                               
+        Class[] paramTypes = {JMXServiceURL.class, Map.class};                           
+        Constructor cons = klass.getConstructor(paramTypes);
+
+        Object[] args = {_jmxUrl, _env};           
+        Object theObject = cons.newInstance(args);
+
+        _jmxc = (JMXConnector)theObject;
+        _jmxc.connect();
     }
     
     /**

Modified: incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java?view=diff&rev=531989&r1=531988&r2=531989
==============================================================================
--- incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java (original)
+++ incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java Tue Apr 24 08:49:03 2007
@@ -208,20 +208,9 @@
      */
     private void createRMIServerConnection(ManagedServer server) throws Exception
     {
-        try
-        {
-            // Currently Qpid Management Console only supports JMX MBeanServer
-            ServerRegistry serverRegistry = new JMXServerRegistry(server);
-            ApplicationRegistry.addServer(server, serverRegistry);
-        }
-        catch (IOException ex)
-        {
-            if (ex.getCause() == null)
-            {
-                throw ex;
-            }
-            throw (Exception)ex.getCause();
-        }
+        // Currently Qpid Management Console only supports JMX MBeanServer
+        ServerRegistry serverRegistry = new JMXServerRegistry(server);
+        ApplicationRegistry.addServer(server, serverRegistry);
     }
 
     /**