sun.rmi.server.UnicastRef Java Examples

The following examples show how to use sun.rmi.server.UnicastRef. 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: JRMPClient.java    From ysoserial with MIT License 6 votes vote down vote up
public Registry getObject ( final String command ) throws Exception {

        String host;
        int port;
        int sep = command.indexOf(':');
        if ( sep < 0 ) {
            port = new Random().nextInt(65535);
            host = command;
        }
        else {
            host = command.substring(0, sep);
            port = Integer.valueOf(command.substring(sep + 1));
        }
        ObjID id = new ObjID(new Random().nextInt()); // RMI registry
        TCPEndpoint te = new TCPEndpoint(host, port);
        UnicastRef ref = new UnicastRef(new LiveRef(id, te, false));
        RemoteObjectInvocationHandler obj = new RemoteObjectInvocationHandler(ref);
        Registry proxy = (Registry) Proxy.newProxyInstance(JRMPClient.class.getClassLoader(), new Class[] {
            Registry.class
        }, obj);
        return proxy;
    }
 
Example #2
Source File: JRMPClient.java    From ysoserial-modified with MIT License 6 votes vote down vote up
public Registry getObject ( String connection ) throws Exception {

        String host;
        int port;
        int sep = connection.indexOf(':');
        if ( sep < 0 ) {
            port = new Random().nextInt(65535);
            host = connection;
        }
        else {
            host = connection.substring(0, sep);
            port = Integer.valueOf(connection.substring(sep + 1));
        }
        ObjID id = new ObjID(new Random().nextInt()); // RMI registry
        TCPEndpoint te = new TCPEndpoint(host, port);
        UnicastRef ref = new UnicastRef(new LiveRef(id, te, false));
        RemoteObjectInvocationHandler obj = new RemoteObjectInvocationHandler(ref);
        Registry proxy = (Registry) Proxy.newProxyInstance(JRMPClient.class.getClassLoader(), new Class[] {
            Registry.class
        }, obj);
        return proxy;
    }
 
Example #3
Source File: DGCClient.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private EndpointEntry(final Endpoint endpoint) {
    this.endpoint = endpoint;
    try {
        LiveRef dgcRef = new LiveRef(dgcID, endpoint, false);
        dgc = (DGC) Util.createProxy(DGCImpl.class,
                                     new UnicastRef(dgcRef), true);
    } catch (RemoteException e) {
        throw new Error("internal error creating DGC stub");
    }
    renewCleanThread =  AccessController.doPrivileged(
        new NewThreadAction(new RenewCleanThread(),
                            "RenewClean-" + endpoint, true));
    renewCleanThread.start();
}
 
Example #4
Source File: JDKUtil.java    From marshalsec with MIT License 5 votes vote down vote up
private static Object makeRegistryImpl ( String codebase, String clazz ) throws IllegalArgumentException, Exception {
    Class<?> regcl = Class.forName("sun.management.jmxremote.SingleEntryRegistry");
    Object reg = Reflections.createWithoutConstructor(regcl);
    Reflections.setFieldValue(reg, "name", "exp");

    TCPEndpoint te = new TCPEndpoint("127.0.0.1", 1337);
    LiveRef liveRef = new LiveRef(new ObjID(), te, true);
    UnicastRef value = new UnicastRef(liveRef);
    Reflections.setFieldValue(reg, "ref", value);
    Reflections.setFieldValue(reg, "object", makeReference(codebase, clazz));
    return reg;
}
 
Example #5
Source File: JDKUtil.java    From learnjavabug with MIT License 5 votes vote down vote up
private static Object makeRegistryImpl ( String codebase, String clazz ) throws IllegalArgumentException, Exception {
    Class<?> regcl = Class.forName("sun.management.jmxremote.SingleEntryRegistry");
    Object reg = Reflections.createWithoutConstructor(regcl);
    Reflections.setFieldValue(reg, "name", "exp");

    TCPEndpoint te = new TCPEndpoint("127.0.0.1", 1337);
    LiveRef liveRef = new LiveRef(new ObjID(), te, true);
    UnicastRef value = new UnicastRef(liveRef);
    Reflections.setFieldValue(reg, "ref", value);
    Reflections.setFieldValue(reg, "object", makeReference(codebase, clazz));
    return reg;
}
 
