diff options
author | Matthew Newhook <matthew@zeroc.com> | 2009-01-09 11:49:20 -0330 |
---|---|---|
committer | Matthew Newhook <matthew@zeroc.com> | 2009-01-09 11:49:20 -0330 |
commit | 9117e9040c02465cb9f0a1e0bcc6aa963f71c61a (patch) | |
tree | ef345adb5612327136e70c8207182e015dfc6349 /java | |
parent | Fixed NRVO demo depend file (diff) | |
parent | http://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=3553. database demo uses w... (diff) | |
download | ice-9117e9040c02465cb9f0a1e0bcc6aa963f71c61a.tar.bz2 ice-9117e9040c02465cb9f0a1e0bcc6aa963f71c61a.tar.xz ice-9117e9040c02465cb9f0a1e0bcc6aa963f71c61a.zip |
Merge commit 'origin/R3_3_branch'
Conflicts:
cs/demo/WCF/latency/Client.cs
cs/demo/WCF/latency_m/Client.cs
cs/demo/WCF/throughput/Client.cs
cs/demo/WCF/throughput_m/Client.cs
cs/demo/WCF/throughput_m/Service.cs
java/demo/Database/library/BookI.java
java/demo/Database/library/BookQueryResultI.java
java/demo/Database/library/Client.java
java/demo/Database/library/ConnectionPool.java
java/demo/Database/library/DispatchInterceptorI.java
java/demo/Database/library/Glacier2Session.ice
java/demo/Database/library/Glacier2SessionManagerI.java
java/demo/Database/library/Grammar.java
java/demo/Database/library/Library.ice
java/demo/Database/library/LibraryI.java
java/demo/Database/library/Parser.java
java/demo/Database/library/ReapThread.java
java/demo/Database/library/RunParser.java
java/demo/Database/library/SQLRequestContext.java
java/demo/Database/library/Scanner.java
java/demo/Database/library/Server.java
java/demo/Database/library/Session.ice
java/demo/Database/library/SessionFactoryI.java
java/demo/Database/library/SessionI.java
java/demo/Database/library/Token.java
java/demo/Database/library/build.xml
java/demo/Database/library/config.client
Diffstat (limited to 'java')
38 files changed, 378 insertions, 883 deletions
diff --git a/java/CHANGES b/java/CHANGES index 88989eece0c..28e43ac5801 100644 --- a/java/CHANGES +++ b/java/CHANGES @@ -53,8 +53,8 @@ Changes since version 3.2.0 encapsulation) in base64 encoding. This syntax is useful if, for example, a client that has the SSL - plugin configured sends a proxy with an SSL endpoint to a server - without the SSL plugin. Prior to this version, the server would + plug-in configured sends a proxy with an SSL endpoint to a server + without the SSL plug-in. Prior to this version, the server would drop the unknown SSL endpoint when it stringified the proxy. As of this version, the server preserves the endpoint and, when the server stringifies a proxy containing an unknown endpoint, it uses @@ -277,7 +277,7 @@ Changes since version 3.0.1 - Added identityToString and stringToIdentity to the Communicator interface. -- Added an SSL plugin for Java5 that supports the thread pool +- Added an SSL plug-in for Java5 that supports the thread pool concurrency model. - Added support for specifying an alternate abstract type in diff --git a/java/INSTALL b/java/INSTALL index b6edfa9e1b5..3a78294a206 100644 --- a/java/INSTALL +++ b/java/INSTALL @@ -39,7 +39,7 @@ You can download Java5 and Java6 for Solaris, Windows, and Linux from: Make sure to add javac and java to your PATH. -When using the Ice for Java SSL plugin (IceSSL), you may experience +When using the Ice for Java SSL plug-in (IceSSL), you may experience occasional hangs. The most likely reason is that your system's entropy pool is empty. If you have sufficient system privileges, you can solve this issue by editing the following file diff --git a/java/config/build.properties b/java/config/build.properties index e3f8ca595ff..ce46f1d3adb 100644 --- a/java/config/build.properties +++ b/java/config/build.properties @@ -7,7 +7,7 @@ # # ********************************************************************** -ice.version = 3.3.0 +ice.version = 3.3.1 db.version = 4.6.21 # @@ -38,5 +38,5 @@ debug = on # jgoodies.forms = /usr/share/java/forms-1.2.0.jar jgoodies.looks = /usr/share/java/looks-2.1.4.jar -#jgoodies.forms = C:/Ice-3.3.0-ThirdParty-VC80/lib/forms-1.2.0.jar -#jgoodies.looks = C:/Ice-3.3.0-ThirdParty-VC80/lib/looks-2.1.4.jar +#jgoodies.forms = C:/Ice-3.3.1-ThirdParty-VC80/lib/forms-1.2.0.jar +#jgoodies.looks = C:/Ice-3.3.1-ThirdParty-VC80/lib/looks-2.1.4.jar diff --git a/java/demo/Database/.DS_Store b/java/demo/Database/.DS_Store Binary files differnew file mode 100644 index 00000000000..ca6143d6f15 --- /dev/null +++ b/java/demo/Database/.DS_Store diff --git a/java/demo/Database/library/Glacier2Session.ice b/java/demo/Database/library/Glacier2Session.ice index 5a9ab2dd252..1dce2feae44 100644 --- a/java/demo/Database/library/Glacier2Session.ice +++ b/java/demo/Database/library/Glacier2Session.ice @@ -1,6 +1,10 @@ // ********************************************************************** // +<<<<<<< HEAD:java/demo/Database/library/Glacier2Session.ice // Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +======= +// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved. +>>>>>>> origin/R3_3_branch:java/demo/Database/library/Glacier2Session.ice // // This copy of Ice is licensed to you under the terms described in the // ICE_LICENSE file included in this distribution. diff --git a/java/demo/Database/library/Library.ice b/java/demo/Database/library/Library.ice index a26dbe20b01..8d647be0360 100644 --- a/java/demo/Database/library/Library.ice +++ b/java/demo/Database/library/Library.ice @@ -1,6 +1,10 @@ // ********************************************************************** // +<<<<<<< HEAD:java/demo/Database/library/Library.ice // Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +======= +// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved. +>>>>>>> origin/R3_3_branch:java/demo/Database/library/Library.ice // // This copy of Ice is licensed to you under the terms described in the // ICE_LICENSE file included in this distribution. diff --git a/java/demo/Database/library/RunParser.java b/java/demo/Database/library/RunParser.java index e616218df9e..17a21db127e 100644 --- a/java/demo/Database/library/RunParser.java +++ b/java/demo/Database/library/RunParser.java @@ -21,56 +21,6 @@ class RunParser public void refresh(); } - static class Glacier2SessionAdapter implements SessionAdapter - { - public LibraryPrx getLibrary() - { - return _session.getLibrary(); - } - - public void destroy() - { - _session.destroy(); - } - - public void refresh() - { - _session.refresh(); - } - - Glacier2SessionAdapter(Glacier2SessionPrx session) - { - _session = session; - } - - private Glacier2SessionPrx _session; - } - - static class DemoSessionAdapter implements SessionAdapter - { - public LibraryPrx getLibrary() - { - return _session.getLibrary(); - } - - public void destroy() - { - _session.destroy(); - } - - public void refresh() - { - _session.refresh(); - } - - DemoSessionAdapter(SessionPrx session) - { - _session = session; - } - - private SessionPrx _session; - } - static private class SessionRefreshThread extends Thread { SessionRefreshThread(Ice.Logger logger, long timeout, SessionAdapter session) @@ -124,7 +74,7 @@ class RunParser runParser(String appName, String[] args, Ice.Communicator communicator) { SessionAdapter session; - Glacier2.RouterPrx router = Glacier2.RouterPrxHelper.uncheckedCast(communicator.getDefaultRouter()); + final Glacier2.RouterPrx router = Glacier2.RouterPrxHelper.uncheckedCast(communicator.getDefaultRouter()); long timeout; if(router != null) { @@ -166,7 +116,36 @@ class RunParser ex.printStackTrace(); } } - session = new Glacier2SessionAdapter(Glacier2SessionPrxHelper.uncheckedCast(glacier2session)); + final Glacier2SessionPrx sess = Glacier2SessionPrxHelper.uncheckedCast(glacier2session); + session = new SessionAdapter() + { + public LibraryPrx getLibrary() + { + return sess.getLibrary(); + } + + public void destroy() + { + try + { + router.destroySession(); + } + catch(Glacier2.SessionNotExistException ex) + { + } + catch(Ice.ConnectionLostException ex) + { + // + // Expected: the router closed the connection. + // + } + } + + public void refresh() + { + sess.refresh(); + } + }; } else { @@ -178,7 +157,24 @@ class RunParser return 1; } - session = new DemoSessionAdapter(factory.create()); + final SessionPrx sess = factory.create(); + session = new SessionAdapter() + { + public LibraryPrx getLibrary() + { + return sess.getLibrary(); + } + + public void destroy() + { + sess.destroy(); + } + + public void refresh() + { + sess.refresh(); + } + }; timeout = factory.getSessionTimeout()/2; } SessionRefreshThread refresh = new SessionRefreshThread(communicator.getLogger(), timeout, session); diff --git a/java/demo/Database/library/Session.ice b/java/demo/Database/library/Session.ice index 5640227eb05..8c223c370f4 100644 --- a/java/demo/Database/library/Session.ice +++ b/java/demo/Database/library/Session.ice @@ -1,6 +1,10 @@ // ********************************************************************** // +<<<<<<< HEAD:java/demo/Database/library/Session.ice // Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +======= +// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved. +>>>>>>> origin/R3_3_branch:java/demo/Database/library/Session.ice // // This copy of Ice is licensed to you under the terms described in the // ICE_LICENSE file included in this distribution. diff --git a/java/demo/Database/library/build.xml b/java/demo/Database/library/build.xml index 915b235a438..5d894d4610c 100644 --- a/java/demo/Database/library/build.xml +++ b/java/demo/Database/library/build.xml @@ -1,7 +1,11 @@ <!-- ********************************************************************** +<<<<<<< HEAD:java/demo/Database/library/build.xml Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +======= + Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved. +>>>>>>> origin/R3_3_branch:java/demo/Database/library/build.xml This copy of Ice is licensed to you under the terms described in the ICE_LICENSE file included in this distribution. diff --git a/java/demo/Database/library/config.client b/java/demo/Database/library/config.client index 9f0fa65a663..ca71c17ee16 100644 --- a/java/demo/Database/library/config.client +++ b/java/demo/Database/library/config.client @@ -25,7 +25,11 @@ Ice.RetryIntervals=-1 # # Warn about connection exceptions # +<<<<<<< HEAD:java/demo/Database/library/config.client Ice.Warn.Connections=1 +======= +#Ice.Warn.Connections=1 +>>>>>>> origin/R3_3_branch:java/demo/Database/library/config.client # # Network Tracing diff --git a/java/demo/Ice/applet/.gitignore b/java/demo/Ice/applet/.gitignore new file mode 100644 index 00000000000..e5786e5ddd4 --- /dev/null +++ b/java/demo/Ice/applet/.gitignore @@ -0,0 +1 @@ +Hello.jar diff --git a/java/demo/Ice/applet/HelloApplet.java b/java/demo/Ice/applet/HelloApplet.java index 2de5b0ba04d..504f775a148 100644 --- a/java/demo/Ice/applet/HelloApplet.java +++ b/java/demo/Ice/applet/HelloApplet.java @@ -43,7 +43,27 @@ public class HelloApplet extends JApplet Ice.InitializationData initData = new Ice.InitializationData(); initData.properties = Ice.Util.createProperties(); initData.properties.setProperty("Ice.ACM.Client", "10"); + initData.properties.setProperty("Ice.Trace.Network", "3"); + initData.properties.setProperty("IceSSL.Trace.Security", "3"); + initData.properties.setProperty("IceSSL.Password", "password"); + initData.properties.setProperty("Ice.InitPlugins", "0"); + initData.properties.setProperty("Ice.Plugin.IceSSL", "IceSSL.PluginFactory"); _communicator = Ice.Util.initialize(initData); + + // + // We delayed the initialization of the IceSSL plug-in by setting Ice.InitPlugins=0. + // Now we obtain a reference to the plugin so that we can supply a keystore and + // truststore using a resource file. + // + IceSSL.Plugin plugin = (IceSSL.Plugin)_communicator.getPluginManager().getPlugin("IceSSL"); + java.io.InputStream certs = getClass().getClassLoader().getResourceAsStream("client.jks"); + plugin.setKeystoreStream(certs); + plugin.setTruststoreStream(certs); + + // + // Finally, we're ready to complete the initialization. + // + _communicator.getPluginManager().initializePlugins(); } catch(Throwable ex) { diff --git a/java/demo/Ice/applet/README b/java/demo/Ice/applet/README index 83e3cfc5e84..c5edfad259f 100644 --- a/java/demo/Ice/applet/README +++ b/java/demo/Ice/applet/README @@ -1,5 +1,7 @@ This demo presents an unsigned applet that shows how to make -asynchronous Ice invocations in a graphical application. +asynchronous Ice invocations in a graphical application. It also +demonstrates how to configure IceSSL using a resource file as the +keystore. The demo includes a start page (hello.html) that you will need to publish on a web server. This page assumes that the demo applet is diff --git a/java/demo/Ice/applet/build.xml b/java/demo/Ice/applet/build.xml index 0f3ea00c870..495021109ad 100644 --- a/java/demo/Ice/applet/build.xml +++ b/java/demo/Ice/applet/build.xml @@ -52,6 +52,9 @@ <include name="Demo/**"/> <include name="HelloApplet*"/> </jar> + <jar jarfile="Hello.jar" update="true" basedir="${top.dir}/../certs"> + <include name="client.jks"/> + </jar> </target> <target name="proguard-jar" depends="jar" if="proguard-found"> @@ -77,6 +80,7 @@ <proguard configuration="applet.pro"> <injar path="${class.dir}"/> + <injar path="${top.dir}/../certs/client.jks"/> <injar refid="ice.classpath" filter="!META-INF/**"/> <outjar path="Hello.jar"/> <libraryjar path="${library.jars}"/> diff --git a/java/demo/RMI/README b/java/demo/RMI/README deleted file mode 100644 index 50bf06f8b2f..00000000000 --- a/java/demo/RMI/README +++ /dev/null @@ -1,12 +0,0 @@ -Demos in this directory: - -- latency - - A simple latency test that measures the basic call dispatch delay of RMI. - -- throughput - - A simple RMI throughput demo that allows you to send sequences of - various types between client and server and to measure the maximum - bandwidth that can be achieved using serialized synchronous - requests. diff --git a/java/demo/RMI/build.xml b/java/demo/RMI/build.xml deleted file mode 100644 index d7424212ffe..00000000000 --- a/java/demo/RMI/build.xml +++ /dev/null @@ -1,24 +0,0 @@ -<!-- - ********************************************************************** - - Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. - - This copy of Ice is licensed to you under the terms described in the - ICE_LICENSE file included in this distribution. - - ********************************************************************** ---> - -<project name="demo" default="all" basedir="."> - - <target name="all"> - <ant dir="latency"/> - <ant dir="throughput"/> - </target> - - <target name="clean"> - <ant dir="latency" target="clean"/> - <ant dir="throughput" target="clean"/> - </target> - -</project> diff --git a/java/demo/RMI/throughput/Client.java b/java/demo/RMI/throughput/Client.java deleted file mode 100755 index f54ea3e6c21..00000000000 --- a/java/demo/RMI/throughput/Client.java +++ /dev/null @@ -1,421 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -import java.rmi.registry.LocateRegistry; -import java.rmi.registry.Registry; - -public class Client -{ - private static void - menu() - { - System.out.println( - "usage:\n" + - "\n" + - "toggle type of data to send:\n" + - "1: sequence of bytes (default)\n" + - "2: sequence of strings (\"hello\")\n" + - "3: sequence of structs with a string (\"hello\") and a double\n" + - "4: sequence of structs with two ints and a double\n" + - "\n" + - "select test to run:\n" + - "t: Send sequence\n" + - "r: Receive sequence\n" + - "e: Echo (send and receive) sequence\n" + - "\n" + - "other commands:\n" + - "s: shutdown server\n" + - "x: exit\n" + - "?: help\n"); - } - - public int - run(String args[]) throws java.lang.Exception - { - String registryHost; - if(args.length == 0) - { - registryHost = "127.0.0.1"; - } - else if(args.length == 1) - { - registryHost = args[0]; - } - else - { - System.err.println("usage: java Client [registryHost]"); - return 1; - } - - - if(System.getSecurityManager() == null) - { - System.setSecurityManager(new SecurityManager()); - } - Registry registry = LocateRegistry.getRegistry(registryHost); - Throughput throughput = (Throughput)registry.lookup("throughput"); - - byte[] byteSeq = new byte[Throughput.ByteSeqSize]; - - String[] stringSeq = new String[Throughput.StringSeqSize]; - for(int i = 0; i < Throughput.StringSeqSize; ++i) - { - stringSeq[i] = new String("hello"); - } - - Throughput.StringDouble[] structSeq = new Throughput.StringDouble[Throughput.StringDoubleSeqSize]; - for(int i = 0; i < Throughput.StringDoubleSeqSize; ++i) - { - structSeq[i] = new Throughput.StringDouble(); - structSeq[i].s = new String("Hello"); - structSeq[i].d = 3.14; - } - - Throughput.Fixed[] fixedSeq = new Throughput.Fixed[Throughput.FixedSeqSize]; - for(int i = 0; i < Throughput.FixedSeqSize; ++i) - { - fixedSeq[i] = new Throughput.Fixed(); - fixedSeq[i].i = 0; - fixedSeq[i].j = 0; - fixedSeq[i].d = 0; - } - - { - byte[] emptyBytes= new byte[1]; - String[] emptyStrings = new String[1]; - Throughput.StringDouble[] emptyStructs = new Throughput.StringDouble[1]; - emptyStructs[0] = new Throughput.StringDouble(); - Throughput.Fixed[] emptyFixed = new Throughput.Fixed[1]; - emptyFixed[0] = new Throughput.Fixed(); - - System.out.print("warming up..."); - System.out.flush(); - for(int i = 0; i < 100; i++) - { - throughput.sendByteSeq(emptyBytes); - throughput.recvByteSeq(); - throughput.echoByteSeq(emptyBytes); - - throughput.sendStringSeq(emptyStrings); - throughput.recvStringSeq(); - throughput.echoFixedSeq(emptyFixed); - - throughput.sendStructSeq(emptyStructs); - throughput.recvStructSeq(); - throughput.echoStructSeq(emptyStructs); - - throughput.sendFixedSeq(emptyFixed); - throughput.recvFixedSeq(); - throughput.echoStringSeq(emptyStrings); - } - System.out.println(); - } - - menu(); - - java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in)); - - char currentType = '1'; - int seqSize = Throughput.ByteSeqSize; - - String line = null; - do - { - try - { - System.out.print("==> "); - System.out.flush(); - line = in.readLine(); - if(line == null) - { - break; - } - - long tmsec = System.currentTimeMillis(); - final int repetitions = 100; - - if(line.equals("1") || line.equals("2") || line.equals("3") || line.equals("4")) - { - currentType = line.charAt(0); - - switch(currentType) - { - case '1': - { - System.out.println("using byte sequences"); - seqSize = Throughput.ByteSeqSize; - break; - } - - case '2': - { - System.out.println("using string sequences"); - seqSize = Throughput.StringSeqSize; - break; - } - - case '3': - { - System.out.println("using variable-length struct sequences"); - seqSize = Throughput.StringDoubleSeqSize; - break; - } - - case '4': - { - System.out.println("using fixed-length struct sequences"); - seqSize = Throughput.FixedSeqSize; - break; - } - } - } - else if(line.equals("t") || line.equals("o") || line.equals("r") || line.equals("e")) - { - char c = line.charAt(0); - - switch(c) - { - case 't': - { - System.out.print("sending"); - break; - } - - case 'r': - { - System.out.print("receiving"); - break; - } - - case 'e': - { - System.out.print("sending and receiving"); - break; - } - } - - System.out.print(" " + repetitions); - switch(currentType) - { - case '1': - { - System.out.print(" byte"); - break; - } - - case '2': - { - System.out.print(" string"); - break; - } - - case '3': - { - System.out.print(" variable-length struct"); - break; - } - - case '4': - { - System.out.print(" fixed-length struct"); - break; - } - } - - System.out.print(" sequences of size " + seqSize + "..."); - - - for(int i = 0; i < repetitions; ++i) - { - switch(currentType) - { - case '1': - { - switch(c) - { - case 't': - { - throughput.sendByteSeq(byteSeq); - break; - } - - case 'r': - { - throughput.recvByteSeq(); - break; - } - - case 'e': - { - throughput.echoByteSeq(byteSeq); - break; - } - } - break; - } - - case '2': - { - switch(c) - { - case 't': - { - throughput.sendStringSeq(stringSeq); - break; - } - - case 'r': - { - throughput.recvStringSeq(); - break; - } - - case 'e': - { - throughput.echoStringSeq(stringSeq); - break; - } - } - break; - } - - case '3': - { - switch(c) - { - case 't': - { - throughput.sendStructSeq(structSeq); - break; - } - - case 'r': - { - throughput.recvStructSeq(); - break; - } - - case 'e': - { - throughput.echoStructSeq(structSeq); - break; - } - } - break; - } - - case '4': - { - switch(c) - { - case 't': - { - throughput.sendFixedSeq(fixedSeq); - break; - } - - case 'r': - { - throughput.recvFixedSeq(); - break; - } - - case 'e': - { - throughput.echoFixedSeq(fixedSeq); - break; - } - } - break; - } - } - } - - double dmsec = System.currentTimeMillis() - tmsec; - System.out.println("time for " + repetitions + " sequences: " + dmsec + "ms"); - System.out.println("time per sequence: " + dmsec / repetitions + "ms"); - int size = 0; - switch(currentType) - { - case '1': - { - size = 1; - break; - } - - case '2': - { - size = stringSeq[0].length(); - break; - } - - case '3': - { - size = structSeq[0].s.length() + 8; - break; - } - - case '4': - { - size = 16; // Two ints and a double. - break; - } - } - double mbit = repetitions * seqSize * size * 8.0 / dmsec / 1000.0; - if(c == 'e') - { - mbit *= 2; - } - System.out.println("throughput: " + new java.text.DecimalFormat("#.##").format(mbit) + "Mbps"); - } - else if(line.equals("s")) - { - throughput.shutdown(); - } - else if(line.equals("x")) - { - // Nothing to do - } - else if(line.equals("?")) - { - menu(); - } - else - { - System.out.println("unknown command `" + line + "'"); - menu(); - } - } - catch(Exception ex) - { - ex.printStackTrace(); - } - } - while(!line.equals("x")); - - return 0; - } - - public static void - main(String[] args) - { - Client app = new Client(); - int status; - try - { - status = app.run(args); - } - catch(Exception e) - { - System.err.println(e); - status = 1; - } - System.exit(status); - } -} diff --git a/java/demo/RMI/throughput/README b/java/demo/RMI/throughput/README deleted file mode 100755 index 82fa2178612..00000000000 --- a/java/demo/RMI/throughput/README +++ /dev/null @@ -1,26 +0,0 @@ -A simple RMI throughput demo that allows you to send sequences of various -types between client and server and to measure the maximum bandwidth -that can be achieved using serialized synchronous requests. - -To run the demo, start the RMI registry: - -$ rmiregistry - -In a separate window, start the server: - -$ java -Djava.rmi.server.hostname=127.0.0.1 -Djava.rmi.server.codebase=file:/c:/path/to/ice/java/demo/RMI/throughput/classes/ -Djava.security.policy=policy Server - -You need to edit the path on the command line to specify this directory. -Under Vista, you must run the server as administrator. - -In a separate window, start the client: - -$ client.exe --Djava.security.policy=policy Client - -If you want to run client and server on different machines, you -can specify the hsot on which you started the registry on -the client's command line, for example: - -$ client.exe --Djava.security.policy=policy Client 192.168.4.2 - -This directs the client to connect to the registry at the specified IP address. diff --git a/java/demo/RMI/throughput/Server.java b/java/demo/RMI/throughput/Server.java deleted file mode 100755 index fbfc8680d8d..00000000000 --- a/java/demo/RMI/throughput/Server.java +++ /dev/null @@ -1,145 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -import java.rmi.RemoteException; -import java.rmi.registry.LocateRegistry; -import java.rmi.registry.Registry; -import java.rmi.server.UnicastRemoteObject; - -public class Server implements Throughput -{ - - public - Server() - { - _byteSeq = new byte[ByteSeqSize]; - - _stringSeq = new String[StringSeqSize]; - for(int i = 0; i < StringSeqSize; ++i) - { - _stringSeq[i] = new String("hello"); - } - - _structSeq = new StringDouble[StringDoubleSeqSize]; - for(int i = 0; i < StringDoubleSeqSize; ++i) - { - _structSeq[i] = new StringDouble(); - _structSeq[i].s = new String("hello"); - _structSeq[i].d = 3.14; - } - - _fixedSeq = new Fixed[FixedSeqSize]; - for(int i = 0; i < FixedSeqSize; ++i) - { - _fixedSeq[i] = new Fixed(); - _fixedSeq[i].i = 0; - _fixedSeq[i].j = 0; - _fixedSeq[i].d = 0; - } - } - - public void - sendByteSeq(byte[] seq) - { - } - - public byte[] - recvByteSeq() - { - return _byteSeq; - } - - public byte[] - echoByteSeq(byte[] seq) - { - return seq; - } - - public void - sendStringSeq(String[] seq) - { - } - - public String[] - recvStringSeq() - { - return _stringSeq; - } - - public String[] - echoStringSeq(String[] seq) - { - return seq; - } - - public void - sendStructSeq(StringDouble[] seq) - { - } - - public StringDouble[] - recvStructSeq() - { - return _structSeq; - } - - public StringDouble[] - echoStructSeq(StringDouble[] seq) - { - return seq; - } - - public void - sendFixedSeq(Fixed[] seq) - { - } - - public Fixed[] - recvFixedSeq() - { - return _fixedSeq; - } - - public Fixed[] - echoFixedSeq(Fixed[] seq) - { - return seq; - } - - public void - shutdown() - { - System.exit(0); - } - - private byte[] _byteSeq; - private String[] _stringSeq; - private StringDouble[] _structSeq; - private Fixed[] _fixedSeq; - - public static void main(String[] args) - { - if(System.getSecurityManager() == null) - { - System.setSecurityManager(new SecurityManager()); - } - try - { - Throughput servant = new Server(); - Throughput stub = (Throughput)UnicastRemoteObject.exportObject(servant, 0); - Registry registry = LocateRegistry.getRegistry(); - registry.rebind("throughput", stub); - System.out.println("ready"); - } - catch(Exception e) - { - System.err.println(e); - } - } -} diff --git a/java/demo/RMI/throughput/Throughput.java b/java/demo/RMI/throughput/Throughput.java deleted file mode 100755 index 92c7f8717a7..00000000000 --- a/java/demo/RMI/throughput/Throughput.java +++ /dev/null @@ -1,51 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -import java.rmi.Remote; -import java.rmi.RemoteException; - -public interface Throughput extends Remote -{ - int ByteSeqSize = 500000; - - int StringSeqSize = 50000; - - class StringDouble implements java.io.Serializable - { - public String s; - public double d; - }; - int StringDoubleSeqSize = 50000; - - class Fixed implements java.io.Serializable - { - int i; - int j; - double d; - }; - int FixedSeqSize = 50000; - - void sendByteSeq(byte[] seq) throws RemoteException; - byte[] recvByteSeq() throws RemoteException; - byte[] echoByteSeq(byte[] seq) throws RemoteException; - - void sendStringSeq(String[] seq) throws RemoteException; - String[] recvStringSeq() throws RemoteException; - String[] echoStringSeq(String[] seq) throws RemoteException; - - void sendStructSeq(StringDouble[] seq) throws RemoteException; - StringDouble[] recvStructSeq() throws RemoteException; - StringDouble[] echoStructSeq(StringDouble[] seq) throws RemoteException; - - void sendFixedSeq(Fixed[] seq) throws RemoteException; - Fixed[] recvFixedSeq() throws RemoteException; - Fixed[] echoFixedSeq(Fixed[] seq) throws RemoteException; - - void shutdown() throws RemoteException; -} diff --git a/java/demo/RMI/throughput/build.xml b/java/demo/RMI/throughput/build.xml deleted file mode 100755 index 89f2881febc..00000000000 --- a/java/demo/RMI/throughput/build.xml +++ /dev/null @@ -1,35 +0,0 @@ -<!-- - ********************************************************************** - - Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. - - This copy of Ice is licensed to you under the terms described in the - ICE_LICENSE file included in this distribution. - - ********************************************************************** ---> - -<project name="rmi_throughput" default="all" basedir="."> - - <!-- set global properties for this build --> - <property name="top.dir" value="../../.."/> - - <!-- import common definitions --> - <import file="${top.dir}/config/common.xml"/> - - <target name="compile"> - <mkdir dir="${class.dir}"/> - <javac srcdir="." destdir="${class.dir}" - debug="${debug}"> - <compilerarg value="${javac.lint}"/> - </javac> - </target> - - <target name="all" depends="compile"/> - - <target name="clean"> - <delete dir="${generated.dir}"/> - <delete dir="${class.dir}"/> - </target> - -</project> diff --git a/java/demo/RMI/throughput/policy b/java/demo/RMI/throughput/policy deleted file mode 100755 index 1b73fb10b9c..00000000000 --- a/java/demo/RMI/throughput/policy +++ /dev/null @@ -1,3 +0,0 @@ -grant { - permission java.net.SocketPermission "*:*", "connect,accept,resolve,listen"; -}; diff --git a/java/src/Ice/PluginManagerI.java b/java/src/Ice/PluginManagerI.java index f76789f4a21..2c5e33bfb63 100644 --- a/java/src/Ice/PluginManagerI.java +++ b/java/src/Ice/PluginManagerI.java @@ -19,12 +19,12 @@ public final class PluginManagerI implements PluginManager if(_initialized) { InitializationException ex = new InitializationException(); - ex.reason = "plugins already initialized"; + ex.reason = "plug-ins already initialized"; throw ex; } // - // Invoke initialize() on the plugins, in the order they were loaded. + // Invoke initialize() on the plug-ins, in the order they were loaded. // java.util.List<Plugin> initializedPlugins = new java.util.ArrayList<Plugin>(); try @@ -40,7 +40,7 @@ public final class PluginManagerI implements PluginManager catch(RuntimeException ex) { // - // Destroy the plugins that have been successfully initialized, in the + // Destroy the plug-ins that have been successfully initialized, in the // reverse order. // java.util.ListIterator<Plugin> i = initializedPlugins.listIterator(initializedPlugins.size()); @@ -104,11 +104,24 @@ public final class PluginManagerI implements PluginManager { if(_communicator != null) { - java.util.Iterator<Plugin> i = _plugins.values().iterator(); - while(i.hasNext()) + if(_initialized) { - Plugin p = i.next(); - p.destroy(); + java.util.Iterator<java.util.Map.Entry<String, Plugin> > i = _plugins.entrySet().iterator(); + java.util.Map.Entry<String, Plugin> entry; + while(i.hasNext()) + { + entry = i.next(); + try + { + Plugin p = entry.getValue(); + p.destroy(); + } + catch(RuntimeException ex) + { + Ice.Util.getProcessLogger().warning("unexpected exception raised by plug-in '" + entry.getKey() + "' destruction.\n"); + Ice.Util.getProcessLogger().warning("exception: " + ex.toString()); + } + } } _communicator = null; @@ -135,8 +148,8 @@ public final class PluginManagerI implements PluginManager // Ice.Plugin.name[.<language>]=entry_point [args] // // If the Ice.PluginLoadOrder property is defined, load the - // specified plugins in the specified order, then load any - // remaining plugins. + // specified plug-ins in the specified order, then load any + // remaining plug-ins. // final String prefix = "Ice.Plugin."; Properties properties = _communicator.getProperties(); @@ -148,7 +161,7 @@ public final class PluginManagerI implements PluginManager if(_plugins.containsKey(loadOrder[i])) { PluginInitializationException ex = new PluginInitializationException(); - ex.reason = "plugin `" + loadOrder[i] + "' already loaded"; + ex.reason = "plug-in `" + loadOrder[i] + "' already loaded"; throw ex; } @@ -173,13 +186,13 @@ public final class PluginManagerI implements PluginManager else { PluginInitializationException ex = new PluginInitializationException(); - ex.reason = "plugin `" + loadOrder[i] + "' not defined"; + ex.reason = "plug-in `" + loadOrder[i] + "' not defined"; throw ex; } } // - // Load any remaining plugins that weren't specified in PluginLoadOrder. + // Load any remaining plug-ins that weren't specified in PluginLoadOrder. // while(!plugins.isEmpty()) { @@ -240,7 +253,7 @@ public final class PluginManagerI implements PluginManager // // An application can set Ice.InitPlugins=0 if it wants to postpone // initialization until after it has interacted directly with the - // plugins. + // plug-ins. // if(properties.getPropertyAsIntWithDefault("Ice.InitPlugins", 1) > 0) { diff --git a/java/src/Ice/Util.java b/java/src/Ice/Util.java index 6db12d27cc2..4d9b5488691 100644 --- a/java/src/Ice/Util.java +++ b/java/src/Ice/Util.java @@ -343,13 +343,13 @@ public final class Util public static String stringVersion() { - return "3.3.0"; // "A.B.C", with A=major, B=minor, C=patch + return "3.3.1"; // "A.B.C", with A=major, B=minor, C=patch } public static int intVersion() { - return 30300; // AABBCC, with AA=major, BB=minor, CC=patch + return 30301; // AABBCC, with AA=major, BB=minor, CC=patch } private static String _localAddress = null; diff --git a/java/src/IceBox/ServiceManagerI.java b/java/src/IceBox/ServiceManagerI.java index d327c4bfa9a..87fb274fac1 100644 --- a/java/src/IceBox/ServiceManagerI.java +++ b/java/src/IceBox/ServiceManagerI.java @@ -981,7 +981,7 @@ public class ServiceManagerI extends _ServiceManagerDisp // // Remaining command line options are passed to the communicator. This is - // necessary for Ice plugin properties (e.g.: IceSSL). + // necessary for Ice plug-in properties (e.g.: IceSSL). // Ice.InitializationData initData = new Ice.InitializationData(); initData.properties = properties; diff --git a/java/src/IceInternal/Instance.java b/java/src/IceInternal/Instance.java index 37f95cfe1ff..a11d2044b66 100644 --- a/java/src/IceInternal/Instance.java +++ b/java/src/IceInternal/Instance.java @@ -553,7 +553,7 @@ public final class Instance setLogger(Ice.Logger logger) { // - // No locking, as it can only be called during plugin loading + // No locking, as it can only be called during plug-in loading // _initData.logger = logger; } diff --git a/java/src/IceInternal/Network.java b/java/src/IceInternal/Network.java index 40b411d5f9d..3eb8a840d14 100644 --- a/java/src/IceInternal/Network.java +++ b/java/src/IceInternal/Network.java @@ -772,9 +772,7 @@ public final class Network // } - if(addr == null || - (addr instanceof java.net.Inet4Address && protocol == EnableIPv6) || - (addr instanceof java.net.Inet6Address && protocol == EnableIPv4)) + if(addr == null || isValidAddr(addr, protocol)) { // // Iterate over the network interfaces and pick an IP @@ -785,9 +783,7 @@ public final class Network while(addr == null && iter.hasNext()) { java.net.InetAddress a = iter.next(); - if(protocol == EnableBoth || - (protocol == EnableIPv4 && a instanceof java.net.Inet4Address) || - (protocol == EnableIPv6 && a instanceof java.net.Inet6Address)) + if(protocol == EnableBoth || isValidAddr(a, protocol)) { addr = a; } @@ -822,9 +818,7 @@ public final class Network for(int i = 0; i < addrs.length; ++i) { - if(protocol == EnableBoth || - (protocol == EnableIPv4 && addrs[i] instanceof java.net.Inet4Address) || - (protocol == EnableIPv6 && addrs[i] instanceof java.net.Inet6Address)) + if(protocol == EnableBoth || isValidAddr(addrs[i], protocol)) { addresses.add(new java.net.InetSocketAddress(addrs[i], port)); } @@ -873,9 +867,7 @@ public final class Network java.net.InetAddress addr = addrs.nextElement(); if(!addr.isLoopbackAddress()) { - if(protocol == EnableBoth || - (protocol == EnableIPv4 && addr instanceof java.net.Inet4Address) || - (protocol == EnableIPv6 && addr instanceof java.net.Inet6Address)) + if(protocol == EnableBoth || isValidAddr(addr, protocol)) { result.add(addr); } @@ -1148,6 +1140,20 @@ public final class Network return ex instanceof java.io.InterruptedIOException; } + private static boolean + isValidAddr(java.net.InetAddress addr, int protocol) + { + byte[] bytes = null; + if(addr != null) + { + bytes = addr.getAddress(); + } + return bytes != null && + ((bytes.length == 16 && protocol == EnableIPv6) || + (bytes.length == 4 && protocol == EnableIPv4)); + } + + private static java.net.InetSocketAddress getAddressImpl(String host, int port, int protocol, boolean server) { @@ -1172,9 +1178,7 @@ public final class Network for(int i = 0; i < addrs.length; ++i) { - if(protocol == EnableBoth || - (protocol == EnableIPv4 && addrs[i] instanceof java.net.Inet4Address) || - (protocol == EnableIPv6 && addrs[i] instanceof java.net.Inet6Address)) + if(protocol == EnableBoth || isValidAddr(addrs[i], protocol)) { return new java.net.InetSocketAddress(addrs[i], port); } diff --git a/java/src/IceSSL/AcceptorI.java b/java/src/IceSSL/AcceptorI.java index d07846bcc15..4ce1e5f70bf 100644 --- a/java/src/IceSSL/AcceptorI.java +++ b/java/src/IceSSL/AcceptorI.java @@ -47,12 +47,12 @@ final class AcceptorI implements IceInternal.Acceptor accept() { // - // The plugin may not be fully initialized. + // The plug-in may not be fully initialized. // if(!_instance.initialized()) { Ice.PluginInitializationException ex = new Ice.PluginInitializationException(); - ex.reason = "IceSSL: plugin is not initialized"; + ex.reason = "IceSSL: plug-in is not initialized"; throw ex; } diff --git a/java/src/IceSSL/ConnectionInfo.java b/java/src/IceSSL/ConnectionInfo.java index 53433eb4e3d..5e10a24bec8 100644 --- a/java/src/IceSSL/ConnectionInfo.java +++ b/java/src/IceSSL/ConnectionInfo.java @@ -42,11 +42,11 @@ public class ConnectionInfo // If the connection is incoming this bool is true, false // otherwise. // - boolean incoming; + public boolean incoming; // // The name of the object adapter that hosts this endpoint, if // any. // - String adapterName; + public String adapterName; } diff --git a/java/src/IceSSL/ConnectorI.java b/java/src/IceSSL/ConnectorI.java index b5606444887..847cb173d0a 100644 --- a/java/src/IceSSL/ConnectorI.java +++ b/java/src/IceSSL/ConnectorI.java @@ -15,12 +15,12 @@ final class ConnectorI implements IceInternal.Connector, java.lang.Comparable connect() { // - // The plugin may not be fully initialized. + // The plug-in may not be fully initialized. // if(!_instance.initialized()) { Ice.PluginInitializationException ex = new Ice.PluginInitializationException(); - ex.reason = "IceSSL: plugin is not initialized"; + ex.reason = "IceSSL: plug-in is not initialized"; throw ex; } diff --git a/java/src/IceSSL/Instance.java b/java/src/IceSSL/Instance.java index 9a53f10e9a9..afddf43071a 100644 --- a/java/src/IceSSL/Instance.java +++ b/java/src/IceSSL/Instance.java @@ -9,6 +9,12 @@ package IceSSL; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + +import Ice.Logger; + class Instance { Instance(Ice.Communicator communicator) @@ -19,10 +25,10 @@ class Instance _securityTraceCategory = "Security"; _trustManager = new TrustManager(communicator); - // + // // Register the endpoint factory. We have to do this now, rather than // in initialize, because the communicator may need to interpret - // proxies before the plugin is fully initialized. + // proxies before the plug-in is fully initialized. // _facade.addEndpointFactory(new EndpointFactoryI(this)); } @@ -31,7 +37,7 @@ class Instance initialize() { if(_initialized) - { + { return; } @@ -89,12 +95,12 @@ class Instance // _verifyDepthMax = properties.getPropertyAsIntWithDefault(prefix + "VerifyDepthMax", 2); - // + // // Check for a certificate verifier. - // + // final String certVerifierClass = properties.getProperty(prefix + "CertVerifier"); if(certVerifierClass.length() > 0) - { + { if(_verifier != null) { Ice.PluginInitializationException e = new Ice.PluginInitializationException(); @@ -200,8 +206,6 @@ class Instance final String seedFiles = properties.getProperty(prefix + "Random"); if(seedFiles.length() > 0) { - byte[] seed = null; - int start = 0; final String[] arr = seedFiles.split(java.io.File.pathSeparator); for(int i = 0; i < arr.length; ++i) { @@ -213,34 +217,54 @@ class Instance throw e; } java.io.File f = new java.io.File(seedFile.value); - int num = (int)f.length(); - if(seed == null) + try { - seed = new byte[num]; + _seeds.add(new java.io.FileInputStream(f)); } - else + catch(java.io.IOException ex) { - byte[] tmp = new byte[seed.length + num]; - System.arraycopy(seed, 0, tmp, 0, seed.length); - start = seed.length; - seed = tmp; + Ice.PluginInitializationException e = new Ice.PluginInitializationException(); + e.reason = "IceSSL: error while reading random seed file:\n" + arr[i]; + e.initCause(ex); + throw e; } + } + } + + if(!_seeds.isEmpty()) + { + byte[] seed = null; + int start = 0; + for(java.util.Iterator<InputStream> p = _seeds.iterator(); p.hasNext();) + { + InputStream in = p.next(); try { - java.io.FileInputStream in = new java.io.FileInputStream(f); + int num = in.available(); + if(seed == null) + { + seed = new byte[num]; + } + else + { + byte[] tmp = new byte[seed.length + num]; + System.arraycopy(seed, 0, tmp, 0, seed.length); + start = seed.length; + seed = tmp; + } in.read(seed, start, num); - in.close(); } catch(java.io.IOException ex) { Ice.PluginInitializationException e = new Ice.PluginInitializationException(); - e.reason = "IceSSL: error while reading random seed file:\n" + arr[i]; + e.reason = "IceSSL: error while reading random seed"; e.initCause(ex); throw e; } } rand.setSeed(seed); } + _seeds.clear(); // // We call nextInt() in order to force the object to perform any time-consuming @@ -264,7 +288,8 @@ class Instance String keystorePassword = properties.getProperty(prefix + "KeystorePassword"); // - // The default keystore type value is "JKS", but it can also be "PKCS12". + // The default keystore type is usually "JKS", but the legal values are determined + // by the JVM implementation. Other possibilities include "PKCS12" and "BKS". // final String defaultType = java.security.KeyStore.getDefaultType(); final String keystoreType = properties.getPropertyWithDefault(prefix + "KeystoreType", defaultType); @@ -285,7 +310,8 @@ class Instance String truststorePassword = properties.getProperty(prefix + "TruststorePassword"); // - // The truststore type defaults to "JKS", but it can also be "PKCS12". + // The default truststore type is usually "JKS", but the legal values are determined + // by the JVM implementation. Other possibilities include "PKCS12" and "BKS". // final String truststoreType = properties.getPropertyWithDefault(prefix + "TruststoreType", @@ -295,15 +321,16 @@ class Instance // Collect the key managers. // javax.net.ssl.KeyManager[] keyManagers = null; - if(keystorePath.value.length() > 0) + java.security.KeyStore keys = null; + if(_keystoreStream != null || keystorePath.value.length() > 0) { - if(!checkPath(keystorePath, false)) + if(_keystoreStream == null && !checkPath(keystorePath, false)) { Ice.PluginInitializationException e = new Ice.PluginInitializationException(); e.reason = "IceSSL: keystore file not found:\n" + keystorePath.value; throw e; } - java.security.KeyStore keys = java.security.KeyStore.getInstance(keystoreType); + keys = java.security.KeyStore.getInstance(keystoreType); try { char[] passwordChars = null; @@ -315,9 +342,21 @@ class Instance { passwordChars = _passwordCallback.getKeystorePassword(); } + else if(keystoreType.equals("BKS")) + { + // Bouncy Castle does not permit null passwords. + passwordChars = new char[0]; + } - java.io.BufferedInputStream bis = - new java.io.BufferedInputStream(new java.io.FileInputStream(keystorePath.value)); + java.io.InputStream bis; + if(_keystoreStream != null) + { + bis = _keystoreStream; + } + else + { + bis = new java.io.BufferedInputStream(new java.io.FileInputStream(keystorePath.value)); + } keys.load(bis, passwordChars); if(passwordChars != null) @@ -337,7 +376,7 @@ class Instance String algorithm = javax.net.ssl.KeyManagerFactory.getDefaultAlgorithm(); javax.net.ssl.KeyManagerFactory kmf = javax.net.ssl.KeyManagerFactory.getInstance(algorithm); char[] passwordChars = new char[0]; // This password cannot be null. - if(password.length() > 0) + if(password.length() > 0) { passwordChars = password.toCharArray(); } @@ -377,43 +416,71 @@ class Instance // Collect the trust managers. // javax.net.ssl.TrustManager[] trustManagers = null; - if(truststorePath.value.length() > 0) + if(_truststoreStream != null || truststorePath.value.length() > 0) { - if(!checkPath(truststorePath, false)) + if(_truststoreStream == null && !checkPath(truststorePath, false)) { Ice.PluginInitializationException e = new Ice.PluginInitializationException(); e.reason = "IceSSL: truststore file not found:\n" + truststorePath.value; throw e; } - java.security.KeyStore ts = java.security.KeyStore.getInstance(truststoreType); - try + + // + // If the trust store and the key store are the same input + // stream or file, don't create another key store. + // + java.security.KeyStore ts; + if((_truststoreStream != null && _truststoreStream == _keystoreStream) || + (truststorePath.value.length() > 0 && truststorePath.value.equals(keystorePath.value))) { - char[] passwordChars = null; - if(truststorePassword.length() > 0) - { - passwordChars = truststorePassword.toCharArray(); - } - else if(_passwordCallback != null) + assert keys != null; + ts = keys; + } + else + { + ts = java.security.KeyStore.getInstance(truststoreType); + try { - passwordChars = _passwordCallback.getTruststorePassword(); - } + char[] passwordChars = null; + if(truststorePassword.length() > 0) + { + passwordChars = truststorePassword.toCharArray(); + } + else if(_passwordCallback != null) + { + passwordChars = _passwordCallback.getTruststorePassword(); + } + else if(truststoreType.equals("BKS")) + { + // Bouncy Castle does not permit null passwords. + passwordChars = new char[0]; + } - java.io.BufferedInputStream bis = - new java.io.BufferedInputStream(new java.io.FileInputStream(truststorePath.value)); - ts.load(bis, passwordChars); + java.io.InputStream bis; + if(_truststoreStream != null) + { + bis = _truststoreStream; + } + else + { + bis = new java.io.BufferedInputStream( + new java.io.FileInputStream(truststorePath.value)); + } + ts.load(bis, passwordChars); - if(passwordChars != null) + if(passwordChars != null) + { + java.util.Arrays.fill(passwordChars, '\0'); + } + truststorePassword = null; + } + catch(java.io.IOException ex) { - java.util.Arrays.fill(passwordChars, '\0'); + Ice.PluginInitializationException e = new Ice.PluginInitializationException(); + e.reason = "IceSSL: unable to load truststore:\n" + truststorePath.value; + e.initCause(ex); + throw e; } - truststorePassword = null; - } - catch(java.io.IOException ex) - { - Ice.PluginInitializationException e = new Ice.PluginInitializationException(); - e.reason = "IceSSL: unable to load truststore:\n" + truststorePath.value; - e.initCause(ex); - throw e; } String algorithm = javax.net.ssl.TrustManagerFactory.getDefaultAlgorithm(); @@ -442,7 +509,7 @@ class Instance // // Initialize the SSL context. // - _context = javax.net.ssl.SSLContext.getInstance("SSL"); + _context = javax.net.ssl.SSLContext.getInstance("TLS"); _context.init(keyManagers, trustManagers, rand); } catch(java.security.GeneralSecurityException ex) @@ -454,6 +521,13 @@ class Instance } } + // + // Clear cached input streams. + // + _seeds.clear(); + _keystoreStream = null; + _truststoreStream = null; + _initialized = true; } @@ -463,7 +537,7 @@ class Instance if(_initialized) { Ice.PluginInitializationException ex = new Ice.PluginInitializationException(); - ex.reason = "IceSSL: plugin is already initialized"; + ex.reason = "IceSSL: plug-in is already initialized"; throw ex; } @@ -500,6 +574,38 @@ class Instance return _passwordCallback; } + void + setKeystoreStream(java.io.InputStream stream) + { + if(_initialized) + { + Ice.PluginInitializationException ex = new Ice.PluginInitializationException(); + ex.reason = "IceSSL: plugin is already initialized"; + throw ex; + } + + _keystoreStream = stream; + } + + void + setTruststoreStream(java.io.InputStream stream) + { + if(_initialized) + { + Ice.PluginInitializationException ex = new Ice.PluginInitializationException(); + ex.reason = "IceSSL: plugin is already initialized"; + throw ex; + } + + _truststoreStream = stream; + } + + void + addSeedStream(java.io.InputStream stream) + { + _seeds.add(stream); + } + Ice.Communicator communicator() { @@ -713,7 +819,6 @@ class Instance return _protocols; } - // TODO: Remove void traceConnection(java.nio.channels.SocketChannel fd, javax.net.ssl.SSLEngine engine, boolean incoming) { @@ -861,12 +966,12 @@ class Instance { String msg = (incoming ? "incoming" : "outgoing") + " connection rejected by certificate verifier\n" + IceInternal.Network.fdToString(fd); - + if(_securityTraceLevel > 0) { _logger.trace(_securityTraceCategory, msg); } - + Ice.SecurityException ex = new Ice.SecurityException(); ex.reason = msg; throw ex; @@ -1004,4 +1109,8 @@ class Instance private CertificateVerifier _verifier; private PasswordCallback _passwordCallback; private TrustManager _trustManager; + + private InputStream _keystoreStream; + private InputStream _truststoreStream; + private List<InputStream> _seeds = new ArrayList<InputStream>(); } diff --git a/java/src/IceSSL/PasswordCallback.java b/java/src/IceSSL/PasswordCallback.java index 5a7cbb3db83..be1e9dff4cd 100644 --- a/java/src/IceSSL/PasswordCallback.java +++ b/java/src/IceSSL/PasswordCallback.java @@ -10,7 +10,7 @@ package IceSSL; // -// A password callback is an alternate way of supplying the plugin with +// A password callback is an alternate way of supplying the plug-in with // passwords that avoids using plaintext configuration properties. // public interface PasswordCallback diff --git a/java/src/IceSSL/Plugin.java b/java/src/IceSSL/Plugin.java index c192b8d0953..7e7aabf5651 100644 --- a/java/src/IceSSL/Plugin.java +++ b/java/src/IceSSL/Plugin.java @@ -13,13 +13,13 @@ public interface Plugin extends Ice.Plugin { // // Establish the SSL context. This must be done before the - // plugin is initialized, therefore the application must define + // plug-in 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. - // + // plug-in skips its normal property-based configuration. + // void setContext(javax.net.ssl.SSLContext context); // @@ -28,7 +28,7 @@ public interface Plugin extends Ice.Plugin // javax.net.ssl.SSLContext getContext(); - // + // // Establish the certificate verifier object. This should be // done before any connections are established. // @@ -42,7 +42,7 @@ public interface Plugin extends Ice.Plugin // // Establish the password callback object. This should be - // done before the plugin is initialized. + // done before the plug-in is initialized. // void setPasswordCallback(PasswordCallback callback); @@ -51,4 +51,24 @@ public interface Plugin extends Ice.Plugin // callback is set. // PasswordCallback getPasswordCallback(); + + // + // Supplies an input stream for the keystore. Calling this method + // causes IceSSL to ignore the IceSSL.Keystore property. + // + void setKeystoreStream(java.io.InputStream stream); + + // + // Supplies an input stream for the truststore. Calling this method + // causes IceSSL to ignore the IceSSL.Truststore property. It is + // legal to supply the same input stream as setKeystoreStream, in + // which case IceSSL uses the certificates contained in the keystore. + // + void setTruststoreStream(java.io.InputStream stream); + + // + // Add an input stream for the random number seed. You may call + // this method multiple times if necessary. + // + void addSeedStream(java.io.InputStream stream); } diff --git a/java/src/IceSSL/PluginI.java b/java/src/IceSSL/PluginI.java index 2e9ac2427f8..cb5cc915bc6 100644 --- a/java/src/IceSSL/PluginI.java +++ b/java/src/IceSSL/PluginI.java @@ -64,5 +64,23 @@ class PluginI implements Plugin return _instance.getPasswordCallback(); } + public void + setKeystoreStream(java.io.InputStream stream) + { + _instance.setKeystoreStream(stream); + } + + public void + setTruststoreStream(java.io.InputStream stream) + { + _instance.setTruststoreStream(stream); + } + + public void + addSeedStream(java.io.InputStream stream) + { + _instance.addSeedStream(stream); + } + private Instance _instance; } diff --git a/java/src/IceUtil/Version.java b/java/src/IceUtil/Version.java index db4ce177de4..cb153ac230c 100644 --- a/java/src/IceUtil/Version.java +++ b/java/src/IceUtil/Version.java @@ -18,6 +18,6 @@ public final class Version // // The Ice version. // - public final static String ICE_STRING_VERSION = "3.3.0"; // "A.B.C", with A=major, B=minor, C=patch - public final static int ICE_INT_VERSION = 30300; // AABBCC, with AA=major, BB=minor, CC=patch + public final static String ICE_STRING_VERSION = "3.3.1"; // "A.B.C", with A=major, B=minor, C=patch + public final static int ICE_INT_VERSION = 30301; // AABBCC, with AA=major, BB=minor, CC=patch } diff --git a/java/test/Ice/background/Client.java b/java/test/Ice/background/Client.java index 7631b086a2c..91a4be7dbe8 100644 --- a/java/test/Ice/background/Client.java +++ b/java/test/Ice/background/Client.java @@ -40,7 +40,7 @@ public class Client initData.properties.setProperty("Ice.Warn.Connections", "0"); // - // Setup the test transport plugin. + // Setup the test transport plug-in. // initData.properties.setProperty("Ice.Plugin.Test", "PluginFactory"); String defaultProtocol = initData.properties.getPropertyWithDefault("Ice.Default.Protocol", "tcp"); diff --git a/java/test/Ice/background/Server.java b/java/test/Ice/background/Server.java index f444015c944..7e5cdb7d513 100644 --- a/java/test/Ice/background/Server.java +++ b/java/test/Ice/background/Server.java @@ -133,7 +133,7 @@ public class Server initData.properties.setProperty("Ice.Warn.Connections", "0"); // - // Setup the test transport plugin. + // Setup the test transport plug-in. // initData.properties.setProperty("Ice.Plugin.Test", "PluginFactory"); String defaultProtocol = initData.properties.getPropertyWithDefault("Ice.Default.Protocol", "tcp"); diff --git a/java/test/IceGrid/simple/AllTests.java b/java/test/IceGrid/simple/AllTests.java index 9b4f3d02144..7df041ec955 100644 --- a/java/test/IceGrid/simple/AllTests.java +++ b/java/test/IceGrid/simple/AllTests.java @@ -78,6 +78,11 @@ public class AllTests test(base != null); System.out.println("ok"); + System.out.print("testing IceGrid.Locator is present... "); + IceGrid.LocatorPrx locator = IceGrid.LocatorPrxHelper.uncheckedCast(base); + test(locator != null); + System.out.println("ok"); + System.out.print("testing checked cast... "); System.out.flush(); TestIntfPrx obj = TestIntfPrxHelper.checkedCast(base); |