APIdia Launch Partner
Top Description Fields Constructors Methods
sun.security.ssl

public final Class SSLSocketFactoryImpl

extends SSLSocketFactory
Class Inheritance
Imports
java.io.*, java.net.*, javax.net.ssl.SSLSocketFactory

Implementation of an SSL socket factory. This provides the public hooks to create SSL sockets, using a "high level" programming interface which encapsulates system security policy defaults rather than offering application flexibility. In particular, it uses a configurable authentication context (and the keys held there) rather than offering any flexibility about which keys to use; that context defaults to the process-default context, but may be explicitly specified.
Author
David Brownell

Field Summary

Modifier and TypeField and Description
private final SSLContextImpl

Constructor Summary

AccessConstructor and Description
public
SSLSocketFactoryImpl()

Constructor used to instantiate the default factory.

pack-priv
SSLSocketFactoryImpl(SSLContextImpl context)

Constructs an SSL socket factory.

Method Summary

Modifier and TypeMethod and Description
public Socket

Returns:

the unconnected socket
createSocket
()

Overrides javax.net.SocketFactory.createSocket.

Creates an unconnected socket.

public Socket
createSocket(String
name of the host with which to connect
host
,
int
number of the server's port
port
)

Implements abstract javax.net.SocketFactory.createSocket.

Constructs an SSL connection to a named host at a specified port.

public Socket
createSocket(Socket
the existing socket
s
,
String
the server host
host
,
int
the server port
port
,
boolean
close the underlying socket when this socket is closed
autoClose
)

Implements abstract javax.net.ssl.SSLSocketFactory.createSocket.

Returns a socket layered over an existing socket to a ServerSocket on the named host, at the given port.

public Socket
createSocket(Socket s, InputStream consumed, boolean autoClose)

Overrides javax.net.ssl.SSLSocketFactory.createSocket.

Creates a server mode Socket layered over an existing connected socket, and is able to read data which has already been consumed/removed from the Socket's underlying InputStream.

public Socket
createSocket(InetAddress
the server's host
address
,
int
its port
port
)

Implements abstract javax.net.SocketFactory.createSocket.

Constructs an SSL connection to a server at a specified address and TCP port.

public Socket
createSocket(String host, int port, InetAddress clientAddress, int clientPort)

Implements abstract javax.net.SocketFactory.createSocket.

Constructs an SSL connection to a named host at a specified port.

public Socket
createSocket(InetAddress address, int port, InetAddress clientAddress, int clientPort)

Implements abstract javax.net.SocketFactory.createSocket.

Constructs an SSL connection to a server at a specified address and TCP port.

public String[]
getDefaultCipherSuites()

Implements abstract javax.net.ssl.SSLSocketFactory.getDefaultCipherSuites.

Returns the subset of the supported cipher suites which are enabled by default.

public String[]
getSupportedCipherSuites()

Implements abstract javax.net.ssl.SSLSocketFactory.getSupportedCipherSuites.

Returns the names of the cipher suites which could be enabled for use on an SSL connection.

Inherited from javax.net.ssl.SSLSocketFactory:
getDefault

Field Detail

contextback to summary
private final SSLContextImpl context

Constructor Detail

SSLSocketFactoryImplback to summary
public SSLSocketFactoryImpl() throws Exception

Constructor used to instantiate the default factory. This method is only called if the old "ssl.SocketFactory.provider" property in the java.security file is set.

SSLSocketFactoryImplback to summary
pack-priv SSLSocketFactoryImpl(SSLContextImpl context)

Constructs an SSL socket factory.

Method Detail

createSocketback to summary
public Socket createSocket()

Overrides javax.net.SocketFactory.createSocket.

Creates an unconnected socket.

Returns:Socket

the unconnected socket

Annotations
@Override
See Also
java.net.Socket#connect(java.net.SocketAddress, int)
createSocketback to summary
public Socket createSocket(String host, int port) throws IOException

Implements abstract javax.net.SocketFactory.createSocket.

Constructs an SSL connection to a named host at a specified port. This acts as the SSL client, and may authenticate itself or rejoin existing SSL sessions allowed by the authentication context which has been configured.

Parameters
host:String

name of the host with which to connect

port:int

number of the server's port

Annotations
@Override
Exceptions
IOException:

Doc from javax.net.SocketFactory.createSocket.