Example #6
Source File: StreamRemoteCall.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Routine that causes the stack traces of remote exceptions to be
 * filled in with the current stack trace on the client.  Detail
 * exceptions are filled in iteratively.
 */
protected void exceptionReceivedFromServer(Exception ex) throws Exception {
    serverException = ex;

    StackTraceElement[] serverTrace = ex.getStackTrace();
    StackTraceElement[] clientTrace = (new Throwable()).getStackTrace();
    StackTraceElement[] combinedTrace =
        new StackTraceElement[serverTrace.length + clientTrace.length];
    System.arraycopy(serverTrace, 0, combinedTrace, 0,
                     serverTrace.length);
    System.arraycopy(clientTrace, 0, combinedTrace, serverTrace.length,
                     clientTrace.length);
    ex.setStackTrace(combinedTrace);

    /*
     * Log the details of a server exception thrown as a result of a
     * remote method invocation.
     */
    if (UnicastRef.clientCallLog.isLoggable(Log.BRIEF)) {
        /* log call exception returned from server before it is rethrown */
        TCPEndpoint ep = (TCPEndpoint) conn.getChannel().getEndpoint();
        UnicastRef.clientCallLog.log(Log.BRIEF, "outbound call " +
            "received exception: [" + ep.getHost() + ":" +
            ep.getPort() + "] exception: ", ex);
    }

    throw ex;
}
 
