/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* A "registry" exists on every node that allows RMI connections to
* servers on that node. The registry on a particular node contains a
* transient database that maps names to remote objects. When the
* node boots, the registry database is empty. The names stored in the
* registry are pure and are not parsed. A service storing itself in
* the registry may want to prefix its name of the service by a package
* name (although not required), to reduce name collisions in the
* registry.
*
* The LocateRegistry class is used to obtain registry for different hosts.
*
* @see java.rmi.registry.LocateRegistry
*/
implements Registry
{
/* indicate compatibility with JDK 1.1.x version of class */
= new Hashtable<>(101);
= new Hashtable<>(3);
/**
* Construct a new RegistryImpl on the specified port with the
* given custom socket factory pair.
*/
throws RemoteException
{
}
/**
* Construct a new RegistryImpl on the specified port.
*/
throws RemoteException
{
}
/*
* Create the export the object using the parameter
* <code>uref</code>
*/
throws RemoteException
{
/* Server ref must be created and assigned before remote
* object 'this' can be exported.
*/
}
/**
* Returns the remote object for specified name in the registry.
* @exception RemoteException If remote operation failed.
* @exception NotBound If name is not currently bound.
*/
throws RemoteException, NotBoundException
{
synchronized (bindings) {
throw new NotBoundException(name);
return obj;
}
}
/**
* Binds the name to the specified remote object.
* @exception RemoteException If remote operation failed.
* @exception AlreadyBoundException If name is already bound.
*/
{
checkAccess("Registry.bind");
synchronized (bindings) {
throw new AlreadyBoundException(name);
}
}
/**
* Unbind the name.
* @exception RemoteException If remote operation failed.
* @exception NotBound If name is not currently bound.
*/
{
checkAccess("Registry.unbind");
synchronized (bindings) {
throw new NotBoundException(name);
}
}
/**
* Rebind the name to a new object, replaces any existing binding.
* @exception RemoteException If remote operation failed.
*/
throws RemoteException, AccessException
{
checkAccess("Registry.rebind");
}
/**
* Returns an enumeration of the names in the registry.
* @exception RemoteException If remote operation failed.
*/
throws RemoteException
{
synchronized (bindings) {
while ((--i) >= 0)
}
return names;
}
/**
* Check that the caller has access to perform indicated operation.
* The client must be on same the same host as this server.
*/
try {
/*
* Get client host that this registry operation was made from.
*/
try {
public InetAddress run()
{
}
});
} catch (PrivilegedActionException pae) {
}
// if client not yet seen, make sure client allowed access
if (clientHost.isAnyLocalAddress()) {
throw new AccessException(
}
try {
/*
* if a ServerSocket can be bound to the client's
* address then that address must be local
*/
return null;
}
});
} catch (PrivilegedActionException pae) {
// must have been an IOException
throw new AccessException(
clientHost + " is non-local host");
}
}
} catch (ServerNotActiveException ex) {
/*
* Local call from this VM: allow access.
*/
" disallowed; origin is unknown host");
}
}
return id;
}
/**
* Retrieves text resources from the locale-specific properties file.
*/
try {
"sun.rmi.registry.resources.rmiregistry");
} catch (MissingResourceException mre) {
}
// throwing an Error is a bit extreme, methinks
}
}
try {
} catch (MissingResourceException mre) {
}
} else {
return (val);
}
}
/**
* Main program to start a registry. <br>
* The port number can be specified on the command line.
*/
{
// Create and install the security manager if one is not installed
// already.
}
try {
/*
* Fix bugid 4147561: When JDK tools are executed, the value of
* the CLASSPATH environment variable for the shell in which they
* were invoked is no longer incorporated into the application
* class path; CLASSPATH's only effect is to be the value of the
* system property "env.class.path". To preserve the previous
* (JDK1.1 and JDK1.2beta3) behavior of this tool, however, its
* CLASSPATH should still be considered when resolving classes
* being unmarshalled. To effect this old behavior, a class
* loader that loads from the file path specified in the
* "env.class.path" property is created and set to be the context
* class loader before the remote object is exported.
*/
}
/*
* Fix bugid 4242317: Classes defined by this class loader should
* be annotated with the value of the "java.rmi.server.codebase"
* property, not the "file:" URLs for the CLASSPATH elements.
*/
try {
new PrivilegedExceptionAction<RegistryImpl>() {
return new RegistryImpl(regPort);
}
}, getAccessControlContext());
} catch (PrivilegedActionException ex) {
}
// prevent registry from exiting
while (true) {
try {
} catch (InterruptedException e) {
}
}
} catch (NumberFormatException e) {
getTextResource("rmiregistry.port.badnumber"),
args[0] ));
getTextResource("rmiregistry.usage"),
"rmiregistry" ));
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Generates an AccessControlContext with minimal permissions.
* The approach used here is taken from the similar method
* getAccessControlContext() in the sun.applet.AppletPanel class.
*/
// begin with permissions granted to all code in current policy
public PermissionCollection run() {
if (p != null) {
return p.getPermissions(codesource);
} else {
return new Permissions();
}
}
});
/*
* Anyone can connect to the registry and the registry can connect
* to and possibly download stubs from anywhere. Downloaded stubs and
* related classes themselves are more tightly limited by RMI.
*/
/*
* Create an AccessControlContext that consists of a single
* protection domain with only the permissions calculated above.
*/
new CodeSource(null,
}
}