From bcaba939417522ac95226f1fab2a82949f05a6e9 Mon Sep 17 00:00:00 2001 From: Eric Yang Date: Sat, 8 Dec 2012 00:48:04 +0000 Subject: [PATCH] HADOOP-8418. Update UGI Principal classes name for running with IBM JDK on 64 bits Windows. (Yu Gao via eyang) git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1418572 13f79535-47bb-0310-9956-ffa450edef68 --- .../hadoop-common/CHANGES.txt | 3 +++ .../hadoop/security/UserGroupInformation.java | 24 +++++++++++-------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 27346df30bd..bcd337a2e77 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -143,6 +143,9 @@ Trunk (Unreleased) BUG FIXES + HADOOP-8418. Update UGI Principal classes name for running with + IBM JDK on 64 bits Windows. (Yu Gao via eyang) + HADOOP-8177. MBeans shouldn't try to register when it fails to create MBeanName. (Devaraj K via umamahesh) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/UserGroupInformation.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/UserGroupInformation.java index d206f3ace86..9260fbe9f53 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/UserGroupInformation.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/UserGroupInformation.java @@ -299,13 +299,17 @@ public class UserGroupInformation { private static String OS_LOGIN_MODULE_NAME; private static Class OS_PRINCIPAL_CLASS; - private static final boolean windows = - System.getProperty("os.name").startsWith("Windows"); + private static final boolean windows = + System.getProperty("os.name").startsWith("Windows"); + private static final boolean is64Bit = + System.getProperty("os.arch").contains("64"); /* Return the OS login module class name */ private static String getOSLoginModuleName() { if (System.getProperty("java.vendor").contains("IBM")) { - return windows ? "com.ibm.security.auth.module.NTLoginModule" - : "com.ibm.security.auth.module.LinuxLoginModule"; + return windows ? (is64Bit + ? "com.ibm.security.auth.module.Win64LoginModule" + : "com.ibm.security.auth.module.NTLoginModule") + : "com.ibm.security.auth.module.LinuxLoginModule"; } else { return windows ? "com.sun.security.auth.module.NTLoginModule" : "com.sun.security.auth.module.UnixLoginModule"; @@ -319,13 +323,13 @@ public class UserGroupInformation { try { if (System.getProperty("java.vendor").contains("IBM")) { if (windows) { - return (Class) - cl.loadClass("com.ibm.security.auth.UsernamePrincipal"); + return (Class) (is64Bit + ? cl.loadClass("com.ibm.security.auth.UsernamePrincipal") + : cl.loadClass("com.ibm.security.auth.NTUserPrincipal")); } else { - return (Class) - (System.getProperty("os.arch").contains("64") - ? cl.loadClass("com.ibm.security.auth.UsernamePrincipal") - : cl.loadClass("com.ibm.security.auth.LinuxPrincipal")); + return (Class) (is64Bit + ? cl.loadClass("com.ibm.security.auth.UsernamePrincipal") + : cl.loadClass("com.ibm.security.auth.LinuxPrincipal")); } } else { return (Class) (windows