APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javax.net.ssl

public abstract Class SSLSocketFactory

Additional top-level class in compilation unit: DefaultSSLSocketFactory.

extends SocketFactory
Class Inheritance
Known Direct Subclasses
javax.net.ssl.DefaultSSLSocketFactory, sun.security.ssl.SSLSocketFactoryImpl
Imports
java.net.*, javax.net.SocketFactory, java.io.IOException, .InputStream, java.security.*, java.util.Locale

SSLSocketFactorys create SSLSockets.
Author
David Brownell
Since
1.4
See Also
SSLSocket

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
pack-priv static final boolean

Constructor Summary

AccessConstructor and Description
public
SSLSocketFactory()

Constructor is used only by subclasses.

Method Summary

Modifier and TypeMethod and Description
public abstract Socket

Returns:

a socket connected to the specified host and port
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
)

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

public Socket

Returns:

the Socket compliant with the socket options established for this factory
createSocket
(Socket
the existing socket
s
,
InputStream
the consumed inbound network data that has already been removed from the existing Socket InputStream. This parameter may be null if no data has been removed.
consumed
,
boolean
close the underlying socket when this socket is closed.
autoClose
)

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 static SocketFactory

Returns:

the default SocketFactory
getDefault
()

Hides javax.net.SocketFactory.getDefault.

Returns the default SSL socket factory.

public abstract String[]

Returns:

array of the cipher suites enabled by default
getDefaultCipherSuites
()

Returns the list of cipher suites which are enabled by default.

pack-priv static String
public abstract String[]

Returns:

an array of cipher suite names
getSupportedCipherSuites
()

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

Inherited from javax.net.SocketFactory:
createSocketcreateSocketcreateSocketcreateSocketcreateSocket

Field Detail

DEBUGback to summary
pack-priv static final boolean DEBUG

Constructor Detail

SSLSocketFactoryback to summary
public SSLSocketFactory()

Constructor is used only by subclasses.

Method Detail

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

Returns a socket layered over an existing socket connected to the named host, at the given port. This constructor can be used when tunneling SSL through a proxy or when negotiating the use of SSL over an existing socket. The host and port refer to the logical peer destination. 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

Returns:Socket

a socket connected to the specified host and port

Exceptions
IOException:
if an I/O error occurs when creating the socket
NullPointerException:
if the parameter s is null
createSocketback to summary
public Socket createSocket(Socket s, InputStream consumed, boolean autoClose) throws IOException

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)).

Parameters
s:Socket

the existing socket

consumed:InputStream

the consumed inbound network data that has already been removed from the existing Socket InputStream. This parameter may be null if no data has been removed.

autoClose:boolean

close the underlying socket when this socket is closed.

Returns:Socket

the Socket compliant with the socket options established for this factory

Exceptions
IOException:
if an I/O error occurs when creating the socket
UnsupportedOperationException:
if the underlying provider does not implement the operation
NullPointerException:
if s is null
Since
1.8
External Specification
https://www.rfc-editor.org/info/rfc6066
getDefaultback to summary
public static SocketFactory getDefault()

Hides javax.net.SocketFactory.getDefault.

Returns the default SSL socket factory.

The first time this method is called, the security property "ssl.SocketFactory.provider" is examined. If it is non-null, a class by that name is loaded and instantiated. If that is successful and the object is an instance of SSLSocketFactory, it is made the default SSL socket factory.

Otherwise, this method returns SSLContext.getDefault().getSocketFactory(). If that call fails, an inoperative factory is returned.

Returns:SocketFactory

the default SocketFactory

See Also
SSLContext#getDefault
getDefaultCipherSuitesback to summary
public abstract String[] getDefaultCipherSuites()

Returns the list of cipher suites which are enabled by default. Unless a different list is enabled, handshaking on an SSL connection will use one of these cipher suites. The minimum quality of service for these defaults requires confidentiality protection and server authentication (that is, no anonymous cipher suites).

The returned array includes cipher suites from the list of standard cipher suite names in the JSSE Cipher Suite Names section of the Java Security Standard Algorithm Names Specification, and may also include other cipher suites that the provider supports.

Returns:String[]

array of the cipher suites enabled by default

External Specification
Java Security Standard Algorithm Names
See Also
getSupportedCipherSuites()
getSecurityPropertyback to summary
pack-priv static String getSecurityProperty(final String name)
getSupportedCipherSuitesback to summary
public abstract String[] 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 meet quality of service requirements for those defaults. Such cipher suites are useful in specialized applications.

The returned array includes cipher suites from the list of standard cipher suite names in the JSSE Cipher Suite Names section of the Java Security Standard Algorithm Names Specification, and may also include other cipher suites that the provider supports.

Returns:String[]

an array of cipher suite names

External Specification
Java Security Standard Algorithm Names
See Also
getDefaultCipherSuites()
javax.net.ssl back to summary

private final Class SSLSocketFactory.DefaultFactoryHolder

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static final SSLSocketFactory

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static void
log(String msg)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

defaultFactoryback to summary
private static final SSLSocketFactory defaultFactory

Constructor Detail

DefaultFactoryHolderback to summary
private DefaultFactoryHolder()

Method Detail

logback to summary
private static void log(String msg)