Skip to content

Fix LdapGroupMapping on JDK 16+#32

Merged
findepi merged 2 commits intotrinodb:masterfrom
wendigo:serafin/ldap-jdk16
Nov 3, 2021
Merged

Fix LdapGroupMapping on JDK 16+#32
findepi merged 2 commits intotrinodb:masterfrom
wendigo:serafin/ldap-jdk16

Conversation

@wendigo
Copy link
Copy Markdown
Contributor

@wendigo wendigo commented Oct 26, 2021

No description provided.

@cla-bot cla-bot Bot added the cla-signed label Oct 26, 2021
@wendigo
Copy link
Copy Markdown
Contributor Author

wendigo commented Oct 26, 2021

cc @findepi @electrum

Hashtable<String, String> env = new Hashtable<String, String>();
env.put(Context.INITIAL_CONTEXT_FACTORY,
com.sun.jndi.ldap.LdapCtxFactory.class.getName());
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since JDK 16 this class is inteded to be used by javax.naming only

Shouldn't we use javax.something here then?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. Javax.naming has an access to com.sun so it's fine

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove compile-time reference to LdapCtxFactory

is it about compile-time only (and could perhaps be alleviated with some javac toggles), or runtime as well? i guess both?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should compile on 17 but will fail in runtime due to the access to the module

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, this will fail on JDK 17 due to JEP 403:

Strong encapsulation applies at both compile time and run time, including when compiled code attempts to access elements via reflection at run time. The non-public elements of exported packages, and all elements of unexported packages, are said to be strongly encapsulated.

com.sun.jndi.ldap.LdapCtxFactory is in the java.naming module which doesn't export anything outside of the javax.naming package, so simply referencing the class will fail at runtime and probably at compile time, even though it is public and accessible via the pre-module rules.

Comment thread pom.xml
<exclude>org/apache/hadoop/util/LineReader.class</exclude>
<exclude>org/apache/hadoop/crypto/key/kms/KMSClientProvider.class</exclude>
<exclude>org/apache/hadoop/crypto/key/kms/KMSClientProvider$*.class</exclude>
<exclude>org/apache/hadoop/security/LdapGroupsMapping.class</exclude>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does LdapGroupsMapping have any anonymous inner classes? Won't it ever have?
would be safer to exclude them proactively, like KMSClientProvider$*.class above

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't have but I can add it proactively

@wendigo wendigo force-pushed the serafin/ldap-jdk16 branch from bf1b36a to 3087294 Compare November 3, 2021 09:14
@wendigo
Copy link
Copy Markdown
Contributor Author

wendigo commented Nov 3, 2021

PTAL @findepi

Comment thread pom.xml
Since JDK 16 this class is inteded to be used by javax.naming only.
@wendigo wendigo force-pushed the serafin/ldap-jdk16 branch from 3087294 to 2f9bced Compare November 3, 2021 13:48
@findepi findepi merged commit a8e71e6 into trinodb:master Nov 3, 2021
@wendigo wendigo deleted the serafin/ldap-jdk16 branch November 17, 2021 14:31
@oneonestar oneonestar mentioned this pull request Sep 2, 2022
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants