提交 60cd59d2 编写于 作者: W weijun

7031536: test/sun/security/krb5/auto/HttpNegotiateServer.java should not use static ports

Reviewed-by: xuelei
上级 5b3a1ff4
/* /*
* Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
/* /*
* @test * @test
* @bug 6345338 * @bug 6345338
* @run main/othervm GssNPE
* @summary GSS throws NPE when the JAAS config file does not exist * @summary GSS throws NPE when the JAAS config file does not exist
*/ */
......
/* /*
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
/* /*
* @test * @test
* @bug 6770883 * @bug 6770883
* @run main/othervm NoSpnegoAsDefMech
* @summary Infinite loop if SPNEGO specified as sun.security.jgss.mechanism * @summary Infinite loop if SPNEGO specified as sun.security.jgss.mechanism
*/ */
......
/* /*
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
* @bug 6857795 * @bug 6857795
* @bug 6858589 * @bug 6858589
* @bug 6972005 * @bug 6972005
* @run main/othervm ConfPlusProp
* @summary krb5.conf ignored if system properties on realm and kdc are provided * @summary krb5.conf ignored if system properties on realm and kdc are provided
*/ */
......
/* /*
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
/* /*
* @test * @test
* @bug 6714845 * @bug 6714845
* @run main/othervm ConfigWithQuotations
* @summary Quotes in Kerberos configuration file are included in the values * @summary Quotes in Kerberos configuration file are included in the values
*/ */
......
/* /*
* Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
* @test * @test
* @bug 6673164 * @bug 6673164
* @bug 6552334 * @bug 6552334
* @run main/othervm DnsFallback
* @summary fix dns_fallback parse error, and use dns by default * @summary fix dns_fallback parse error, and use dns by default
*/ */
......
/* /*
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
/* /*
* @test * @test
* @bug 6877357 6885166 * @bug 6877357 6885166
* @run main/othervm IPv6
* @summary IPv6 address does not work * @summary IPv6 address does not work
*/ */
......
/* /*
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
/* /*
* @test * @test
* @bug 6319046 * @bug 6319046
* @run main/othervm ParseConfig
* @summary Problem with parsing krb5.conf * @summary Problem with parsing krb5.conf
*/ */
......
/* /*
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
/* /*
* @test * @test
* @bug 6862679 * @bug 6862679
* @run main/othervm RFC396xTest
* @summary ESC: AD Authentication with user with umlauts fails * @summary ESC: AD Authentication with user with umlauts fails
*/ */
......
/* /*
* Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
/* /*
* @test * @test
* @bug 6590930 * @bug 6590930
* @run main/othervm TimeInCCache
* @summary read/write does not match for ccache * @summary read/write does not match for ccache
*/ */
......
...@@ -74,11 +74,10 @@ public class HttpNegotiateServer { ...@@ -74,11 +74,10 @@ public class HttpNegotiateServer {
final static char[] WEB_PASS = "webby".toCharArray(); final static char[] WEB_PASS = "webby".toCharArray();
final static String PROXY_USER = "pro"; final static String PROXY_USER = "pro";
final static char[] PROXY_PASS = "proxy".toCharArray(); final static char[] PROXY_PASS = "proxy".toCharArray();
final static int WEB_PORT = 17840;
final static String WEB_HOST = "host.web.domain"; final static String WEB_HOST = "host.web.domain";
final static String PROXY_HOST = "host.proxy.domain"; final static String PROXY_HOST = "host.proxy.domain";
final static int PROXY_PORT = 17841;
// web page content // web page content
final static String CONTENT = "Hello, World!"; final static String CONTENT = "Hello, World!";
...@@ -86,18 +85,11 @@ public class HttpNegotiateServer { ...@@ -86,18 +85,11 @@ public class HttpNegotiateServer {
// For 6829283, count how many times the Authenticator is called. // For 6829283, count how many times the Authenticator is called.
static int count = 0; static int count = 0;
static int webPort, proxyPort;
// URLs for web test, proxy test. The proxy server is not a real proxy // URLs for web test, proxy test. The proxy server is not a real proxy
// since it fakes the same content for any URL. :) // since it fakes the same content for any URL. :)
final static URL webUrl, proxyUrl; static URL webUrl, proxyUrl;
static {
URL u1 = null, u2 = null;
try {
u1 = new URL("http://" + WEB_HOST +":" + WEB_PORT + "/a/b/c");
u2 = new URL("http://nosuchplace/a/b/c");
} catch (Exception e) {
}
webUrl = u1; proxyUrl = u2;
}
/** /**
* This Authenticator checks everything: * This Authenticator checks everything:
...@@ -127,7 +119,7 @@ public class HttpNegotiateServer { ...@@ -127,7 +119,7 @@ public class HttpNegotiateServer {
if (!this.getRequestingHost().equalsIgnoreCase(PROXY_HOST)) { if (!this.getRequestingHost().equalsIgnoreCase(PROXY_HOST)) {
throw new RuntimeException("Bad host"); throw new RuntimeException("Bad host");
} }
if (this.getRequestingPort() != PROXY_PORT) { if (this.getRequestingPort() != proxyPort) {
throw new RuntimeException("Bad port"); throw new RuntimeException("Bad port");
} }
if (!this.getRequestingURL().equals(proxyUrl)) { if (!this.getRequestingURL().equals(proxyUrl)) {
...@@ -188,10 +180,15 @@ public class HttpNegotiateServer { ...@@ -188,10 +180,15 @@ public class HttpNegotiateServer {
fos.close(); fos.close();
f.deleteOnExit(); f.deleteOnExit();
HttpServer h1 = httpd(WEB_PORT, "Negotiate", false, HttpServer h1 = httpd("Negotiate", false,
"HTTP/" + WEB_HOST + "@" + REALM_WEB, KRB5_TAB); "HTTP/" + WEB_HOST + "@" + REALM_WEB, KRB5_TAB);
HttpServer h2 = httpd(PROXY_PORT, "Negotiate", true, webPort = h1.getAddress().getPort();
HttpServer h2 = httpd("Negotiate", true,
"HTTP/" + PROXY_HOST + "@" + REALM_PROXY, KRB5_TAB); "HTTP/" + PROXY_HOST + "@" + REALM_PROXY, KRB5_TAB);
proxyPort = h2.getAddress().getPort();
webUrl = new URL("http://" + WEB_HOST +":" + webPort + "/a/b/c");
proxyUrl = new URL("http://nosuchplace/a/b/c");
try { try {
Exception e1 = null, e2 = null; Exception e1 = null, e2 = null;
...@@ -230,7 +227,7 @@ public class HttpNegotiateServer { ...@@ -230,7 +227,7 @@ public class HttpNegotiateServer {
reader = new BufferedReader(new InputStreamReader( reader = new BufferedReader(new InputStreamReader(
proxyUrl.openConnection( proxyUrl.openConnection(
new Proxy(Proxy.Type.HTTP, new Proxy(Proxy.Type.HTTP,
new InetSocketAddress(PROXY_HOST, PROXY_PORT))) new InetSocketAddress(PROXY_HOST, proxyPort)))
.getInputStream())); .getInputStream()));
if (!reader.readLine().equals(CONTENT)) { if (!reader.readLine().equals(CONTENT)) {
throw new RuntimeException("Bad content"); throw new RuntimeException("Bad content");
...@@ -258,10 +255,10 @@ public class HttpNegotiateServer { ...@@ -258,10 +255,10 @@ public class HttpNegotiateServer {
* @param principal the krb5 service principal the server runs with * @param principal the krb5 service principal the server runs with
* @return the server * @return the server
*/ */
public static HttpServer httpd(int port, String scheme, boolean proxy, public static HttpServer httpd(String scheme, boolean proxy,
String principal, String ktab) throws Exception { String principal, String ktab) throws Exception {
MyHttpHandler h = new MyHttpHandler(); MyHttpHandler h = new MyHttpHandler();
HttpServer server = HttpServer.create(new InetSocketAddress(port), 0); HttpServer server = HttpServer.create(new InetSocketAddress(0), 0);
HttpContext hc = server.createContext("/", h); HttpContext hc = server.createContext("/", h);
hc.setAuthenticator(new MyServerAuthenticator( hc.setAuthenticator(new MyServerAuthenticator(
proxy, scheme, principal, ktab)); proxy, scheme, principal, ktab));
......
/* /*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
/* /*
* @test * @test
* @bug 6844907 * @bug 6844907
* @run main/othervm ETypeOrder
* @summary krb5 etype order should be from strong to weak * @summary krb5 etype order should be from strong to weak
*/ */
......
/* /*
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
* @test * @test
* @bug 6867665 * @bug 6867665
* @bug 6875033 * @bug 6875033
* @run main/othervm HighestKvno
* @summary Problem with keytabs with multiple kvno's (key versions) * @summary Problem with keytabs with multiple kvno's (key versions)
*/ */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册