Skip to content

Commit 875502a

Browse files
committed
Remove compiler warning for internal com.sun.jndi.ldap classes by specifying them as strings instead
1 parent 4757e6d commit 875502a

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

pom.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,5 +212,23 @@
212212
</plugins>
213213
</build>
214214
</profile>
215+
<profile>
216+
<id>java11</id>
217+
<activation>
218+
<jdk>11</jdk>
219+
</activation>
220+
<properties>
221+
<java.version>11</java.version>
222+
</properties>
223+
</profile>
224+
<profile>
225+
<id>java8</id>
226+
<activation>
227+
<jdk>8</jdk>
228+
</activation>
229+
<properties>
230+
<java.version>8</java.version>
231+
</properties>
232+
</profile>
215233
</profiles>
216234
</project>

src/main/java/org/zapodot/junit/ldap/internal/EmbeddedLdapRuleImpl.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
import com.google.common.base.Charsets;
44
import com.google.common.io.Resources;
5-
import com.sun.jndi.ldap.DefaultResponseControlFactory;
6-
import com.sun.jndi.ldap.LdapCtxFactory;
75
import com.unboundid.ldap.listener.InMemoryDirectoryServer;
86
import com.unboundid.ldap.listener.InMemoryDirectoryServerConfig;
97
import com.unboundid.ldap.sdk.LDAPConnection;
@@ -29,6 +27,10 @@
2927

3028
public class EmbeddedLdapRuleImpl implements EmbeddedLdapRule {
3129

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+
3234
private static Logger logger = LoggerFactory.getLogger(EmbeddedLdapRuleImpl.class);
3335
private final InMemoryDirectoryServer inMemoryDirectoryServer;
3436
private final AuthenticationConfiguration authenticationConfiguration;
@@ -127,11 +129,11 @@ private InitialDirContext createOrGetInitialDirContext() throws NamingException
127129

128130
private Hashtable<String, String> createLdapEnvironment() {
129131
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);
131133
environment.put(Context.PROVIDER_URL, String.format("ldap://%s:%s",
132134
inMemoryDirectoryServer.getListenAddress().getHostName(),
133135
embeddedServerPort()));
134-
environment.put(Context.INITIAL_CONTEXT_FACTORY, LdapCtxFactory.class.getName());
136+
environment.put(Context.INITIAL_CONTEXT_FACTORY, JAVA_RT_CONTEXT_FACTORY);
135137
if (authenticationConfiguration != null) {
136138
environment.putAll(authenticationConfiguration.toAuthenticationEnvironment());
137139
}

0 commit comments

Comments
 (0)