|
| 1 | + |
| 2 | +# Java Remote Method Invocation (RMI) Example Client and Server |
| 3 | + |
| 4 | +This is a simple example of Java Remote Method Invocation (RMI), including |
| 5 | +the implementation of a very basic client (RmiClient.java) and server |
| 6 | +(RmiServer.java) with associated remote object interface definition |
| 7 | +(RmiRemoteInterface.java). These examples are set up to work over SSL/TLS. |
| 8 | + |
| 9 | +The `RmiRemoteInterface.java` file defines an interface with one public method |
| 10 | +named `String getServerMessage() throws RemoteException;`. This method |
| 11 | +should be implemented to one that returns a simple string message from the |
| 12 | +server implementation. |
| 13 | + |
| 14 | +The `RmiServer.java` file implements a simple server, which implements the |
| 15 | +`RemoteInterface` class and `getServerMessage()` method. The server binds |
| 16 | +an object with the stub "RemoteInterface" to the local default registry at |
| 17 | +localhost:1099. |
| 18 | + |
| 19 | +The `RmiClient.java` file gets an object stub from the remote registry, and |
| 20 | +makes the remote method invocation for `getServerMessage()`. |
| 21 | + |
| 22 | +## Compiling Example Code |
| 23 | + |
| 24 | +The example code is set up to compile as part of the `ant examples` target: |
| 25 | + |
| 26 | +``` |
| 27 | +$ cd wolfssljni |
| 28 | +$ ./java.sh |
| 29 | +$ ant |
| 30 | +$ ant examples |
| 31 | +``` |
| 32 | + |
| 33 | +## Start the Server |
| 34 | + |
| 35 | +To start the server, run the following helper script from the wolfSSL JNI/JSSE |
| 36 | +root directory: |
| 37 | + |
| 38 | +``` |
| 39 | +$ cd wolfssljni |
| 40 | +$ ./examples/provider/rmi/RmiServer.sh |
| 41 | +``` |
| 42 | + |
| 43 | +You should see the following message after the server has finished setting up |
| 44 | +the RMI object: |
| 45 | + |
| 46 | +``` |
| 47 | +Created server TrustManagerFactory |
| 48 | +Created server KeyManagerFactory |
| 49 | +Created server SSLContext |
| 50 | +Created server SSLServerSocketFactory |
| 51 | +Creating server Socket |
| 52 | +Created server TrustManagerFactory |
| 53 | +Created server KeyManagerFactory |
| 54 | +Created server SSLContext |
| 55 | +Created server SSLServerSocketFactory |
| 56 | +Server started, listening for connections |
| 57 | +``` |
| 58 | + |
| 59 | +## Connecting the Client |
| 60 | + |
| 61 | +To start the client, run the following helper script from the wolfSSL JNI/JSSE |
| 62 | +root directory: |
| 63 | + |
| 64 | +``` |
| 65 | +$ cd wolfssljni |
| 66 | +$ ./examples/provider/rmi/RmiClient.sh |
| 67 | +``` |
| 68 | + |
| 69 | +You should see the response sent back from the server method: |
| 70 | + |
| 71 | +``` |
| 72 | +Created client TrustManagerFactory |
| 73 | +Created client KeyManagerFactory |
| 74 | +Created client SSLContext |
| 75 | +Created client SocketFactory |
| 76 | +Creating client Socket |
| 77 | +Created client TrustManagerFactory |
| 78 | +Created client KeyManagerFactory |
| 79 | +Created client SSLContext |
| 80 | +Created client SocketFactory |
| 81 | +Creating client Socket |
| 82 | +Message from server via RMI: Hello from server |
| 83 | +``` |
| 84 | + |
| 85 | +## Support |
| 86 | + |
| 87 | +For support or questions with these examples, please email support@wolfssl.com. |
| 88 | + |
0 commit comments