if an I/O error occurs when creating the socket

createSocketback to summary
public Socket createSocket(Socket s, String host, int port, boolean autoClose) throws IOException

Implements abstract javax.net.ssl.SSLSocketFactory.createSocket.

Returns a socket layered over an existing socket to a ServerSocket on the named host, at the given port. This constructor can be used when tunneling SSL through a proxy. The host and port refer to the logical destination server. This socket is configured using the socket options established for this factory.

Parameters
s:Socket

the existing socket

host:String

the server host

port:int

the server port

autoClose:boolean

close the underlying socket when this socket is closed

Annotations
@Override
Exceptions
IOException:
if the connection can't be established
UnknownHostException:
if the host is not known
createSocketback to summary
public Socket createSocket(Socket s, InputStream consumed, boolean autoClose) throws IOException

Overrides javax.net.ssl.SSLSocketFactory.createSocket.

Doc from javax.net.ssl.SSLSocketFactory.createSocket.

Creates a server mode Socket layered over an existing connected socket, and is able to read data which has already been consumed/removed from the Socket's underlying InputStream.

This method can be used by a server application that needs to observe the inbound data but still create valid SSL/TLS connections: for example, inspection of Server Name Indication (SNI) extensions (See section 3 of TLS Extensions (RFC6066)). Data that has been already removed from the underlying InputStream should be loaded into the consumed stream before this method is called, perhaps using a java.io.ByteArrayInputStream. When this Socket begins handshaking, it will read all the data in consumed until it reaches EOF, then all further data is read from the underlying InputStream as usual.

The returned socket is configured using the socket options established for this factory, and is set to use server mode when handshaking (see SSLSocket#setUseClientMode(boolean)).

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs when creating the socket
createSocketback to summary
public Socket createSocket(InetAddress address, int port) throws IOException

Implements abstract javax.net.SocketFactory.createSocket.

Constructs an SSL connection to a server at a specified address and TCP port. This acts as the SSL client, and may authenticate itself or rejoin existing SSL sessions allowed by the authentication context which has been configured.

Parameters
address:InetAddress

the server's host

port:int

its port

Annotations
@Override
Exceptions
IOException:

Doc from javax.net.SocketFactory.createSocket.

if an I/O error occurs when creating the socket

createSocketback to summary
public Socket createSocket(String host, int port, InetAddress clientAddress, int clientPort) throws IOException

Implements abstract javax.net.SocketFactory.createSocket.

Constructs an SSL connection to a named host at a specified port. This acts as the SSL client, and may authenticate itself or rejoin existing SSL sessions allowed by the authentication context which has been configured. The socket will also bind() to the local address and port supplied.

Annotations
@Override
Exceptions
IOException:

Doc from javax.net.SocketFactory.createSocket.

if an I/O error occurs when creating the socket

createSocketback to summary
public Socket createSocket(InetAddress address, int port, InetAddress clientAddress, int clientPort) throws IOException

Implements abstract javax.net.SocketFactory.createSocket.

Constructs an SSL connection to a server at a specified address and TCP port. This acts as the SSL client, and may authenticate itself or rejoin existing SSL sessions allowed by the authentication context which has been configured. The socket will also bind() to the local address and port supplied.

Annotations
@Override
Exceptions
IOException:

Doc from javax.net.SocketFactory.createSocket.

if an I/O error occurs when creating the socket

getDefaultCipherSuitesback to summary
public String[] getDefaultCipherSuites()

Implements abstract javax.net.ssl.SSLSocketFactory.getDefaultCipherSuites.

Returns the subset of the supported cipher suites which are enabled by default. These cipher suites all provide a minimum quality of service whereby the server authenticates itself (preventing person-in-the-middle attacks) and where traffic is encrypted to provide confidentiality.

Annotations
@Override
getSupportedCipherSuitesback to summary
public String[] getSupportedCipherSuites()

Implements abstract javax.net.ssl.SSLSocketFactory.getSupportedCipherSuites.

Returns the names of the cipher suites which could be enabled for use on an SSL connection. Normally, only a subset of these will actually be enabled by default, since this list may include cipher suites which do not support the mutual authentication of servers and clients, or which do not protect data confidentiality. Servers may also need certain kinds of certificates to use certain cipher suites.

Annotations
@Override