Skip to content

Commit

Permalink
JSSE: add threaded RMI example client and server apps
Browse files Browse the repository at this point in the history
  • Loading branch information
cconlon committed Oct 24, 2024
1 parent ad59d74 commit 09088cd
Show file tree
Hide file tree
Showing 8 changed files with 933 additions and 0 deletions.
88 changes: 88 additions & 0 deletions examples/provider/rmi/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@

# Java Remote Method Invocation (RMI) Example Client and Server

This is a simple example of Java Remote Method Invocation (RMI), including
the implementation of a very basic client (RmiClient.java) and server
(RmiServer.java) with associated remote object interface definition
(RmiRemoteInterface.java). These examples are set up to work over SSL/TLS.

The `RmiRemoteInterface.java` file defines an interface with one public method
named `String getServerMessage() throws RemoteException;`. This method
should be implemented to one that returns a simple string message from the
server implementation.

The `RmiServer.java` file implements a simple server, which implements the
`RemoteInterface` class and `getServerMessage()` method. The server binds
an object with the stub "RemoteInterface" to the local default registry at
localhost:1099.

The `RmiClient.java` file gets an object stub from the remote registry, and
makes the remote method invocation for `getServerMessage()`.

## Compiling Example Code

The example code is set up to compile as part of the `ant examples` target:

```
$ cd wolfssljni
$ ./java.sh
$ ant
$ ant examples
```

## Start the Server

To start the server, run the following helper script from the wolfSSL JNI/JSSE
root directory:

```
$ cd wolfssljni
$ ./examples/provider/rmi/RmiServer.sh
```

You should see the following message after the server has finished setting up
the RMI object:

```
Created server TrustManagerFactory
Created server KeyManagerFactory
Created server SSLContext
Created server SSLServerSocketFactory
Creating server Socket
Created server TrustManagerFactory
Created server KeyManagerFactory
Created server SSLContext
Created server SSLServerSocketFactory
Server started, listening for connections
```

## Connecting the Client

To start the client, run the following helper script from the wolfSSL JNI/JSSE
root directory:

```
$ cd wolfssljni
$ ./examples/provider/rmi/RmiClient.sh
```

You should see the response sent back from the server method:

```
Created client TrustManagerFactory
Created client KeyManagerFactory
Created client SSLContext
Created client SocketFactory
Creating client Socket
Created client TrustManagerFactory
Created client KeyManagerFactory
Created client SSLContext
Created client SocketFactory
Creating client Socket
Message from server via RMI: Hello from server
```

## Support

For support or questions with these examples, please email [email protected].

Loading

0 comments on commit 09088cd

Please sign in to comment.