net.cnri.dobj
Class DOConnection

java.lang.Object
  extended by net.cnri.dobj.DOConnection
Direct Known Subclasses:
DOClientConnection, DOServerConnection

public class DOConnection
extends java.lang.Object

This class encapsulates the connection to a digital object server. A connection comprises a multiplexed set of channels, each channel being a pair of input/output streams, with one channel being used for controlling the connection (opening new channels, negotiating authentication, etc). The protocol is flexible due to the use of simple text control messages, connection parameter negotiation (protocol version, encryption method, etc).


Field Summary
static int CONTROL_CHANNEL_ID
           
 boolean DEBUG
           
 boolean DEBUG_BLOCKING
           
static java.util.Hashtable DEBUG_BUFFERS
           
 boolean DEBUG_BYTES
           
 boolean DEBUG_CONTROL
           
static boolean DEFAULT_DEBUG
           
static boolean DEFAULT_DEBUG_BLOCKING
           
static boolean DEFAULT_DEBUG_BYTES
           
static boolean DEFAULT_DEBUG_CONTROL
           
static int DEFAULT_READ_BUFFER_SIZE
           
static int DEFAULT_WRITE_BUFFER_SIZE
           
static java.lang.String ERROR_RESPONSE_CODE
           
static long MAX_BYTES_IN_BLOCKING_WINDOW
           
static long MIN_BYTES_IN_BLOCKING_WINDOW
           
static java.lang.String SUCCESS_RESPONSE_CODE
           
 
Constructor Summary
DOConnection(DOAuthentication authentication)
           
 
Method Summary
 void close()
           
static java.lang.String decodeUTF8(byte[] buf)
          Decode a UTF8 byte array into a String
static java.lang.String decodeUTF8(byte[] buf, int offset, int len)
          Decode a UTF8 byte array into a String
static byte[] encodeUTF8(java.lang.String str)
          Encode a String into a UTF8 byte array
 java.lang.String getAuthID()
          Return the identifier that we are using to identify ourself
 int getProtocolMajorVersion()
          Return the major protocol version of this connection if the connection handshake has already taken place.
 int getProtocolMinorVersion()
          Return the minor protocol version of this connection if the connection handshake has already taken place.
static net.handle.hdllib.Resolver getResolver()
          Returns a singleton Resolver object.
 java.net.Socket getSocket()
          Returns the socket over which the connection is made
 boolean isEncrypted()
          Returns true iff this connection is encrypted in some way.
 boolean isOpen()
          Returns true iff the connection is still open
 java.security.PublicKey[] resolvePublicKeys(java.lang.String clientID)
          Securely resolve a public key for the given handle
 void setListener(DOConnectionListener newListener)
          Sets the listener that will be notified when new channels are opened.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEBUG_BUFFERS

public static java.util.Hashtable DEBUG_BUFFERS

CONTROL_CHANNEL_ID

public static final int CONTROL_CHANNEL_ID
See Also:
Constant Field Values

DEFAULT_DEBUG_BYTES

public static final boolean DEFAULT_DEBUG_BYTES
See Also:
Constant Field Values

DEFAULT_DEBUG_CONTROL

public static final boolean DEFAULT_DEBUG_CONTROL
See Also:
Constant Field Values

DEFAULT_DEBUG

public static final boolean DEFAULT_DEBUG
See Also:
Constant Field Values

DEFAULT_DEBUG_BLOCKING

public static final boolean DEFAULT_DEBUG_BLOCKING
See Also:
Constant Field Values

MAX_BYTES_IN_BLOCKING_WINDOW

public static long MAX_BYTES_IN_BLOCKING_WINDOW

MIN_BYTES_IN_BLOCKING_WINDOW

public static long MIN_BYTES_IN_BLOCKING_WINDOW

DEBUG

public boolean DEBUG

DEBUG_CONTROL

public boolean DEBUG_CONTROL

DEBUG_BYTES

public boolean DEBUG_BYTES

DEBUG_BLOCKING

public boolean DEBUG_BLOCKING

DEFAULT_WRITE_BUFFER_SIZE

public static final int DEFAULT_WRITE_BUFFER_SIZE
See Also:
Constant Field Values

DEFAULT_READ_BUFFER_SIZE

public static final int DEFAULT_READ_BUFFER_SIZE
See Also:
Constant Field Values

SUCCESS_RESPONSE_CODE

public static final java.lang.String SUCCESS_RESPONSE_CODE
See Also:
Constant Field Values

ERROR_RESPONSE_CODE

public static final java.lang.String ERROR_RESPONSE_CODE
See Also:
Constant Field Values
Constructor Detail

DOConnection

public DOConnection(DOAuthentication authentication)
Method Detail

getProtocolMajorVersion

public int getProtocolMajorVersion()
Return the major protocol version of this connection if the connection handshake has already taken place.


getProtocolMinorVersion

public int getProtocolMinorVersion()
Return the minor protocol version of this connection if the connection handshake has already taken place.


getAuthID

public final java.lang.String getAuthID()
Return the identifier that we are using to identify ourself


resolvePublicKeys

public java.security.PublicKey[] resolvePublicKeys(java.lang.String clientID)
Securely resolve a public key for the given handle


isEncrypted

public boolean isEncrypted()
Returns true iff this connection is encrypted in some way.


isOpen

public boolean isOpen()
Returns true iff the connection is still open


setListener

public void setListener(DOConnectionListener newListener)
Sets the listener that will be notified when new channels are opened.


close

public void close()
           throws java.io.IOException
Throws:
java.io.IOException

getSocket

public java.net.Socket getSocket()
Returns the socket over which the connection is made


encodeUTF8

public static final byte[] encodeUTF8(java.lang.String str)
Encode a String into a UTF8 byte array


decodeUTF8

public static final java.lang.String decodeUTF8(byte[] buf,
                                                int offset,
                                                int len)
Decode a UTF8 byte array into a String


decodeUTF8

public static final java.lang.String decodeUTF8(byte[] buf)
Decode a UTF8 byte array into a String


getResolver

public static final net.handle.hdllib.Resolver getResolver()
Returns a singleton Resolver object.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object