sun.rmi.server.UnicastRef2 Java Examples

The following examples show how to use sun.rmi.server.UnicastRef2. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProxyClient.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void checkStub(Remote stub,
                              Class<? extends Remote> stubClass) {
    // Check remote stub is from the expected class.
    //
    if (stub.getClass() != stubClass) {
        if (!Proxy.isProxyClass(stub.getClass())) {
            throw new SecurityException(
                "Expecting a " + stubClass.getName() + " stub!");
        } else {
            InvocationHandler handler = Proxy.getInvocationHandler(stub);
            if (handler.getClass() != RemoteObjectInvocationHandler.class) {
                throw new SecurityException(
                    "Expecting a dynamic proxy instance with a " +
                    RemoteObjectInvocationHandler.class.getName() +
                    " invocation handler!");
            } else {
                stub = (Remote) handler;
            }
        }
    }
    // Check RemoteRef in stub is from the expected class
    // "sun.rmi.server.UnicastRef2".
    //
    RemoteRef ref = ((RemoteObject)stub).getRef();
    if (ref.getClass() != UnicastRef2.class) {
        throw new SecurityException(
            "Expecting a " + UnicastRef2.class.getName() +
            " remote reference in stub!");
    }
    // Check RMIClientSocketFactory in stub is from the expected class
    // "javax.rmi.ssl.SslRMIClientSocketFactory".
    //
    LiveRef liveRef = ((UnicastRef2)ref).getLiveRef();
    RMIClientSocketFactory csf = liveRef.getClientSocketFactory();
    if (csf == null || csf.getClass() != SslRMIClientSocketFactory.class) {
        throw new SecurityException(
            "Expecting a " + SslRMIClientSocketFactory.class.getName() +
            " RMI client socket factory in stub!");
    }
}
 
Example #2
Source File: ProxyClient.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private static void checkStub(Remote stub,
                              Class<? extends Remote> stubClass) {
    // Check remote stub is from the expected class.
    //
    if (stub.getClass() != stubClass) {
        if (!Proxy.isProxyClass(stub.getClass())) {
            throw new SecurityException(
                "Expecting a " + stubClass.getName() + " stub!");
        } else {
            InvocationHandler handler = Proxy.getInvocationHandler(stub);
            if (handler.getClass() != RemoteObjectInvocationHandler.class) {
                throw new SecurityException(
                    "Expecting a dynamic proxy instance with a " +
                    RemoteObjectInvocationHandler.class.getName() +
                    " invocation handler!");
            } else {
                stub = (Remote) handler;
            }
        }
    }
    // Check RemoteRef in stub is from the expected class
    // "sun.rmi.server.UnicastRef2".
    //
    RemoteRef ref = ((RemoteObject)stub).getRef();
    if (ref.getClass() != UnicastRef2.class) {
        throw new SecurityException(
            "Expecting a " + UnicastRef2.class.getName() +
            " remote reference in stub!");
    }
    // Check RMIClientSocketFactory in stub is from the expected class
    // "javax.rmi.ssl.SslRMIClientSocketFactory".
    //
    LiveRef liveRef = ((UnicastRef2)ref).getLiveRef();
    RMIClientSocketFactory csf = liveRef.getClientSocketFactory();
    if (csf == null || csf.getClass() != SslRMIClientSocketFactory.class) {
        throw new SecurityException(
            "Expecting a " + SslRMIClientSocketFactory.class.getName() +
            " RMI client socket factory in stub!");
    }
}
 
Example #3
Source File: ProxyClient.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void checkStub(Remote stub,
                              Class<? extends Remote> stubClass) {
    // Check remote stub is from the expected class.
    //
    if (stub.getClass() != stubClass) {
        if (!Proxy.isProxyClass(stub.getClass())) {
            throw new SecurityException(
                "Expecting a " + stubClass.getName() + " stub!");
        } else {
            InvocationHandler handler = Proxy.getInvocationHandler(stub);
            if (handler.getClass() != RemoteObjectInvocationHandler.class) {
                throw new SecurityException(
                    "Expecting a dynamic proxy instance with a " +
                    RemoteObjectInvocationHandler.class.getName() +
                    " invocation handler!");
            } else {
                stub = (Remote) handler;
            }
        }
    }
    // Check RemoteRef in stub is from the expected class
    // "sun.rmi.server.UnicastRef2".
    //
    RemoteRef ref = ((RemoteObject)stub).getRef();
    if (ref.getClass() != UnicastRef2.class) {
        throw new SecurityException(
            "Expecting a " + UnicastRef2.class.getName() +
            " remote reference in stub!");
    }
    // Check RMIClientSocketFactory in stub is from the expected class
    // "javax.rmi.ssl.SslRMIClientSocketFactory".
    //
    LiveRef liveRef = ((UnicastRef2)ref).getLiveRef();
    RMIClientSocketFactory csf = liveRef.getClientSocketFactory();
    if (csf == null || csf.getClass() != SslRMIClientSocketFactory.class) {
        throw new SecurityException(
            "Expecting a " + SslRMIClientSocketFactory.class.getName() +
            " RMI client socket factory in stub!");
    }
}
 
Example #4
Source File: ProxyClient.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static void checkStub(Remote stub,
                              Class<? extends Remote> stubClass) {
    // Check remote stub is from the expected class.
    //
    if (stub.getClass() != stubClass) {
        if (!Proxy.isProxyClass(stub.getClass())) {
            throw new SecurityException(
                "Expecting a " + stubClass.getName() + " stub!");
        } else {
            InvocationHandler handler = Proxy.getInvocationHandler(stub);
            if (handler.getClass() != RemoteObjectInvocationHandler.class) {
                throw new SecurityException(
                    "Expecting a dynamic proxy instance with a " +
                    RemoteObjectInvocationHandler.class.getName() +
                    " invocation handler!");
            } else {
                stub = (Remote) handler;
            }
        }
    }
    // Check RemoteRef in stub is from the expected class
    // "sun.rmi.server.UnicastRef2".
    //
    RemoteRef ref = ((RemoteObject)stub).getRef();
    if (ref.getClass() != UnicastRef2.class) {
        throw new SecurityException(
            "Expecting a " + UnicastRef2.class.getName() +
            " remote reference in stub!");
    }
    // Check RMIClientSocketFactory in stub is from the expected class
    // "javax.rmi.ssl.SslRMIClientSocketFactory".
    //
    LiveRef liveRef = ((UnicastRef2)ref).getLiveRef();
    RMIClientSocketFactory csf = liveRef.getClientSocketFactory();
    if (csf == null || csf.getClass() != SslRMIClientSocketFactory.class) {
        throw new SecurityException(
            "Expecting a " + SslRMIClientSocketFactory.class.getName() +
            " RMI client socket factory in stub!");
    }
}
 
