diff options
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/Ice/PluginManagerI.java | 65 | ||||
-rw-r--r-- | java/src/IceInternal/PropertyNames.java | 7 | ||||
-rw-r--r-- | java/src/IceSSL/Instance.java | 38 | ||||
-rw-r--r-- | java/src/IceSSL/Plugin.java | 18 | ||||
-rw-r--r-- | java/src/IceSSL/PluginI.java | 16 |
5 files changed, 118 insertions, 26 deletions
diff --git a/java/src/Ice/PluginManagerI.java b/java/src/Ice/PluginManagerI.java index 780333c0b2f..d0583e7b192 100644 --- a/java/src/Ice/PluginManagerI.java +++ b/java/src/Ice/PluginManagerI.java @@ -11,7 +11,56 @@ package Ice; public final class PluginManagerI extends LocalObjectImpl implements PluginManager { - private static String _kindOfObject = "plug-in"; + private static String _kindOfObject = "plugin"; + + public synchronized void + initializePlugins() + { + if(_initialized) + { + InitializationException ex = new InitializationException(); + ex.reason = "plugins already initialized"; + throw ex; + } + + // + // Invoke initialize() on the plugins, in the order they were loaded. + // + java.util.ArrayList initializedPlugins = new java.util.ArrayList(); + try + { + java.util.Iterator i = _initOrder.iterator(); + while(i.hasNext()) + { + Plugin p = (Plugin)i.next(); + p.initialize(); + initializedPlugins.add(p); + } + } + catch(RuntimeException ex) + { + // + // Destroy the plugins that have been successfully initialized, in the + // reverse order. + // + java.util.ListIterator i = initializedPlugins.listIterator(initializedPlugins.size()); + while(i.hasPrevious()) + { + Plugin p = (Plugin)i.previous(); + try + { + p.destroy(); + } + catch(RuntimeException e) + { + // Ignore. + } + } + throw ex; + } + + _initialized = true; + } public synchronized Plugin getPlugin(String name) @@ -70,6 +119,7 @@ public final class PluginManagerI extends LocalObjectImpl implements PluginManag PluginManagerI(Communicator communicator) { _communicator = communicator; + _initialized = false; } public void @@ -132,6 +182,16 @@ public final class PluginManagerI extends LocalObjectImpl implements PluginManag String value = (String)entry.getValue(); loadPlugin(name, value, cmdArgs); } + + // + // An application can set Ice.InitPlugins=0 if it wants to postpone + // initialization until after it has interacted directly with the + // plugins. + // + if(properties.getPropertyAsIntWithDefault("Ice.InitPlugins", 1) > 0) + { + initializePlugins(); + } } private void @@ -243,8 +303,11 @@ public final class PluginManagerI extends LocalObjectImpl implements PluginManag } _plugins.put(name, plugin); + _initOrder.add(plugin); } private Communicator _communicator; private java.util.HashMap _plugins = new java.util.HashMap(); + private java.util.ArrayList _initOrder = new java.util.ArrayList(); + private boolean _initialized; } diff --git a/java/src/IceInternal/PropertyNames.java b/java/src/IceInternal/PropertyNames.java index 2d111c9383d..8fcde1c2f37 100644 --- a/java/src/IceInternal/PropertyNames.java +++ b/java/src/IceInternal/PropertyNames.java @@ -7,7 +7,8 @@ // // ********************************************************************** -// Generated by makeprops.py from file `../config/PropertyNames.def', Mon Apr 17 10:30:14 2006 +// Generated by makeprops.py from file `../config/PropertyNames.def', Tue Apr 25 16:28:52 2006 + // IMPORTANT: Do not edit this file -- any edits made here will be lost! package IceInternal; @@ -29,6 +30,7 @@ public final class PropertyNames "^Ice\\.Default\\.Protocol$", "^Ice\\.Default\\.Router$", "^Ice\\.GC\\.Interval$", + "^Ice\\.InitPlugins$", "^Ice\\.Logger\\.Timestamp$", "^Ice\\.MessageSizeMax$", "^Ice\\.MonitorConnections$", @@ -209,13 +211,10 @@ public final class PropertyNames "^IceSSL\\.CertAuthDir$", "^IceSSL\\.CertAuthFile$", "^IceSSL\\.CertFile$", - "^IceSSL\\.Certs$", - "^IceSSL\\.CertsPassword$", "^IceSSL\\.CheckCertName$", "^IceSSL\\.CheckCRL$", "^IceSSL\\.Ciphers$", "^IceSSL\\.DefaultDir$", - "^IceSSL\\.DelayInit$", "^IceSSL\\.DH\\.[^\\s.]+$", "^IceSSL\\.EntropyDaemon$", "^IceSSL\\.ImportCert\\.[^\\s.]+\\.[^\\s.]+$", diff --git a/java/src/IceSSL/Instance.java b/java/src/IceSSL/Instance.java index 4b6fa6baf66..e14619334d7 100644 --- a/java/src/IceSSL/Instance.java +++ b/java/src/IceSSL/Instance.java @@ -18,34 +18,24 @@ class Instance _securityTraceCategory = "Security"; // - // Initialize the plugin, unless IceSSL.DelayInit=1. - // - if(communicator.getProperties().getPropertyAsInt("IceSSL.DelayInit") == 0) - { - initialize(null); - } - - // // Register the endpoint factory. // _facade.addEndpointFactory(new EndpointFactoryI(this)); } void - initialize(javax.net.ssl.SSLContext context) + initialize() { if(_context != null) { - Ice.PluginInitializationException e = new Ice.PluginInitializationException(); - e.reason = "plugin is already initialized"; - throw e; + return; } // // If we have to initialize an SSLContext, we'll need a SecureRandom object. // java.security.SecureRandom rand = null; - if(context == null) + if(_ctx == null) { try { @@ -71,7 +61,7 @@ class Instance // try { - _context = new Context(this, context, rand); + _context = new Context(this, _ctx, rand); } catch(java.security.GeneralSecurityException ex) { @@ -83,6 +73,25 @@ class Instance } void + setContext(javax.net.ssl.SSLContext context) + { + if(_context != null) + { + Ice.PluginInitializationException ex = new Ice.PluginInitializationException(); + ex.reason = "IceSSL: plugin is already initialized"; + throw ex; + } + + _ctx = context; + } + + javax.net.ssl.SSLContext + getContext() + { + return _ctx; + } + + void setCertificateVerifier(CertificateVerifier verifier) { _verifier = verifier; @@ -147,4 +156,5 @@ class Instance private String _securityTraceCategory; private Context _context; private CertificateVerifier _verifier; + private javax.net.ssl.SSLContext _ctx; } diff --git a/java/src/IceSSL/Plugin.java b/java/src/IceSSL/Plugin.java index 64eac3f1b2b..f5555fa2a4e 100644 --- a/java/src/IceSSL/Plugin.java +++ b/java/src/IceSSL/Plugin.java @@ -11,14 +11,22 @@ package IceSSL; public interface Plugin extends Ice.Plugin { + // + // Establish the SSL context. This must be done before the + // plugin is initialized, therefore the application must define + // the property Ice.InitPlugins=0, set the context, and finally + // invoke initializePlugins on the PluginManager. + // + // When the application supplies its own SSL context, the + // plugin skips its normal property-based configuration. // - // Manually initialize the plugin. The application must set the property - // IceSSL.DelayInit=1 in order to use this method. + void setContext(javax.net.ssl.SSLContext context); + // - // It is legal to pass null as the argument, in which case the plugin - // obtains its configuration via properties. + // Obtain the SSL context. Use caution when modifying this value. + // Changes made to this value have no effect on existing connections. // - void initialize(javax.net.ssl.SSLContext context); + javax.net.ssl.SSLContext getContext(); // // Establish the certificate verifier object. This should be diff --git a/java/src/IceSSL/PluginI.java b/java/src/IceSSL/PluginI.java index 13748a83061..838322ec034 100644 --- a/java/src/IceSSL/PluginI.java +++ b/java/src/IceSSL/PluginI.java @@ -18,14 +18,26 @@ class PluginI extends Ice.LocalObjectImpl implements Plugin } public void + initialize() + { + _instance.initialize(); + } + + public void destroy() { } public void - initialize(javax.net.ssl.SSLContext context) + setContext(javax.net.ssl.SSLContext context) + { + _instance.setContext(context); + } + + public javax.net.ssl.SSLContext + getContext() { - _instance.initialize(context); + return _instance.getContext(); } public void |