Holger's
Java API

com.antelmann.net
Class SecureConnection

java.lang.Object
  extended by com.antelmann.net.SecureConnection
All Implemented Interfaces:
NetConnection, Closeable

public class SecureConnection
extends Object
implements NetConnection

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

Author:
Holger Antelmann
See Also:
Encoded, NetConnection

Constructor Summary
SecureConnection(NetConnection con, SynchronousKey key)
           
 
Method Summary
 void close()
           
 NetConnection getEmbeddedConnection()
           
 Handshake getHandshake()
          returns the identification type object for this connection; this signature is the same on both sides of the connection.
 SynchronousKey getKey()
           
 Socket getSocket()
          returns the underlying Socket of this connection
 boolean isActive()
          returns whether this NetConnection is currently active
 Object readMessage()
          extracts the encoded object from the Encoded object received
 void sendMessage(Object message)
          every message will be encoded before it is sent unless it is already an Encoded object
 void setKey(SynchronousKey key)
           
 
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)
Method Detail

getKey

public SynchronousKey getKey()

setKey

public void setKey(SynchronousKey key)

getEmbeddedConnection

public NetConnection getEmbeddedConnection()

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Throws:
IOException

getHandshake

public Handshake getHandshake()
Description copied from interface: NetConnection
returns the identification type object for this connection; this signature is the same on both sides of the connection. Note that this object requires the equals(Object obj) method to work after serialization/de-serialization; Strings work just fine.

Specified by:
getHandshake in interface NetConnection

getSocket

public Socket getSocket()
Description copied from interface: NetConnection
returns the underlying Socket of this connection

Specified by:
getSocket in interface NetConnection

isActive

public boolean isActive()
Description copied from interface: NetConnection
returns whether this NetConnection is currently active

Specified by:
isActive in interface NetConnection

readMessage

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

Specified by:
readMessage in interface NetConnection
Throws:
IOException - also if the key is incorrect when an Encoded message was received
ClassNotFoundException

sendMessage

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

Specified by:
sendMessage in interface NetConnection
Throws:
IOException


(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads