net.jini.jeri.kerberos
Class KerberosServerEndpoint.ServerConnectionImpl

java.lang.Object
  extended by net.jini.jeri.kerberos.KerberosUtil.Connection
      extended by net.jini.jeri.kerberos.KerberosServerEndpoint.ServerConnectionImpl
All Implemented Interfaces:
ServerConnection
Enclosing class:
KerberosServerEndpoint

private final class KerberosServerEndpoint.ServerConnectionImpl
extends KerberosUtil.Connection
implements ServerConnection

Implementation class of the server side connection abstraction


Nested Class Summary
private  class KerberosServerEndpoint.ServerConnectionImpl.CacheKey
          The key used for the softcache of this server endpoint.
private  class KerberosServerEndpoint.ServerConnectionImpl.InboundRequestHandleImpl
           
 
Field Summary
private  GSSCredential clientCred
           
private  Subject clientSubject
           
private  boolean closed
           
private  KerberosServerEndpoint.ServerConnectionImpl.InboundRequestHandleImpl handleWithEncryption
           
private  KerberosServerEndpoint.ServerConnectionImpl.InboundRequestHandleImpl handleWithoutEncryption
           
private  InputStream istream
           
private  KerberosServerEndpoint.ListenHandleImpl listenHandle
           
private  Object lock
           
private  OutputStream ostream
           
 
Fields inherited from class net.jini.jeri.kerberos.KerberosUtil.Connection
clientPrincipal, connectionLogger, dis, doDelegation, doEncryption, dos, gssContext, INTEGRITY_QOP, PRIVACY_QOP, sock
 
Constructor Summary
KerberosServerEndpoint.ServerConnectionImpl(Socket sock, KerberosServerEndpoint.ListenHandleImpl listenHandle)
          Construct a server connection
 
Method Summary
 InvocationConstraints checkConstraints(InboundRequestHandle handle, InvocationConstraints constraints)
          Implements InboundRequest.checkConstraints for a request with the specified handle.
 void checkPermissions(InboundRequestHandle handle)
          Implements InboundRequest.checkPermissions for a request with the specified handle.
private  KerberosServerEndpoint.ServerConnectionImpl.InboundRequestHandleImpl checkRequestHandle(Object h)
          Make sure that the passed in inbound request handle has the right type, and was previously instantiated in this connection.
 void close()
          Close the connection
(package private)  void establishContext()
          Carry out the GSS context establishment message exchanges
 SocketChannel getChannel()
          Returns a socket channel that performs I/O on this connection, or null if no socket channel is available.
 InputStream getInputStream()
          Returns an input stream that reads data from this connection.
 OutputStream getOutputStream()
          Returns an output stream that writes data to this connection.
 void populateContext(InboundRequestHandle handle, Collection context)
          Populates the supplied collection with context information representing a request with the specified handle.
 InboundRequestHandle processRequestData(InputStream in, OutputStream out)
          Reads from the specified input stream any per-request data required by this connection for an inbound request, writes any required response data to the specified output stream, and returns a handle for the request.
 String toString()
          Returns a string representation of this object.
 
Methods inherited from class net.jini.jeri.kerberos.KerberosUtil.Connection
flush, read, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

listenHandle

private final KerberosServerEndpoint.ListenHandleImpl listenHandle

clientCred

private GSSCredential clientCred

clientSubject

private Subject clientSubject

istream

private InputStream istream

ostream

private OutputStream ostream

handleWithEncryption

private KerberosServerEndpoint.ServerConnectionImpl.InboundRequestHandleImpl handleWithEncryption

handleWithoutEncryption

private KerberosServerEndpoint.ServerConnectionImpl.InboundRequestHandleImpl handleWithoutEncryption

lock

private final Object lock

closed

private boolean closed
Constructor Detail

KerberosServerEndpoint.ServerConnectionImpl

KerberosServerEndpoint.ServerConnectionImpl(Socket sock,
                                            KerberosServerEndpoint.ListenHandleImpl listenHandle)
                                      throws IOException
Construct a server connection

Throws:
IOException
Method Detail

