Class ThreadLocalSSLSocketFactory
- java.lang.Object
-
- javax.net.SocketFactory
-
- org.wildfly.security.auth.realm.ldap.ThreadLocalSSLSocketFactory
-
public class ThreadLocalSSLSocketFactory extends SocketFactory
AnSocketFactory
that allow passing SSLSocket into DirContext. DirContext allows SocketFactory passing only in form of class name string, which prevent to pass different SSL configuration into different DirContexts without standalone classes. This socket factory bypass this using thread local variable with SocketFactory, which should be used in directly following socket-creating DirContext operation.- Author:
- Jan Kalina
-
-
Field Summary
Fields Modifier and Type Field Description private SocketFactory
socketFactory
private static ThreadLocal<SocketFactory>
threadLocal
-
Constructor Summary
Constructors Modifier Constructor Description private
ThreadLocalSSLSocketFactory(SocketFactory socketFactory)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Socket
createSocket()
Socket
createSocket(String host, int port)
Socket
createSocket(String host, int port, InetAddress localHost, int localPort)
Socket
createSocket(InetAddress host, int port)
Socket
createSocket(InetAddress address, int port, InetAddress localAddress, int localPort)
static SocketFactory
getDefault()
static void
set(SocketFactory socketFactory)
static void
unset()
-
-
-
Field Detail
-
threadLocal
private static final ThreadLocal<SocketFactory> threadLocal
-
socketFactory
private SocketFactory socketFactory
-
-
Constructor Detail
-
ThreadLocalSSLSocketFactory
private ThreadLocalSSLSocketFactory(SocketFactory socketFactory)
-
-
Method Detail
-
getDefault
public static SocketFactory getDefault()
-
set
public static void set(SocketFactory socketFactory)
-
unset
public static void unset()
-
createSocket
public Socket createSocket() throws IOException
- Overrides:
createSocket
in classSocketFactory
- Throws:
IOException
-
createSocket
public Socket createSocket(String host, int port) throws IOException
- Specified by:
createSocket
in classSocketFactory
- Throws:
IOException
-
createSocket
public Socket createSocket(String host, int port, InetAddress localHost, int localPort) throws IOException
- Specified by:
createSocket
in classSocketFactory
- Throws:
IOException
-
createSocket
public Socket createSocket(InetAddress host, int port) throws IOException
- Specified by:
createSocket
in classSocketFactory
- Throws:
IOException
-
createSocket
public Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort) throws IOException
- Specified by:
createSocket
in classSocketFactory
- Throws:
IOException
-
-