public interface SecureConnection extends SocketConnection
Connector.open
with the scheme "ssl" and the secure
connection is established before open
returns.
If the secure connection cannot be established due to errors
related to certificates a CertificateException
is thrown.
A secure socket is accessed using a generic connection string
with an explicit host and port number. The host may be specified
as a fully qualified host name or
IPv4 number.
e.g. ssl://host.com:79
defines a target socket on the
host.com
system at
port 79
.
Note that RFC1900 recommends the use of names rather than IP numbers for best results in the event of IP number reassignment.
A secure connection MUST be implemented by one or more of the following specifications:
The URI must conform to the BNF syntax specified below. If the URI
does not conform to this syntax, an IllegalArgumentException
is thrown.
<socket_connection_string> | ::= "ssl://"<hostport> |
<hostport> | ::= host ":" port |
<host> | ::= host name or IP address |
<port> | ::= numeric port number |
The following examples show how a SecureConnection
would be used to access a sample loopback program.
SecureConnection sc = (SecureConnection) Connector.open("ssl://host.com:79"); SecurityInfo info = sc.getSecurityInfo(); boolean isTLS = (info.getProtocolName().equals("TLS")); sc.setSocketOption(SocketConnection.LINGER, 5); InputStream is = sc.openInputStream(); OutputStream os = sc.openOutputStream(); os.write("\r\n".getBytes()); int ch = 0; while(ch != -1) { ch = is.read(); } is.close(); os.close(); sc.close();
Modifier and Type | Method and Description |
---|---|
SecurityInfo |
getSecurityInfo()
Return the security information associated with this connection
when it was opened.
|
getAddress, getLocalAddress, getLocalPort, getPort, getSocketOption, setSocketOption
openDataInputStream, openInputStream
openDataOutputStream, openOutputStream
close
SecurityInfo getSecurityInfo() throws IOException
IOException
- if an arbitrary connection failure occursCopyright (c) 1990, 2012, Oracle and/or its affiliates. All rights reserved.