Package eu.tneitzel.rmg.networking
Class LoopbackSslSocketFactory
- java.lang.Object
-
- javax.net.SocketFactory
-
- javax.net.ssl.SSLSocketFactory
-
- eu.tneitzel.rmg.networking.LoopbackSslSocketFactory
-
- All Implemented Interfaces:
RMIClientSocketFactory
public class LoopbackSslSocketFactory extends SSLSocketFactory implements RMIClientSocketFactory
Remote objects bound to an RMI registry are usually pointing to remote endpoints on the same host. In order to protect from unauthorized access, some developers suggest setting these references to localhost or 127.0.0.1 explicitly. This will indeed cause hiccups in most RMI clients, as they try to call to 127.0.0.1 after fetching a remote object. However, when the TCP ports of the corresponding remote objects are open, it is still possible to communicate with them. The LoopbackSslSocketFactory class extends the default SSLSocketFactory and can be set as a replacement. The class uses remote-method-guessers global option access to obtain the actual target of the RMI communication (usually the registry host). All other RMI connections are then expected to target the same host. This is implemented by overwriting the createSocket function. If the specified host value does not match the expected value, it is replaced by the expected value and the connection is therefore redirected. During a redirect, the class prints a warning to the user to inform about the redirection. If redirection is a desired behavior, the user can use the --follow option with remote-method-guesser, which sets the followRedirect attribute to true. In these cases, a warning is still printed, but the connection goes to the specified target.- Author:
- Tobias Neitzel (@qtc_de)
-
-
Field Summary
Fields Modifier and Type Field Description SSLSocketFactoryfaxSSLSocketFactory used for socket creationbooleanprintInfoWhether to print redirection information
-
Constructor Summary
Constructors Constructor Description LoopbackSslSocketFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SocketcreateSocket(String target, int port)Overwrites the default implementation of createSocket.SocketcreateSocket(String arg0, int arg1, InetAddress arg2, int arg3)SocketcreateSocket(InetAddress arg0, int arg1)SocketcreateSocket(InetAddress arg0, int arg1, InetAddress arg2, int arg3)SocketcreateSocket(Socket arg0, String arg1, int arg2, boolean arg3)String[]getDefaultCipherSuites()String[]getSupportedCipherSuites()-
Methods inherited from class javax.net.ssl.SSLSocketFactory
createSocket, getDefault
-
Methods inherited from class javax.net.SocketFactory
createSocket
-
-
-
-
Field Detail
-
fax
public transient SSLSocketFactory fax
SSLSocketFactory used for socket creation
-
printInfo
public transient boolean printInfo
Whether to print redirection information
-
-
Method Detail
-
createSocket
public Socket createSocket(String target, int port) throws IOException
Overwrites the default implementation of createSocket. Checks whether host matches the expected value and changes the value if required. After the host check was done, the default socket factory is used to create the real socket.- Specified by:
createSocketin interfaceRMIClientSocketFactory- Specified by:
createSocketin classSocketFactory- Throws:
IOException
-
createSocket
public Socket createSocket(Socket arg0, String arg1, int arg2, boolean arg3) throws IOException
- Specified by:
createSocketin classSSLSocketFactory- Throws:
IOException
-
getDefaultCipherSuites
public String[] getDefaultCipherSuites()
- Specified by:
getDefaultCipherSuitesin classSSLSocketFactory
-
getSupportedCipherSuites
public String[] getSupportedCipherSuites()
- Specified by:
getSupportedCipherSuitesin classSSLSocketFactory
-
createSocket
public Socket createSocket(InetAddress arg0, int arg1) throws IOException
- Specified by:
createSocketin classSocketFactory- Throws:
IOException
-
createSocket
public Socket createSocket(String arg0, int arg1, InetAddress arg2, int arg3) throws IOException, UnknownHostException
- Specified by:
createSocketin classSocketFactory- Throws:
IOExceptionUnknownHostException
-
createSocket
public Socket createSocket(InetAddress arg0, int arg1, InetAddress arg2, int arg3) throws IOException
- Specified by:
createSocketin classSocketFactory- Throws:
IOException
-
-