org.jscience.net
Class SecureConnection

java.lang.Object
  extended by org.jscience.net.SecureConnection
All Implemented Interfaces:
NetConnection

public class SecureConnection
extends java.lang.Object
implements NetConnection

SecureConnection is a small wrapper for NetConnection objects, which provides automatic encoding/decoding of messages. objects as Encoded objects.

See Also:
Encoded, NetConnection

Constructor Summary
SecureConnection(NetConnection con, SynchronousKey key)
          Creates a new SecureConnection object.
 
Method Summary
 void close()
          DOCUMENT ME!
 NetConnection getEmbeddedConnection()
          DOCUMENT ME!
 SynchronousKey getKey()
          DOCUMENT ME!
 java.lang.Object getSignature()
          DOCUMENT ME!
 java.net.Socket getSocket()
          DOCUMENT ME!
 boolean isActive()
          DOCUMENT ME!
 java.lang.Object readMessage()
          extracts the encoded object from the Encoded object received
 void sendMessage(java.lang.Object message)
          every message will be encoded before it is sent unless it is already an Encoded object
 void setKey(SynchronousKey key)
          DOCUMENT ME!
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SecureConnection

public SecureConnection(NetConnection con,
                        SynchronousKey key)
Creates a new SecureConnection object.

Parameters:
con - DOCUMENT ME!
key - DOCUMENT ME!
Method Detail

getKey

public SynchronousKey getKey()
DOCUMENT ME!

Returns:
DOCUMENT ME!

setKey

public void setKey(SynchronousKey key)
DOCUMENT ME!

Parameters:
key - DOCUMENT ME!
Throws:
java.lang.NullPointerException - DOCUMENT ME!

getEmbeddedConnection

public NetConnection getEmbeddedConnection()
DOCUMENT ME!

Returns:
DOCUMENT ME!

close

public void close()
DOCUMENT ME!

Specified by:
close in interface NetConnection

getSignature

public java.lang.Object getSignature()
DOCUMENT ME!

Specified by:
getSignature in interface NetConnection
Returns:
DOCUMENT ME!

getSocket

public java.net.Socket getSocket()
DOCUMENT ME!

Specified by:
getSocket in interface NetConnection
Returns:
DOCUMENT ME!

isActive

public boolean isActive()
DOCUMENT ME!

Specified by:
isActive in interface NetConnection
Returns:
DOCUMENT ME!

readMessage

public java.lang.Object readMessage()
                             throws java.io.IOException,
                                    java.lang.ClassNotFoundException
extracts the encoded object from the Encoded object received

Specified by:
readMessage in interface NetConnection
Returns:
DOCUMENT ME!
Throws:
java.io.IOException - also if the key is incorrect when an Encoded message was received
java.lang.ClassNotFoundException - DOCUMENT ME!

sendMessage

public void sendMessage(java.lang.Object message)
                 throws java.io.IOException
every message will be encoded before it is sent unless it is already an Encoded object

Specified by:
sendMessage in interface NetConnection
Parameters:
message - DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!