Class SpringRemotingWrapper


  • public class SpringRemotingWrapper
    extends UnicastWrapper
    SpringRemoting represents a wrapper around regular Java RMI. Exposed methods are not directly available via RemoteObjects, but are invoked using a dispatcher object that supports an invoke method. This class contains functions to convert an ordinary RMI method call into a SpringRemoting call.
    Author:
    Tobias Neitzel (@qtc_de)
    • Field Detail

      • invocationHandlerClass

        public static final String invocationHandlerClass
        class name of the RmiInvocationHandler class
        See Also:
        Constant Field Values
      • methodGetStr

        public static final String methodGetStr
        method signature of the getTargetInterfaceName method
        See Also:
        Constant Field Values
    • Constructor Detail

      • SpringRemotingWrapper

        public SpringRemotingWrapper​(Remote remoteObject,
                                     String boundName,
                                     sun.rmi.server.UnicastRef ref)
                              throws IllegalArgumentException,
                                     IllegalAccessException,
                                     NoSuchFieldException,
                                     SecurityException
        Within it's constructor, SpringRemotingWrapper already sends an RMI call to the server using the getTargetInterfaceName method. This is required to tell remote-method-guesser what the underlying interface class is. This information is displayed within the enum output and used for identifying potentialy known endpoints.
        Parameters:
        remoteObject - the spring remoting remoteObject obtained from the registry
        boundName - the boundName that is associated with the remoteObject
        ref - a UnicastRef that can be used to call methods on the remoteObject
        Throws:
        IllegalArgumentException - if reflective access fails
        IllegalAccessException - if reflective access fails
        NoSuchFieldException - if reflective access fails
        SecurityException - if reflective access fails
    • Method Detail

      • getInterfaceNameMethod

        public static MethodCandidate getInterfaceNameMethod()
        Return a MethodCandidate for the getTargetInterfaceName method that is exposed by the RmiInvocationHandler remote object.
        Returns:
        method candidate for the getTargetInterfaceName method
      • getInvokeMethod

        public static MethodCandidate getInvokeMethod()
        Return a MethodCandidate for the invoke method that is exposed by the RmiInvocationHandler remote object.
        Returns:
        method candidate for the invoke method
      • isRemotingCall

        public boolean isRemotingCall​(MethodCandidate targetMethod)
        Determines whether the method to call is a known spring remoting method, that needs to be processed by the remoting wrapper itself, or whether it is an RMI method implemented by the underlying object.
        Parameters:
        targetMethod - the method to check
        Returns:
        true if the method needs to be dispatched using spring remoting
      • getInterfaceName

        public String getInterfaceName()
        Return the interface name of the underlying interface class that can be accessed via spring remoting.
        Overrides:
        getInterfaceName in class RemoteObjectWrapper
        Returns:
        interface name implemented by the underlying remote object
      • buildRemoteInvocation

        public static org.springframework.remoting.support.RemoteInvocation buildRemoteInvocation​(MethodCandidate targetMethod,
                                                                                                  Object[] args)
        Prepare a RemoteInvocation object from a MethodCandidate and the user specified arguments. The resulting object can be passed to the spring remoting endpoint in order to call the specified MethodCandidate.
        Parameters:
        targetMethod - method that should be called via spring remoting
        args - arguments that should be used for the call
        Returns:
        RemoteInvocation that can be passed to the spring remoting server
      • getInvocationHolders

        public static Set<RemoteInvocationHolder> getInvocationHolders​(Set<MethodCandidate> candidates)
        Transform a set of MethodCandidate to a set of RemoteInvocationHolders.
        Parameters:
        candidates - v set of MethodCandidate to transform
        Returns:
        set of RemoteInvocationHolders
      • getSignature

        public static String getSignature​(MethodCandidate method)
        Returns a method signature for the specified MethodCandidate that lacks the return value. The return value is replaced with three question marks. The reason is that spring remoting treats similar methods with different return values the same. Therefore, it is not possible to determine the return value of a successfully guessed method.
        Parameters:
        method - MethodCandidate to obtain the modified signature from
        Returns:
        modified signature without a return value
      • containsSpringRemotingClient

        public static boolean containsSpringRemotingClient​(UnicastWrapper[] wrappers)
        Helper function that checks whether a list of UnicastWrapper objects contains a SpringRemotingWrapper (which is a child class of UnicastWrapper).
        Parameters:
        wrappers - list of UnicastWrapper objects
        Returns:
        true if at least one SpringRemotingWrapper is contained within the list