Class LdapSslSocketFactory
java.lang.Object
javax.net.SocketFactory
javax.net.ssl.SSLSocketFactory
org.springframework.boot.ldap.autoconfigure.LdapSslSocketFactory
Bridges the JNDI
java.naming.ldap.factory.socket environment property to an
SslBundle. That property only accepts a class name, which JNDI loads and on
which it then calls getDefault(), with no way of passing an actual factory
instance. The bundle to use is therefore held in a static field.
JNDI calls getDefault() once per new connection and the SslBundle is
asked for a fresh SSLContext each time, so key and trust material of a bundle
that has been reloaded is picked up by connections opened from then on. Reloading is
only tracked for a bundle configured by name through spring.ldap.ssl.bundle; a
bundle supplied by a custom LdapConnectionDetails is used as given.
As the bundle is held statically, a single SslBundle applies JVM-wide. This is
sufficient for the auto-configured
LdapContextSource, of which there is at
most one per application context.
This class is referenced by name from a JNDI environment and is not intended to be used directly.
- Since:
- 4.2.0
- Author:
- Moritz Halbritter
-
Method Summary
Modifier and TypeMethodDescriptionCreates an unconnected socket.createSocket(String host, int port) createSocket(String host, int port, InetAddress localAddress, int localPort) createSocket(InetAddress host, int port) createSocket(InetAddress address, int port, InetAddress localAddress, int localPort) createSocket(Socket socket, InputStream consumed, boolean autoClose) createSocket(Socket socket, String host, int port, boolean autoClose) static SocketFactoryString[]String[]
-
Method Details
-
getDefault
-
getDefaultCipherSuites
- Specified by:
getDefaultCipherSuitesin classSSLSocketFactory
-
getSupportedCipherSuites
- Specified by:
getSupportedCipherSuitesin classSSLSocketFactory
-
createSocket
public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException - Specified by:
createSocketin classSSLSocketFactory- Throws:
IOException
-
createSocket
public Socket createSocket(Socket socket, InputStream consumed, boolean autoClose) throws IOException - Overrides:
createSocketin classSSLSocketFactory- Throws:
IOException
-
createSocket
Creates an unconnected socket. JNDI tries this first when a connect timeout has been configured, so it has to be delegated rather than inheritingSocketFactory.createSocket(), which throws and makes JNDI fall back to a connected socket that ignores the timeout.- Overrides:
createSocketin classSocketFactory- Returns:
- an unconnected socket
- Throws:
IOException- if the socket cannot be created
-
createSocket
- Specified by:
createSocketin classSocketFactory- Throws:
IOException
-
createSocket
public Socket createSocket(String host, int port, InetAddress localAddress, int localPort) throws IOException - Specified by:
createSocketin classSocketFactory- Throws:
IOException
-
createSocket
- Specified by:
createSocketin classSocketFactory- Throws:
IOException
-
createSocket
public Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort) throws IOException - Specified by:
createSocketin classSocketFactory- Throws:
IOException
-