|
2 | 2 |
|
3 | 3 | import com.google.common.base.Charsets; |
4 | 4 | import com.google.common.io.Resources; |
5 | | -import com.sun.jndi.ldap.DefaultResponseControlFactory; |
6 | | -import com.sun.jndi.ldap.LdapCtxFactory; |
7 | 5 | import com.unboundid.ldap.listener.InMemoryDirectoryServer; |
8 | 6 | import com.unboundid.ldap.listener.InMemoryDirectoryServerConfig; |
9 | 7 | import com.unboundid.ldap.sdk.LDAPConnection; |
|
29 | 27 |
|
30 | 28 | public class EmbeddedLdapRuleImpl implements EmbeddedLdapRule { |
31 | 29 |
|
| 30 | + private static final String JAVA_RT_CONTROL_FACTORY = "com.sun.jndi.ldap.DefaultResponseControlFactory"; |
| 31 | + |
| 32 | + private static final String JAVA_RT_CONTEXT_FACTORY = "com.sun.jndi.ldap.LdapCtxFactory"; |
| 33 | + |
32 | 34 | private static Logger logger = LoggerFactory.getLogger(EmbeddedLdapRuleImpl.class); |
33 | 35 | private final InMemoryDirectoryServer inMemoryDirectoryServer; |
34 | 36 | private final AuthenticationConfiguration authenticationConfiguration; |
@@ -127,11 +129,11 @@ private InitialDirContext createOrGetInitialDirContext() throws NamingException |
127 | 129 |
|
128 | 130 | private Hashtable<String, String> createLdapEnvironment() { |
129 | 131 | final Hashtable<String, String> environment = new Hashtable<>(); |
130 | | - environment.put(LdapContext.CONTROL_FACTORIES, DefaultResponseControlFactory.class.getName()); |
| 132 | + environment.put(LdapContext.CONTROL_FACTORIES, JAVA_RT_CONTROL_FACTORY); |
131 | 133 | environment.put(Context.PROVIDER_URL, String.format("ldap://%s:%s", |
132 | 134 | inMemoryDirectoryServer.getListenAddress().getHostName(), |
133 | 135 | embeddedServerPort())); |
134 | | - environment.put(Context.INITIAL_CONTEXT_FACTORY, LdapCtxFactory.class.getName()); |
| 136 | + environment.put(Context.INITIAL_CONTEXT_FACTORY, JAVA_RT_CONTEXT_FACTORY); |
135 | 137 | if (authenticationConfiguration != null) { |
136 | 138 | environment.putAll(authenticationConfiguration.toAuthenticationEnvironment()); |
137 | 139 | } |
|
0 commit comments