All Packages Class Hierarchy This Package Previous Next Index
Class AcmeNet.Assn4.NameService
AcmeNet.Assn2.Service
|
+----AcmeNet.Assn3.SecureService
|
+----AcmeNet.Assn4.NameService
- public class NameService
- extends SecureService
A Service that provides a mapping from names (Strings) to ServiceAddresses. A NameService
plays a role analogous to a directory in the Unix file system.
This class implements dummy versions of the hasBindPermission, hasListPermission, and
hasLookupPermission methods. These dummy versions always return true, implying that everybody
is allowed to do everything. Subclasses may choose to override the permission-related
methods to implement a different security policy.
- See Also:
- SecureService, Naming
-
Location
- The location of the root name service.
-
NameService()
- Create a NameService at the default NetAddress, at the default serviceNumber,
under the "cs461" user-ID.
-
NameService(ClientServerNI, int, String, long)
- Create a NameService at in a specified network interface, at a specified serviceNumber.
-
NameService(ClientServerNI, String, long)
- Create a NameService at in a specified network interface, at the default serviceNumber.
-
()
- Set Location to the default location of the root name service (tucson.princeton.edu, port 9090, service number 144).
-
hasBindPermission(String, String)
- Check whether the client has permission to bind (or unbind) a name.
-
hasListPermission(String)
- Check whether the client has permission to do a List operation.
-
hasLookupPermission(String)
- Check whether the client has permission to do a Lookup operation.
-
main(String[])
- Running this causes a NameService to be created and started at the default location.
-
readServiceAddress(DataInputStream)
- Read a ServiceAddress from a DataInputStream, and return the ServiceAddress that was read.
-
serviceConnection(Connection)
- Receive one request on the connection, service that request, and then close the connection.
-
writeServiceAddress(DataOutputStream, ServiceAddress)
- Write a ServiceAddress TO a DataOutputStream.
Location
public static ServiceAddress Location
- The location of the root name service. The root name service defines the root of the
hierarchical name space.
NameService
NameService(ClientServerNI ni,
int serviceNum,
String identity,
long key) throws AlreadyBoundException
- Create a NameService at in a specified network interface, at a specified serviceNumber.
- Parameters:
- ni - the network interface the new service should use
- serviceNum - the serviceNumber the new service should use
- identity - the user-ID under which the new service should run
- key - the secret key of the user-ID under which the new service should run
- Throws: AlreadyBoundException
- there was already a service at that service number
NameService
public NameService(ClientServerNI ni,
String identity,
long key) throws AlreadyBoundException
- Create a NameService at in a specified network interface, at the default serviceNumber.
- Parameters:
- ni - the network interface the new service should use
- identity - the user-ID under which the new service should run
- key - the secret key of the user-ID under which the new service should run
- Throws: AlreadyBoundException
- there was already a service at that service number
NameService
public NameService() throws AlreadyBoundException, AddressUnavailableException
- Create a NameService at the default NetAddress, at the default serviceNumber,
under the "cs461" user-ID.
Note: students will be unable to provide a working implementation of this, since they
don't know the secret key for the "cs461" user. Students should just provide a dummy
implementation that compiles correctly; it won't be tested.
- Throws: AlreadyBoundException
- there was already a service at that service number
- Throws: AddressUnavailableException
- the default NetAddress is on another machine, or the default port number was already in use
main
public static void main(String unused[]) throws AlreadyBoundException, AddressUnavailableException
- Running this causes a NameService to be created and started at the default location.
serviceConnection
public void serviceConnection(Connection rawConn)
- Receive one request on the connection, service that request, and then close the connection.
- Parameters:
- rawConn - the connection to the client (can safely be cast to SecureConnection)
- Overrides:
- serviceConnection in class Service
hasBindPermission
protected boolean hasBindPermission(String identity,
String name)
- Check whether the client has permission to bind (or unbind) a name.
This method should return true; subclasses can change this policy by overriding this method.
- Parameters:
- identity - the user-ID of the requesting client
- name - the name that the client wants to bind or unbind
- Returns:
- true if the client has permission to bind or unbind the requested name; false otherwise
hasListPermission
protected boolean hasListPermission(String identity)
- Check whether the client has permission to do a List operation.
This method should return true; subclasses can change this policy by overriding this method.
- Parameters:
- identity - the user-ID of the requesting client
- Returns:
- true if the client has permission to do the List operation; false otherwise
hasLookupPermission
protected boolean hasLookupPermission(String identity)
- Check whether the client has permission to do a Lookup operation.
This method should return true; subclasses can change this policy by overriding this method.
- Parameters:
- identity - the user-ID of the requesting client
- Returns:
- true if the client has permission to do the Lookup operation; false otherwise
readServiceAddress
static ServiceAddress readServiceAddress(DataInputStream in) throws IOException
- Read a ServiceAddress from a DataInputStream, and return the ServiceAddress that was read.
- Parameters:
- in - the stream to read from
- Returns:
- the ServiceAddress read from the stream
- Throws: IOException
- some I/O error occurred
writeServiceAddress
static void writeServiceAddress(DataOutputStream out,
ServiceAddress sa) throws IOException
- Write a ServiceAddress TO a DataOutputStream.
- Parameters:
- out - the stream to write to
- sa - the ServiceAddress to write
- Throws: IOException
- some I/O error occurred
static void ()
- Set Location to the default location of the root name service (tucson.princeton.edu, port 9090, service number 144).
All Packages Class Hierarchy This Package Previous Next Index