Example #5
Source File: ProxyClient.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void checkStub(Remote stub,
                              Class<? extends Remote> stubClass) {
    // Check remote stub is from the expected class.
    //
    if (stub.getClass() != stubClass) {
        if (!Proxy.isProxyClass(stub.getClass())) {
            throw new SecurityException(
                "Expecting a " + stubClass.getName() + " stub!");
        } else {
            InvocationHandler handler = Proxy.getInvocationHandler(stub);
            if (handler.getClass() != RemoteObjectInvocationHandler.class) {
                throw new SecurityException(
                    "Expecting a dynamic proxy instance with a " +
                    RemoteObjectInvocationHandler.class.getName() +
                    " invocation handler!");
            } else {
                stub = (Remote) handler;
            }
        }
    }
    // Check RemoteRef in stub is from the expected class
    // "sun.rmi.server.UnicastRef2".
    //
    RemoteRef ref = ((RemoteObject)stub).getRef();
    if (ref.getClass() != UnicastRef2.class) {
        throw new SecurityException(
            "Expecting a " + UnicastRef2.class.getName() +
            " remote reference in stub!");
    }
    // Check RMIClientSocketFactory in stub is from the expected class
    // "javax.rmi.ssl.SslRMIClientSocketFactory".
    //
    LiveRef liveRef = ((UnicastRef2)ref).getLiveRef();
    RMIClientSocketFactory csf = liveRef.getClientSocketFactory();
    if (csf == null || csf.getClass() != SslRMIClientSocketFactory.class) {
        throw new SecurityException(
            "Expecting a " + SslRMIClientSocketFactory.class.getName() +
            " RMI client socket factory in stub!");
    }
}
 
Example #6
Source File: ProxyClient.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void checkStub(Remote stub,
                              Class<? extends Remote> stubClass) {
    // Check remote stub is from the expected class.
    //
    if (stub.getClass() != stubClass) {
        if (!Proxy.isProxyClass(stub.getClass())) {
            throw new SecurityException(
                "Expecting a " + stubClass.getName() + " stub!");
        } else {
            InvocationHandler handler = Proxy.getInvocationHandler(stub);
            if (handler.getClass() != RemoteObjectInvocationHandler.class) {
                throw new SecurityException(
                    "Expecting a dynamic proxy instance with a " +
                    RemoteObjectInvocationHandler.class.getName() +
                    " invocation handler!");
            } else {
                stub = (Remote) handler;
            }
        }
    }
    // Check RemoteRef in stub is from the expected class
    // "sun.rmi.server.UnicastRef2".
    //
    RemoteRef ref = ((RemoteObject)stub).getRef();
    if (ref.getClass() != UnicastRef2.class) {
        throw new SecurityException(
            "Expecting a " + UnicastRef2.class.getName() +
            " remote reference in stub!");
    }
    // Check RMIClientSocketFactory in stub is from the expected class
    // "javax.rmi.ssl.SslRMIClientSocketFactory".
    //
    LiveRef liveRef = ((UnicastRef2)ref).getLiveRef();
    RMIClientSocketFactory csf = liveRef.getClientSocketFactory();
    if (csf == null || csf.getClass() != SslRMIClientSocketFactory.class) {
        throw new SecurityException(
            "Expecting a " + SslRMIClientSocketFactory.class.getName() +
            " RMI client socket factory in stub!");
    }
}
 
Example #7
Source File: ProxyClient.java    From jvmtop with GNU General Public License v2.0 5 votes vote down vote up
private static void checkStub(Remote stub,
                              Class<? extends Remote> stubClass) {
    // Check remote stub is from the expected class.
    //
    if (stub.getClass() != stubClass) {
        if (!Proxy.isProxyClass(stub.getClass())) {
            throw new SecurityException(
                "Expecting a " + stubClass.getName() + " stub!");
        } else {
            InvocationHandler handler = Proxy.getInvocationHandler(stub);
            if (handler.getClass() != RemoteObjectInvocationHandler.class) {
                throw new SecurityException(
                    "Expecting a dynamic proxy instance with a " +
                    RemoteObjectInvocationHandler.class.getName() +
                    " invocation handler!");
            } else {
                stub = (Remote) handler;
            }
        }
    }
    // Check RemoteRef in stub is from the expected class
    // "sun.rmi.server.UnicastRef2".
    //
    RemoteRef ref = ((RemoteObject)stub).getRef();
    if (ref.getClass() != UnicastRef2.class) {
        throw new SecurityException(
            "Expecting a " + UnicastRef2.class.getName() +
            " remote reference in stub!");
    }
    // Check RMIClientSocketFactory in stub is from the expected class
    // "javax.rmi.ssl.SslRMIClientSocketFactory".
    //
    LiveRef liveRef = ((UnicastRef2)ref).getLiveRef();
    RMIClientSocketFactory csf = liveRef.getClientSocketFactory();
    if (csf == null || csf.getClass() != SslRMIClientSocketFactory.class) {
        throw new SecurityException(
            "Expecting a " + SslRMIClientSocketFactory.class.getName() +
            " RMI client socket factory in stub!");
    }
}
 
Example #8
Source File: ProxyClient.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static void checkStub(Remote stub,
                              Class<? extends Remote> stubClass) {
    // Check remote stub is from the expected class.
    //
    if (stub.getClass() != stubClass) {
        if (!Proxy.isProxyClass(stub.getClass())) {
            throw new SecurityException(
                "Expecting a " + stubClass.getName() + " stub!");
        } else {
            InvocationHandler handler = Proxy.getInvocationHandler(stub);
            if (handler.getClass() != RemoteObjectInvocationHandler.class) {
                throw new SecurityException(
                    "Expecting a dynamic proxy instance with a " +
                    RemoteObjectInvocationHandler.class.getName() +
                    " invocation handler!");
            } else {
                stub = (Remote) handler;
            }
        }
    }
    // Check RemoteRef in stub is from the expected class
    // "sun.rmi.server.UnicastRef2".
    //
    RemoteRef ref = ((RemoteObject)stub).getRef();
    if (ref.getClass() != UnicastRef2.class) {
        throw new SecurityException(
            "Expecting a " + UnicastRef2.class.getName() +
            " remote reference in stub!");
    }
    // Check RMIClientSocketFactory in stub is from the expected class
    // "javax.rmi.ssl.SslRMIClientSocketFactory".
    //
    LiveRef liveRef = ((UnicastRef2)ref).getLiveRef();
    RMIClientSocketFactory csf = liveRef.getClientSocketFactory();
    if (csf == null || csf.getClass() != SslRMIClientSocketFactory.class) {
        throw new SecurityException(
            "Expecting a " + SslRMIClientSocketFactory.class.getName() +
            " RMI client socket factory in stub!");
    }
}
 
Example #9
Source File: ProxyClient.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static void checkStub(Remote stub,
                              Class<? extends Remote> stubClass) {
    // Check remote stub is from the expected class.
    //
    if (stub.getClass() != stubClass) {
        if (!Proxy.isProxyClass(stub.getClass())) {
            throw new SecurityException(
                "Expecting a " + stubClass.getName() + " stub!");
        } else {
            InvocationHandler handler = Proxy.getInvocationHandler(stub);
            if (handler.getClass() != RemoteObjectInvocationHandler.class) {
                throw new SecurityException(
                    "Expecting a dynamic proxy instance with a " +
                    RemoteObjectInvocationHandler.class.getName() +
                    " invocation handler!");
            } else {
                stub = (Remote) handler;
            }
        }
    }
    // Check RemoteRef in stub is from the expected class
    // "sun.rmi.server.UnicastRef2".
    //
    RemoteRef ref = ((RemoteObject)stub).getRef();
    if (ref.getClass() != UnicastRef2.class) {
        throw new SecurityException(
            "Expecting a " + UnicastRef2.class.getName() +
            " remote reference in stub!");
    }
    // Check RMIClientSocketFactory in stub is from the expected class
    // "javax.rmi.ssl.SslRMIClientSocketFactory".
    //
    LiveRef liveRef = ((UnicastRef2)ref).getLiveRef();
    RMIClientSocketFactory csf = liveRef.getClientSocketFactory();
    if (csf == null || csf.getClass() != SslRMIClientSocketFactory.class) {
        throw new SecurityException(
            "Expecting a " + SslRMIClientSocketFactory.class.getName() +
            " RMI client socket factory in stub!");
    }
}
 
