File tree Expand file tree Collapse file tree 3 files changed +21
-21
lines changed
hadoop-auth/src/main/java/org/apache/hadoop/util
src/test/java/org/apache/hadoop/minikdc Expand file tree Collapse file tree 3 files changed +21
-21
lines changed Original file line number Diff line number Diff line change @@ -49,23 +49,18 @@ public class PlatformName {
4949 * own implementations of many security packages and Cipher suites.
5050 * Note that these are not provided in Semeru runtimes:
5151 * See https://developer.ibm.com/languages/java/semeru-runtimes/
52+ * The class used is present in any supported IBM JTE Runtimes.
5253 */
53- public static final boolean IBM_JAVA = shouldUseIbmPackages ();
54+ public static final boolean IBM_JAVA = JAVA_VENDOR_NAME .contains ("IBM" ) &&
55+ hasClass ("com.ibm.security.auth.module.JAASLoginModule" );
5456
55- private static boolean shouldUseIbmPackages () {
56- if (JAVA_VENDOR_NAME .contains ("IBM" )) {
57- try {
58- /**
59- * This class is provided by all supported IBM JTE Runtimes,
60- * but ensures we do not make assumptions of existence of
61- * specialised security modules based on vendor alone.
62- */
63- Class .forName ("com.ibm.security.auth.module.JAASLoginModule" );
64- return true ;
65- } catch (ClassNotFoundException ignored ) {}
57+ private static boolean hasClass (String className ) {
58+ try {
59+ Thread .currentThread ().getContextClassLoader ().loadClass (className );
60+ return true ;
61+ } catch (ClassNotFoundException ignored ) {
62+ return false ;
6663 }
67-
68- return false ;
6964 }
7065
7166 public static void main (String [] args ) {
Original file line number Diff line number Diff line change 4848 <artifactId >junit</artifactId >
4949 <scope >compile</scope >
5050 </dependency >
51- <dependency >
52- <groupId >org.apache.hadoop</groupId >
53- <artifactId >hadoop-auth</artifactId >
54- <scope >test</scope >
55- </dependency >
5651 </dependencies >
5752
5853 <build >
Original file line number Diff line number Diff line change 3737import java .util .HashMap ;
3838import java .util .Arrays ;
3939
40- import static org .apache .hadoop .util .PlatformName .IBM_JAVA ;
41-
4240public class TestMiniKdc extends KerberosSecurityTestcase {
41+ private static final boolean IBM_JAVA = shouldUseIbmPackages ();
42+
43+ private static boolean shouldUseIbmPackages () {
44+ if (System .getProperty ("java.vendor" ).contains ("IBM" )) {
45+ try {
46+ Class .forName ("com.ibm.security.auth.module.JAASLoginModule" );
47+ return true ;
48+ } catch (ClassNotFoundException ignored ) {}
49+ }
50+
51+ return false ;
52+ }
4353
4454 @ Test
4555 public void testMiniKdcStart () {
You can’t perform that action at this time.
0 commit comments