From ed6a73140e2608ade7cf64518a937858813e4637 Mon Sep 17 00:00:00 2001 From: Jitendra Nath Pandey Date: Sat, 28 Jan 2012 02:24:08 +0000 Subject: [PATCH] HADOOP-7988. Upper case in hostname part of the principals doesn't work with kerberos. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1236960 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-common-project/hadoop-common/CHANGES.txt | 3 +++ .../java/org/apache/hadoop/security/SecurityUtil.java | 2 +- .../org/apache/hadoop/security/TestSecurityUtil.java | 10 ++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 30fa5f25da..4a420692a7 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -76,6 +76,9 @@ Trunk (unreleased changes) HADOOP-7965. Support for protocol version and signature in PB. (jitendra) + HADOOP-7988. Upper case in hostname part of the principals doesn't work with + kerberos. (jitendra) + BUGS HADOOP-7998. CheckFileSystem does not correctly honor setVerifyChecksum (Daryn Sharp via bobby) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/SecurityUtil.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/SecurityUtil.java index a72b1f272c..abf9f3aa80 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/SecurityUtil.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/SecurityUtil.java @@ -236,7 +236,7 @@ private static String replacePattern(String[] components, String hostname) if (fqdn == null || fqdn.equals("") || fqdn.equals("0.0.0.0")) { fqdn = getLocalHostName(); } - return components[0] + "/" + fqdn + "@" + components[2]; + return components[0] + "/" + fqdn.toLowerCase() + "@" + components[2]; } static String getLocalHostName() throws UnknownHostException { diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/TestSecurityUtil.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/TestSecurityUtil.java index 84f585b599..57a1e116de 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/TestSecurityUtil.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/TestSecurityUtil.java @@ -89,6 +89,16 @@ public void testGetServerPrincipal() throws IOException { Mockito.verify(notUsed, Mockito.never()).getCanonicalHostName(); } + @Test + public void testPrincipalsWithLowerCaseHosts() throws IOException { + String service = "xyz/"; + String realm = "@REALM"; + String principalInConf = service + SecurityUtil.HOSTNAME_PATTERN + realm; + String hostname = "FooHost"; + String principal = service + hostname.toLowerCase() + realm; + verify(principalInConf, hostname, principal); + } + @Test public void testLocalHostNameForNullOrWild() throws Exception { String local = SecurityUtil.getLocalHostName();