Example #10
Source File: ProxyClient.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void checkStub(Remote stub,
                              Class<? extends Remote> stubClass) {
    // Check remote stub is from the expected class.
    //
    if (stub.getClass() != stubClass) {
        if (!Proxy.isProxyClass(stub.getClass())) {
            throw new SecurityException(
                "Expecting a " + stubClass.getName() + " stub!");
        } else {
            InvocationHandler handler = Proxy.getInvocationHandler(stub);
            if (handler.getClass() != RemoteObjectInvocationHandler.class) {
                throw new SecurityException(
                    "Expecting a dynamic proxy instance with a " +
                    RemoteObjectInvocationHandler.class.getName() +
                    " invocation handler!");
            } else {
                stub = (Remote) handler;
            }
        }
    }
    // Check RemoteRef in stub is from the expected class
    // "sun.rmi.server.UnicastRef2".
    //
    RemoteRef ref = ((RemoteObject)stub).getRef();
    if (ref.getClass() != UnicastRef2.class) {
        throw new SecurityException(
            "Expecting a " + UnicastRef2.class.getName() +
            " remote reference in stub!");
    }
    // Check RMIClientSocketFactory in stub is from the expected class
    // "javax.rmi.ssl.SslRMIClientSocketFactory".
    //
    LiveRef liveRef = ((UnicastRef2)ref).getLiveRef();
    RMIClientSocketFactory csf = liveRef.getClientSocketFactory();
    if (csf == null || csf.getClass() != SslRMIClientSocketFactory.class) {
        throw new SecurityException(
            "Expecting a " + SslRMIClientSocketFactory.class.getName() +
            " RMI client socket factory in stub!");
    }
}
 
Example #11
Source File: RMIConnector.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void checkStub(Remote stub,
        Class<?> stubClass) {

    // Check remote stub is from the expected class.
    //
    if (stub.getClass() != stubClass) {
        if (!Proxy.isProxyClass(stub.getClass())) {
            throw new SecurityException(
                    "Expecting a " + stubClass.getName() + " stub!");
        } else {
            InvocationHandler handler = Proxy.getInvocationHandler(stub);
            if (handler.getClass() != RemoteObjectInvocationHandler.class)
                throw new SecurityException(
                        "Expecting a dynamic proxy instance with a " +
                        RemoteObjectInvocationHandler.class.getName() +
                        " invocation handler!");
            else
                stub = (Remote) handler;
        }
    }

    // Check RemoteRef in stub is from the expected class
    // "sun.rmi.server.UnicastRef2".
    //
    RemoteRef ref = ((RemoteObject)stub).getRef();
    if (ref.getClass() != UnicastRef2.class)
        throw new SecurityException(
                "Expecting a " + UnicastRef2.class.getName() +
                " remote reference in stub!");

    // Check RMIClientSocketFactory in stub is from the expected class
    // "javax.rmi.ssl.SslRMIClientSocketFactory".
    //
    LiveRef liveRef = ((UnicastRef2)ref).getLiveRef();
    RMIClientSocketFactory csf = liveRef.getClientSocketFactory();
    if (csf == null || csf.getClass() != SslRMIClientSocketFactory.class)
        throw new SecurityException(
                "Expecting a " + SslRMIClientSocketFactory.class.getName() +
                " RMI client socket factory in stub!");
}
 
Example #12
Source File: ProxyClient.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static void checkStub(Remote stub,
                              Class<? extends Remote> stubClass) {
    // Check remote stub is from the expected class.
    //
    if (stub.getClass() != stubClass) {
        if (!Proxy.isProxyClass(stub.getClass())) {
            throw new SecurityException(
                "Expecting a " + stubClass.getName() + " stub!");
        } else {
            InvocationHandler handler = Proxy.getInvocationHandler(stub);
            if (handler.getClass() != RemoteObjectInvocationHandler.class) {
                throw new SecurityException(
                    "Expecting a dynamic proxy instance with a " +
                    RemoteObjectInvocationHandler.class.getName() +
                    " invocation handler!");
            } else {
                stub = (Remote) handler;
            }
        }
    }
    // Check RemoteRef in stub is from the expected class
    // "sun.rmi.server.UnicastRef2".
    //
    RemoteRef ref = ((RemoteObject)stub).getRef();
    if (ref.getClass() != UnicastRef2.class) {
        throw new SecurityException(
            "Expecting a " + UnicastRef2.class.getName() +
            " remote reference in stub!");
    }
    // Check RMIClientSocketFactory in stub is from the expected class
    // "javax.rmi.ssl.SslRMIClientSocketFactory".
    //
    LiveRef liveRef = ((UnicastRef2)ref).getLiveRef();
    RMIClientSocketFactory csf = liveRef.getClientSocketFactory();
    if (csf == null || csf.getClass() != SslRMIClientSocketFactory.class) {
        throw new SecurityException(
            "Expecting a " + SslRMIClientSocketFactory.class.getName() +
            " RMI client socket factory in stub!");
    }
}
 
Example #13
Source File: ProxyClient.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void checkStub(Remote stub,
                              Class<? extends Remote> stubClass) {
    // Check remote stub is from the expected class.
    //
    if (stub.getClass() != stubClass) {
        if (!Proxy.isProxyClass(stub.getClass())) {
            throw new SecurityException(
                "Expecting a " + stubClass.getName() + " stub!");
        } else {
            InvocationHandler handler = Proxy.getInvocationHandler(stub);
            if (handler.getClass() != RemoteObjectInvocationHandler.class) {
                throw new SecurityException(
                    "Expecting a dynamic proxy instance with a " +
                    RemoteObjectInvocationHandler.class.getName() +
                    " invocation handler!");
            } else {
                stub = (Remote) handler;
            }
        }
    }
    // Check RemoteRef in stub is from the expected class
    // "sun.rmi.server.UnicastRef2".
    //
    RemoteRef ref = ((RemoteObject)stub).getRef();
    if (ref.getClass() != UnicastRef2.class) {
        throw new SecurityException(
            "Expecting a " + UnicastRef2.class.getName() +
            " remote reference in stub!");
    }
    // Check RMIClientSocketFactory in stub is from the expected class
    // "javax.rmi.ssl.SslRMIClientSocketFactory".
    //
    LiveRef liveRef = ((UnicastRef2)ref).getLiveRef();
    RMIClientSocketFactory csf = liveRef.getClientSocketFactory();
    if (csf == null || csf.getClass() != SslRMIClientSocketFactory.class) {
        throw new SecurityException(
            "Expecting a " + SslRMIClientSocketFactory.class.getName() +
            " RMI client socket factory in stub!");
    }
}
 