getInputStream

public InputStream getInputStream()
                           throws IOException
Description copied from interface: ServerConnection
Returns an input stream that reads data from this connection.

Specified by:
getInputStream in interface ServerConnection
Returns:
an input stream that reads data from this connection
Throws:
IOException - if an I/O exception occurs

getOutputStream

public OutputStream getOutputStream()
                             throws IOException
Description copied from interface: ServerConnection
Returns an output stream that writes data to this connection.

Specified by:
getOutputStream in interface ServerConnection
Returns:
an output stream that writes data to this connection
Throws:
IOException - if an I/O exception occurs

getChannel

public SocketChannel getChannel()
Description copied from interface: ServerConnection
Returns a socket channel that performs I/O on this connection, or null if no socket channel is available. If a non-null socket channel is returned, it is connected.

Specified by:
getChannel in interface ServerConnection
Returns:
a socket channel that performs I/O on this connection, or null

processRequestData

public InboundRequestHandle processRequestData(InputStream in,
                                               OutputStream out)
                                        throws IOException
Description copied from interface: ServerConnection
Reads from the specified input stream any per-request data required by this connection for an inbound request, writes any required response data to the specified output stream, and returns a handle for the request.

This method is invoked by ServerConnectionManager with the request input stream and the response output stream of the InboundRequest that it creates for the request when the request is first received. This method reads information that was sent by Connection.writeRequestData and writes information to be read by Connection.readResponseData. This method can be used, for example, to process per-request information about delegation, client authentication, or client privileges.

If, for security reasons, this method determines that the request must not be processed further (for example, because client authentication failed), this method should close the response output stream and throw a SecurityException after writing any response data.

There may be multiple requests in progress concurrently over this connection, and data read from and written to the specified streams may be buffered and multiplexed with data from other requests on this connection's underlying streams. Therefore, this method should only read data from the request input stream and write data to the response output stream and must not otherwise read from or write to this connection's underlying streams.

Specified by:
processRequestData in interface ServerConnection
Parameters:
in - the request input stream of the request
out - the response output stream of the request
Returns:
a handle to identify the request in later invocations on this connection
Throws:
IOException - if an I/O exception occurs

checkPermissions

public void checkPermissions(InboundRequestHandle handle)
Description copied from interface: ServerConnection
Implements InboundRequest.checkPermissions for a request with the specified handle.

Specified by:
checkPermissions in interface ServerConnection
Parameters:
handle - the handle for the request

checkConstraints

public InvocationConstraints checkConstraints(InboundRequestHandle handle,
                                              InvocationConstraints constraints)
                                       throws UnsupportedConstraintException
Description copied from interface: ServerConnection
Implements InboundRequest.checkConstraints for a request with the specified handle.

Specified by:
checkConstraints in interface ServerConnection
Parameters:
handle - the handle for the request
constraints - the constraints that must be satisfied
Returns:
the constraints that must be at least partially implemented by higher layers
Throws:
UnsupportedConstraintException - if the transport layer aspects of any of the specified requirements are not satisfied by this request

populateContext

public void populateContext(InboundRequestHandle handle,
                            Collection context)
Description copied from interface: ServerConnection
Populates the supplied collection with context information representing a request with the specified handle. This method is used to implement InboundRequest.populateContext for such requests; the context may also be populated by the connection manager.

Specified by:
populateContext in interface ServerConnection
Parameters:
handle - the handle for the request
context - the context collection to populate

close

public void close()
Description copied from class: KerberosUtil.Connection
Close the connection

Specified by:
close in interface ServerConnection
Overrides:
close in class KerberosUtil.Connection

toString

public String toString()
Returns a string representation of this object.

Overrides:
toString in class Object

establishContext

void establishContext()
                throws IOException,
                       GSSException
Carry out the GSS context establishment message exchanges

Throws:
IOException
GSSException

checkRequestHandle

private KerberosServerEndpoint.ServerConnectionImpl.InboundRequestHandleImpl checkRequestHandle(Object h)
Make sure that the passed in inbound request handle has the right type, and was previously instantiated in this connection.



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