changeset 1951:bc12627832e0

6906854: SSL/Krb5 testcase should not use a fixed port number Reviewed-by: alanb
author vinnie
date Thu, 03 Dec 2009 21:30:27 +0000
parents 79d91585d7d7
children 1755493c5774
files test/ProblemList.txt test/sun/security/krb5/auto/SSL.java
diffstat 2 files changed, 10 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/test/ProblemList.txt	Wed Dec 02 17:34:56 2009 +0000
+++ b/test/ProblemList.txt	Thu Dec 03 21:30:27 2009 +0000
@@ -893,10 +893,6 @@
 
 # jdk_security
 
-# Fails on OpenSolaris, IOException: Attempt to obtain kerberos service ticket
-#     for host/`hostname`@RABBIT.HOLE failed!
-sun/security/krb5/auto/SSL.java					generic-all
-
 # Run too slow on Solaris 10 sparc
 sun/security/ssl/com/sun/net/ssl/internal/ssl/InputRecord/SSLSocketTimeoutNulls.java solaris-sparc
 sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/ClientTimeout.java solaris-sparc
--- a/test/sun/security/krb5/auto/SSL.java	Wed Dec 02 17:34:56 2009 +0000
+++ b/test/sun/security/krb5/auto/SSL.java	Thu Dec 03 21:30:27 2009 +0000
@@ -36,33 +36,32 @@
 public class SSL {
 
     private static final String KRB5_CIPHER = "TLS_KRB5_WITH_3DES_EDE_CBC_SHA";
-    private static final int PORT = 4569;
     private static final int LOOP_LIMIT = 1;
     private static final char[] PASS = "secret".toCharArray();
     private static int loopCount = 0;
-
-    private static String SERVER;
+    private static volatile String server;
+    private static volatile int port;
 
     public static void main(String[] args) throws Exception {
 
         KDC kdc = KDC.create(OneKDC.REALM);
         // Run this after KDC, so our own DNS service can be started
         try {
-            SERVER = InetAddress.getLocalHost().getHostName().toLowerCase();
+            server = InetAddress.getLocalHost().getHostName().toLowerCase();
         } catch (java.net.UnknownHostException e) {
-            SERVER = "localhost";
+            server = "localhost";
         }
 
         kdc.addPrincipal(OneKDC.USER, OneKDC.PASS);
         kdc.addPrincipalRandKey("krbtgt/" + OneKDC.REALM);
-        kdc.addPrincipal("host/" + SERVER, PASS);
+        kdc.addPrincipal("host/" + server, PASS);
         KDC.saveConfig(OneKDC.KRB5_CONF, kdc);
         System.setProperty("java.security.krb5.conf", OneKDC.KRB5_CONF);
 
         final Context c = Context.fromUserPass(OneKDC.USER, OneKDC.PASS, false);
-        final Context s = Context.fromUserPass("host/" + SERVER, PASS, true);
+        final Context s = Context.fromUserPass("host/" + server, PASS, true);
 
-        c.startAsClient("host/" + SERVER, GSSUtil.GSS_KRB5_MECH_OID);
+        c.startAsClient("host/" + server, GSSUtil.GSS_KRB5_MECH_OID);
         s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID);
 
         new Thread(new Runnable() {
@@ -87,7 +86,7 @@
         public byte[] run(Context s, byte[] input) throws Exception {
             SSLSocketFactory sslsf =
                 (SSLSocketFactory) SSLSocketFactory.getDefault();
-            SSLSocket sslSocket = (SSLSocket) sslsf.createSocket(SERVER, PORT);
+            SSLSocket sslSocket = (SSLSocket) sslsf.createSocket(server, port);
 
             // Enable only a KRB5 cipher suite.
             String enabledSuites[] = {KRB5_CIPHER};
@@ -124,7 +123,8 @@
             SSLServerSocketFactory sslssf =
                 (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
             SSLServerSocket sslServerSocket =
-                (SSLServerSocket) sslssf.createServerSocket(PORT);
+                (SSLServerSocket) sslssf.createServerSocket(0); // any port
+            port = sslServerSocket.getLocalPort();
 
             // Enable only a KRB5 cipher suite.
             String enabledSuites[] = {KRB5_CIPHER};