Example #14
Source File: ProxyClient.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void checkStub(Remote stub,
                              Class<? extends Remote> stubClass) {
    // Check remote stub is from the expected class.
    //
    if (stub.getClass() != stubClass) {
        if (!Proxy.isProxyClass(stub.getClass())) {
            throw new SecurityException(
                "Expecting a " + stubClass.getName() + " stub!");
        } else {
            InvocationHandler handler = Proxy.getInvocationHandler(stub);
            if (handler.getClass() != RemoteObjectInvocationHandler.class) {
                throw new SecurityException(
                    "Expecting a dynamic proxy instance with a " +
                    RemoteObjectInvocationHandler.class.getName() +
                    " invocation handler!");
            } else {
                stub = (Remote) handler;
            }
        }
    }
    // Check RemoteRef in stub is from the expected class
    // "sun.rmi.server.UnicastRef2".
    //
    RemoteRef ref = ((RemoteObject)stub).getRef();
    if (ref.getClass() != UnicastRef2.class) {
        throw new SecurityException(
            "Expecting a " + UnicastRef2.class.getName() +
            " remote reference in stub!");
    }
    // Check RMIClientSocketFactory in stub is from the expected class
    // "javax.rmi.ssl.SslRMIClientSocketFactory".
    //
    LiveRef liveRef = ((UnicastRef2)ref).getLiveRef();
    RMIClientSocketFactory csf = liveRef.getClientSocketFactory();
    if (csf == null || csf.getClass() != SslRMIClientSocketFactory.class) {
        throw new SecurityException(
            "Expecting a " + SslRMIClientSocketFactory.class.getName() +
            " RMI client socket factory in stub!");
    }
}
 
Example #15
Source File: ProxyClient.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void checkStub(Remote stub,
                              Class<? extends Remote> stubClass) {
    // Check remote stub is from the expected class.
    //
    if (stub.getClass() != stubClass) {
        if (!Proxy.isProxyClass(stub.getClass())) {
            throw new SecurityException(
                "Expecting a " + stubClass.getName() + " stub!");
        } else {
            InvocationHandler handler = Proxy.getInvocationHandler(stub);
            if (handler.getClass() != RemoteObjectInvocationHandler.class) {
                throw new SecurityException(
                    "Expecting a dynamic proxy instance with a " +
                    RemoteObjectInvocationHandler.class.getName() +
                    " invocation handler!");
            } else {
                stub = (Remote) handler;
            }
        }
    }
    // Check RemoteRef in stub is from the expected class
    // "sun.rmi.server.UnicastRef2".
    //
    RemoteRef ref = ((RemoteObject)stub).getRef();
    if (ref.getClass() != UnicastRef2.class) {
        throw new SecurityException(
            "Expecting a " + UnicastRef2.class.getName() +
            " remote reference in stub!");
    }
    // Check RMIClientSocketFactory in stub is from the expected class
    // "javax.rmi.ssl.SslRMIClientSocketFactory".
    //
    LiveRef liveRef = ((UnicastRef2)ref).getLiveRef();
    RMIClientSocketFactory csf = liveRef.getClientSocketFactory();
    if (csf == null || csf.getClass() != SslRMIClientSocketFactory.class) {
        throw new SecurityException(
            "Expecting a " + SslRMIClientSocketFactory.class.getName() +
            " RMI client socket factory in stub!");
    }
}
 
Example #16
Source File: RMIConnector.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void checkStub(Remote stub,
        Class<?> stubClass) {

    // Check remote stub is from the expected class.
    //
    if (stub.getClass() != stubClass) {
        if (!Proxy.isProxyClass(stub.getClass())) {
            throw new SecurityException(
                    "Expecting a " + stubClass.getName() + " stub!");
        } else {
            InvocationHandler handler = Proxy.getInvocationHandler(stub);
            if (handler.getClass() != RemoteObjectInvocationHandler.class)
                throw new SecurityException(
                        "Expecting a dynamic proxy instance with a " +
                        RemoteObjectInvocationHandler.class.getName() +
                        " invocation handler!");
            else
                stub = (Remote) handler;
        }
    }

    // Check RemoteRef in stub is from the expected class
    // "sun.rmi.server.UnicastRef2".
    //
    RemoteRef ref = ((RemoteObject)stub).getRef();
    if (ref.getClass() != UnicastRef2.class)
        throw new SecurityException(
                "Expecting a " + UnicastRef2.class.getName() +
                " remote reference in stub!");

    // Check RMIClientSocketFactory in stub is from the expected class
    // "javax.rmi.ssl.SslRMIClientSocketFactory".
    //
    LiveRef liveRef = ((UnicastRef2)ref).getLiveRef();
    RMIClientSocketFactory csf = liveRef.getClientSocketFactory();
    if (csf == null || csf.getClass() != SslRMIClientSocketFactory.class)
        throw new SecurityException(
                "Expecting a " + SslRMIClientSocketFactory.class.getName() +
                " RMI client socket factory in stub!");
}
 
Example #17
Source File: LocateRegistry.java    From Java8CN with Apache License 2.0 4 votes vote down vote up
/**
 * Returns a locally created remote reference to the remote object
 * <code>Registry</code> on the specified <code>host</code> and
 * <code>port</code>.  Communication with this remote registry will
 * use the supplied <code>RMIClientSocketFactory</code> <code>csf</code>
 * to create <code>Socket</code> connections to the registry on the
 * remote <code>host</code> and <code>port</code>.
 *
 * @param host host for the remote registry
 * @param port port on which the registry accepts requests
 * @param csf  client-side <code>Socket</code> factory used to
 *      make connections to the registry.  If <code>csf</code>
 *      is null, then the default client-side <code>Socket</code>
 *      factory will be used in the registry stub.
 * @return reference (a stub) to the remote registry
 * @exception RemoteException if the reference could not be created
 * @since 1.2
 */
public static Registry getRegistry(String host, int port,
                                   RMIClientSocketFactory csf)
    throws RemoteException
{
    Registry registry = null;

    if (port <= 0)
        port = Registry.REGISTRY_PORT;

    if (host == null || host.length() == 0) {
        // If host is blank (as returned by "file:" URL in 1.0.2 used in
        // java.rmi.Naming), try to convert to real local host name so
        // that the RegistryImpl's checkAccess will not fail.
        try {
            host = java.net.InetAddress.getLocalHost().getHostAddress();
        } catch (Exception e) {
            // If that failed, at least try "" (localhost) anyway...
            host = "";
        }
    }

    /*
     * Create a proxy for the registry with the given host, port, and
     * client socket factory.  If the supplied client socket factory is
     * null, then the ref type is a UnicastRef, otherwise the ref type
     * is a UnicastRef2.  If the property
     * java.rmi.server.ignoreStubClasses is true, then the proxy
     * returned is an instance of a dynamic proxy class that implements
     * the Registry interface; otherwise the proxy returned is an
     * instance of the pregenerated stub class for RegistryImpl.
     **/
    LiveRef liveRef =
        new LiveRef(new ObjID(ObjID.REGISTRY_ID),
                    new TCPEndpoint(host, port, csf, null),
                    false);
    RemoteRef ref =
        (csf == null) ? new UnicastRef(liveRef) : new UnicastRef2(liveRef);

    return (Registry) Util.createProxy(RegistryImpl.class, ref, false);
}
 
