net.jini.jeri.kerberos
Class KerberosEndpoint.ConnectionImpl

java.lang.Object
  extended by net.jini.jeri.kerberos.KerberosUtil.Connection
      extended by net.jini.jeri.kerberos.KerberosEndpoint.ConnectionImpl
All Implemented Interfaces:
Connection
Enclosing class:
KerberosEndpoint

private final class KerberosEndpoint.ConnectionImpl
extends KerberosUtil.Connection
implements Connection

Implementation class of the client side connection abstraction


Field Summary
private  InputStream istream
          InputStream this connection will provide to the upper layer
private static int KRB_AP_ERR_REPEAT
          Kerberos error code defined in RFC1510 (Request is a replay)
private  OutputStream ostream
          OutputStream this connection will provide to the upper layer
 
Fields inherited from class net.jini.jeri.kerberos.KerberosUtil.Connection
clientPrincipal, connectionLogger, dis, doDelegation, doEncryption, dos, gssContext, INTEGRITY_QOP, PRIVACY_QOP, sock
 
Constructor Summary
KerberosEndpoint.ConnectionImpl(Socket sock, KerberosUtil.Config config)
          Establish a connection to server.
 
Method Summary
(package private)  void checkConnectPermission()
          Check whether the caller has sufficient permissions to reuse the socket that this connection has connected with.
private  void establishContext()
          Exchange handshake messages with server to establish the session or context of the connection.
 SocketChannel getChannel()
          Returns a socket channel that performs I/O on this connection, or null if no socket channel is available.
(package private)  KerberosEndpoint getEndpoint()
          Get the enclosing endpoint instance
 InputStream getInputStream()
          Returns an input stream that reads data from this connection.
 OutputStream getOutputStream()
          Returns an output stream that writes data to this connection.
 InvocationConstraints getUnfulfilledConstraints(OutboundRequestHandle handle)
          Implements OutboundRequest.getUnfulfilledConstraints for a request with the specified handle.
 void populateContext(OutboundRequestHandle handle, Collection context)
          Populates the supplied collection with context information representing a request with the specified handle.
 IOException readResponseData(OutboundRequestHandle handle, InputStream in)
          Reads from the specified stream any per-response data required by this connection for a request with the specified handle.
(package private)  boolean satisfies(KerberosUtil.Config config)
          Check whether this connection can satisfy the requirements specified by the given configuration.
(package private)  boolean switchTo(KerberosUtil.Config config)
          Switch an idle connection to satisfy the given configuration.
 String toString()
          Returns a string representation of this connection.
 void writeRequestData(OutboundRequestHandle handle, OutputStream out)
          Writes to the specified stream any per-request data required by this connection for a request with the specified handle.
 
Methods inherited from class net.jini.jeri.kerberos.KerberosUtil.Connection
close, flush, read, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.jini.jeri.connection.Connection
close
 

Field Detail

KRB_AP_ERR_REPEAT

private static final int KRB_AP_ERR_REPEAT
Kerberos error code defined in RFC1510 (Request is a replay)

See Also:
Constant Field Values

istream

private InputStream istream
InputStream this connection will provide to the upper layer


ostream

private OutputStream ostream
OutputStream this connection will provide to the upper layer

Constructor Detail

KerberosEndpoint.ConnectionImpl

KerberosEndpoint.ConnectionImpl(Socket sock,
                                KerberosUtil.Config config)
                          throws IOException
Establish a connection to server.

Parameters:
sock - socket over which the connection traffic will be carried
config - a configuration object that specifies how the connection should be setup
Throws:
IOException - if the connection establishment handshake fails
Method Detail

getOutputStream

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

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

getInputStream

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

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

getChannel

public SocketChannel getChannel()
Description copied from interface: Connection
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 Connection
Returns:
a socket channel that performs I/O on this connection, or null

populateContext

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

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

getUnfulfilledConstraints

public InvocationConstraints getUnfulfilledConstraints(OutboundRequestHandle handle)
Description copied from interface: Connection
Implements OutboundRequest.getUnfulfilledConstraints for a request with the specified handle.

Specified by:
getUnfulfilledConstraints in interface Connection
Parameters:
handle - the handle for the request
Returns:
the constraints for the request that must be partially or fully implemented by higher layers

writeRequestData

public void writeRequestData(OutboundRequestHandle handle,
                             OutputStream out)
Description copied from interface: Connection
Writes to the specified stream any per-request data required by this connection for a request with the specified handle.

This method is invoked by ConnectionManager with the request output stream of the OutboundRequest that it creates for the request. This method can be used, for example, to convey per-request information about delegation, client authentication, or client privileges.

There may be multiple requests in progress concurrently over this connection, and data written to the specified stream may be buffered and multiplexed with data from other requests before being written to this connection's underlying output stream. Therefore, this method should only write data to the specified stream and must not read any data from this connection's underlying input stream; data can, however, be subsequently read with readResponseData.

Specified by:
writeRequestData in interface Connection
Parameters:
handle - the handle for the request
out - the request output stream of the request

readResponseData

public IOException readResponseData(OutboundRequestHandle handle,
                                    InputStream in)
Description copied from interface: Connection
Reads from the specified stream any per-response data required by this connection for a request with the specified handle.

This method returns null if the information read (if any) indicates that the constraints are satisfied, and it returns an exception if the constraints could not be satisfied. If an exception is returned rather than thrown, the delivery status of a corresponding OutboundRequest will be false.

This method is invoked by ConnectionManager with the response input stream of the OutboundRequest that it creates for the request and the same handle that was passed to writeRequestData. This method can be used to read information produced by ServerConnection.processRequestData in response to the information sent by writeRequestData.

There may be multiple requests in progress concurrently over this connection, and data read from the specified stream may have been buffered and multiplexed with data from other requests being read from this connection's underlying input stream. Therefore, this method should only read data from the specified stream and must not write any data to this connection's underlying output stream.

Specified by:
readResponseData in interface Connection
Parameters:
handle - the handle for the request
in - the response input stream of the request
Returns:
null if the constraints are satisfied, or an exception if the constraints could not be satisfied

toString

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

Overrides:
toString in class Object

satisfies

boolean satisfies(KerberosUtil.Config config)
Check whether this connection can satisfy the requirements specified by the given configuration.


checkConnectPermission

void checkConnectPermission()
Check whether the caller has sufficient permissions to reuse the socket that this connection has connected with.


switchTo

boolean switchTo(KerberosUtil.Config config)
Switch an idle connection to satisfy the given configuration.

Parameters:
config - target configuration
Returns:
true if succeed, false otherwise. If false is returned, the connection is unchanged.

getEndpoint

KerberosEndpoint getEndpoint()
Get the enclosing endpoint instance


establishContext

private void establishContext()
                       throws IOException,
                              GSSException
Exchange handshake messages with server to establish the session or context of the connection.

Throws:
IOException
GSSException


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