Project JXTA

net.jxta.impl.endpoint.tls
Class TlsConn

java.lang.Object
  extended bynet.jxta.impl.endpoint.tls.TlsConn

class TlsConn
extends Object

This class implements the TLS connection between two peers.

Properties:

net.jxta.impl.endpoint.tls.TMFAlgorithm - if defined provides the name of the trust manager factory alogrithm to use.


Nested Class Summary
(package private) static class TlsConn.HandshakeState
          Tracks the state of our TLS connection with a remote peer.
 
Field Summary
(package private) static int BOSIZE
           
(package private)  String closeLock
           
(package private)  EndpointAddress destAddr
          The address of the peer to which we will be forwarding ciphertext messages.
(package private)  long lastAccessed
          Time that something "good" last happened on the connection
(package private)  String lastAccessedLock
           
(package private)  int retrans
          Number of retransmissions we have received.
(package private)  TlsSocket tlsSocket
          Our synthetic socket which sends and receives the ciphertext.
(package private)  TlsTransport transport
          TLS transport this connection is working for.
 
Constructor Summary
(package private) TlsConn(TlsTransport tp, EndpointAddress destAddr, boolean client)
          Create a new connection
 
Method Summary
(package private)  void close(TlsConn.HandshakeState finalstate)
          Close this connection.
(package private)  void finishHandshake()
          Open the connection with the remote peer.
(package private)  TlsConn.HandshakeState getHandshakeState()
          Returns the current state of the connection
(package private)  void sendMessage(Message msg)
          sendMessage is called by the TlsMessenger each time a service or an application sends a new message over a TLS connection.
(package private)  boolean sendToRemoteTls(Message msg)
          Used by the TlsManager and the TlsConn in order to send a message, either a TLS connection establishement, or TLS fragments to the remote TLS.
(package private)  TlsConn.HandshakeState setHandshakeState(TlsConn.HandshakeState newstate)
          Changes the state of the connection.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BOSIZE

static final int BOSIZE
See Also:
Constant Field Values

transport

final TlsTransport transport
TLS transport this connection is working for.


destAddr

final EndpointAddress destAddr
The address of the peer to which we will be forwarding ciphertext messages.


lastAccessed

long lastAccessed
Time that something "good" last happened on the connection


lastAccessedLock

final String lastAccessedLock

closeLock

final String closeLock

retrans

int retrans
Number of retransmissions we have received.


tlsSocket

final TlsSocket tlsSocket
Our synthetic socket which sends and receives the ciphertext.

Constructor Detail

TlsConn

TlsConn(TlsTransport tp,
        EndpointAddress destAddr,
        boolean client)
  throws Exception
Create a new connection

Method Detail

toString

public String toString()

getHandshakeState

TlsConn.HandshakeState getHandshakeState()
Returns the current state of the connection

Returns:
the current state of the connection.

setHandshakeState

TlsConn.HandshakeState setHandshakeState(TlsConn.HandshakeState newstate)
Changes the state of the connection. Calls Object.notifyAll() to wake any threads waiting on connection state changes.

Parameters:
newstate - the new connection state.
Returns:
the previous state of the connection.

finishHandshake

void finishHandshake()
               throws IOException
Open the connection with the remote peer.

Throws:
IOException

close

void close(TlsConn.HandshakeState finalstate)
     throws IOException
Close this connection.

Parameters:
finalstate - state that the connection will be in after close.
Throws:
IOException

sendToRemoteTls

boolean sendToRemoteTls(Message msg)
                  throws IOException
Used by the TlsManager and the TlsConn in order to send a message, either a TLS connection establishement, or TLS fragments to the remote TLS.

Returns:
if true then message was sent, otherwise false.
Throws:
IOException - if there was a problem sending the message.

sendMessage

void sendMessage(Message msg)
           throws IOException
sendMessage is called by the TlsMessenger each time a service or an application sends a new message over a TLS connection. IOException is thrown when something goes wrong.

The message is encrypted by TLS ultimately calling JTlsOutputStream.write(byte[], int, int); with the resulting TLS Record(s).

Parameters:
msg - The plaintext message to be sent via this connection.
Throws:
IOException - for errors in sending the message.

JXTA J2SE