Example #18
Source File: LocateRegistry.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a locally created remote reference to the remote object
 * <code>Registry</code> on the specified <code>host</code> and
 * <code>port</code>.  Communication with this remote registry will
 * use the supplied <code>RMIClientSocketFactory</code> <code>csf</code>
 * to create <code>Socket</code> connections to the registry on the
 * remote <code>host</code> and <code>port</code>.
 *
 * @param host host for the remote registry
 * @param port port on which the registry accepts requests
 * @param csf  client-side <code>Socket</code> factory used to
 *      make connections to the registry.  If <code>csf</code>
 *      is null, then the default client-side <code>Socket</code>
 *      factory will be used in the registry stub.
 * @return reference (a stub) to the remote registry
 * @exception RemoteException if the reference could not be created
 * @since 1.2
 */
public static Registry getRegistry(String host, int port,
                                   RMIClientSocketFactory csf)
    throws RemoteException
{
    Registry registry = null;

    if (port <= 0)
        port = Registry.REGISTRY_PORT;

    if (host == null || host.length() == 0) {
        // If host is blank (as returned by "file:" URL in 1.0.2 used in
        // java.rmi.Naming), try to convert to real local host name so
        // that the RegistryImpl's checkAccess will not fail.
        try {
            host = java.net.InetAddress.getLocalHost().getHostAddress();
        } catch (Exception e) {
            // If that failed, at least try "" (localhost) anyway...
            host = "";
        }
    }

    /*
     * Create a proxy for the registry with the given host, port, and
     * client socket factory.  If the supplied client socket factory is
     * null, then the ref type is a UnicastRef, otherwise the ref type
     * is a UnicastRef2.  If the property
     * java.rmi.server.ignoreStubClasses is true, then the proxy
     * returned is an instance of a dynamic proxy class that implements
     * the Registry interface; otherwise the proxy returned is an
     * instance of the pregenerated stub class for RegistryImpl.
     **/
    LiveRef liveRef =
        new LiveRef(new ObjID(ObjID.REGISTRY_ID),
                    new TCPEndpoint(host, port, csf, null),
                    false);
    RemoteRef ref =
        (csf == null) ? new UnicastRef(liveRef) : new UnicastRef2(liveRef);

    return (Registry) Util.createProxy(RegistryImpl.class, ref, false);
}
 
Example #19
Source File: LocateRegistry.java    From jdk-1.7-annotated with Apache License 2.0 4 votes vote down vote up
/**
 * Returns a locally created remote reference to the remote object
 * <code>Registry</code> on the specified <code>host</code> and
 * <code>port</code>.  Communication with this remote registry will
 * use the supplied <code>RMIClientSocketFactory</code> <code>csf</code>
 * to create <code>Socket</code> connections to the registry on the
 * remote <code>host</code> and <code>port</code>.
 *
 * @param host host for the remote registry
 * @param port port on which the registry accepts requests
 * @param csf  client-side <code>Socket</code> factory used to
 *      make connections to the registry.  If <code>csf</code>
 *      is null, then the default client-side <code>Socket</code>
 *      factory will be used in the registry stub.
 * @return reference (a stub) to the remote registry
 * @exception RemoteException if the reference could not be created
 * @since 1.2
 */
public static Registry getRegistry(String host, int port,
                                   RMIClientSocketFactory csf)
    throws RemoteException
{
    Registry registry = null;

    if (port <= 0)
        port = Registry.REGISTRY_PORT;

    if (host == null || host.length() == 0) {
        // If host is blank (as returned by "file:" URL in 1.0.2 used in
        // java.rmi.Naming), try to convert to real local host name so
        // that the RegistryImpl's checkAccess will not fail.
        try {
            host = java.net.InetAddress.getLocalHost().getHostAddress();
        } catch (Exception e) {
            // If that failed, at least try "" (localhost) anyway...
            host = "";
        }
    }

    /*
     * Create a proxy for the registry with the given host, port, and
     * client socket factory.  If the supplied client socket factory is
     * null, then the ref type is a UnicastRef, otherwise the ref type
     * is a UnicastRef2.  If the property
     * java.rmi.server.ignoreStubClasses is true, then the proxy
     * returned is an instance of a dynamic proxy class that implements
     * the Registry interface; otherwise the proxy returned is an
     * instance of the pregenerated stub class for RegistryImpl.
     **/
    LiveRef liveRef =
        new LiveRef(new ObjID(ObjID.REGISTRY_ID),
                    new TCPEndpoint(host, port, csf, null),
                    false);
    RemoteRef ref =
        (csf == null) ? new UnicastRef(liveRef) : new UnicastRef2(liveRef);

    return (Registry) Util.createProxy(RegistryImpl.class, ref, false);
}
 
Example #20
Source File: LocateRegistry.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a locally created remote reference to the remote object
 * <code>Registry</code> on the specified <code>host</code> and
 * <code>port</code>.  Communication with this remote registry will
 * use the supplied <code>RMIClientSocketFactory</code> <code>csf</code>
 * to create <code>Socket</code> connections to the registry on the
 * remote <code>host</code> and <code>port</code>.
 *
 * @param host host for the remote registry
 * @param port port on which the registry accepts requests
 * @param csf  client-side <code>Socket</code> factory used to
 *      make connections to the registry.  If <code>csf</code>
 *      is null, then the default client-side <code>Socket</code>
 *      factory will be used in the registry stub.
 * @return reference (a stub) to the remote registry
 * @exception RemoteException if the reference could not be created
 * @since 1.2
 */
public static Registry getRegistry(String host, int port,
                                   RMIClientSocketFactory csf)
    throws RemoteException
{
    Registry registry = null;

    if (port <= 0)
        port = Registry.REGISTRY_PORT;

    if (host == null || host.length() == 0) {
        // If host is blank (as returned by "file:" URL in 1.0.2 used in
        // java.rmi.Naming), try to convert to real local host name so
        // that the RegistryImpl's checkAccess will not fail.
        try {
            host = java.net.InetAddress.getLocalHost().getHostAddress();
        } catch (Exception e) {
            // If that failed, at least try "" (localhost) anyway...
            host = "";
        }
    }

    /*
     * Create a proxy for the registry with the given host, port, and
     * client socket factory.  If the supplied client socket factory is
     * null, then the ref type is a UnicastRef, otherwise the ref type
     * is a UnicastRef2.  If the property
     * java.rmi.server.ignoreStubClasses is true, then the proxy
     * returned is an instance of a dynamic proxy class that implements
     * the Registry interface; otherwise the proxy returned is an
     * instance of the pregenerated stub class for RegistryImpl.
     **/
    LiveRef liveRef =
        new LiveRef(new ObjID(ObjID.REGISTRY_ID),
                    new TCPEndpoint(host, port, csf, null),
                    false);
    RemoteRef ref =
        (csf == null) ? new UnicastRef(liveRef) : new UnicastRef2(liveRef);

    return (Registry) Util.createProxy(RegistryImpl.class, ref, false);
}
 
Example #21
Source File: LocateRegistry.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a locally created remote reference to the remote object
 * <code>Registry</code> on the specified <code>host</code> and
 * <code>port</code>.  Communication with this remote registry will
 * use the supplied <code>RMIClientSocketFactory</code> <code>csf</code>
 * to create <code>Socket</code> connections to the registry on the
 * remote <code>host</code> and <code>port</code>.
 *
 * @param host host for the remote registry
 * @param port port on which the registry accepts requests
 * @param csf  client-side <code>Socket</code> factory used to
 *      make connections to the registry.  If <code>csf</code>
 *      is null, then the default client-side <code>Socket</code>
 *      factory will be used in the registry stub.
 * @return reference (a stub) to the remote registry
 * @exception RemoteException if the reference could not be created
 * @since 1.2
 */
