java.rmi.registry
Class LocateSecureRegistry

java.lang.Object
  |
  +--java.rmi.registry.LocateSecureRegistry

public class LocateSecureRegistry
extends java.lang.Object

Used to create secure registries (that is, registries that support the RemoteSecurity interface) and obtain references to them. To avoid requiring that clients know the details of how a secure registry is exported, each secure registry is coupled with a "bootstrap" non-secure read-only registry. The bootstrap registry contains a single entry, binding the name "java.rmi.registry.Registry" to the stub for the secure registry. The getRegistry methods of this class obtain the secure registry's stub by making a remote call to the bootstrap registry and then verifying that the stub is in fact a secure RMI stub for a unicast secure registry. As such, a client need not use Security.verifyProxyTrust on the secure registry's stub before making further use of the stub.

Since:
1.4

Method Summary
static java.rmi.registry.Registry createRegistry(int port, SecureExportDesc desc, RemoteCallControl controller)
          Creates and exports a default implementation of a secure registry using the specified export descriptor, and creates and exports a bootstrap registry at the specified port (or a dynamically allocated port if the specified port is zero), and returns the secure registry implementation object.
static java.rmi.registry.Registry exportRegistry(java.rmi.registry.Registry impl, int port, SecureExportDesc desc)
          Exports a custom implementation of a secure registry using the specified export descriptor, and creates and exports a bootstrap registry at the specified port (or a dynamically allocated port if the specified port is zero), and returns a stub for the secure registry.
static java.rmi.registry.Registry getRegistry()
          Returns a reference to a secure registry from the bootstrap registry on the current host at the default port (Registry.REGISTRY_PORT).
static java.rmi.registry.Registry getRegistry(int port)
          Returns a reference to a secure registry from the bootstrap registry on the current host at the specified port (or the default port Registry.REGISTRY_PORT if the specified port is less than or equal to zero).
static java.rmi.registry.Registry getRegistry(java.lang.String host)
          Returns a reference to a secure registry from the bootstrap registry on the specified host (or the current host if the specified host is null or of zero length) at the default port (Registry.REGISTRY_PORT).
static java.rmi.registry.Registry getRegistry(java.lang.String host, int port)
          Returns a reference to a secure registry from the bootstrap registry on the specified host (or the current host if the specified host is null or of zero length) at the specified port (or the default port Registry.REGISTRY_PORT if the specified port is less than or equal to zero).
static boolean unexportRegistry(java.rmi.registry.Registry impl, boolean force)
          Unexports a secure registry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getRegistry

public static java.rmi.registry.Registry getRegistry()
                                              throws java.rmi.RemoteException,
                                                     java.rmi.NotBoundException
Returns a reference to a secure registry from the bootstrap registry on the current host at the default port (Registry.REGISTRY_PORT).
Returns:
a reference to a secure registry from the bootstrap registry on the current host at the default port
Throws:
java.rmi.RemoteException - if a communication-related exception occurs
java.rmi.NotBoundException - if the entry in the bootstrap registry is not bound, or the entry is bound to something other than a secure RMI stub for a unicast secure registry

getRegistry

public static java.rmi.registry.Registry getRegistry(int port)
                                              throws java.rmi.RemoteException,
                                                     java.rmi.NotBoundException
Returns a reference to a secure registry from the bootstrap registry on the current host at the specified port (or the default port Registry.REGISTRY_PORT if the specified port is less than or equal to zero).
Parameters:
port - bootstrap registry port
Returns:
a reference to a secure registry from the bootstrap registry on the current host at the specified port (or the default port if the specified port is less than or equal to zero)
Throws:
java.rmi.RemoteException - if a communication-related exception occurs
java.rmi.NotBoundException - if the entry in the bootstrap registry is not bound, or the entry is bound to something other than a secure RMI stub for a unicast secure registry

getRegistry

public static java.rmi.registry.Registry getRegistry(java.lang.String host)
                                              throws java.rmi.RemoteException,
                                                     java.rmi.NotBoundException
Returns a reference to a secure registry from the bootstrap registry on the specified host (or the current host if the specified host is null or of zero length) at the default port (Registry.REGISTRY_PORT).
Parameters:
host - host the registry is on
Returns:
a reference to a secure registry from the bootstrap registry on the specified host (or the current host if the specified host is null or of zero length) at the default port
Throws:
java.rmi.RemoteException - if a communication-related exception occurs
java.rmi.NotBoundException - if the entry in the bootstrap registry is not bound, or the entry is bound to something other than a secure RMI stub for a unicast secure registry

getRegistry

public static java.rmi.registry.Registry getRegistry(java.lang.String host,
                                                     int port)
                                              throws java.rmi.RemoteException,
                                                     java.rmi.NotBoundException
Returns a reference to a secure registry from the bootstrap registry on the specified host (or the current host if the specified host is null or of zero length) at the specified port (or the default port Registry.REGISTRY_PORT if the specified port is less than or equal to zero).
Parameters:
host - host the registry is on
port - bootstrap registry port
Returns:
a reference to a secure registry from the bootstrap registry on the specified host (or the current host if the specified host is null or of zero length) at the specified port (or the default port if the specified port is less than or equal to zero)
Throws:
java.rmi.RemoteException - if a communication-related exception occurs
java.rmi.NotBoundException - if the entry in the bootstrap registry is not bound, or the entry is bound to something other than a secure RMI stub for a unicast secure registry

createRegistry

public static java.rmi.registry.Registry createRegistry(int port,
                                                        SecureExportDesc desc,
                                                        RemoteCallControl controller)
                                                 throws java.rmi.server.ExportException
Creates and exports a default implementation of a secure registry using the specified export descriptor, and creates and exports a bootstrap registry at the specified port (or a dynamically allocated port if the specified port is zero), and returns the secure registry implementation object. If a non-null instance of RemoteCallControl is specified, then it is responsible for implementing the remote call control policy for the secure registry, and the RemoteCallControl methods of that instance will be called for each remote method invocation on the secure registry. If a null instance is specified, then a default RemoteCallControl implementation is used that has semantics equivalent to BasicCallController used with the RegistryPermission class. The default implementation of the controlRemoteCall method throws an AccessControlException if the client subject has not been granted a RegistryPermission with a name that equals the name of the remote method being invoked, and never executes the parameter unmarshalling action. The default implementation of the controlRemoteResult method does nothing.
Parameters:
port - bootstrap registry port, or zero if a dynamically allocated port should be used
desc - the export descriptor to use
controller - the remote call controller to use, or null if the default controller should be used
Returns:
the secure registry implementation object
Throws:
java.rmi.server.ExportException - if a communication-related exception occurs
NullPointerException - if the export descriptor is null

exportRegistry

public static java.rmi.registry.Registry exportRegistry(java.rmi.registry.Registry impl,
                                                        int port,
                                                        SecureExportDesc desc)
                                                 throws java.rmi.server.ExportException
Exports a custom implementation of a secure registry using the specified export descriptor, and creates and exports a bootstrap registry at the specified port (or a dynamically allocated port if the specified port is zero), and returns a stub for the secure registry.
Parameters:
impl - the secure registry implementation object
port - bootstrap registry port, or zero if a dynamically allocated port should be used
desc - the export descriptor to use
Returns:
the stub for the registry
Throws:
java.rmi.server.ExportException - if a communication-related exception occurs
NullPointerException - if the secure registry implementation object or the export descriptor is null

unexportRegistry

public static boolean unexportRegistry(java.rmi.registry.Registry impl,
                                       boolean force)
                                throws java.rmi.NoSuchObjectException
Unexports a secure registry. If the force parameter is true, the registry is forcibly unexported even if there are pending calls to the registry or the registry still has calls in progress. If the force parameter is false, the registry is only unexported if there are no pending or in progress calls to the registry. If the secure registry is successfully unexported then the bootstrap registry is also unexported. Returns true if the registry was unexported, and false otherwise.
Parameters:
impl - the secure registry implementation object
force - true if the registry should be forcibly unexported, and false otherwise
Returns:
true if the registry was unexported; false otherwise
Throws:
java.rmi.NoSuchObjectException - if the registry is not exported


Copyright © 2000 Sun Microsystems, Inc. All rights reserved