gov.nist.javax.sip.stack
Class TLSMessageChannel

java.lang.Object
  extended by gov.nist.javax.sip.stack.MessageChannel
      extended by gov.nist.javax.sip.stack.ConnectionOrientedMessageChannel
          extended by gov.nist.javax.sip.stack.TLSMessageChannel
All Implemented Interfaces:
ParseExceptionListener, SIPMessageListener, RawMessageChannel, Runnable

public class TLSMessageChannel
extends ConnectionOrientedMessageChannel

This is sipStack for TLS connections. This abstracts a stream of parsed messages. The SIP sipStack starts this from the main SIPStack class for each connection that it accepts. It starts a message parser in its own thread and talks to the message parser via a pipe. The message parser calls back via the parseError or processMessage functions that are defined as part of the SIPMessageListener interface.

Version:
1.2 $Revision: 1.43 $ $Date: 2010-12-02 22:44:53 $
Author:
M. Ranganathan
See Also:
PipelinedMsgParser

Field Summary
 
Fields inherited from class gov.nist.javax.sip.stack.ConnectionOrientedMessageChannel
isCached, isRunning, key, myAddress, myClientInputStream, myParser, myPort, mySock, mythread, peerAddress, peerPort, peerPortAdvertisedInHeaders, peerProtocol, sipStack
 
Fields inherited from class gov.nist.javax.sip.stack.MessageChannel
messageProcessor, useCount
 
Constructor Summary
protected TLSMessageChannel(InetAddress inetAddr, int port, SIPTransactionStack sipStack, TLSMessageProcessor messageProcessor)
          Constructor - connects to the given inet address.
protected TLSMessageChannel(Socket sock, SIPTransactionStack sipStack, TLSMessageProcessor msgProcessor, String threadName)
          Constructor - gets called from the SIPStack class with a socket on accepting a new client.
 
Method Summary
 void close(boolean removeSocket)
          Close the message channel.
 boolean equals(Object other)
          Equals predicate.
 HandshakeCompletedListenerImpl getHandshakeCompletedListener()
           
 String getTransport()
          get the transport string.
 void handleException(ParseException ex, SIPMessage sipMessage, Class hdrClass, String header, String message)
          Exception processor for exceptions detected from the parser.
 boolean isHandshakeCompleted()
           
 boolean isSecure()
          TLS Is a secure protocol.
 void run()
          This gets invoked when thread.start is called from the constructor.
protected  void sendMessage(byte[] msg, boolean retry)
          Send message to whoever is connected to us.
 void sendMessage(byte[] message, InetAddress receiverAddress, int receiverPort, boolean retry)
          Send a message to a specified address.
 void setHandshakeCompleted(boolean handshakeCompleted)
           
 void setHandshakeCompletedListener(HandshakeCompletedListener handshakeCompletedListenerImpl)
           
 
Methods inherited from class gov.nist.javax.sip.stack.ConnectionOrientedMessageChannel
cancelPingKeepAliveTimeoutTaskIfStarted, close, getKeepAliveTimeout, getKey, getPeerAddress, getPeerInetAddress, getPeerPacketSourceAddress, getPeerPacketSourcePort, getPeerPort, getPeerProtocol, getSIPStack, getViaHost, getViaPort, isReliable, processMessage, processMessage, rescheduleKeepAliveTimeout, sendMessage, sendSingleCLRF, setKeepAliveTimeout, uncache
 
Methods inherited from class gov.nist.javax.sip.stack.MessageChannel
createBadReqRes, getEncapsulatedClientTransaction, getHost, getHostPort, getKey, getKey, getMessageProcessor, getPeerHostPort, getPort, getRawIpSourceAddress, getViaHeader, getViaHostPort, logMessage, logResponse, sendMessage, sendMessage, setEncapsulatedClientTransaction
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TLSMessageChannel

protected TLSMessageChannel(Socket sock,
                            SIPTransactionStack sipStack,
                            TLSMessageProcessor msgProcessor,
                            String threadName)
                     throws IOException
Constructor - gets called from the SIPStack class with a socket on accepting a new client. All the processing of the message is done here with the sipStack being freed up to handle new connections. The sock input is the socket that is returned from the accept. Global data that is shared by all threads is accessible in the Server structure.

Parameters:
sock - Socket from which to read and write messages. The socket is already connected (was created as a result of an accept).
sipStack - Ptr to SIP Stack
msgProcessor - -- the message processor that created us.
Throws:
IOException

TLSMessageChannel

protected TLSMessageChannel(InetAddress inetAddr,
                            int port,
                            SIPTransactionStack sipStack,
                            TLSMessageProcessor messageProcessor)
                     throws IOException
Constructor - connects to the given inet address.

Parameters:
inetAddr - inet address to connect to.
sipStack - is the sip sipStack from which we are created.
messageProcessor - -- the message processor that created us.
Throws:
IOException - if we cannot connect.
Method Detail

close

public void close(boolean removeSocket)
Close the message channel.

Specified by:
close in class ConnectionOrientedMessageChannel

getTransport

public String getTransport()
get the transport string.

Specified by:
getTransport in class MessageChannel
Returns:
"tcp" in this case.

sendMessage

protected void sendMessage(byte[] msg,
                           boolean retry)
                    throws IOException
Send message to whoever is connected to us. Uses the topmost via address to send to.

Specified by:
sendMessage in class ConnectionOrientedMessageChannel
Parameters:
msg - is the message to send.
retry -
Throws:
IOException

sendMessage

public void sendMessage(byte[] message,
                        InetAddress receiverAddress,
                        int receiverPort,
                        boolean retry)
                 throws IOException
Send a message to a specified address.

Specified by:
sendMessage in class MessageChannel
Parameters:
message - Pre-formatted message to send.
receiverAddress - Address to send it to.
receiverPort - Receiver port.
Throws:
IOException - If there is a problem connecting or sending.

handleException

public void handleException(ParseException ex,
                            SIPMessage sipMessage,
                            Class hdrClass,
                            String header,
                            String message)
                     throws ParseException
Exception processor for exceptions detected from the parser. (This is invoked by the parser when an error is detected).

Parameters:
sipMessage - -- the message that incurred the error.
ex - -- parse exception detected by the parser.
header - -- header that caused the error.
message - -- message where this header was detected.
Throws:
ParseException - Thrown if we want to reject the message.

equals

public boolean equals(Object other)
Equals predicate.

Overrides:
equals in class Object
Parameters:
other - is the other object to compare ourselves to for equals

isSecure

public boolean isSecure()
TLS Is a secure protocol.

Specified by:
isSecure in class MessageChannel

setHandshakeCompletedListener

public void setHandshakeCompletedListener(HandshakeCompletedListener handshakeCompletedListenerImpl)

getHandshakeCompletedListener

public HandshakeCompletedListenerImpl getHandshakeCompletedListener()
Returns:
the handshakeCompletedListener

run

public void run()
Description copied from class: ConnectionOrientedMessageChannel
This gets invoked when thread.start is called from the constructor. Implements a message loop - reading the tcp connection and processing messages until we are done or the other end has closed.

Specified by:
run in interface Runnable
Overrides:
run in class ConnectionOrientedMessageChannel

isHandshakeCompleted

public boolean isHandshakeCompleted()
Returns:
the handshakeCompleted

setHandshakeCompleted

public void setHandshakeCompleted(boolean handshakeCompleted)
Parameters:
handshakeCompleted - the handshakeCompleted to set


Copyright © 2012. All Rights Reserved.