public static Registry getRegistry(String host, int port,
                                   RMIClientSocketFactory csf)
    throws RemoteException
{
    Registry registry = null;

    if (port <= 0)
        port = Registry.REGISTRY_PORT;

    if (host == null || host.length() == 0) {
        // If host is blank (as returned by "file:" URL in 1.0.2 used in
        // java.rmi.Naming), try to convert to real local host name so
        // that the RegistryImpl's checkAccess will not fail.
        try {
            host = java.net.InetAddress.getLocalHost().getHostAddress();
        } catch (Exception e) {
            // If that failed, at least try "" (localhost) anyway...
            host = "";
        }
    }

    /*
     * Create a proxy for the registry with the given host, port, and
     * client socket factory.  If the supplied client socket factory is
     * null, then the ref type is a UnicastRef, otherwise the ref type
     * is a UnicastRef2.  If the property
     * java.rmi.server.ignoreStubClasses is true, then the proxy
     * returned is an instance of a dynamic proxy class that implements
     * the Registry interface; otherwise the proxy returned is an
     * instance of the pregenerated stub class for RegistryImpl.
     **/
    LiveRef liveRef =
        new LiveRef(new ObjID(ObjID.REGISTRY_ID),
                    new TCPEndpoint(host, port, csf, null),
                    false);
    RemoteRef ref =
        (csf == null) ? new UnicastRef(liveRef) : new UnicastRef2(liveRef);

    return (Registry) Util.createProxy(RegistryImpl.class, ref, false);
}
 
Example #22
Source File: LocateRegistry.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a locally created remote reference to the remote object
 * <code>Registry</code> on the specified <code>host</code> and
 * <code>port</code>.  Communication with this remote registry will
 * use the supplied <code>RMIClientSocketFactory</code> <code>csf</code>
 * to create <code>Socket</code> connections to the registry on the
 * remote <code>host</code> and <code>port</code>.
 *
 * @param host host for the remote registry
 * @param port port on which the registry accepts requests
 * @param csf  client-side <code>Socket</code> factory used to
 *      make connections to the registry.  If <code>csf</code>
 *      is null, then the default client-side <code>Socket</code>
 *      factory will be used in the registry stub.
 * @return reference (a stub) to the remote registry
 * @exception RemoteException if the reference could not be created
 * @since 1.2
 */
public static Registry getRegistry(String host, int port,
                                   RMIClientSocketFactory csf)
    throws RemoteException
{
    Registry registry = null;

    if (port <= 0)
        port = Registry.REGISTRY_PORT;

    if (host == null || host.length() == 0) {
        // If host is blank (as returned by "file:" URL in 1.0.2 used in
        // java.rmi.Naming), try to convert to real local host name so
        // that the RegistryImpl's checkAccess will not fail.
        try {
            host = java.net.InetAddress.getLocalHost().getHostAddress();
        } catch (Exception e) {
            // If that failed, at least try "" (localhost) anyway...
            host = "";
        }
    }

    /*
     * Create a proxy for the registry with the given host, port, and
     * client socket factory.  If the supplied client socket factory is
     * null, then the ref type is a UnicastRef, otherwise the ref type
     * is a UnicastRef2.  If the property
     * java.rmi.server.ignoreStubClasses is true, then the proxy
     * returned is an instance of a dynamic proxy class that implements
     * the Registry interface; otherwise the proxy returned is an
     * instance of the pregenerated stub class for RegistryImpl.
     **/
    LiveRef liveRef =
        new LiveRef(new ObjID(ObjID.REGISTRY_ID),
                    new TCPEndpoint(host, port, csf, null),
                    false);
    RemoteRef ref =
        (csf == null) ? new UnicastRef(liveRef) : new UnicastRef2(liveRef);

    return (Registry) Util.createProxy(RegistryImpl.class, ref, false);
}
 
Example #23
Source File: LocateRegistry.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a locally created remote reference to the remote object
 * <code>Registry</code> on the specified <code>host</code> and
 * <code>port</code>.  Communication with this remote registry will
 * use the supplied <code>RMIClientSocketFactory</code> <code>csf</code>
 * to create <code>Socket</code> connections to the registry on the
 * remote <code>host</code> and <code>port</code>.
 *
 * @param host host for the remote registry
 * @param port port on which the registry accepts requests
 * @param csf  client-side <code>Socket</code> factory used to
 *      make connections to the registry.  If <code>csf</code>
 *      is null, then the default client-side <code>Socket</code>
 *      factory will be used in the registry stub.
 * @return reference (a stub) to the remote registry
 * @exception RemoteException if the reference could not be created
 * @since 1.2
 */
public static Registry getRegistry(String host, int port,
                                   RMIClientSocketFactory csf)
    throws RemoteException
{
    Registry registry = null;

    if (port <= 0)
        port = Registry.REGISTRY_PORT;

    if (host == null || host.length() == 0) {
        // If host is blank (as returned by "file:" URL in 1.0.2 used in
        // java.rmi.Naming), try to convert to real local host name so
        // that the RegistryImpl's checkAccess will not fail.
        try {
            host = java.net.InetAddress.getLocalHost().getHostAddress();
        } catch (Exception e) {
            // If that failed, at least try "" (localhost) anyway...
            host = "";
        }
    }

    /*
     * Create a proxy for the registry with the given host, port, and
     * client socket factory.  If the supplied client socket factory is
     * null, then the ref type is a UnicastRef, otherwise the ref type
     * is a UnicastRef2.  If the property
     * java.rmi.server.ignoreStubClasses is true, then the proxy
     * returned is an instance of a dynamic proxy class that implements
     * the Registry interface; otherwise the proxy returned is an
     * instance of the pregenerated stub class for RegistryImpl.
     **/
    LiveRef liveRef =
        new LiveRef(new ObjID(ObjID.REGISTRY_ID),
                    new TCPEndpoint(host, port, csf, null),
                    false);
    RemoteRef ref =
        (csf == null) ? new UnicastRef(liveRef) : new UnicastRef2(liveRef);

    return (Registry) Util.createProxy(RegistryImpl.class, ref, false);
}
 
Example #24
Source File: LocateRegistry.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a locally created remote reference to the remote object
 * <code>Registry</code> on the specified <code>host</code> and
 * <code>port</code>.  Communication with this remote registry will
 * use the supplied <code>RMIClientSocketFactory</code> <code>csf</code>
 * to create <code>Socket</code> connections to the registry on the
 * remote <code>host</code> and <code>port</code>.
 *
 * @param host host for the remote registry
 * @param port port on which the registry accepts requests
 * @param csf  client-side <code>Socket</code> factory used to
 *      make connections to the registry.  If <code>csf</code>
 *      is null, then the default client-side <code>Socket</code>
 *      factory will be used in the registry stub.
 * @return reference (a stub) to the remote registry
 * @exception RemoteException if the reference could not be created
 * @since 1.2
 */
public static Registry getRegistry(String host, int port,
                                   RMIClientSocketFactory csf)
    throws RemoteException
{
    Registry registry = null;

    if (port <= 0)
        port = Registry.REGISTRY_PORT;

    if (host == null || host.length() == 0) {
        // If host is blank (as returned by "file:" URL in 1.0.2 used in
        // java.rmi.Naming), try to convert to real local host name so
        // that the RegistryImpl's checkAccess will not fail.
        try {
            host = java.net.InetAddress.getLocalHost().getHostAddress();
        } catch (Exception e) {
            // If that failed, at least try "" (localhost) anyway...
            host = "";
        }
    }

    /*
     * Create a proxy for the registry with the given host, port, and
     * client socket factory.  If the supplied client socket factory is
     * null, then the ref type is a UnicastRef, otherwise the ref type
     * is a UnicastRef2.  If the property
     * java.rmi.server.ignoreStubClasses is true, then the proxy
     * returned is an instance of a dynamic proxy class that implements
     * the Registry interface; otherwise the proxy returned is an
     * instance of the pregenerated stub class for RegistryImpl.
     **/
    LiveRef liveRef =
        new LiveRef(new ObjID(ObjID.REGISTRY_ID),
                    new TCPEndpoint(host, port, csf, null),
                    false);
    RemoteRef ref =
        (csf == null) ? new UnicastRef(liveRef) : new UnicastRef2(liveRef);

    return (Registry) Util.createProxy(RegistryImpl.class, ref, false);
}
 
Example #25
Source File: LocateRegistry.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
 * Returns a locally created remote reference to the remote object
 * <code>Registry</code> on the specified <code>host</code> and
 * <code>port</code>.  Communication with this remote registry will
 * use the supplied <code>RMIClientSocketFactory</code> <code>csf</code>
 * to create <code>Socket</code> connections to the registry on the
 * remote <code>host</code> and <code>port</code>.
 *
 * @param host host for the remote registry
 * @param port port on which the registry accepts requests
 * @param csf  client-side <code>Socket</code> factory used to
 *      make connections to the registry.  If <code>csf</code>
 *      is null, then the default client-side <code>Socket</code>
 *      factory will be used in the registry stub.
 * @return reference (a stub) to the remote registry
 * @exception RemoteException if the reference could not be created
 * @since 1.2
 */
public static Registry getRegistry(String host, int port,
                                   RMIClientSocketFactory csf)
    throws RemoteException
{
    Registry registry = null;

    if (port <= 0)
        port = Registry.REGISTRY_PORT;

    if (host == null || host.length() == 0) {
        // If host is blank (as returned by "file:" URL in 1.0.2 used in
        // java.rmi.Naming), try to convert to real local host name so
        // that the RegistryImpl's checkAccess will not fail.
        try {
            host = java.net.InetAddress.getLocalHost().getHostAddress();
        } catch (Exception e) {
            // If that failed, at least try "" (localhost) anyway...
            host = "";
        }
    }

    /*
     * Create a proxy for the registry with the given host, port, and
     * client socket factory.  If the supplied client socket factory is
     * null, then the ref type is a UnicastRef, otherwise the ref type
     * is a UnicastRef2.  If the property
     * java.rmi.server.ignoreStubClasses is true, then the proxy
     * returned is an instance of a dynamic proxy class that implements
     * the Registry interface; otherwise the proxy returned is an
     * instance of the pregenerated stub class for RegistryImpl.
     **/
    LiveRef liveRef =
        new LiveRef(new ObjID(ObjID.REGISTRY_ID),
                    new TCPEndpoint(host, port, csf, null),
                    false);
    RemoteRef ref =
        (csf == null) ? new UnicastRef(liveRef) : new UnicastRef2(liveRef);

    return (Registry) Util.createProxy(RegistryImpl.class, ref, false);
}
 
Example #26
Source File: LocateRegistry.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a locally created remote reference to the remote object
 * <code>Registry</code> on the specified <code>host</code> and
 * <code>port</code>.  Communication with this remote registry will
 * use the supplied <code>RMIClientSocketFactory</code> <code>csf</code>
 * to create <code>Socket</code> connections to the registry on the
 * remote <code>host</code> and <code>port</code>.
 *
 * @param host host for the remote registry
 * @param port port on which the registry accepts requests
 * @param csf  client-side <code>Socket</code> factory used to
 *      make connections to the registry.  If <code>csf</code>
 *      is null, then the default client-side <code>Socket</code>
 *      factory will be used in the registry stub.
 * @return reference (a stub) to the remote registry
 * @exception RemoteException if the reference could not be created
 * @since 1.2
 */
public static Registry getRegistry(String host, int port,
                                   RMIClientSocketFactory csf)
    throws RemoteException
{
    Registry registry = null;

    if (port <= 0)
        port = Registry.REGISTRY_PORT;

    if (host == null || host.length() == 0) {
        // If host is blank (as returned by "file:" URL in 1.0.2 used in
        // java.rmi.Naming), try to convert to real local host name so
        // that the RegistryImpl's checkAccess will not fail.
        try {
            host = java.net.InetAddress.getLocalHost().getHostAddress();
        } catch (Exception e) {
            // If that failed, at least try "" (localhost) anyway...
            host = "";
        }
    }

    /*
     * Create a proxy for the registry with the given host, port, and
     * client socket factory.  If the supplied client socket factory is
     * null, then the ref type is a UnicastRef, otherwise the ref type
     * is a UnicastRef2.  If the property
     * java.rmi.server.ignoreStubClasses is true, then the proxy
     * returned is an instance of a dynamic proxy class that implements
     * the Registry interface; otherwise the proxy returned is an
     * instance of the pregenerated stub class for RegistryImpl.
     **/
    LiveRef liveRef =
        new LiveRef(new ObjID(ObjID.REGISTRY_ID),
                    new TCPEndpoint(host, port, csf, null),
                    false);
    RemoteRef ref =
        (csf == null) ? new UnicastRef(liveRef) : new UnicastRef2(liveRef);

    return (Registry) Util.createProxy(RegistryImpl.class, ref, false);
}
 
Example #27
Source File: LocateRegistry.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a locally created remote reference to the remote object
 * <code>Registry</code> on the specified <code>host</code> and
 * <code>port</code>.  Communication with this remote registry will
 * use the supplied <code>RMIClientSocketFactory</code> <code>csf</code>
 * to create <code>Socket</code> connections to the registry on the
 * remote <code>host</code> and <code>port</code>.
 *
 * @param host host for the remote registry
 * @param port port on which the registry accepts requests
 * @param csf  client-side <code>Socket</code> factory used to
 *      make connections to the registry.  If <code>csf</code>
 *      is null, then the default client-side <code>Socket</code>
 *      factory will be used in the registry stub.
 * @return reference (a stub) to the remote registry
 * @exception RemoteException if the reference could not be created
 * @since 1.2
 */
public static Registry getRegistry(String host, int port,
                                   RMIClientSocketFactory csf)
    throws RemoteException
{
    Registry registry = null;

    if (port <= 0)
        port = Registry.REGISTRY_PORT;

    if (host == null || host.length() == 0) {
        // If host is blank (as returned by "file:" URL in 1.0.2 used in
        // java.rmi.Naming), try to convert to real local host name so
        // that the RegistryImpl's checkAccess will not fail.
        try {
            host = java.net.InetAddress.getLocalHost().getHostAddress();
        } catch (Exception e) {
            // If that failed, at least try "" (localhost) anyway...
            host = "";
        }
    }

    /*
     * Create a proxy for the registry with the given host, port, and
     * client socket factory.  If the supplied client socket factory is
     * null, then the ref type is a UnicastRef, otherwise the ref type
     * is a UnicastRef2.  If the property
     * java.rmi.server.ignoreStubClasses is true, then the proxy
     * returned is an instance of a dynamic proxy class that implements
     * the Registry interface; otherwise the proxy returned is an
     * instance of the pregenerated stub class for RegistryImpl.
     **/
    LiveRef liveRef =
        new LiveRef(new ObjID(ObjID.REGISTRY_ID),
                    new TCPEndpoint(host, port, csf, null),
                    false);
    RemoteRef ref =
        (csf == null) ? new UnicastRef(liveRef) : new UnicastRef2(liveRef);

    return (Registry) Util.createProxy(RegistryImpl.class, ref, false);
}
 
