All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class iaik.security.ssl.SSLSocket

java.lang.Object
   |
   +----java.net.Socket
           |
           +----iaik.security.ssl.SSLSocket

public class SSLSocket
extends Socket
This class implements a socket to establish a secure connection according to the SSL protocol specified by Netscape Communications Corporation. All properties of this SSLSocket can be defined in a SSLContext.

See Also:
SSLContext

Constructor Index

 o SSLSocket(InetAddress, int, InetAddress, int, SSLContext)
Creates a SSL socket and connects it to the specified remote address on the specified remote port.
 o SSLSocket(InetAddress, int, SSLContext)
Creates a SSL stream socket and connects it to the specified port number at the specified IP address.
 o SSLSocket(String, int, InetAddress, int, SSLContext)
Creates a SSL socket and connects it to the specified remote host on the specified remote port.
 o SSLSocket(String, int, SSLContext)
Creates a SSL stream socket and connects it to the specified port number on the named host.

Method Index

 o getActiveCipherSuite()
Returns the active cipher suite.
 o getActiveCompressionMethod()
Returns the active compression method.
 o getInputStream()
Returns an input stream for this socket.
 o getOutputStream()
Returns an output stream for this socket.
 o getPeerCertificateChain()
Returns the certificate chain sent by the peer or null if the peer has no certificate.
 o isServer()
Returns true if this is the socket of a server.
 o setAutoHandshake(boolean)
Can be used to switch off the automatic start of the handshake procedure.
 o setDebugStream(PrintStream)
Enables debugging mode.
 o startHandshake()
Start a handshake procedure manually if autoHandshake is switched off.

Constructors

 o SSLSocket
 public SSLSocket(String host,
                  int port,
                  SSLContext context) throws IOException, UnknownHostException
Creates a SSL stream socket and connects it to the specified port number on the named host.

All properties of this SSLSocket are defined in the SSLContext.

Parameters:
host - the host name.
port - the port number.
context - the SSLContext for the new socket
Throws: IOException
if an error occurs when creating the socket
 o SSLSocket
 public SSLSocket(InetAddress address,
                  int port,
                  SSLContext context) throws IOException
Creates a SSL stream socket and connects it to the specified port number at the specified IP address.

All properties of this SSLSocket are defined in the SSLContext.

Parameters:
address - the IP address.
port - the port number.
context - the SSLContext for the new socket
Throws: IOException
if an error occurs when creating the socket
 o SSLSocket
 public SSLSocket(String host,
                  int port,
                  InetAddress localAddr,
                  int localPort,
                  SSLContext context) throws IOException
Creates a SSL socket and connects it to the specified remote host on the specified remote port. The Socket will also bind() to the local address and port supplied.

All properties of this SSLSocket are defined in the SSLContext.

Parameters:
host - the name of the remote host
port - the remote port
localAddr - the local address the socket is bound to
localPort - the local port the socket is bound to
context - the SSLContext for the new socket
Throws: IOException
if an error occurs when creating the socket
 o SSLSocket
 public SSLSocket(InetAddress address,
                  int port,
                  InetAddress localAddr,
                  int localPort,
                  SSLContext context) throws IOException
Creates a SSL socket and connects it to the specified remote address on the specified remote port. The Socket will also bind() to the local address and port supplied.

All properties of this SSLSocket are defined in the SSLContext.

Parameters:
address - the remote address
port - the remote port
localAddr - the local address the socket is bound to
localPort - the local port the socket is bound to
context - the SSLContext for the new socket
Throws: IOException
if an error occurs when creating the socket

Methods

 o isServer
 public boolean isServer()
Returns true if this is the socket of a server.

Returns:
true if this is the socket of a server
 o setAutoHandshake
 public void setAutoHandshake(boolean on)
Can be used to switch off the automatic start of the handshake procedure. If auto handshake is switched off the application has to start the handshaking process manually using the method startHandshake(). This kind of operation is used when connecting over a proxy or firewall.

Parameters:
on - true if handshake should start automatically, false otherwise
See Also:
startHandshake
 o getPeerCertificateChain
 public X509Certificate[] getPeerCertificateChain()
Returns the certificate chain sent by the peer or null if the peer has no certificate. X509Certificate[0] contains the peers certificate. X509Certificate[len-1] contains the top CA certificate.

Returns:
the certificate chain sent by the peer
 o getActiveCipherSuite
 public CipherSuite getActiveCipherSuite()
Returns the active cipher suite.

Returns:
the active cipher suite
See Also:
CipherSuite
 o getActiveCompressionMethod
 public CompressionMethod getActiveCompressionMethod()
Returns the active compression method.

Returns:
the active compression method
See Also:
CompressionMethod
 o startHandshake
 public void startHandshake() throws IOException
Start a handshake procedure manually if autoHandshake is switched off.

Throws: IOException
if an error occurs during the handshake procedure
See Also:
setAutoHandshake
 o getOutputStream
 public OutputStream getOutputStream() throws IOException
Returns an output stream for this socket.

Returns:
an output stream for writing bytes to this socket
Throws: IOException
if an error occurs when creating the output stream
Overrides:
getOutputStream in class Socket
 o getInputStream
 public InputStream getInputStream() throws IOException
Returns an input stream for this socket.

Returns:
an input stream for reading bytes from this socket.
Throws: IOException
if an error occurs when creating the input stream.
Overrides:
getInputStream in class Socket
 o setDebugStream
 public void setDebugStream(PrintStream ps)
Enables debugging mode.

Parameters:
ps - the PrintStream to which debug information shall be written

All Packages  Class Hierarchy  This Package  Previous  Next  Index