| java.lang.Object com.sun.midp.ssl.SSLStreamConnection
SSLStreamConnection | public class SSLStreamConnection implements StreamConnection(Code) | | The SSLStreamConnection class implements the StreamConnection
interface. Data exchanged through a SSLStreamConnection is
automatically protected by SSL. Currently, only SSL version 3.0
is supported and the list of cipher suites proposed
by the client is hardcoded to {SSL_RSA_WITH_RC4_128_MD5,
SSL_RSA_EXPORT_WITH_RC4_40_MD5}. This version of the implementation
does not support client authentication at the SSL layer -- a feature
that is rarely used.
Typical usage of this class by an application would be along the
following lines:
// create a TCP connection
StreamConnection t = Connector.open("socket://www.server.com:443");
// Create an SSL connection
SSLStreamConnection s = new SSLStreamConnection("www.server.com", 443,
t.openInputStream(), t.openOutputStream());
t.close();
// obtain the associated input/output streams
OutputStream sout = s.openOutputStream();
InputStream sin = s.openInputStream();
...
// send SSL-protected data by writing to sout and
// receive SSL-protected by reading from sin
...
sin.close();
sout.close();
s.close(); // close the SSL connection when done
|
Field Summary | |
final static int | CLOSED Indicates that a stream is closed. | final static int | OPEN Indicates that a stream is opened. | final static int | READY Indicates that a is ready to be opened. | int | inputStreamState State of the input stream given out by getInputStream. | int | outputStreamState State of the output stream given out by getOutputStream. |
CLOSED | final static int CLOSED(Code) | | Indicates that a stream is closed.
|
OPEN | final static int OPEN(Code) | | Indicates that a stream is opened.
|
READY | final static int READY(Code) | | Indicates that a is ready to be opened.
|
inputStreamState | int inputStreamState(Code) | | State of the input stream given out by getInputStream.
|
outputStreamState | int outputStreamState(Code) | | State of the output stream given out by getOutputStream.
|
SSLStreamConnection | public SSLStreamConnection(String host, int port, InputStream in, OutputStream out, CertStore cs) throws IOException(Code) | | Establish and SSL session over a reliable stream.
This connection will forward the input and output stream close methods
to the given connection. If the caller wants to have the given
connection closed with this connection, the caller can close given
connection after constructing this connection, but leaving the closing
of the streams to this connection.
Parameters: host - hostname of the SSL server Parameters: port - port number of the SSL server Parameters: in - InputStream associated with the StreamConnection Parameters: out - OutputStream associated with the StreamConnection Parameters: cs - trusted certificate store to be used for this connection exception: IOException - if there is a problem initializing the SSLdata structures or the SSL handshake fails |
cleanupIfNeeded | void cleanupIfNeeded() throws IOException(Code) | | Closes the SSL connection. The underlying TCP socket, over which
SSL is layered, is also closed unless the latter was opened by
an external application and its input/output streams were passed
as argument to the SSLStreamConnection constructor.
exception: IOException - if the SSL connection could not beterminated cleanly |
close | public synchronized void close() throws IOException(Code) | | Closes the SSL connection. The underlying TCP socket, over which
SSL is layered, is also closed unless the latter was opened by
an external application and its input/output streams were passed
as argument to the SSLStreamConnection constructor.
exception: IOException - if the SSL connection could not beterminated cleanly |
getCipherSuite | String getCipherSuite()(Code) | | Returns the cipher suite in use for the connection.
The value returned is one of the CipherSuite definitions
in Appendix C of RFC 2246.
The cipher suite string should be used to represent the
actual parameters used to establish the connection regardless
of whether the secure connection uses SSL V3 or TLS 1.0 or WTLS.
a String containing the cipher suite in use |
getSecurityInfo | public SecurityInfo getSecurityInfo() throws IOException(Code) | | Returns the security information associated with this connection.
the security information associated with this open connection exception: IOException - if the connection is closed |
getServerCertificate | public X509Certificate getServerCertificate()(Code) | | Returns the server certificate associated with this connection.
the server certificate associated with this connection |
openDataInputStream | public DataInputStream openDataInputStream() throws IOException(Code) | | Returns the DataInputStream associated with this SSLStreamConnection.
exception: IOException - if the connection is not open or the stream was already open a DataInputStream object |
openDataOutputStream | public DataOutputStream openDataOutputStream() throws IOException(Code) | | Returns the DataOutputStream associated with this SSLStreamConnection.
exception: IOException - if the connection is not open or the stream was already open a DataOutputStream object |
openInputStream | public synchronized InputStream openInputStream() throws IOException(Code) | | Returns the InputStream associated with this SSLStreamConnection.
InputStream object from which SSL protected bytes canbe read exception: IOException - if the connection is not open or the stream was already open |
openOutputStream | public synchronized OutputStream openOutputStream() throws IOException(Code) | | Returns the OutputStream associated with this SSLStreamConnection.
OutputStream object such that bytes written to this streamare sent over an SSL secured channel exception: IOException - if the connection is not open or the stream was already open |
|
|