Example #28
Source File: LocateRegistry.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a locally created remote reference to the remote object
 * <code>Registry</code> on the specified <code>host</code> and
 * <code>port</code>.  Communication with this remote registry will
 * use the supplied <code>RMIClientSocketFactory</code> <code>csf</code>
 * to create <code>Socket</code> connections to the registry on the
 * remote <code>host</code> and <code>port</code>.
 *
 * @param host host for the remote registry
 * @param port port on which the registry accepts requests
 * @param csf  client-side <code>Socket</code> factory used to
 *      make connections to the registry.  If <code>csf</code>
 *      is null, then the default client-side <code>Socket</code>
 *      factory will be used in the registry stub.
 * @return reference (a stub) to the remote registry
 * @exception RemoteException if the reference could not be created
 * @since 1.2
 */
public static Registry getRegistry(String host, int port,
                                   RMIClientSocketFactory csf)
    throws RemoteException
{
    Registry registry = null;

    if (port <= 0)
        port = Registry.REGISTRY_PORT;

    if (host == null || host.length() == 0) {
        // If host is blank (as returned by "file:" URL in 1.0.2 used in
        // java.rmi.Naming), try to convert to real local host name so
        // that the RegistryImpl's checkAccess will not fail.
        try {
            host = java.net.InetAddress.getLocalHost().getHostAddress();
        } catch (Exception e) {
            // If that failed, at least try "" (localhost) anyway...
            host = "";
        }
    }

    /*
     * Create a proxy for the registry with the given host, port, and
     * client socket factory.  If the supplied client socket factory is
     * null, then the ref type is a UnicastRef, otherwise the ref type
     * is a UnicastRef2.  If the property
     * java.rmi.server.ignoreStubClasses is true, then the proxy
     * returned is an instance of a dynamic proxy class that implements
     * the Registry interface; otherwise the proxy returned is an
     * instance of the pregenerated stub class for RegistryImpl.
     **/
    LiveRef liveRef =
        new LiveRef(new ObjID(ObjID.REGISTRY_ID),
                    new TCPEndpoint(host, port, csf, null),
                    false);
    RemoteRef ref =
        (csf == null) ? new UnicastRef(liveRef) : new UnicastRef2(liveRef);

    return (Registry) Util.createProxy(RegistryImpl.class, ref, false);
}
 
Example #29
Source File: LocateRegistry.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a locally created remote reference to the remote object
 * <code>Registry</code> on the specified <code>host</code> and
 * <code>port</code>.  Communication with this remote registry will
 * use the supplied <code>RMIClientSocketFactory</code> <code>csf</code>
 * to create <code>Socket</code> connections to the registry on the
 * remote <code>host</code> and <code>port</code>.
 *
 * @param host host for the remote registry
 * @param port port on which the registry accepts requests
 * @param csf  client-side <code>Socket</code> factory used to
 *      make connections to the registry.  If <code>csf</code>
 *      is null, then the default client-side <code>Socket</code>
 *      factory will be used in the registry stub.
 * @return reference (a stub) to the remote registry
 * @exception RemoteException if the reference could not be created
 * @since 1.2
 */
public static Registry getRegistry(String host, int port,
                                   RMIClientSocketFactory csf)
    throws RemoteException
{
    Registry registry = null;

    if (port <= 0)
        port = Registry.REGISTRY_PORT;

    if (host == null || host.length() == 0) {
        // If host is blank (as returned by "file:" URL in 1.0.2 used in
        // java.rmi.Naming), try to convert to real local host name so
        // that the RegistryImpl's checkAccess will not fail.
        try {
            host = java.net.InetAddress.getLocalHost().getHostAddress();
        } catch (Exception e) {
            // If that failed, at least try "" (localhost) anyway...
            host = "";
        }
    }

    /*
     * Create a proxy for the registry with the given host, port, and
     * client socket factory.  If the supplied client socket factory is
     * null, then the ref type is a UnicastRef, otherwise the ref type
     * is a UnicastRef2.  If the property
     * java.rmi.server.ignoreStubClasses is true, then the proxy
     * returned is an instance of a dynamic proxy class that implements
     * the Registry interface; otherwise the proxy returned is an
     * instance of the pregenerated stub class for RegistryImpl.
     **/
    LiveRef liveRef =
        new LiveRef(new ObjID(ObjID.REGISTRY_ID),
                    new TCPEndpoint(host, port, csf, null),
                    false);
    RemoteRef ref =
        (csf == null) ? new UnicastRef(liveRef) : new UnicastRef2(liveRef);

    return (Registry) Util.createProxy(RegistryImpl.class, ref, false);
}
 
Example #30
Source File: LocateRegistry.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
 * Returns a locally created remote reference to the remote object
 * <code>Registry</code> on the specified <code>host</code> and
 * <code>port</code>.  Communication with this remote registry will
 * use the supplied <code>RMIClientSocketFactory</code> <code>csf</code>
 * to create <code>Socket</code> connections to the registry on the
 * remote <code>host</code> and <code>port</code>.
 *
 * @param host host for the remote registry
 * @param port port on which the registry accepts requests
 * @param csf  client-side <code>Socket</code> factory used to
 *      make connections to the registry.  If <code>csf</code>
 *      is null, then the default client-side <code>Socket</code>
 *      factory will be used in the registry stub.
 * @return reference (a stub) to the remote registry
 * @exception RemoteException if the reference could not be created
 * @since 1.2
 */
public static Registry getRegistry(String host, int port,
                                   RMIClientSocketFactory csf)
    throws RemoteException
{
    Registry registry = null;

    if (port <= 0)
        port = Registry.REGISTRY_PORT;

    if (host == null || host.length() == 0) {
        // If host is blank (as returned by "file:" URL in 1.0.2 used in
        // java.rmi.Naming), try to convert to real local host name so
        // that the RegistryImpl's checkAccess will not fail.
        try {
            host = java.net.InetAddress.getLocalHost().getHostAddress();
        } catch (Exception e) {
            // If that failed, at least try "" (localhost) anyway...
            host = "";
        }
    }

    /*
     * Create a proxy for the registry with the given host, port, and
     * client socket factory.  If the supplied client socket factory is
     * null, then the ref type is a UnicastRef, otherwise the ref type
     * is a UnicastRef2.  If the property
     * java.rmi.server.ignoreStubClasses is true, then the proxy
     * returned is an instance of a dynamic proxy class that implements
     * the Registry interface; otherwise the proxy returned is an
     * instance of the pregenerated stub class for RegistryImpl.
     **/
    LiveRef liveRef =
        new LiveRef(new ObjID(ObjID.REGISTRY_ID),
                    new TCPEndpoint(host, port, csf, null),
                    false);
    RemoteRef ref =
        (csf == null) ? new UnicastRef(liveRef) : new UnicastRef2(liveRef);

    return (Registry) Util.createProxy(RegistryImpl.class, ref, false);
}