diff options
author | Jose <jose@zeroc.com> | 2012-10-25 00:03:42 +0200 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2012-10-25 00:03:42 +0200 |
commit | 1d13180dbc75b2107346fa9b2cf22812622657cc (patch) | |
tree | 99cf0e933f75f5cb744619209dcf09ab9e70089f /java/src | |
parent | Fixed typo in build.xml (diff) | |
download | ice-1d13180dbc75b2107346fa9b2cf22812622657cc.tar.bz2 ice-1d13180dbc75b2107346fa9b2cf22812622657cc.tar.xz ice-1d13180dbc75b2107346fa9b2cf22812622657cc.zip |
Fixed ICE-4905 - Provide a SSL X509 Certificate dialog
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/IceGridGUI/Coordinator.java | 43 | ||||
-rw-r--r-- | java/src/IceGridGUI/SessionKeeper.java | 302 |
2 files changed, 296 insertions, 49 deletions
diff --git a/java/src/IceGridGUI/Coordinator.java b/java/src/IceGridGUI/Coordinator.java index 12966c06fe5..684d16b68a8 100644 --- a/java/src/IceGridGUI/Coordinator.java +++ b/java/src/IceGridGUI/Coordinator.java @@ -630,6 +630,25 @@ public class Coordinator return _communicator; } + public Ice.Communicator getWizardCommunicator() + { + if(_wizardCommunicator == null) + { + // + // Create a communicator that is used by connection wizards to + // parse endpoints. + // + // We enable IceSSL so the communicator knows how to parse ssl + // endpoints. + // + Ice.InitializationData initData = new Ice.InitializationData(); + initData.properties = Ice.Util.createProperties(); + initData.properties.setProperty("Ice.Plugin.IceSSL", "IceSSL.PluginFactory"); + _wizardCommunicator = Ice.Util.initialize(initData); + } + return _wizardCommunicator; + } + public Ice.Properties getProperties() { return _initData.properties; @@ -2459,6 +2478,7 @@ public class Coordinator { destroyIceGridAdmin(); destroyCommunicator(); + destroyWizardCommunicator(); } }; @@ -3215,6 +3235,7 @@ public class Coordinator destroyIceGridAdmin(); destroyCommunicator(); + destroyWizardCommunicator(); Runtime.getRuntime().removeShutdownHook(_shutdownHook); _mainFrame.dispose(); Runtime.getRuntime().exit(status); @@ -3241,6 +3262,27 @@ public class Coordinator } } + // + // Can be called by the shutdown hook thread + // + private void destroyWizardCommunicator() + { + if(_wizardCommunicator != null) + { + try + { + _wizardCommunicator.destroy(); + } + catch(Ice.LocalException e) + { + System.err.println("_wizardCommunicator.destroy() raised " + + e.toString()); + e.printStackTrace(); + } + _wizardCommunicator = null; + } + } + private boolean loadWindowPrefs() { try @@ -3633,6 +3675,7 @@ public class Coordinator private boolean _substitute = false; private JFrame _mainFrame; + private Ice.Communicator _wizardCommunicator; private final SessionKeeper _sessionKeeper; private Object _clipboard; diff --git a/java/src/IceGridGUI/SessionKeeper.java b/java/src/IceGridGUI/SessionKeeper.java index ca69be167ee..0f8cf23a787 100644 --- a/java/src/IceGridGUI/SessionKeeper.java +++ b/java/src/IceGridGUI/SessionKeeper.java @@ -1306,7 +1306,7 @@ public class SessionKeeper } }); group.add(_directDefaultEndpointSSL); - _directDefaultEndpointSSL.setSelected(true); + _directDefaultEndpointTCP.setSelected(true); JPanel protocolOptionPane; { DefaultFormBuilder protocolBuilder = new DefaultFormBuilder( @@ -1392,7 +1392,7 @@ public class SessionKeeper } }); group.add(_routedDefaultEndpointSSL); - _routedDefaultEndpointSSL.setSelected(true); + _routedDefaultEndpointTCP.setSelected(true); JPanel protocolOptionPane; { DefaultFormBuilder protocolBuilder = @@ -1468,7 +1468,7 @@ public class SessionKeeper _cardPanel.add(builder.getPanel(), WizardStep.RoutedCustomEnpointStep.toString()); } - // Authentication panel + // X509Certificate panel { FormLayout layout = new FormLayout("pref", "pref"); DefaultFormBuilder builder = new DefaultFormBuilder(layout); @@ -1477,35 +1477,32 @@ public class SessionKeeper ButtonGroup group = new ButtonGroup(); - _usernamePasswordAuthButton = new JRadioButton( - new AbstractAction("Use Username/Password authentication") + _x509CertificateNoButton = new JRadioButton(new AbstractAction("No") + { + public void actionPerformed(ActionEvent e) { - public void actionPerformed(ActionEvent e) - { - validatePanel(); - } - }); - _usernamePasswordAuthButton.setSelected(true); - group.add(_usernamePasswordAuthButton); - _certificateAuthButton = new JRadioButton(new AbstractAction("Use X509 Certificate authentication") + validatePanel(); + } + }); + _x509CertificateNoButton.setSelected(true); + group.add(_x509CertificateNoButton); + _x509CertificateYesButton = new JRadioButton(new AbstractAction("Yes") { public void actionPerformed(ActionEvent e) { validatePanel(); } }); - group.add(_certificateAuthButton); + group.add(_x509CertificateYesButton); - builder.append(new JLabel("<html><b>Authentication Type</b></html>")); - builder.append(_usernamePasswordAuthButton); - builder.append(new JLabel("This option will use the Username/Password for authentication.")); - builder.append(_certificateAuthButton); - builder.append(new JLabel("This option will use X509 Certificates for authentication.")); + builder.append(new JLabel("<html><b>Provide a SSL X509 Certificate?</b></html>")); + builder.append(_x509CertificateNoButton); + builder.append(_x509CertificateYesButton); - _cardPanel.add(builder.getPanel(), WizardStep.AuthStep.toString()); + _cardPanel.add(builder.getPanel(), WizardStep.X509CertificateStep.toString()); } - // X509Certificate panel + // Authentication panel { FormLayout layout = new FormLayout("pref", "pref"); DefaultFormBuilder builder = new DefaultFormBuilder(layout); @@ -1514,29 +1511,32 @@ public class SessionKeeper ButtonGroup group = new ButtonGroup(); - _x509CertificateNoButton = new JRadioButton(new AbstractAction("No") - { - public void actionPerformed(ActionEvent e) + _usernamePasswordAuthButton = new JRadioButton( + new AbstractAction("Use Username/Password authentication") { - validatePanel(); - } - }); - _x509CertificateNoButton.setSelected(true); - group.add(_x509CertificateNoButton); - _x509CertificateYesButton = new JRadioButton(new AbstractAction("Yes") + public void actionPerformed(ActionEvent e) + { + validatePanel(); + } + }); + _usernamePasswordAuthButton.setSelected(true); + group.add(_usernamePasswordAuthButton); + _certificateAuthButton = new JRadioButton(new AbstractAction("Use X509 Certificate authentication") { public void actionPerformed(ActionEvent e) { validatePanel(); } }); - group.add(_x509CertificateYesButton); + group.add(_certificateAuthButton); - builder.append(new JLabel("<html><b>Provide a SSL X509 Certificate?</b></html>")); - builder.append(_x509CertificateNoButton); - builder.append(_x509CertificateYesButton); + builder.append(new JLabel("<html><b>Authentication Type</b></html>")); + builder.append(_usernamePasswordAuthButton); + builder.append(new JLabel("This option will use the Username/Password for authentication.")); + builder.append(_certificateAuthButton); + builder.append(new JLabel("This option will use X509 Certificates for authentication.")); - _cardPanel.add(builder.getPanel(), WizardStep.X509CertificateStep.toString()); + _cardPanel.add(builder.getPanel(), WizardStep.AuthStep.toString()); } // Finish configuration panel @@ -1643,18 +1643,23 @@ public class SessionKeeper } break; } - case RoutedDefaultEndpointStep: - case RoutedCustomEnpointStep: case DirectDefaultEndpointStep: - case DirectCustomEnpointStep: { - _cardLayout.show(_cardPanel, WizardStep.AuthStep.toString()); - _wizardSteps.push(WizardStep.AuthStep); + if(_directDefaultEndpointSSL.isSelected()) + { + _cardLayout.show(_cardPanel, WizardStep.X509CertificateStep.toString()); + _wizardSteps.push(WizardStep.X509CertificateStep); + } + else + { + _cardLayout.show(_cardPanel, WizardStep.FinishStep.toString()); + _wizardSteps.push(WizardStep.FinishStep); + } break; } - case AuthStep: + case RoutedDefaultEndpointStep: { - if(_usernamePasswordAuthButton.isSelected()) + if(_routedDefaultEndpointSSL.isSelected()) { _cardLayout.show(_cardPanel, WizardStep.X509CertificateStep.toString()); _wizardSteps.push(WizardStep.X509CertificateStep); @@ -1666,8 +1671,106 @@ public class SessionKeeper } break; } + case DirectCustomEnpointStep: + { + try + { + Ice.Identity id = new Ice.Identity(); + id.name = "router"; + id.category = _directInstanceName.getText(); + StringBuilder endpoint = new StringBuilder(); + endpoint.append(_coordinator.getWizardCommunicator().identityToString(id)); + endpoint.append(":"); + endpoint.append(_directCustomEndpointValue.getText()); + if(hasSecureEndpoints(endpoint.toString())) + { + _cardLayout.show(_cardPanel, WizardStep.X509CertificateStep.toString()); + _wizardSteps.push(WizardStep.X509CertificateStep); + } + else + { + _cardLayout.show(_cardPanel, WizardStep.FinishStep.toString()); + _wizardSteps.push(WizardStep.FinishStep); + } + } + catch(Ice.EndpointParseException ex) + { + JOptionPane.showMessageDialog( + ConnectionWizardDialog.this, + ex.str, + "Error parsing endpoint", + JOptionPane.ERROR_MESSAGE); + return; + } + catch(Ice.ProxyParseException ex) + { + JOptionPane.showMessageDialog( + ConnectionWizardDialog.this, + ex.str, + "Error parsing endpoint", + JOptionPane.ERROR_MESSAGE); + return; + } + break; + } + case RoutedCustomEnpointStep: + { + try + { + Ice.Identity id = new Ice.Identity(); + id.name = "router"; + id.category = _routedInstanceName.getText(); + StringBuilder endpoint = new StringBuilder(); + endpoint.append(_coordinator.getWizardCommunicator().identityToString(id)); + endpoint.append(":"); + endpoint.append(_routedCustomEndpointValue.getText()); + if(hasSecureEndpoints(endpoint.toString())) + { + _cardLayout.show(_cardPanel, WizardStep.X509CertificateStep.toString()); + _wizardSteps.push(WizardStep.X509CertificateStep); + } + else + { + _cardLayout.show(_cardPanel, WizardStep.FinishStep.toString()); + _wizardSteps.push(WizardStep.FinishStep); + } + } + catch(Ice.EndpointParseException ex) + { + JOptionPane.showMessageDialog( + ConnectionWizardDialog.this, + ex.str, + "Error parsing endpoint", + JOptionPane.ERROR_MESSAGE); + return; + } + catch(Ice.ProxyParseException ex) + { + JOptionPane.showMessageDialog( + ConnectionWizardDialog.this, + ex.str, + "Error parsing endpoint", + JOptionPane.ERROR_MESSAGE); + return; + } + break; + } case X509CertificateStep: { + if(_x509CertificateYesButton.isSelected()) + { + _cardLayout.show(_cardPanel, WizardStep.AuthStep.toString()); + _wizardSteps.push(WizardStep.AuthStep); + } + else + { + _cardLayout.show(_cardPanel, WizardStep.FinishStep.toString()); + _wizardSteps.push(WizardStep.FinishStep); + } + break; + } + case AuthStep: + { _cardLayout.show(_cardPanel, WizardStep.FinishStep.toString()); _wizardSteps.push(WizardStep.FinishStep); break; @@ -1737,6 +1840,35 @@ public class SessionKeeper } else { + try + { + Ice.Identity id = new Ice.Identity(); + id.name = "locator"; + id.category = _directInstanceName.getText(); + StringBuilder endpoint = new StringBuilder(); + endpoint.append(_coordinator.getWizardCommunicator().identityToString(id)); + endpoint.append(":"); + endpoint.append(_directCustomEndpointValue.getText()); + _coordinator.getWizardCommunicator().stringToProxy(endpoint.toString()); + } + catch(Ice.EndpointParseException ex) + { + JOptionPane.showMessageDialog( + ConnectionWizardDialog.this, + ex.str, + "Error parsing endpoint", + JOptionPane.ERROR_MESSAGE); + return; + } + catch(Ice.ProxyParseException ex) + { + JOptionPane.showMessageDialog( + ConnectionWizardDialog.this, + ex.str, + "Error parsing endpoint", + JOptionPane.ERROR_MESSAGE); + return; + } inf.setEndpoint(_directCustomEndpointValue.getText()); } } @@ -1768,10 +1900,38 @@ public class SessionKeeper JOptionPane.ERROR_MESSAGE); return; } - inf.setSSL(_directDefaultEndpointSSL.isSelected()); } else { + try + { + Ice.Identity id = new Ice.Identity(); + id.name = "router"; + id.category = _routedInstanceName.getText(); + StringBuilder endpoint = new StringBuilder(); + endpoint.append(_coordinator.getWizardCommunicator().identityToString(id)); + endpoint.append(":"); + endpoint.append(_routedCustomEndpointValue.getText()); + _coordinator.getWizardCommunicator().stringToProxy(endpoint.toString()); + } + catch(Ice.EndpointParseException ex) + { + JOptionPane.showMessageDialog( + ConnectionWizardDialog.this, + ex.str, + "Error parsing endpoint", + JOptionPane.ERROR_MESSAGE); + return; + } + catch(Ice.ProxyParseException ex) + { + JOptionPane.showMessageDialog( + ConnectionWizardDialog.this, + ex.str, + "Error parsing endpoint", + JOptionPane.ERROR_MESSAGE); + return; + } inf.setEndpoint(_routedCustomEndpointValue.getText()); } } @@ -1905,6 +2065,18 @@ public class SessionKeeper _routedCustomEndpointValue.requestFocusInWindow(); break; } + case X509CertificateStep: + { + finalStep = true; + if(_x509CertificateYesButton.isSelected()) + { + _x509CertificateYesButton.requestFocusInWindow(); + } + else + { + _x509CertificateNoButton.requestFocusInWindow(); + } + } case AuthStep: { finalStep = true; @@ -1918,11 +2090,6 @@ public class SessionKeeper } break; } - case X509CertificateStep: - { - finalStep = true; - break; - } case FinishStep: { finalStep = true; @@ -2271,6 +2438,18 @@ public class SessionKeeper ConnectionInfo _conf; } + private boolean hasSecureEndpoints(String str) + { + for(Ice.Endpoint endpoint : _coordinator.getWizardCommunicator().stringToProxy(str).ice_getEndpoints()) + { + if(endpoint.getInfo().secure()) + { + return true; + } + } + return false; + } + enum WizardStep {ConnectionTypeStep, DirectInstanceStep, DirectEndpointStep, DirectDefaultEndpointStep, DirectCustomEnpointStep, RoutedInstanceStep, RoutedEndpointStep, RoutedDefaultEndpointStep, RoutedCustomEnpointStep, @@ -2305,6 +2484,7 @@ public class SessionKeeper new JLabel(inf.getInstanceName())); } + boolean ssl = false; if(inf.getDefaultEndpoint()) { builder.append(new JLabel("<html><b>Hostname:</b></html>"), @@ -2323,11 +2503,21 @@ public class SessionKeeper builder.append(new JLabel("<html><b>Protocol:</b></html>"), new JLabel("TCP")); } + ssl = inf.getSSL(); } else { builder.append(new JLabel("<html><b>Endpoints:</b></html>"), new JLabel(inf.getEndpoint())); + + Ice.Identity id = new Ice.Identity(); + id.name = inf.getDirect() ? "locator" : "router"; + id.category = inf.getInstanceName(); + StringBuilder endpoint = new StringBuilder(); + endpoint.append(_coordinator.getWizardCommunicator().identityToString(id)); + endpoint.append(":"); + endpoint.append(inf.getEndpoint()); + ssl = hasSecureEndpoints(endpoint.toString()); } if(inf.getAuth() == AuthType.UsernamePasswordAuthType) @@ -2340,6 +2530,20 @@ public class SessionKeeper builder.append(new JLabel("<html><b>Authentication mode:</b></html>"), new JLabel("SSL Certificate")); } + + if(ssl) + { + if(inf.getUseX509Certificate()) + { + builder.append(new JLabel("<html><b>Use SSL Client Certificate:</b></html>"), + new JLabel("Yes")); + } + else + { + builder.append(new JLabel("<html><b>Use SSL Client Certificate:</b></html>"), + new JLabel("No")); + } + } detailsPane = builder.getPanel(); } @@ -2612,7 +2816,7 @@ public class SessionKeeper }); JScrollPane registryListScroll = createStrippedScrollPane(_connectionList); - _connectionList.setFixedCellWidth(300); + _connectionList.setFixedCellWidth(500); builder.append(registryListScroll); savedConfigurationsPanel = builder.getPanel(); |