Trying to fix localhost hostname usage

- Created principal needs to match resolved hostname
  so trying to add a tweak to make it happen.
This commit is contained in:
Janne Valkealahti
2015-02-26 11:42:26 +00:00
parent b1b3eefa41
commit 3d7c0365bd
2 changed files with 6 additions and 3 deletions

View File

@@ -24,6 +24,7 @@ import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.net.InetAddress;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -69,12 +70,13 @@ public class KerberosRestTemplateTests extends KerberosSecurityTestcase {
MiniKdc kdc = getKdc();
File workDir = getWorkDir();
String host = InetAddress.getLocalHost().getHostName();
String serverPrincipal = "HTTP/localhost";
String serverPrincipal = "HTTP/" + host;
File serverKeytab = new File(workDir, "server.keytab");
kdc.createPrincipal(serverKeytab, serverPrincipal);
String clientPrincipal = "client/localhost";
String clientPrincipal = "client/" + host;
File clientKeytab = new File(workDir, "client.keytab");
kdc.createPrincipal(clientKeytab, clientPrincipal);
@@ -90,7 +92,7 @@ public class KerberosRestTemplateTests extends KerberosSecurityTestcase {
KerberosRestTemplate restTemplate = new KerberosRestTemplate(clientKeytab.getAbsolutePath(), clientPrincipal);
String response = restTemplate.getForObject("http://localhost:" + port + "/hello", String.class);
String response = restTemplate.getForObject("http://" + host + ":" + port + "/hello", String.class);
assertThat(response, is("home"));
}

View File

@@ -251,6 +251,7 @@ public class MiniKdc {
for (Map.Entry<?, ?> entry : conf.entrySet()) {
LOG.info(" {}: {}", entry.getKey(), entry.getValue());
}
LOG.info(" localhost hostname: {}", InetAddress.getLocalHost().getHostName());
LOG.info("---------------------------------------------------------------");
this.conf = conf;
port = Integer.parseInt(conf.getProperty(KDC_PORT));