Example #7
Source File: RegistryImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ObjectInputFilter to filter Registry input objects.
 * The list of acceptable classes is limited to classes normally
 * stored in a registry.
 *
 * @param filterInfo access to the class, array length, etc.
 * @return  {@link ObjectInputFilter.Status#ALLOWED} if allowed,
 *          {@link ObjectInputFilter.Status#REJECTED} if rejected,
 *          otherwise {@link ObjectInputFilter.Status#UNDECIDED}
 */
private static ObjectInputFilter.Status registryFilter(ObjectInputFilter.FilterInfo filterInfo) {
    if (registryFilter != null) {
        ObjectInputFilter.Status status = registryFilter.checkInput(filterInfo);
        if (status != ObjectInputFilter.Status.UNDECIDED) {
            // The Registry filter can override the built-in white-list
            return status;
        }
    }

    if (filterInfo.depth() > REGISTRY_MAX_DEPTH) {
        return ObjectInputFilter.Status.REJECTED;
    }
    Class<?> clazz = filterInfo.serialClass();
    if (clazz != null) {
        if (clazz.isArray()) {
            // Arrays are REJECTED only if they exceed the limit
            return (filterInfo.arrayLength() >= 0 && filterInfo.arrayLength() > REGISTRY_MAX_ARRAY_SIZE)
                ? ObjectInputFilter.Status.REJECTED
                : ObjectInputFilter.Status.UNDECIDED;
        }
        if (String.class == clazz
                || java.lang.Number.class.isAssignableFrom(clazz)
                || Remote.class.isAssignableFrom(clazz)
                || java.lang.reflect.Proxy.class.isAssignableFrom(clazz)
                || UnicastRef.class.isAssignableFrom(clazz)
                || RMIClientSocketFactory.class.isAssignableFrom(clazz)
                || RMIServerSocketFactory.class.isAssignableFrom(clazz)
                || java.rmi.activation.ActivationID.class.isAssignableFrom(clazz)
                || java.rmi.server.UID.class.isAssignableFrom(clazz)) {
            return ObjectInputFilter.Status.ALLOWED;
        } else {
            return ObjectInputFilter.Status.REJECTED;
        }
    }
    return ObjectInputFilter.Status.UNDECIDED;
}
 
Example #8
Source File: DGCClient.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private EndpointEntry(final Endpoint endpoint) {
    this.endpoint = endpoint;
    try {
        LiveRef dgcRef = new LiveRef(dgcID, endpoint, false);
        dgc = (DGC) Util.createProxy(DGCImpl.class,
                                     new UnicastRef(dgcRef), true);
    } catch (RemoteException e) {
        throw new Error("internal error creating DGC stub");
    }
    renewCleanThread =  AccessController.doPrivileged(
        new NewThreadAction(new RenewCleanThread(),
                            "RenewClean-" + endpoint, true));
    renewCleanThread.start();
}
 
Example #9
Source File: RegistryImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ObjectInputFilter to filter Registry input objects.
 * The list of acceptable classes is limited to classes normally
 * stored in a registry.
 *
 * @param filterInfo access to the class, array length, etc.
 * @return  {@link ObjectInputFilter.Status#ALLOWED} if allowed,
 *          {@link ObjectInputFilter.Status#REJECTED} if rejected,
 *          otherwise {@link ObjectInputFilter.Status#UNDECIDED}
 */
private static ObjectInputFilter.Status registryFilter(ObjectInputFilter.FilterInfo filterInfo) {
    if (registryFilter != null) {
        ObjectInputFilter.Status status = registryFilter.checkInput(filterInfo);
        if (status != ObjectInputFilter.Status.UNDECIDED) {
            // The Registry filter can override the built-in white-list
            return status;
        }
    }

    if (filterInfo.depth() > REGISTRY_MAX_DEPTH) {
        return ObjectInputFilter.Status.REJECTED;
    }
    Class<?> clazz = filterInfo.serialClass();
    if (clazz != null) {
        if (clazz.isArray()) {
            // Arrays are REJECTED only if they exceed the limit
            return (filterInfo.arrayLength() >= 0 && filterInfo.arrayLength() > REGISTRY_MAX_ARRAY_SIZE)
                ? ObjectInputFilter.Status.REJECTED
                : ObjectInputFilter.Status.UNDECIDED;
        }
        if (String.class == clazz
                || java.lang.Number.class.isAssignableFrom(clazz)
                || Remote.class.isAssignableFrom(clazz)
                || java.lang.reflect.Proxy.class.isAssignableFrom(clazz)
                || UnicastRef.class.isAssignableFrom(clazz)
                || RMIClientSocketFactory.class.isAssignableFrom(clazz)
                || RMIServerSocketFactory.class.isAssignableFrom(clazz)
                || java.rmi.activation.ActivationID.class.isAssignableFrom(clazz)
                || java.rmi.server.UID.class.isAssignableFrom(clazz)) {
            return ObjectInputFilter.Status.ALLOWED;
        } else {
            return ObjectInputFilter.Status.REJECTED;
        }
    }
    return ObjectInputFilter.Status.UNDECIDED;
}
 
Example #10
Source File: StreamRemoteCall.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Routine that causes the stack traces of remote exceptions to be
 * filled in with the current stack trace on the client.  Detail
 * exceptions are filled in iteratively.
 */
protected void exceptionReceivedFromServer(Exception ex) throws Exception {
    serverException = ex;

    StackTraceElement[] serverTrace = ex.getStackTrace();
    StackTraceElement[] clientTrace = (new Throwable()).getStackTrace();
    StackTraceElement[] combinedTrace =
        new StackTraceElement[serverTrace.length + clientTrace.length];
    System.arraycopy(serverTrace, 0, combinedTrace, 0,
                     serverTrace.length);
    System.arraycopy(clientTrace, 0, combinedTrace, serverTrace.length,
                     clientTrace.length);
    ex.setStackTrace(combinedTrace);

    /*
     * Log the details of a server exception thrown as a result of a
     * remote method invocation.
     */
    if (UnicastRef.clientCallLog.isLoggable(Log.BRIEF)) {
        /* log call exception returned from server before it is rethrown */
        TCPEndpoint ep = (TCPEndpoint) conn.getChannel().getEndpoint();
        UnicastRef.clientCallLog.log(Log.BRIEF, "outbound call " +
            "received exception: [" + ep.getHost() + ":" +
            ep.getPort() + "] exception: ", ex);
    }

    throw ex;
}
 
Example #11
Source File: DGCClient.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private EndpointEntry(final Endpoint endpoint) {
    this.endpoint = endpoint;
    try {
        LiveRef dgcRef = new LiveRef(dgcID, endpoint, false);
        dgc = (DGC) Util.createProxy(DGCImpl.class,
                                     new UnicastRef(dgcRef), true);
    } catch (RemoteException e) {
        throw new Error("internal error creating DGC stub");
    }
    renewCleanThread =  AccessController.doPrivileged(
        new NewThreadAction(new RenewCleanThread(),
                            "RenewClean-" + endpoint, true));
    renewCleanThread.start();
}
 
Example #12
Source File: StreamRemoteCall.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Routine that causes the stack traces of remote exceptions to be
 * filled in with the current stack trace on the client.  Detail
 * exceptions are filled in iteratively.
 */
protected void exceptionReceivedFromServer(Exception ex) throws Exception {
    serverException = ex;

    StackTraceElement[] serverTrace = ex.getStackTrace();
    StackTraceElement[] clientTrace = (new Throwable()).getStackTrace();
    StackTraceElement[] combinedTrace =
        new StackTraceElement[serverTrace.length + clientTrace.length];
    System.arraycopy(serverTrace, 0, combinedTrace, 0,
                     serverTrace.length);
    System.arraycopy(clientTrace, 0, combinedTrace, serverTrace.length,
                     clientTrace.length);
    ex.setStackTrace(combinedTrace);

    /*
     * Log the details of a server exception thrown as a result of a
     * remote method invocation.
     */
    if (UnicastRef.clientCallLog.isLoggable(Log.BRIEF)) {
        /* log call exception returned from server before it is rethrown */
        TCPEndpoint ep = (TCPEndpoint) conn.getChannel().getEndpoint();
        UnicastRef.clientCallLog.log(Log.BRIEF, "outbound call " +
            "received exception: [" + ep.getHost() + ":" +
            ep.getPort() + "] exception: ", ex);
    }

    throw ex;
}
 
Example #13
Source File: DGCClient.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private EndpointEntry(final Endpoint endpoint) {
    this.endpoint = endpoint;
    try {
        LiveRef dgcRef = new LiveRef(dgcID, endpoint, false);
        dgc = (DGC) Util.createProxy(DGCImpl.class,
                                     new UnicastRef(dgcRef), true);
    } catch (RemoteException e) {
        throw new Error("internal error creating DGC stub");
    }
    renewCleanThread =  AccessController.doPrivileged(
        new NewThreadAction(new RenewCleanThread(),
                            "RenewClean-" + endpoint, true));
    renewCleanThread.start();
}
 
Example #14
Source File: StreamRemoteCall.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Routine that causes the stack traces of remote exceptions to be
 * filled in with the current stack trace on the client.  Detail
 * exceptions are filled in iteratively.
 */
protected void exceptionReceivedFromServer(Exception ex) throws Exception {
    serverException = ex;

    StackTraceElement[] serverTrace = ex.getStackTrace();
    StackTraceElement[] clientTrace = (new Throwable()).getStackTrace();
    StackTraceElement[] combinedTrace =
        new StackTraceElement[serverTrace.length + clientTrace.length];
    System.arraycopy(serverTrace, 0, combinedTrace, 0,
                     serverTrace.length);
    System.arraycopy(clientTrace, 0, combinedTrace, serverTrace.length,
                     clientTrace.length);
    ex.setStackTrace(combinedTrace);

    /*
     * Log the details of a server exception thrown as a result of a
     * remote method invocation.
     */
    if (UnicastRef.clientCallLog.isLoggable(Log.BRIEF)) {
        /* log call exception returned from server before it is rethrown */
        TCPEndpoint ep = (TCPEndpoint) conn.getChannel().getEndpoint();
        UnicastRef.clientCallLog.log(Log.BRIEF, "outbound call " +
            "received exception: [" + ep.getHost() + ":" +
            ep.getPort() + "] exception: ", ex);
    }

    throw ex;
}
 
Example #15
Source File: DGCClient.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private EndpointEntry(final Endpoint endpoint) {
    this.endpoint = endpoint;
    try {
        LiveRef dgcRef = new LiveRef(dgcID, endpoint, false);
        dgc = (DGC) Util.createProxy(DGCImpl.class,
                                     new UnicastRef(dgcRef), true);
    } catch (RemoteException e) {
        throw new Error("internal error creating DGC stub");
    }
    renewCleanThread =  AccessController.doPrivileged(
        new NewThreadAction(new RenewCleanThread(),
                            "RenewClean-" + endpoint, true));
    renewCleanThread.start();
}
 
Example #16
Source File: StreamRemoteCall.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Routine that causes the stack traces of remote exceptions to be
 * filled in with the current stack trace on the client.  Detail
 * exceptions are filled in iteratively.
 */
protected void exceptionReceivedFromServer(Exception ex) throws Exception {
    serverException = ex;

    StackTraceElement[] serverTrace = ex.getStackTrace();
    StackTraceElement[] clientTrace = (new Throwable()).getStackTrace();
    StackTraceElement[] combinedTrace =
        new StackTraceElement[serverTrace.length + clientTrace.length];
    System.arraycopy(serverTrace, 0, combinedTrace, 0,
                     serverTrace.length);
    System.arraycopy(clientTrace, 0, combinedTrace, serverTrace.length,
                     clientTrace.length);
    ex.setStackTrace(combinedTrace);

    /*
     * Log the details of a server exception thrown as a result of a
     * remote method invocation.
     */
    if (UnicastRef.clientCallLog.isLoggable(Log.BRIEF)) {
        /* log call exception returned from server before it is rethrown */
        TCPEndpoint ep = (TCPEndpoint) conn.getChannel().getEndpoint();
        UnicastRef.clientCallLog.log(Log.BRIEF, "outbound call " +
            "received exception: [" + ep.getHost() + ":" +
            ep.getPort() + "] exception: ", ex);
    }

    throw ex;
}
 
Example #17
Source File: DGCImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public Void run() {
    ClassLoader savedCcl =
        Thread.currentThread().getContextClassLoader();
    try {
        Thread.currentThread().setContextClassLoader(
            ClassLoader.getSystemClassLoader());

        /*
         * Put remote collector object in table by hand to prevent
         * listen on port.  (UnicastServerRef.exportObject would
         * cause transport to listen.)
         */
        try {
            dgc = new DGCImpl();
            ObjID dgcID = new ObjID(ObjID.DGC_ID);
            LiveRef ref = new LiveRef(dgcID, 0);
            UnicastServerRef disp = new UnicastServerRef(ref);
            Remote stub =
                Util.createProxy(DGCImpl.class,
                                 new UnicastRef(ref), true);
            disp.setSkeleton(dgc);
            Target target =
                new Target(dgc, disp, stub, dgcID, true);
            ObjectTable.putTarget(target);
        } catch (RemoteException e) {
            throw new Error(
                "exception initializing server-side DGC", e);
        }
    } finally {
        Thread.currentThread().setContextClassLoader(savedCcl);
    }
    return null;
}
 
Example #18
Source File: DGCClient.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private EndpointEntry(final Endpoint endpoint) {
    this.endpoint = endpoint;
    try {
        LiveRef dgcRef = new LiveRef(dgcID, endpoint, false);
        dgc = (DGC) Util.createProxy(DGCImpl.class,
                                     new UnicastRef(dgcRef), true);
    } catch (RemoteException e) {
        throw new Error("internal error creating DGC stub");
    }
    renewCleanThread =  AccessController.doPrivileged(
        new NewThreadAction(new RenewCleanThread(),
                            "RenewClean-" + endpoint, true));
    renewCleanThread.start();
}
 
Example #19
Source File: StreamRemoteCall.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Routine that causes the stack traces of remote exceptions to be
 * filled in with the current stack trace on the client.  Detail
 * exceptions are filled in iteratively.
 */
protected void exceptionReceivedFromServer(Exception ex) throws Exception {
    serverException = ex;

    StackTraceElement[] serverTrace = ex.getStackTrace();
    StackTraceElement[] clientTrace = (new Throwable()).getStackTrace();
    StackTraceElement[] combinedTrace =
        new StackTraceElement[serverTrace.length + clientTrace.length];
    System.arraycopy(serverTrace, 0, combinedTrace, 0,
                     serverTrace.length);
    System.arraycopy(clientTrace, 0, combinedTrace, serverTrace.length,
                     clientTrace.length);
    ex.setStackTrace(combinedTrace);

    /*
     * Log the details of a server exception thrown as a result of a
     * remote method invocation.
     */
    if (UnicastRef.clientCallLog.isLoggable(Log.BRIEF)) {
        /* log call exception returned from server before it is rethrown */
        TCPEndpoint ep = (TCPEndpoint) conn.getChannel().getEndpoint();
        UnicastRef.clientCallLog.log(Log.BRIEF, "outbound call " +
            "received exception: [" + ep.getHost() + ":" +
            ep.getPort() + "] exception: ", ex);
    }

    throw ex;
}
 
Example #20
Source File: DGCImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public Void run() {
    ClassLoader savedCcl =
        Thread.currentThread().getContextClassLoader();
    try {
        Thread.currentThread().setContextClassLoader(
            ClassLoader.getSystemClassLoader());

        /*
         * Put remote collector object in table by hand to prevent
         * listen on port.  (UnicastServerRef.exportObject would
         * cause transport to listen.)
         */
        try {
            dgc = new DGCImpl();
            ObjID dgcID = new ObjID(ObjID.DGC_ID);
            LiveRef ref = new LiveRef(dgcID, 0);
            UnicastServerRef disp = new UnicastServerRef(ref);
            Remote stub =
                Util.createProxy(DGCImpl.class,
                                 new UnicastRef(ref), true);
            disp.setSkeleton(dgc);
            Target target =
                new Target(dgc, disp, stub, dgcID, true);
            ObjectTable.putTarget(target);
        } catch (RemoteException e) {
            throw new Error(
                "exception initializing server-side DGC", e);
        }
    } finally {
        Thread.currentThread().setContextClassLoader(savedCcl);
    }
    return null;
}
 
Example #21
Source File: DGCClient.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private EndpointEntry(final Endpoint endpoint) {
    this.endpoint = endpoint;
    try {
        LiveRef dgcRef = new LiveRef(dgcID, endpoint, false);
        dgc = (DGC) Util.createProxy(DGCImpl.class,
                                     new UnicastRef(dgcRef), true);
    } catch (RemoteException e) {
        throw new Error("internal error creating DGC stub");
    }
    renewCleanThread =  AccessController.doPrivileged(
        new NewThreadAction(new RenewCleanThread(),
                            "RenewClean-" + endpoint, true));
    renewCleanThread.start();
}
 
Example #22
Source File: StreamRemoteCall.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Routine that causes the stack traces of remote exceptions to be
 * filled in with the current stack trace on the client.  Detail
 * exceptions are filled in iteratively.
 */
protected void exceptionReceivedFromServer(Exception ex) throws Exception {
    serverException = ex;

    StackTraceElement[] serverTrace = ex.getStackTrace();
    StackTraceElement[] clientTrace = (new Throwable()).getStackTrace();
    StackTraceElement[] combinedTrace =
        new StackTraceElement[serverTrace.length + clientTrace.length];
    System.arraycopy(serverTrace, 0, combinedTrace, 0,
                     serverTrace.length);
    System.arraycopy(clientTrace, 0, combinedTrace, serverTrace.length,
                     clientTrace.length);
    ex.setStackTrace(combinedTrace);

    /*
     * Log the details of a server exception thrown as a result of a
     * remote method invocation.
     */
    if (UnicastRef.clientCallLog.isLoggable(Log.BRIEF)) {
        /* log call exception returned from server before it is rethrown */
        TCPEndpoint ep = (TCPEndpoint) conn.getChannel().getEndpoint();
        UnicastRef.clientCallLog.log(Log.BRIEF, "outbound call " +
            "received exception: [" + ep.getHost() + ":" +
            ep.getPort() + "] exception: ", ex);
    }

    throw ex;
}
 
Example #23
Source File: DGCClient.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private EndpointEntry(final Endpoint endpoint) {
    this.endpoint = endpoint;
    try {
        LiveRef dgcRef = new LiveRef(dgcID, endpoint, false);
        dgc = (DGC) Util.createProxy(DGCImpl.class,
                                     new UnicastRef(dgcRef), true);
    } catch (RemoteException e) {
        throw new Error("internal error creating DGC stub");
    }
    renewCleanThread =  AccessController.doPrivileged(
        new NewThreadAction(new RenewCleanThread(),
                            "RenewClean-" + endpoint, true));
    renewCleanThread.start();
}
 
Example #24
Source File: RegistryImpl.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ObjectInputFilter to filter Registry input objects.
 * The list of acceptable classes is limited to classes normally
 * stored in a registry.
 *
 * @param filterInfo access to the class, array length, etc.
 * @return  {@link ObjectInputFilter.Status#ALLOWED} if allowed,
 *          {@link ObjectInputFilter.Status#REJECTED} if rejected,
 *          otherwise {@link ObjectInputFilter.Status#UNDECIDED}
 */
private static ObjectInputFilter.Status registryFilter(ObjectInputFilter.FilterInfo filterInfo) {
    if (registryFilter != null) {
        ObjectInputFilter.Status status = registryFilter.checkInput(filterInfo);
        if (status != ObjectInputFilter.Status.UNDECIDED) {
            // The Registry filter can override the built-in white-list
            return status;
        }
    }

    if (filterInfo.depth() > REGISTRY_MAX_DEPTH) {
        return ObjectInputFilter.Status.REJECTED;
    }
    Class<?> clazz = filterInfo.serialClass();
    if (clazz != null) {
        if (clazz.isArray()) {
            // Arrays are REJECTED only if they exceed the limit
            return (filterInfo.arrayLength() >= 0 && filterInfo.arrayLength() > REGISTRY_MAX_ARRAY_SIZE)
                ? ObjectInputFilter.Status.REJECTED
                : ObjectInputFilter.Status.UNDECIDED;
        }
        if (String.class == clazz
                || java.lang.Number.class.isAssignableFrom(clazz)
                || Remote.class.isAssignableFrom(clazz)
                || java.lang.reflect.Proxy.class.isAssignableFrom(clazz)
                || UnicastRef.class.isAssignableFrom(clazz)
                || RMIClientSocketFactory.class.isAssignableFrom(clazz)
                || RMIServerSocketFactory.class.isAssignableFrom(clazz)
                || java.rmi.activation.ActivationID.class.isAssignableFrom(clazz)
                || java.rmi.server.UID.class.isAssignableFrom(clazz)) {
            return ObjectInputFilter.Status.ALLOWED;
        } else {
            return ObjectInputFilter.Status.REJECTED;
        }
    }
    return ObjectInputFilter.Status.UNDECIDED;
}
 
Example #25
Source File: StreamRemoteCall.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Routine that causes the stack traces of remote exceptions to be
 * filled in with the current stack trace on the client.  Detail
 * exceptions are filled in iteratively.
 */
protected void exceptionReceivedFromServer(Exception ex) throws Exception {
    serverException = ex;

    StackTraceElement[] serverTrace = ex.getStackTrace();
    StackTraceElement[] clientTrace = (new Throwable()).getStackTrace();
    StackTraceElement[] combinedTrace =
        new StackTraceElement[serverTrace.length + clientTrace.length];
    System.arraycopy(serverTrace, 0, combinedTrace, 0,
                     serverTrace.length);
    System.arraycopy(clientTrace, 0, combinedTrace, serverTrace.length,
                     clientTrace.length);
    ex.setStackTrace(combinedTrace);

    /*
     * Log the details of a server exception thrown as a result of a
     * remote method invocation.
     */
    if (UnicastRef.clientCallLog.isLoggable(Log.BRIEF)) {
        /* log call exception returned from server before it is rethrown */
        TCPEndpoint ep = (TCPEndpoint) conn.getChannel().getEndpoint();
        UnicastRef.clientCallLog.log(Log.BRIEF, "outbound call " +
            "received exception: [" + ep.getHost() + ":" +
            ep.getPort() + "] exception: ", ex);
    }

    throw ex;
}
 
Example #26
Source File: DGCImpl.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public Void run() {
    ClassLoader savedCcl =
        Thread.currentThread().getContextClassLoader();
    try {
        Thread.currentThread().setContextClassLoader(
            ClassLoader.getSystemClassLoader());

        /*
         * Put remote collector object in table by hand to prevent
         * listen on port.  (UnicastServerRef.exportObject would
         * cause transport to listen.)
         */
        try {
            dgc = new DGCImpl();
            ObjID dgcID = new ObjID(ObjID.DGC_ID);
            LiveRef ref = new LiveRef(dgcID, 0);
            UnicastServerRef disp = new UnicastServerRef(ref);
            Remote stub =
                Util.createProxy(DGCImpl.class,
                                 new UnicastRef(ref), true);
            disp.setSkeleton(dgc);
            Target target =
                new Target(dgc, disp, stub, dgcID, true);
            ObjectTable.putTarget(target);
        } catch (RemoteException e) {
            throw new Error(
                "exception initializing server-side DGC", e);
        }
    } finally {
        Thread.currentThread().setContextClassLoader(savedCcl);
    }
    return null;
}
 
Example #27
Source File: DGCClient.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private EndpointEntry(final Endpoint endpoint) {
    this.endpoint = endpoint;
    try {
        LiveRef dgcRef = new LiveRef(dgcID, endpoint, false);
        dgc = (DGC) Util.createProxy(DGCImpl.class,
                                     new UnicastRef(dgcRef), true);
    } catch (RemoteException e) {
        throw new Error("internal error creating DGC stub");
    }
    renewCleanThread =  AccessController.doPrivileged(
        new NewThreadAction(new RenewCleanThread(),
                            "RenewClean-" + endpoint, true));
    renewCleanThread.start();
}
 
Example #28
Source File: StreamRemoteCall.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Routine that causes the stack traces of remote exceptions to be
 * filled in with the current stack trace on the client.  Detail
 * exceptions are filled in iteratively.
 */
protected void exceptionReceivedFromServer(Exception ex) throws Exception {
    serverException = ex;

    StackTraceElement[] serverTrace = ex.getStackTrace();
    StackTraceElement[] clientTrace = (new Throwable()).getStackTrace();
    StackTraceElement[] combinedTrace =
        new StackTraceElement[serverTrace.length + clientTrace.length];
    System.arraycopy(serverTrace, 0, combinedTrace, 0,
                     serverTrace.length);
    System.arraycopy(clientTrace, 0, combinedTrace, serverTrace.length,
                     clientTrace.length);
    ex.setStackTrace(combinedTrace);

    /*
     * Log the details of a server exception thrown as a result of a
     * remote method invocation.
     */
    if (UnicastRef.clientCallLog.isLoggable(Log.BRIEF)) {
        /* log call exception returned from server before it is rethrown */
        TCPEndpoint ep = (TCPEndpoint) conn.getChannel().getEndpoint();
        UnicastRef.clientCallLog.log(Log.BRIEF, "outbound call " +
            "received exception: [" + ep.getHost() + ":" +
            ep.getPort() + "] exception: ", ex);
    }

    throw ex;
}
 
Example #29
Source File: DGCImpl.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public Void run() {
    ClassLoader savedCcl =
        Thread.currentThread().getContextClassLoader();
    try {
        Thread.currentThread().setContextClassLoader(
            ClassLoader.getSystemClassLoader());

        /*
         * Put remote collector object in table by hand to prevent
         * listen on port.  (UnicastServerRef.exportObject would
         * cause transport to listen.)
         */
        try {
            dgc = new DGCImpl();
            ObjID dgcID = new ObjID(ObjID.DGC_ID);
            LiveRef ref = new LiveRef(dgcID, 0);
            UnicastServerRef disp = new UnicastServerRef(ref);
            Remote stub =
                Util.createProxy(DGCImpl.class,
                                 new UnicastRef(ref), true);
            disp.setSkeleton(dgc);
            Target target =
                new Target(dgc, disp, stub, dgcID, true);
            ObjectTable.putTarget(target);
        } catch (RemoteException e) {
            throw new Error(
                "exception initializing server-side DGC", e);
        }
    } finally {
        Thread.currentThread().setContextClassLoader(savedCcl);
    }
    return null;
}
 
Example #30
Source File: DGCClient.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private EndpointEntry(final Endpoint endpoint) {
    this.endpoint = endpoint;
    try {
        LiveRef dgcRef = new LiveRef(dgcID, endpoint, false);
        dgc = (DGC) Util.createProxy(DGCImpl.class,
                                     new UnicastRef(dgcRef), true);
    } catch (RemoteException e) {
        throw new Error("internal error creating DGC stub");
    }
    renewCleanThread =  AccessController.doPrivileged(
        new NewThreadAction(new RenewCleanThread(),
                            "RenewClean-" + endpoint, true));
    renewCleanThread.start();
}