-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add custom socket factory obj to ExampleServer
A new RemoteObject was added to port 9010 of the ExampleServer. This remote object is registred with a custom RMISocketFactory to allow tests of the dynamic SockerFactory creation feature of remote-method-guesser.
- Loading branch information
Showing
12 changed files
with
218 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
|
||
## v4.1.0 - Nov 12, 2023 | ||
|
||
### Added | ||
|
||
* Add an additional RemoteObject using a custom socket factory class | ||
|
||
|
||
## v4.0.0 and before | ||
|
||
Changelog entries can be found within the global [CHANGELOG.md](/CHANGELOG.md) file | ||
of remote-method-guesser. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,4 +54,4 @@ public String system(String command, String[] args) | |
|
||
return result; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...er/example-server/resources/server/src/de/qtc/rmg/server/factory/CustomSocketFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package de.qtc.rmg.server.factory; | ||
|
||
import java.io.IOException; | ||
import java.io.Serializable; | ||
import java.net.ServerSocket; | ||
import java.net.Socket; | ||
import java.rmi.server.RMISocketFactory; | ||
|
||
public class CustomSocketFactory extends RMISocketFactory implements Serializable | ||
{ | ||
private static final long serialVersionUID = -1168901302380021730L; | ||
private final transient RMISocketFactory defaultFax; | ||
|
||
public CustomSocketFactory() | ||
{ | ||
defaultFax = RMISocketFactory.getDefaultSocketFactory(); | ||
} | ||
|
||
public ServerSocket createServerSocket(int arg0) throws IOException | ||
{ | ||
return defaultFax.createServerSocket(arg0); | ||
} | ||
|
||
public Socket createSocket(String arg0, int arg1) throws IOException | ||
{ | ||
return defaultFax.createSocket(arg0, arg1); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
...mple-server/resources/server/src/de/qtc/rmg/server/factory/CustomSocketFactoryServer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package de.qtc.rmg.server.factory; | ||
|
||
import java.rmi.AlreadyBoundException; | ||
import java.rmi.NotBoundException; | ||
import java.rmi.Remote; | ||
import java.rmi.RemoteException; | ||
import java.rmi.registry.LocateRegistry; | ||
import java.rmi.registry.Registry; | ||
import java.rmi.server.RMISocketFactory; | ||
import java.rmi.server.UnicastRemoteObject; | ||
|
||
import de.qtc.rmg.server.interfaces.IPlainServer; | ||
import de.qtc.rmg.server.operations.PlainServer; | ||
import de.qtc.rmg.server.utils.Logger; | ||
import de.qtc.rmg.server.utils.Utils; | ||
|
||
public class CustomSocketFactoryServer | ||
{ | ||
private static Remote remoteObjectOne;; | ||
private static final String boundName = "custom-socks"; | ||
|
||
public static void startServer(int registryPort) | ||
{ | ||
Logger.increaseIndent(); | ||
|
||
try | ||
{ | ||
RMISocketFactory csf = new CustomSocketFactory(); | ||
|
||
Logger.printMixedBlue("Locating", "RMI-Registry", "on port "); | ||
Logger.printlnPlainYellow(String.valueOf(registryPort)); | ||
Registry registry = LocateRegistry.getRegistry(registryPort); | ||
Logger.println(""); | ||
|
||
Logger.printlnMixedBlue("Creating", "PlainServer", "object."); | ||
remoteObjectOne = new PlainServer(); | ||
IPlainServer stub = (IPlainServer)UnicastRemoteObject.exportObject(remoteObjectOne, 0, csf, null); | ||
Utils.bindToRegistry(stub, registry, boundName); | ||
|
||
Logger.println("Server setup finished."); | ||
} | ||
|
||
catch (RemoteException | AlreadyBoundException | NotBoundException e) | ||
{ | ||
Logger.eprintln("Unexpected RMI Error:"); | ||
e.printStackTrace(); | ||
} | ||
|
||
Logger.println(""); | ||
Logger.decreaseIndent(); | ||
} | ||
} |
Oops, something went wrong.