com.sun.jini.discovery.internal
Class EndpointBasedServer

java.lang.Object
  extended by com.sun.jini.discovery.internal.BaseProvider
      extended by com.sun.jini.discovery.internal.EndpointBasedProvider
          extended by com.sun.jini.discovery.internal.EndpointBasedServer
All Implemented Interfaces:
DiscoveryFormatProvider, UnicastDiscoveryServer
Direct Known Subclasses:
Server.ServerImpl, Server.ServerImpl

public abstract class EndpointBasedServer
extends EndpointBasedProvider
implements UnicastDiscoveryServer

Provides an abstract server endpoint-based UnicastDiscoveryServer implementation, which serves as a superclass for server-side providers for the net.jini.discovery.ssl and net.jini.discovery.kerberos unicast discovery formats.


Nested Class Summary
private static class EndpointBasedServer.ListenContextImpl
          Listen context that listens on the endpoint it is given, and stores the resulting handle.
private static class EndpointBasedServer.PrearrangedServerSocket
          Server socket that returns a prearranged socket once from its accept method, and then blocks on subsequent calls to accept until closed.
private static class EndpointBasedServer.PrearrangedServerSocketFactory
          Server socket factory that returns a PrearrangedServerSocket for a prearranged socket.
private static class EndpointBasedServer.ServerConnManagerImpl
          Server connection manager that stores the connection it is given to handle.
 
Field Summary
 
Fields inherited from class com.sun.jini.discovery.internal.EndpointBasedProvider
endpointInternals
 
Fields inherited from class com.sun.jini.discovery.internal.BaseProvider
formatName
 
Constructor Summary
protected EndpointBasedServer(String formatName, EndpointInternals endpointInternals)
          Constructs instance with the given format name and object providing access to non-public endpoint operations.
 
Method Summary
 void checkUnicastDiscoveryConstraints(InvocationConstraints constraints)
          Checks and returns normally if this server is capable of fulfilling the given absolute constraints.
private static Subject getClientSubject(ServerConnection connection, InboundRequestHandle handle)
          Returns the subject that the client of the given connection has authenticated as, or null if the client is not authenticated.
protected abstract  ServerEndpoint getServerEndpoint(ServerSocketFactory factory)
          Returns a server endpoint which uses the given server socket factory, if non-null.
 void handleUnicastDiscovery(UnicastResponse response, Socket socket, InvocationConstraints constraints, ClientSubjectChecker checker, Collection context, ByteBuffer received, ByteBuffer sent)
          Handles the server side of unicast discovery, transmitting the given response data over the provided socket using the given collection of object stream context objects in a manner that satisfies the specified absolute constraints and client subject checker (if any).
 
Methods inherited from class com.sun.jini.discovery.internal.EndpointBasedProvider
calcHandshakeHash, checkIntegrity
 
Methods inherited from class com.sun.jini.discovery.internal.BaseProvider
getFormatName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sun.jini.discovery.DiscoveryFormatProvider
getFormatName
 

Constructor Detail

EndpointBasedServer

protected EndpointBasedServer(String formatName,
                              EndpointInternals endpointInternals)
Constructs instance with the given format name and object providing access to non-public endpoint operations.

Method Detail

checkUnicastDiscoveryConstraints

public void checkUnicastDiscoveryConstraints(InvocationConstraints constraints)
                                      throws UnsupportedConstraintException
Description copied from interface: UnicastDiscoveryServer
Checks and returns normally if this server is capable of fulfilling the given absolute constraints. null constraints are considered equivalent to empty constraints.

Specified by:
checkUnicastDiscoveryConstraints in interface UnicastDiscoveryServer
Parameters:
constraints - the constraints to check, or null
Throws:
UnsupportedConstraintException - if unable to satisfy the specified constraints

handleUnicastDiscovery

public void handleUnicastDiscovery(UnicastResponse response,
                                   Socket socket,
                                   InvocationConstraints constraints,
                                   ClientSubjectChecker checker,
                                   Collection context,
                                   ByteBuffer received,
                                   ByteBuffer sent)
                            throws IOException
Description copied from interface: UnicastDiscoveryServer
Handles the server side of unicast discovery, transmitting the given response data over the provided socket using the given collection of object stream context objects in a manner that satisfies the specified absolute constraints and client subject checker (if any). Byte buffers containing the data received and sent so far over the given socket (for the unicast discovery protocol 2 handshake) are provided for use by formats which integrity protect or otherwise incorporate the handshake data. null constraints are considered equivalent to empty constraints.

Specified by:
handleUnicastDiscovery in interface UnicastDiscoveryServer
Parameters:
response - the unicast response data to transmit
socket - the socket on which to handle unicast discovery
constraints - the constraints to apply to unicast discovery, or null
checker - the object to use to check the client subject, or null
context - the collection of context information objects to use when marshalling the registrar proxy
received - a buffer containing the data already received
sent - a buffer containing the data already sent
Throws:
IOException - if an error occurs in interpreting received data or in formatting data to send
UnsupportedConstraintException - if unable to satisfy the specified constraints

getServerEndpoint

protected abstract ServerEndpoint getServerEndpoint(ServerSocketFactory factory)
                                             throws UnsupportedConstraintException
Returns a server endpoint which uses the given server socket factory, if non-null. Other parameters of the server endpoint, such as the listen port, are irrelevant from the standpoint of this class and can be chosen arbitrarily.

Throws:
UnsupportedConstraintException

getClientSubject

private static Subject getClientSubject(ServerConnection connection,
                                        InboundRequestHandle handle)
Returns the subject that the client of the given connection has authenticated as, or null if the client is not authenticated.



Copyright 2007-2010, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.