Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.protocol.sip.net
Class SslNetworkLayer

java.lang.Object
  extended by net.java.sip.communicator.impl.protocol.sip.net.SslNetworkLayer
All Implemented Interfaces:
gov.nist.core.net.NetworkLayer
Direct Known Subclasses:
AndroidNetworkLayer

public class SslNetworkLayer
extends Object
implements gov.nist.core.net.NetworkLayer

Manages jain-sip socket creation. When dealing with ssl sockets we interact with the user when the certificate for some reason is not trusted.

Author:
Damian Minkov, Ingo Bauersachs, Sebastien Vincent

Constructor Summary
SslNetworkLayer()
          Creates the network layer.
 
Method Summary
 DatagramSocket createDatagramSocket()
          Constructs a datagram socket and binds it to any available port on the local host machine.
 DatagramSocket createDatagramSocket(int port, InetAddress laddr)
          Creates a datagram socket, bound to the specified local address.
 ServerSocket createServerSocket(int port, int backlog, InetAddress bindAddress)
          Creates a server with the specified port, listen backlog, and local IP address to bind to.
 Socket createSocket(InetAddress address, int port)
          Creates a stream socket and connects it to the specified port number at the specified IP address.
 Socket createSocket(InetAddress address, int port, InetAddress myAddress)
          Creates a stream socket and connects it to the specified port number at the specified IP address.
 Socket createSocket(InetAddress address, int port, InetAddress myAddress, int myPort)
          Creates a new Socket, binds it to myAddress:myPort and connects it to address:port.
 SSLServerSocket createSSLServerSocket(int port, int backlog, InetAddress bindAddress)
          Creates an SSL server with the specified port, listen backlog, and local IP address to bind to.
 SSLSocket createSSLSocket(InetAddress address, int port)
          Creates a stream SSL socket and connects it to the specified port number at the specified IP address.
 SSLSocket createSSLSocket(InetAddress address, int port, InetAddress myAddress)
          Creates a stream SSL socket and connects it to the specified port number at the specified IP address.
protected  SSLServerSocketFactory getSSLServerSocketFactory()
          Creates a ssl server socket factory.
protected  void setTrafficClass(DatagramSocket s)
          Sets the traffic class for the DatagramSocket.
protected  void setTrafficClass(Socket s)
          Sets the traffic class for the Socket.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SslNetworkLayer

public SslNetworkLayer()
Creates the network layer.

Method Detail

createServerSocket

public ServerSocket createServerSocket(int port,
                                       int backlog,
                                       InetAddress bindAddress)
                                throws IOException
Creates a server with the specified port, listen backlog, and local IP address to bind to. Comparable to "new java.net.ServerSocket(port,backlog,bindAddress);"

Specified by:
createServerSocket in interface gov.nist.core.net.NetworkLayer
Parameters:
port - the port
backlog - backlog
bindAddress - local address to use
Returns:
the newly created server socket.
Throws:
IOException - problem creating socket.

createSocket

public Socket createSocket(InetAddress address,
                           int port)
                    throws IOException
Creates a stream socket and connects it to the specified port number at the specified IP address.

Specified by:
createSocket in interface gov.nist.core.net.NetworkLayer
Parameters:
address - the address to connect.
port - the port to connect.
Returns:
the socket
Throws:
IOException - problem creating socket.

createDatagramSocket

public DatagramSocket createDatagramSocket()
                                    throws SocketException
Constructs a datagram socket and binds it to any available port on the local host machine. Comparable to "new java.net.DatagramSocket();"

Specified by:
createDatagramSocket in interface gov.nist.core.net.NetworkLayer
Returns:
the datagram socket
Throws:
SocketException - problem creating socket.

createDatagramSocket

public DatagramSocket createDatagramSocket(int port,
                                           InetAddress laddr)
                                    throws SocketException
Creates a datagram socket, bound to the specified local address. Comparable to "new java.net.DatagramSocket(port,laddr);"

Specified by:
createDatagramSocket in interface gov.nist.core.net.NetworkLayer
Parameters:
port - local port to use
laddr - local address to bind
Returns:
the datagram socket
Throws:
SocketException - problem creating socket.

createSSLServerSocket

public SSLServerSocket createSSLServerSocket(int port,
                                             int backlog,
                                             InetAddress bindAddress)
                                      throws IOException
Creates an SSL server with the specified port, listen backlog, and local IP address to bind to.

Specified by:
createSSLServerSocket in interface gov.nist.core.net.NetworkLayer
Parameters:
port - the port to listen to
backlog - backlog
bindAddress - the address to listen to
Returns:
the server socket.
Throws:
IOException - problem creating socket.

getSSLServerSocketFactory

protected SSLServerSocketFactory getSSLServerSocketFactory()
                                                    throws IOException
Creates a ssl server socket factory.

Returns:
the server socket factory.
Throws:
IOException - problem creating factory.

createSSLSocket

public SSLSocket createSSLSocket(InetAddress address,
                                 int port)
                          throws IOException
Creates a stream SSL socket and connects it to the specified port number at the specified IP address.

Specified by:
createSSLSocket in interface gov.nist.core.net.NetworkLayer
Parameters:
address - the address we are connecting to.
port - the port we use.
Returns:
the socket.
Throws:
IOException - problem creating socket.

createSSLSocket

public SSLSocket createSSLSocket(InetAddress address,
                                 int port,
                                 InetAddress myAddress)
                          throws IOException
Creates a stream SSL socket and connects it to the specified port number at the specified IP address.

Specified by:
createSSLSocket in interface gov.nist.core.net.NetworkLayer
Parameters:
address - the address we are connecting to.
port - the port we use.
myAddress - the local address to use
Returns:
the socket.
Throws:
IOException - problem creating socket.

createSocket

public Socket createSocket(InetAddress address,
                           int port,
                           InetAddress myAddress)
                    throws IOException
Creates a stream socket and connects it to the specified port number at the specified IP address. Comparable to "new java.net.Socket(address, port,localaddress);"

Specified by:
createSocket in interface gov.nist.core.net.NetworkLayer
Parameters:
address - the address to connect to.
port - the port we use.
myAddress - the local address to use.
Returns:
the created socket.
Throws:
IOException - problem creating socket.

createSocket

public Socket createSocket(InetAddress address,
                           int port,
                           InetAddress myAddress,
                           int myPort)
                    throws IOException
Creates a new Socket, binds it to myAddress:myPort and connects it to address:port.

Specified by:
createSocket in interface gov.nist.core.net.NetworkLayer
Parameters:
address - the InetAddress that we'd like to connect to.
port - the port that we'd like to connect to
myAddress - the address that we are supposed to bind on or null for the "any" address.
myPort - the port that we are supposed to bind on or 0 for a random one.
Returns:
a new Socket, bound on myAddress:myPort and connected to address:port.
Throws:
IOException - if binding or connecting the socket fail for a reason (exception relayed from the corresponding Socket methods)

setTrafficClass

protected void setTrafficClass(Socket s)
Sets the traffic class for the Socket.

Parameters:
s - Socket

setTrafficClass

protected void setTrafficClass(DatagramSocket s)
Sets the traffic class for the DatagramSocket.

Parameters:
s - DatagramSocket

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.