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
This commit is contained in:
Jitendra Nath Pandey 2012-01-28 02:24:08 +00:00
parent 5262b7ba4d
commit ed6a73140e
3 changed files with 14 additions and 1 deletions

View File

@ -76,6 +76,9 @@ Trunk (unreleased changes)
HADOOP-7965. Support for protocol version and signature in PB. (jitendra) 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 BUGS
HADOOP-7998. CheckFileSystem does not correctly honor setVerifyChecksum HADOOP-7998. CheckFileSystem does not correctly honor setVerifyChecksum
(Daryn Sharp via bobby) (Daryn Sharp via bobby)

View File

@ -236,7 +236,7 @@ private static String replacePattern(String[] components, String hostname)
if (fqdn == null || fqdn.equals("") || fqdn.equals("0.0.0.0")) { if (fqdn == null || fqdn.equals("") || fqdn.equals("0.0.0.0")) {
fqdn = getLocalHostName(); fqdn = getLocalHostName();
} }
return components[0] + "/" + fqdn + "@" + components[2]; return components[0] + "/" + fqdn.toLowerCase() + "@" + components[2];
} }
static String getLocalHostName() throws UnknownHostException { static String getLocalHostName() throws UnknownHostException {

View File

@ -89,6 +89,16 @@ public void testGetServerPrincipal() throws IOException {
Mockito.verify(notUsed, Mockito.never()).getCanonicalHostName(); 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 @Test
public void testLocalHostNameForNullOrWild() throws Exception { public void testLocalHostNameForNullOrWild() throws Exception {
String local = SecurityUtil.getLocalHostName(); String local = SecurityUtil.getLocalHostName();