Java Code Examples for com.sun.jmx.remote.security.JMXSubjectDomainCombiner#getDomainCombinerContext()

The following examples show how to use com.sun.jmx.remote.security.JMXSubjectDomainCombiner#getDomainCombinerContext() . 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: RMIConnectionImpl.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
 * Constructs a new {@link RMIConnection}. This connection can be
 * used with either the JRMP or IIOP transport. This object does
 * not export itself: it is the responsibility of the caller to
 * export it appropriately (see {@link
 * RMIJRMPServerImpl#makeClient(String,Subject)} and {@link
 * RMIIIOPServerImpl#makeClient(String,Subject)}.
 *
 * @param rmiServer The RMIServerImpl object for which this
 * connection is created.  The behavior is unspecified if this
 * parameter is null.
 * @param connectionId The ID for this connection.  The behavior
 * is unspecified if this parameter is null.
 * @param defaultClassLoader The default ClassLoader to be used
 * when deserializing marshalled objects.  Can be null, to signify
 * the bootstrap class loader.
 * @param subject the authenticated subject to be used for
 * authorization.  Can be null, to signify that no subject has
 * been authenticated.
 * @param env the environment containing attributes for the new
 * <code>RMIServerImpl</code>.  Can be null, equivalent to an
 * empty map.
 */
public RMIConnectionImpl(RMIServerImpl rmiServer,
                         String connectionId,
                         ClassLoader defaultClassLoader,
                         Subject subject,
                         Map<String,?> env) {
    if (rmiServer == null || connectionId == null)
        throw new NullPointerException("Illegal null argument");
    if (env == null)
        env = Collections.emptyMap();
    this.rmiServer = rmiServer;
    this.connectionId = connectionId;
    this.defaultClassLoader = defaultClassLoader;

    this.subjectDelegator = new SubjectDelegator();
    this.subject = subject;
    if (subject == null) {
        this.acc = null;
        this.removeCallerContext = false;
    } else {
        this.removeCallerContext =
            SubjectDelegator.checkRemoveCallerContext(subject);
        if (this.removeCallerContext) {
            this.acc =
                JMXSubjectDomainCombiner.getDomainCombinerContext(subject);
        } else {
            this.acc =
                JMXSubjectDomainCombiner.getContext(subject);
        }
    }
    this.mbeanServer = rmiServer.getMBeanServer();

    final ClassLoader dcl = defaultClassLoader;

    ClassLoaderRepository repository = AccessController.doPrivileged(
        new PrivilegedAction<ClassLoaderRepository>() {
            public ClassLoaderRepository run() {
                return mbeanServer.getClassLoaderRepository();
            }
        },
        withPermissions(new MBeanPermission("*", "getClassLoaderRepository"))
    );
    this.classLoaderWithRepository = AccessController.doPrivileged(
        new PrivilegedAction<ClassLoaderWithRepository>() {
            public ClassLoaderWithRepository run() {
                return new ClassLoaderWithRepository(
                    repository,
                    dcl);
            }
        },
        withPermissions(new RuntimePermission("createClassLoader"))
    );

    this.defaultContextClassLoader =
        AccessController.doPrivileged(
            new PrivilegedAction<ClassLoader>() {
        @Override
                public ClassLoader run() {
                    return new CombinedClassLoader(Thread.currentThread().getContextClassLoader(),
                            dcl);
                }
            });

    serverCommunicatorAdmin = new
      RMIServerCommunicatorAdmin(EnvHelp.getServerConnectionTimeout(env));

    this.env = env;
}
 
Example 2
Source File: RMIConnectionImpl.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructs a new {@link RMIConnection}. This connection can be
 * used with either the JRMP or IIOP transport. This object does
 * not export itself: it is the responsibility of the caller to
 * export it appropriately (see {@link
 * RMIJRMPServerImpl#makeClient(String,Subject)} and {@link
 * RMIIIOPServerImpl#makeClient(String,Subject)}.
 *
 * @param rmiServer The RMIServerImpl object for which this
 * connection is created.  The behavior is unspecified if this
 * parameter is null.
 * @param connectionId The ID for this connection.  The behavior
 * is unspecified if this parameter is null.
 * @param defaultClassLoader The default ClassLoader to be used
 * when deserializing marshalled objects.  Can be null, to signify
 * the bootstrap class loader.
 * @param subject the authenticated subject to be used for
 * authorization.  Can be null, to signify that no subject has
 * been authenticated.
 * @param env the environment containing attributes for the new
 * <code>RMIServerImpl</code>.  Can be null, equivalent to an
 * empty map.
 */
public RMIConnectionImpl(RMIServerImpl rmiServer,
                         String connectionId,
                         ClassLoader defaultClassLoader,
                         Subject subject,
                         Map<String,?> env) {
    if (rmiServer == null || connectionId == null)
        throw new NullPointerException("Illegal null argument");
    if (env == null)
        env = Collections.emptyMap();
    this.rmiServer = rmiServer;
    this.connectionId = connectionId;
    this.defaultClassLoader = defaultClassLoader;

    this.subjectDelegator = new SubjectDelegator();
    this.subject = subject;
    if (subject == null) {
        this.acc = null;
        this.removeCallerContext = false;
    } else {
        this.removeCallerContext =
            SubjectDelegator.checkRemoveCallerContext(subject);
        if (this.removeCallerContext) {
            this.acc =
                JMXSubjectDomainCombiner.getDomainCombinerContext(subject);
        } else {
            this.acc =
                JMXSubjectDomainCombiner.getContext(subject);
        }
    }
    this.mbeanServer = rmiServer.getMBeanServer();

    final ClassLoader dcl = defaultClassLoader;

    ClassLoaderRepository repository = AccessController.doPrivileged(
        new PrivilegedAction<ClassLoaderRepository>() {
            public ClassLoaderRepository run() {
                return mbeanServer.getClassLoaderRepository();
            }
        },
        withPermissions(new MBeanPermission("*", "getClassLoaderRepository"))
    );
    this.classLoaderWithRepository = AccessController.doPrivileged(
        new PrivilegedAction<ClassLoaderWithRepository>() {
            public ClassLoaderWithRepository run() {
                return new ClassLoaderWithRepository(
                    repository,
                    dcl);
            }
        },
        withPermissions(new RuntimePermission("createClassLoader"))
    );

    this.defaultContextClassLoader =
        AccessController.doPrivileged(
            new PrivilegedAction<ClassLoader>() {
        @Override
                public ClassLoader run() {
                    return new CombinedClassLoader(Thread.currentThread().getContextClassLoader(),
                            dcl);
                }
            });

    serverCommunicatorAdmin = new
      RMIServerCommunicatorAdmin(EnvHelp.getServerConnectionTimeout(env));

    this.env = env;
}
 
Example 3
Source File: RMIConnectionImpl.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructs a new {@link RMIConnection}. This connection can be
 * used with either the JRMP or IIOP transport. This object does
 * not export itself: it is the responsibility of the caller to
 * export it appropriately (see {@link
 * RMIJRMPServerImpl#makeClient(String,Subject)} and {@link
 * RMIIIOPServerImpl#makeClient(String,Subject)}.
 *
 * @param rmiServer The RMIServerImpl object for which this
 * connection is created.  The behavior is unspecified if this
 * parameter is null.
 * @param connectionId The ID for this connection.  The behavior
 * is unspecified if this parameter is null.
 * @param defaultClassLoader The default ClassLoader to be used
 * when deserializing marshalled objects.  Can be null, to signify
 * the bootstrap class loader.
 * @param subject the authenticated subject to be used for
 * authorization.  Can be null, to signify that no subject has
 * been authenticated.
 * @param env the environment containing attributes for the new
 * <code>RMIServerImpl</code>.  Can be null, equivalent to an
 * empty map.
 */
public RMIConnectionImpl(RMIServerImpl rmiServer,
                         String connectionId,
                         ClassLoader defaultClassLoader,
                         Subject subject,
                         Map<String,?> env) {
    if (rmiServer == null || connectionId == null)
        throw new NullPointerException("Illegal null argument");
    if (env == null)
        env = Collections.emptyMap();
    this.rmiServer = rmiServer;
    this.connectionId = connectionId;
    this.defaultClassLoader = defaultClassLoader;

    this.subjectDelegator = new SubjectDelegator();
    this.subject = subject;
    if (subject == null) {
        this.acc = null;
        this.removeCallerContext = false;
    } else {
        this.removeCallerContext =
            SubjectDelegator.checkRemoveCallerContext(subject);
        if (this.removeCallerContext) {
            this.acc =
                JMXSubjectDomainCombiner.getDomainCombinerContext(subject);
        } else {
            this.acc =
                JMXSubjectDomainCombiner.getContext(subject);
        }
    }
    this.mbeanServer = rmiServer.getMBeanServer();

    final ClassLoader dcl = defaultClassLoader;

    ClassLoaderRepository repository = AccessController.doPrivileged(
        new PrivilegedAction<ClassLoaderRepository>() {
            public ClassLoaderRepository run() {
                return mbeanServer.getClassLoaderRepository();
            }
        },
        withPermissions(new MBeanPermission("*", "getClassLoaderRepository"))
    );
    this.classLoaderWithRepository = AccessController.doPrivileged(
        new PrivilegedAction<ClassLoaderWithRepository>() {
            public ClassLoaderWithRepository run() {
                return new ClassLoaderWithRepository(
                    repository,
                    dcl);
            }
        },
        withPermissions(new RuntimePermission("createClassLoader"))
    );

    this.defaultContextClassLoader =
        AccessController.doPrivileged(
            new PrivilegedAction<ClassLoader>() {
        @Override
                public ClassLoader run() {
                    return new CombinedClassLoader(Thread.currentThread().getContextClassLoader(),
                            dcl);
                }
            });

    serverCommunicatorAdmin = new
      RMIServerCommunicatorAdmin(EnvHelp.getServerConnectionTimeout(env));

    this.env = env;
}
 
Example 4
Source File: RMIConnectionImpl.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructs a new {@link RMIConnection}. This connection can be
 * used with either the JRMP or IIOP transport. This object does
 * not export itself: it is the responsibility of the caller to
 * export it appropriately (see {@link
 * RMIJRMPServerImpl#makeClient(String,Subject)} and {@link
 * RMIIIOPServerImpl#makeClient(String,Subject)}.
 *
 * @param rmiServer The RMIServerImpl object for which this
 * connection is created.  The behavior is unspecified if this
 * parameter is null.
 * @param connectionId The ID for this connection.  The behavior
 * is unspecified if this parameter is null.
 * @param defaultClassLoader The default ClassLoader to be used
 * when deserializing marshalled objects.  Can be null, to signify
 * the bootstrap class loader.
 * @param subject the authenticated subject to be used for
 * authorization.  Can be null, to signify that no subject has
 * been authenticated.
 * @param env the environment containing attributes for the new
 * <code>RMIServerImpl</code>.  Can be null, equivalent to an
 * empty map.
 */
public RMIConnectionImpl(RMIServerImpl rmiServer,
                         String connectionId,
                         ClassLoader defaultClassLoader,
                         Subject subject,
                         Map<String,?> env) {
    if (rmiServer == null || connectionId == null)
        throw new NullPointerException("Illegal null argument");
    if (env == null)
        env = Collections.emptyMap();
    this.rmiServer = rmiServer;
    this.connectionId = connectionId;
    this.defaultClassLoader = defaultClassLoader;

    this.subjectDelegator = new SubjectDelegator();
    this.subject = subject;
    if (subject == null) {
        this.acc = null;
        this.removeCallerContext = false;
    } else {
        this.removeCallerContext =
            SubjectDelegator.checkRemoveCallerContext(subject);
        if (this.removeCallerContext) {
            this.acc =
                JMXSubjectDomainCombiner.getDomainCombinerContext(subject);
        } else {
            this.acc =
                JMXSubjectDomainCombiner.getContext(subject);
        }
    }
    this.mbeanServer = rmiServer.getMBeanServer();

    final ClassLoader dcl = defaultClassLoader;

    ClassLoaderRepository repository = AccessController.doPrivileged(
        new PrivilegedAction<ClassLoaderRepository>() {
            public ClassLoaderRepository run() {
                return mbeanServer.getClassLoaderRepository();
            }
        },
        withPermissions(new MBeanPermission("*", "getClassLoaderRepository"))
    );
    this.classLoaderWithRepository = AccessController.doPrivileged(
        new PrivilegedAction<ClassLoaderWithRepository>() {
            public ClassLoaderWithRepository run() {
                return new ClassLoaderWithRepository(
                    repository,
                    dcl);
            }
        },
        withPermissions(new RuntimePermission("createClassLoader"))
    );

    this.defaultContextClassLoader =
        AccessController.doPrivileged(
            new PrivilegedAction<ClassLoader>() {
        @Override
                public ClassLoader run() {
                    return new CombinedClassLoader(Thread.currentThread().getContextClassLoader(),
                            dcl);
                }
            });

    serverCommunicatorAdmin = new
      RMIServerCommunicatorAdmin(EnvHelp.getServerConnectionTimeout(env));

    this.env = env;
}
 
Example 5
Source File: RMIConnectionImpl.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
 * Constructs a new {@link RMIConnection}. This connection can be
 * used with either the JRMP or IIOP transport. This object does
 * not export itself: it is the responsibility of the caller to
 * export it appropriately (see {@link
 * RMIJRMPServerImpl#makeClient(String,Subject)} and {@link
 * RMIIIOPServerImpl#makeClient(String,Subject)}.
 *
 * @param rmiServer The RMIServerImpl object for which this
 * connection is created.  The behavior is unspecified if this
 * parameter is null.
 * @param connectionId The ID for this connection.  The behavior
 * is unspecified if this parameter is null.
 * @param defaultClassLoader The default ClassLoader to be used
 * when deserializing marshalled objects.  Can be null, to signify
 * the bootstrap class loader.
 * @param subject the authenticated subject to be used for
 * authorization.  Can be null, to signify that no subject has
 * been authenticated.
 * @param env the environment containing attributes for the new
 * <code>RMIServerImpl</code>.  Can be null, equivalent to an
 * empty map.
 */
public RMIConnectionImpl(RMIServerImpl rmiServer,
                         String connectionId,
                         ClassLoader defaultClassLoader,
                         Subject subject,
                         Map<String,?> env) {
    if (rmiServer == null || connectionId == null)
        throw new NullPointerException("Illegal null argument");
    if (env == null)
        env = Collections.emptyMap();
    this.rmiServer = rmiServer;
    this.connectionId = connectionId;
    this.defaultClassLoader = defaultClassLoader;

    this.subjectDelegator = new SubjectDelegator();
    this.subject = subject;
    if (subject == null) {
        this.acc = null;
        this.removeCallerContext = false;
    } else {
        this.removeCallerContext =
            SubjectDelegator.checkRemoveCallerContext(subject);
        if (this.removeCallerContext) {
            this.acc =
                JMXSubjectDomainCombiner.getDomainCombinerContext(subject);
        } else {
            this.acc =
                JMXSubjectDomainCombiner.getContext(subject);
        }
    }
    this.mbeanServer = rmiServer.getMBeanServer();

    final ClassLoader dcl = defaultClassLoader;

    ClassLoaderRepository repository = AccessController.doPrivileged(
        new PrivilegedAction<ClassLoaderRepository>() {
            public ClassLoaderRepository run() {
                return mbeanServer.getClassLoaderRepository();
            }
        },
        withPermissions(new MBeanPermission("*", "getClassLoaderRepository"))
    );
    this.classLoaderWithRepository = AccessController.doPrivileged(
        new PrivilegedAction<ClassLoaderWithRepository>() {
            public ClassLoaderWithRepository run() {
                return new ClassLoaderWithRepository(
                    repository,
                    dcl);
            }
        },
        withPermissions(new RuntimePermission("createClassLoader"))
    );

    this.defaultContextClassLoader =
        AccessController.doPrivileged(
            new PrivilegedAction<ClassLoader>() {
        @Override
                public ClassLoader run() {
                    return new CombinedClassLoader(Thread.currentThread().getContextClassLoader(),
                            dcl);
                }
            });

    serverCommunicatorAdmin = new
      RMIServerCommunicatorAdmin(EnvHelp.getServerConnectionTimeout(env));

    this.env = env;
}
 
Example 6
Source File: RMIConnectionImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructs a new {@link RMIConnection}. This connection can be
 * used with either the JRMP or IIOP transport. This object does
 * not export itself: it is the responsibility of the caller to
 * export it appropriately (see {@link
 * RMIJRMPServerImpl#makeClient(String,Subject)} and {@link
 * RMIIIOPServerImpl#makeClient(String,Subject)}.
 *
 * @param rmiServer The RMIServerImpl object for which this
 * connection is created.  The behavior is unspecified if this
 * parameter is null.
 * @param connectionId The ID for this connection.  The behavior
 * is unspecified if this parameter is null.
 * @param defaultClassLoader The default ClassLoader to be used
 * when deserializing marshalled objects.  Can be null, to signify
 * the bootstrap class loader.
 * @param subject the authenticated subject to be used for
 * authorization.  Can be null, to signify that no subject has
 * been authenticated.
 * @param env the environment containing attributes for the new
 * <code>RMIServerImpl</code>.  Can be null, equivalent to an
 * empty map.
 */
public RMIConnectionImpl(RMIServerImpl rmiServer,
                         String connectionId,
                         ClassLoader defaultClassLoader,
                         Subject subject,
                         Map<String,?> env) {
    if (rmiServer == null || connectionId == null)
        throw new NullPointerException("Illegal null argument");
    if (env == null)
        env = Collections.emptyMap();
    this.rmiServer = rmiServer;
    this.connectionId = connectionId;
    this.defaultClassLoader = defaultClassLoader;

    this.subjectDelegator = new SubjectDelegator();
    this.subject = subject;
    if (subject == null) {
        this.acc = null;
        this.removeCallerContext = false;
    } else {
        this.removeCallerContext =
            SubjectDelegator.checkRemoveCallerContext(subject);
        if (this.removeCallerContext) {
            this.acc =
                JMXSubjectDomainCombiner.getDomainCombinerContext(subject);
        } else {
            this.acc =
                JMXSubjectDomainCombiner.getContext(subject);
        }
    }
    this.mbeanServer = rmiServer.getMBeanServer();

    final ClassLoader dcl = defaultClassLoader;

    ClassLoaderRepository repository = AccessController.doPrivileged(
        new PrivilegedAction<ClassLoaderRepository>() {
            public ClassLoaderRepository run() {
                return mbeanServer.getClassLoaderRepository();
            }
        },
        withPermissions(new MBeanPermission("*", "getClassLoaderRepository"))
    );
    this.classLoaderWithRepository = AccessController.doPrivileged(
        new PrivilegedAction<ClassLoaderWithRepository>() {
            public ClassLoaderWithRepository run() {
                return new ClassLoaderWithRepository(
                    repository,
                    dcl);
            }
        },
        withPermissions(new RuntimePermission("createClassLoader"))
    );

    this.defaultContextClassLoader =
        AccessController.doPrivileged(
            new PrivilegedAction<ClassLoader>() {
        @Override
                public ClassLoader run() {
                    return new CombinedClassLoader(Thread.currentThread().getContextClassLoader(),
                            dcl);
                }
            });

    serverCommunicatorAdmin = new
      RMIServerCommunicatorAdmin(EnvHelp.getServerConnectionTimeout(env));

    this.env = env;
}
 
Example 7
Source File: RMIConnectionImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructs a new {@link RMIConnection}. This connection can be
 * used with either the JRMP or IIOP transport. This object does
 * not export itself: it is the responsibility of the caller to
 * export it appropriately (see {@link
 * RMIJRMPServerImpl#makeClient(String,Subject)} and {@link
 * RMIIIOPServerImpl#makeClient(String,Subject)}.
 *
 * @param rmiServer The RMIServerImpl object for which this
 * connection is created.  The behavior is unspecified if this
 * parameter is null.
 * @param connectionId The ID for this connection.  The behavior
 * is unspecified if this parameter is null.
 * @param defaultClassLoader The default ClassLoader to be used
 * when deserializing marshalled objects.  Can be null, to signify
 * the bootstrap class loader.
 * @param subject the authenticated subject to be used for
 * authorization.  Can be null, to signify that no subject has
 * been authenticated.
 * @param env the environment containing attributes for the new
 * <code>RMIServerImpl</code>.  Can be null, equivalent to an
 * empty map.
 */
public RMIConnectionImpl(RMIServerImpl rmiServer,
                         String connectionId,
                         ClassLoader defaultClassLoader,
                         Subject subject,
                         Map<String,?> env) {
    if (rmiServer == null || connectionId == null)
        throw new NullPointerException("Illegal null argument");
    if (env == null)
        env = Collections.emptyMap();
    this.rmiServer = rmiServer;
    this.connectionId = connectionId;
    this.defaultClassLoader = defaultClassLoader;

    this.subjectDelegator = new SubjectDelegator();
    this.subject = subject;
    if (subject == null) {
        this.acc = null;
        this.removeCallerContext = false;
    } else {
        this.removeCallerContext =
            SubjectDelegator.checkRemoveCallerContext(subject);
        if (this.removeCallerContext) {
            this.acc =
                JMXSubjectDomainCombiner.getDomainCombinerContext(subject);
        } else {
            this.acc =
                JMXSubjectDomainCombiner.getContext(subject);
        }
    }
    this.mbeanServer = rmiServer.getMBeanServer();

    final ClassLoader dcl = defaultClassLoader;

    ClassLoaderRepository repository = AccessController.doPrivileged(
        new PrivilegedAction<ClassLoaderRepository>() {
            public ClassLoaderRepository run() {
                return mbeanServer.getClassLoaderRepository();
            }
        },
        withPermissions(new MBeanPermission("*", "getClassLoaderRepository"))
    );
    this.classLoaderWithRepository = AccessController.doPrivileged(
        new PrivilegedAction<ClassLoaderWithRepository>() {
            public ClassLoaderWithRepository run() {
                return new ClassLoaderWithRepository(
                    repository,
                    dcl);
            }
        },
        withPermissions(new RuntimePermission("createClassLoader"))
    );

    this.defaultContextClassLoader =
        AccessController.doPrivileged(
            new PrivilegedAction<ClassLoader>() {
        @Override
                public ClassLoader run() {
                    return new CombinedClassLoader(Thread.currentThread().getContextClassLoader(),
                            dcl);
                }
            });

    serverCommunicatorAdmin = new
      RMIServerCommunicatorAdmin(EnvHelp.getServerConnectionTimeout(env));

    this.env = env;
}
 
Example 8
Source File: RMIConnectionImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructs a new {@link RMIConnection}. This connection can be
 * used with the JRMP transport. This object does
 * not export itself: it is the responsibility of the caller to
 * export it appropriately (see {@link
 * RMIJRMPServerImpl#makeClient(String,Subject)}).
 *
 * @param rmiServer The RMIServerImpl object for which this
 * connection is created.  The behavior is unspecified if this
 * parameter is null.
 * @param connectionId The ID for this connection.  The behavior
 * is unspecified if this parameter is null.
 * @param defaultClassLoader The default ClassLoader to be used
 * when deserializing marshalled objects.  Can be null, to signify
 * the bootstrap class loader.
 * @param subject the authenticated subject to be used for
 * authorization.  Can be null, to signify that no subject has
 * been authenticated.
 * @param env the environment containing attributes for the new
 * <code>RMIServerImpl</code>.  Can be null, equivalent to an
 * empty map.
 */
public RMIConnectionImpl(RMIServerImpl rmiServer,
                         String connectionId,
                         ClassLoader defaultClassLoader,
                         Subject subject,
                         Map<String,?> env) {
    if (rmiServer == null || connectionId == null)
        throw new NullPointerException("Illegal null argument");
    if (env == null)
        env = Collections.emptyMap();
    this.rmiServer = rmiServer;
    this.connectionId = connectionId;
    this.defaultClassLoader = defaultClassLoader;

    this.subjectDelegator = new SubjectDelegator();
    this.subject = subject;
    if (subject == null) {
        this.acc = null;
        this.removeCallerContext = false;
    } else {
        this.removeCallerContext =
            SubjectDelegator.checkRemoveCallerContext(subject);
        if (this.removeCallerContext) {
            this.acc =
                JMXSubjectDomainCombiner.getDomainCombinerContext(subject);
        } else {
            this.acc =
                JMXSubjectDomainCombiner.getContext(subject);
        }
    }
    this.mbeanServer = rmiServer.getMBeanServer();

    final ClassLoader dcl = defaultClassLoader;

    ClassLoaderRepository repository = AccessController.doPrivileged(
        new PrivilegedAction<ClassLoaderRepository>() {
            public ClassLoaderRepository run() {
                return mbeanServer.getClassLoaderRepository();
            }
        },
        withPermissions(new MBeanPermission("*", "getClassLoaderRepository"))
    );
    this.classLoaderWithRepository = AccessController.doPrivileged(
        new PrivilegedAction<ClassLoaderWithRepository>() {
            public ClassLoaderWithRepository run() {
                return new ClassLoaderWithRepository(
                    repository,
                    dcl);
            }
        },
        withPermissions(new RuntimePermission("createClassLoader"))
    );

    this.defaultContextClassLoader =
        AccessController.doPrivileged(
            new PrivilegedAction<ClassLoader>() {
        @Override
                public ClassLoader run() {
                    return new CombinedClassLoader(Thread.currentThread().getContextClassLoader(),
                            dcl);
                }
            });

    serverCommunicatorAdmin = new
      RMIServerCommunicatorAdmin(EnvHelp.getServerConnectionTimeout(env));

    this.env = env;
}
 
Example 9
Source File: RMIConnectionImpl.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructs a new {@link RMIConnection}. This connection can be
 * used with either the JRMP or IIOP transport. This object does
 * not export itself: it is the responsibility of the caller to
 * export it appropriately (see {@link
 * RMIJRMPServerImpl#makeClient(String,Subject)} and {@link
 * RMIIIOPServerImpl#makeClient(String,Subject)}.
 *
 * @param rmiServer The RMIServerImpl object for which this
 * connection is created.  The behavior is unspecified if this
 * parameter is null.
 * @param connectionId The ID for this connection.  The behavior
 * is unspecified if this parameter is null.
 * @param defaultClassLoader The default ClassLoader to be used
 * when deserializing marshalled objects.  Can be null, to signify
 * the bootstrap class loader.
 * @param subject the authenticated subject to be used for
 * authorization.  Can be null, to signify that no subject has
 * been authenticated.
 * @param env the environment containing attributes for the new
 * <code>RMIServerImpl</code>.  Can be null, equivalent to an
 * empty map.
 */
public RMIConnectionImpl(RMIServerImpl rmiServer,
                         String connectionId,
                         ClassLoader defaultClassLoader,
                         Subject subject,
                         Map<String,?> env) {
    if (rmiServer == null || connectionId == null)
        throw new NullPointerException("Illegal null argument");
    if (env == null)
        env = Collections.emptyMap();
    this.rmiServer = rmiServer;
    this.connectionId = connectionId;
    this.defaultClassLoader = defaultClassLoader;

    this.subjectDelegator = new SubjectDelegator();
    this.subject = subject;
    if (subject == null) {
        this.acc = null;
        this.removeCallerContext = false;
    } else {
        this.removeCallerContext =
            SubjectDelegator.checkRemoveCallerContext(subject);
        if (this.removeCallerContext) {
            this.acc =
                JMXSubjectDomainCombiner.getDomainCombinerContext(subject);
        } else {
            this.acc =
                JMXSubjectDomainCombiner.getContext(subject);
        }
    }
    this.mbeanServer = rmiServer.getMBeanServer();

    final ClassLoader dcl = defaultClassLoader;

    ClassLoaderRepository repository = AccessController.doPrivileged(
        new PrivilegedAction<ClassLoaderRepository>() {
            public ClassLoaderRepository run() {
                return mbeanServer.getClassLoaderRepository();
            }
        },
        withPermissions(new MBeanPermission("*", "getClassLoaderRepository"))
    );
    this.classLoaderWithRepository = AccessController.doPrivileged(
        new PrivilegedAction<ClassLoaderWithRepository>() {
            public ClassLoaderWithRepository run() {
                return new ClassLoaderWithRepository(
                    repository,
                    dcl);
            }
        },
        withPermissions(new RuntimePermission("createClassLoader"))
    );

    this.defaultContextClassLoader =
        AccessController.doPrivileged(
            new PrivilegedAction<ClassLoader>() {
        @Override
                public ClassLoader run() {
                    return new CombinedClassLoader(Thread.currentThread().getContextClassLoader(),
                            dcl);
                }
            });

    serverCommunicatorAdmin = new
      RMIServerCommunicatorAdmin(EnvHelp.getServerConnectionTimeout(env));

    this.env = env;
}
 
Example 10
Source File: RMIConnectionImpl.java    From Java8CN with Apache License 2.0 4 votes vote down vote up
/**
 * Constructs a new {@link RMIConnection}. This connection can be
 * used with either the JRMP or IIOP transport. This object does
 * not export itself: it is the responsibility of the caller to
 * export it appropriately (see {@link
 * RMIJRMPServerImpl#makeClient(String,Subject)} and {@link
 * RMIIIOPServerImpl#makeClient(String,Subject)}.
 *
 * @param rmiServer The RMIServerImpl object for which this
 * connection is created.  The behavior is unspecified if this
 * parameter is null.
 * @param connectionId The ID for this connection.  The behavior
 * is unspecified if this parameter is null.
 * @param defaultClassLoader The default ClassLoader to be used
 * when deserializing marshalled objects.  Can be null, to signify
 * the bootstrap class loader.
 * @param subject the authenticated subject to be used for
 * authorization.  Can be null, to signify that no subject has
 * been authenticated.
 * @param env the environment containing attributes for the new
 * <code>RMIServerImpl</code>.  Can be null, equivalent to an
 * empty map.
 */
public RMIConnectionImpl(RMIServerImpl rmiServer,
                         String connectionId,
                         ClassLoader defaultClassLoader,
                         Subject subject,
                         Map<String,?> env) {
    if (rmiServer == null || connectionId == null)
        throw new NullPointerException("Illegal null argument");
    if (env == null)
        env = Collections.emptyMap();
    this.rmiServer = rmiServer;
    this.connectionId = connectionId;
    this.defaultClassLoader = defaultClassLoader;

    this.subjectDelegator = new SubjectDelegator();
    this.subject = subject;
    if (subject == null) {
        this.acc = null;
        this.removeCallerContext = false;
    } else {
        this.removeCallerContext =
            SubjectDelegator.checkRemoveCallerContext(subject);
        if (this.removeCallerContext) {
            this.acc =
                JMXSubjectDomainCombiner.getDomainCombinerContext(subject);
        } else {
            this.acc =
                JMXSubjectDomainCombiner.getContext(subject);
        }
    }
    this.mbeanServer = rmiServer.getMBeanServer();

    final ClassLoader dcl = defaultClassLoader;

    ClassLoaderRepository repository = AccessController.doPrivileged(
        new PrivilegedAction<ClassLoaderRepository>() {
            public ClassLoaderRepository run() {
                return mbeanServer.getClassLoaderRepository();
            }
        },
        withPermissions(new MBeanPermission("*", "getClassLoaderRepository"))
    );
    this.classLoaderWithRepository = AccessController.doPrivileged(
        new PrivilegedAction<ClassLoaderWithRepository>() {
            public ClassLoaderWithRepository run() {
                return new ClassLoaderWithRepository(
                    repository,
                    dcl);
            }
        },
        withPermissions(new RuntimePermission("createClassLoader"))
    );

    this.defaultContextClassLoader =
        AccessController.doPrivileged(
            new PrivilegedAction<ClassLoader>() {
        @Override
                public ClassLoader run() {
                    return new CombinedClassLoader(Thread.currentThread().getContextClassLoader(),
                            dcl);
                }
            });

    serverCommunicatorAdmin = new
      RMIServerCommunicatorAdmin(EnvHelp.getServerConnectionTimeout(env));

    this.env = env;
}
 
Example 11
Source File: RMIConnectionImpl.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructs a new {@link RMIConnection}. This connection can be
 * used with either the JRMP or IIOP transport. This object does
 * not export itself: it is the responsibility of the caller to
 * export it appropriately (see {@link
 * RMIJRMPServerImpl#makeClient(String,Subject)} and {@link
 * RMIIIOPServerImpl#makeClient(String,Subject)}.
 *
 * @param rmiServer The RMIServerImpl object for which this
 * connection is created.  The behavior is unspecified if this
 * parameter is null.
 * @param connectionId The ID for this connection.  The behavior
 * is unspecified if this parameter is null.
 * @param defaultClassLoader The default ClassLoader to be used
 * when deserializing marshalled objects.  Can be null, to signify
 * the bootstrap class loader.
 * @param subject the authenticated subject to be used for
 * authorization.  Can be null, to signify that no subject has
 * been authenticated.
 * @param env the environment containing attributes for the new
 * <code>RMIServerImpl</code>.  Can be null, equivalent to an
 * empty map.
 */
public RMIConnectionImpl(RMIServerImpl rmiServer,
                         String connectionId,
                         ClassLoader defaultClassLoader,
                         Subject subject,
                         Map<String,?> env) {
    if (rmiServer == null || connectionId == null)
        throw new NullPointerException("Illegal null argument");
    if (env == null)
        env = Collections.emptyMap();
    this.rmiServer = rmiServer;
    this.connectionId = connectionId;
    this.defaultClassLoader = defaultClassLoader;

    this.subjectDelegator = new SubjectDelegator();
    this.subject = subject;
    if (subject == null) {
        this.acc = null;
        this.removeCallerContext = false;
    } else {
        this.removeCallerContext =
            SubjectDelegator.checkRemoveCallerContext(subject);
        if (this.removeCallerContext) {
            this.acc =
                JMXSubjectDomainCombiner.getDomainCombinerContext(subject);
        } else {
            this.acc =
                JMXSubjectDomainCombiner.getContext(subject);
        }
    }
    this.mbeanServer = rmiServer.getMBeanServer();

    final ClassLoader dcl = defaultClassLoader;

    ClassLoaderRepository repository = AccessController.doPrivileged(
        new PrivilegedAction<ClassLoaderRepository>() {
            public ClassLoaderRepository run() {
                return mbeanServer.getClassLoaderRepository();
            }
        },
        withPermissions(new MBeanPermission("*", "getClassLoaderRepository"))
    );
    this.classLoaderWithRepository = AccessController.doPrivileged(
        new PrivilegedAction<ClassLoaderWithRepository>() {
            public ClassLoaderWithRepository run() {
                return new ClassLoaderWithRepository(
                    repository,
                    dcl);
            }
        },
        withPermissions(new RuntimePermission("createClassLoader"))
    );

    this.defaultContextClassLoader =
        AccessController.doPrivileged(
            new PrivilegedAction<ClassLoader>() {
        @Override
                public ClassLoader run() {
                    return new CombinedClassLoader(Thread.currentThread().getContextClassLoader(),
                            dcl);
                }
            });

    serverCommunicatorAdmin = new
      RMIServerCommunicatorAdmin(EnvHelp.getServerConnectionTimeout(env));

    this.env = env;
}
 
Example 12
Source File: RMIConnectionImpl.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructs a new {@link RMIConnection}. This connection can be
 * used with either the JRMP or IIOP transport. This object does
 * not export itself: it is the responsibility of the caller to
 * export it appropriately (see {@link
 * RMIJRMPServerImpl#makeClient(String,Subject)} and {@link
 * RMIIIOPServerImpl#makeClient(String,Subject)}.
 *
 * @param rmiServer The RMIServerImpl object for which this
 * connection is created.  The behavior is unspecified if this
 * parameter is null.
 * @param connectionId The ID for this connection.  The behavior
 * is unspecified if this parameter is null.
 * @param defaultClassLoader The default ClassLoader to be used
 * when deserializing marshalled objects.  Can be null, to signify
 * the bootstrap class loader.
 * @param subject the authenticated subject to be used for
 * authorization.  Can be null, to signify that no subject has
 * been authenticated.
 * @param env the environment containing attributes for the new
 * <code>RMIServerImpl</code>.  Can be null, equivalent to an
 * empty map.
 */
public RMIConnectionImpl(RMIServerImpl rmiServer,
                         String connectionId,
                         ClassLoader defaultClassLoader,
                         Subject subject,
                         Map<String,?> env) {
    if (rmiServer == null || connectionId == null)
        throw new NullPointerException("Illegal null argument");
    if (env == null)
        env = Collections.emptyMap();
    this.rmiServer = rmiServer;
    this.connectionId = connectionId;
    this.defaultClassLoader = defaultClassLoader;

    this.subjectDelegator = new SubjectDelegator();
    this.subject = subject;
    if (subject == null) {
        this.acc = null;
        this.removeCallerContext = false;
    } else {
        this.removeCallerContext =
            SubjectDelegator.checkRemoveCallerContext(subject);
        if (this.removeCallerContext) {
            this.acc =
                JMXSubjectDomainCombiner.getDomainCombinerContext(subject);
        } else {
            this.acc =
                JMXSubjectDomainCombiner.getContext(subject);
        }
    }
    this.mbeanServer = rmiServer.getMBeanServer();

    final ClassLoader dcl = defaultClassLoader;

    this.classLoaderWithRepository =
        AccessController.doPrivileged(
            new PrivilegedAction<ClassLoaderWithRepository>() {
                public ClassLoaderWithRepository run() {
                    return new ClassLoaderWithRepository(
                                  mbeanServer.getClassLoaderRepository(),
                                  dcl);
                }
            },

            withPermissions( new MBeanPermission("*", "getClassLoaderRepository"),
                             new RuntimePermission("createClassLoader"))
        );


    this.defaultContextClassLoader =
        AccessController.doPrivileged(
            new PrivilegedAction<ClassLoader>() {
        @Override
                public ClassLoader run() {
                    return new CombinedClassLoader(Thread.currentThread().getContextClassLoader(),
                            dcl);
                }
            });

    serverCommunicatorAdmin = new
      RMIServerCommunicatorAdmin(EnvHelp.getServerConnectionTimeout(env));

    this.env = env;
}
 
Example 13
Source File: RMIConnectionImpl.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructs a new {@link RMIConnection}. This connection can be
 * used with either the JRMP or IIOP transport. This object does
 * not export itself: it is the responsibility of the caller to
 * export it appropriately (see {@link
 * RMIJRMPServerImpl#makeClient(String,Subject)} and {@link
 * RMIIIOPServerImpl#makeClient(String,Subject)}.
 *
 * @param rmiServer The RMIServerImpl object for which this
 * connection is created.  The behavior is unspecified if this
 * parameter is null.
 * @param connectionId The ID for this connection.  The behavior
 * is unspecified if this parameter is null.
 * @param defaultClassLoader The default ClassLoader to be used
 * when deserializing marshalled objects.  Can be null, to signify
 * the bootstrap class loader.
 * @param subject the authenticated subject to be used for
 * authorization.  Can be null, to signify that no subject has
 * been authenticated.
 * @param env the environment containing attributes for the new
 * <code>RMIServerImpl</code>.  Can be null, equivalent to an
 * empty map.
 */
public RMIConnectionImpl(RMIServerImpl rmiServer,
                         String connectionId,
                         ClassLoader defaultClassLoader,
                         Subject subject,
                         Map<String,?> env) {
    if (rmiServer == null || connectionId == null)
        throw new NullPointerException("Illegal null argument");
    if (env == null)
        env = Collections.emptyMap();
    this.rmiServer = rmiServer;
    this.connectionId = connectionId;
    this.defaultClassLoader = defaultClassLoader;

    this.subjectDelegator = new SubjectDelegator();
    this.subject = subject;
    if (subject == null) {
        this.acc = null;
        this.removeCallerContext = false;
    } else {
        this.removeCallerContext =
            SubjectDelegator.checkRemoveCallerContext(subject);
        if (this.removeCallerContext) {
            this.acc =
                JMXSubjectDomainCombiner.getDomainCombinerContext(subject);
        } else {
            this.acc =
                JMXSubjectDomainCombiner.getContext(subject);
        }
    }
    this.mbeanServer = rmiServer.getMBeanServer();

    final ClassLoader dcl = defaultClassLoader;

    this.classLoaderWithRepository =
        AccessController.doPrivileged(
            new PrivilegedAction<ClassLoaderWithRepository>() {
                public ClassLoaderWithRepository run() {
                    return new ClassLoaderWithRepository(
                                  mbeanServer.getClassLoaderRepository(),
                                  dcl);
                }
            },

            withPermissions( new MBeanPermission("*", "getClassLoaderRepository"),
                             new RuntimePermission("createClassLoader"))
        );


    this.defaultContextClassLoader =
        AccessController.doPrivileged(
            new PrivilegedAction<ClassLoader>() {
        @Override
                public ClassLoader run() {
                    return new CombinedClassLoader(Thread.currentThread().getContextClassLoader(),
                            dcl);
                }
            });

    serverCommunicatorAdmin = new
      RMIServerCommunicatorAdmin(EnvHelp.getServerConnectionTimeout(env));

    this.env = env;
}
 
Example 14
Source File: RMIConnectionImpl.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructs a new {@link RMIConnection}. This connection can be
 * used with either the JRMP or IIOP transport. This object does
 * not export itself: it is the responsibility of the caller to
 * export it appropriately (see {@link
 * RMIJRMPServerImpl#makeClient(String,Subject)} and {@link
 * RMIIIOPServerImpl#makeClient(String,Subject)}.
 *
 * @param rmiServer The RMIServerImpl object for which this
 * connection is created.  The behavior is unspecified if this
 * parameter is null.
 * @param connectionId The ID for this connection.  The behavior
 * is unspecified if this parameter is null.
 * @param defaultClassLoader The default ClassLoader to be used
 * when deserializing marshalled objects.  Can be null, to signify
 * the bootstrap class loader.
 * @param subject the authenticated subject to be used for
 * authorization.  Can be null, to signify that no subject has
 * been authenticated.
 * @param env the environment containing attributes for the new
 * <code>RMIServerImpl</code>.  Can be null, equivalent to an
 * empty map.
 */
public RMIConnectionImpl(RMIServerImpl rmiServer,
                         String connectionId,
                         ClassLoader defaultClassLoader,
                         Subject subject,
                         Map<String,?> env) {
    if (rmiServer == null || connectionId == null)
        throw new NullPointerException("Illegal null argument");
    if (env == null)
        env = Collections.emptyMap();
    this.rmiServer = rmiServer;
    this.connectionId = connectionId;
    this.defaultClassLoader = defaultClassLoader;

    this.subjectDelegator = new SubjectDelegator();
    this.subject = subject;
    if (subject == null) {
        this.acc = null;
        this.removeCallerContext = false;
    } else {
        this.removeCallerContext =
            SubjectDelegator.checkRemoveCallerContext(subject);
        if (this.removeCallerContext) {
            this.acc =
                JMXSubjectDomainCombiner.getDomainCombinerContext(subject);
        } else {
            this.acc =
                JMXSubjectDomainCombiner.getContext(subject);
        }
    }
    this.mbeanServer = rmiServer.getMBeanServer();

    final ClassLoader dcl = defaultClassLoader;

    ClassLoaderRepository repository = AccessController.doPrivileged(
        new PrivilegedAction<ClassLoaderRepository>() {
            public ClassLoaderRepository run() {
                return mbeanServer.getClassLoaderRepository();
            }
        },
        withPermissions(new MBeanPermission("*", "getClassLoaderRepository"))
    );
    this.classLoaderWithRepository = AccessController.doPrivileged(
        new PrivilegedAction<ClassLoaderWithRepository>() {
            public ClassLoaderWithRepository run() {
                return new ClassLoaderWithRepository(
                    repository,
                    dcl);
            }
        },
        withPermissions(new RuntimePermission("createClassLoader"))
    );

    this.defaultContextClassLoader =
        AccessController.doPrivileged(
            new PrivilegedAction<ClassLoader>() {
        @Override
                public ClassLoader run() {
                    return new CombinedClassLoader(Thread.currentThread().getContextClassLoader(),
                            dcl);
                }
            });

    serverCommunicatorAdmin = new
      RMIServerCommunicatorAdmin(EnvHelp.getServerConnectionTimeout(env));

    this.env = env;
}
 
Example 15
Source File: RMIConnectionImpl.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructs a new {@link RMIConnection}. This connection can be
 * used with either the JRMP or IIOP transport. This object does
 * not export itself: it is the responsibility of the caller to
 * export it appropriately (see {@link
 * RMIJRMPServerImpl#makeClient(String,Subject)} and {@link
 * RMIIIOPServerImpl#makeClient(String,Subject)}.
 *
 * @param rmiServer The RMIServerImpl object for which this
 * connection is created.  The behavior is unspecified if this
 * parameter is null.
 * @param connectionId The ID for this connection.  The behavior
 * is unspecified if this parameter is null.
 * @param defaultClassLoader The default ClassLoader to be used
 * when deserializing marshalled objects.  Can be null, to signify
 * the bootstrap class loader.
 * @param subject the authenticated subject to be used for
 * authorization.  Can be null, to signify that no subject has
 * been authenticated.
 * @param env the environment containing attributes for the new
 * <code>RMIServerImpl</code>.  Can be null, equivalent to an
 * empty map.
 */
public RMIConnectionImpl(RMIServerImpl rmiServer,
                         String connectionId,
                         ClassLoader defaultClassLoader,
                         Subject subject,
                         Map<String,?> env) {
    if (rmiServer == null || connectionId == null)
        throw new NullPointerException("Illegal null argument");
    if (env == null)
        env = Collections.emptyMap();
    this.rmiServer = rmiServer;
    this.connectionId = connectionId;
    this.defaultClassLoader = defaultClassLoader;

    this.subjectDelegator = new SubjectDelegator();
    this.subject = subject;
    if (subject == null) {
        this.acc = null;
        this.removeCallerContext = false;
    } else {
        this.removeCallerContext =
            SubjectDelegator.checkRemoveCallerContext(subject);
        if (this.removeCallerContext) {
            this.acc =
                JMXSubjectDomainCombiner.getDomainCombinerContext(subject);
        } else {
            this.acc =
                JMXSubjectDomainCombiner.getContext(subject);
        }
    }
    this.mbeanServer = rmiServer.getMBeanServer();

    final ClassLoader dcl = defaultClassLoader;

    this.classLoaderWithRepository =
        AccessController.doPrivileged(
            new PrivilegedAction<ClassLoaderWithRepository>() {
                public ClassLoaderWithRepository run() {
                    return new ClassLoaderWithRepository(
                                  mbeanServer.getClassLoaderRepository(),
                                  dcl);
                }
            },

            withPermissions( new MBeanPermission("*", "getClassLoaderRepository"),
                             new RuntimePermission("createClassLoader"))
        );


    this.defaultContextClassLoader =
        AccessController.doPrivileged(
            new PrivilegedAction<ClassLoader>() {
        @Override
                public ClassLoader run() {
                    return new CombinedClassLoader(Thread.currentThread().getContextClassLoader(),
                            dcl);
                }
            });

    serverCommunicatorAdmin = new
      RMIServerCommunicatorAdmin(EnvHelp.getServerConnectionTimeout(env));

    this.env = env;
}
 
Example 16
Source File: RMIConnectionImpl.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructs a new {@link RMIConnection}. This connection can be
 * used with either the JRMP or IIOP transport. This object does
 * not export itself: it is the responsibility of the caller to
 * export it appropriately (see {@link
 * RMIJRMPServerImpl#makeClient(String,Subject)} and {@link
 * RMIIIOPServerImpl#makeClient(String,Subject)}.
 *
 * @param rmiServer The RMIServerImpl object for which this
 * connection is created.  The behavior is unspecified if this
 * parameter is null.
 * @param connectionId The ID for this connection.  The behavior
 * is unspecified if this parameter is null.
 * @param defaultClassLoader The default ClassLoader to be used
 * when deserializing marshalled objects.  Can be null, to signify
 * the bootstrap class loader.
 * @param subject the authenticated subject to be used for
 * authorization.  Can be null, to signify that no subject has
 * been authenticated.
 * @param env the environment containing attributes for the new
 * <code>RMIServerImpl</code>.  Can be null, equivalent to an
 * empty map.
 */
public RMIConnectionImpl(RMIServerImpl rmiServer,
                         String connectionId,
                         ClassLoader defaultClassLoader,
                         Subject subject,
                         Map<String,?> env) {
    if (rmiServer == null || connectionId == null)
        throw new NullPointerException("Illegal null argument");
    if (env == null)
        env = Collections.emptyMap();
    this.rmiServer = rmiServer;
    this.connectionId = connectionId;
    this.defaultClassLoader = defaultClassLoader;

    this.subjectDelegator = new SubjectDelegator();
    this.subject = subject;
    if (subject == null) {
        this.acc = null;
        this.removeCallerContext = false;
    } else {
        this.removeCallerContext =
            SubjectDelegator.checkRemoveCallerContext(subject);
        if (this.removeCallerContext) {
            this.acc =
                JMXSubjectDomainCombiner.getDomainCombinerContext(subject);
        } else {
            this.acc =
                JMXSubjectDomainCombiner.getContext(subject);
        }
    }
    this.mbeanServer = rmiServer.getMBeanServer();

    final ClassLoader dcl = defaultClassLoader;

    this.classLoaderWithRepository =
        AccessController.doPrivileged(
            new PrivilegedAction<ClassLoaderWithRepository>() {
                public ClassLoaderWithRepository run() {
                    return new ClassLoaderWithRepository(
                                  mbeanServer.getClassLoaderRepository(),
                                  dcl);
                }
            },

            withPermissions( new MBeanPermission("*", "getClassLoaderRepository"),
                             new RuntimePermission("createClassLoader"))
        );


    this.defaultContextClassLoader =
        AccessController.doPrivileged(
            new PrivilegedAction<ClassLoader>() {
        @Override
                public ClassLoader run() {
                    return new CombinedClassLoader(Thread.currentThread().getContextClassLoader(),
                            dcl);
                }
            });

    serverCommunicatorAdmin = new
      RMIServerCommunicatorAdmin(EnvHelp.getServerConnectionTimeout(env));

    this.env = env;
}