8039575: liberate two manual kerberos tests
authorweijun
Thu, 10 Apr 2014 10:31:05 +0800
changeset 23735 34d83df87817
parent 23734 439905b27f94
child 23737 6e82e4199fc2
8039575: liberate two manual kerberos tests Reviewed-by: xuelei
jdk/src/share/classes/java/security/Provider.java
jdk/src/share/classes/sun/security/jgss/krb5/Krb5MechFactory.java
jdk/src/share/classes/sun/security/jgss/spnego/SpNegoMechFactory.java
jdk/test/javax/security/auth/kerberos/KerberosHashEqualsTest.java
jdk/test/javax/security/auth/kerberos/KerberosTixDateTest.java
--- a/jdk/src/share/classes/java/security/Provider.java	Wed Apr 09 09:36:19 2014 -0700
+++ b/jdk/src/share/classes/java/security/Provider.java	Thu Apr 10 10:31:05 2014 +0800
@@ -1332,7 +1332,7 @@
         addEngine("SSLContext",                         false, null);
         addEngine("TrustManagerFactory",                false, null);
         // JGSS
-        addEngine("GssApiMechanism",                    false, null);
+        addEngine("GssApiMechanism",                    true, "sun.security.jgss.GSSCaller");
         // SASL
         addEngine("SaslClientFactory",                  false, null);
         addEngine("SaslServerFactory",                  false, null);
--- a/jdk/src/share/classes/sun/security/jgss/krb5/Krb5MechFactory.java	Wed Apr 09 09:36:19 2014 -0700
+++ b/jdk/src/share/classes/sun/security/jgss/krb5/Krb5MechFactory.java	Thu Apr 10 10:31:05 2014 +0800
@@ -86,6 +86,10 @@
         return result;
     }
 
+    public Krb5MechFactory() {
+        this(GSSCaller.CALLER_UNKNOWN);
+    }
+
     public Krb5MechFactory(GSSCaller caller) {
         this.caller = caller;
     }
--- a/jdk/src/share/classes/sun/security/jgss/spnego/SpNegoMechFactory.java	Wed Apr 09 09:36:19 2014 -0700
+++ b/jdk/src/share/classes/sun/security/jgss/spnego/SpNegoMechFactory.java	Thu Apr 10 10:31:05 2014 +0800
@@ -96,6 +96,10 @@
         return result;
     }
 
+    public SpNegoMechFactory() {
+        this(GSSCaller.CALLER_UNKNOWN);
+    }
+
     public SpNegoMechFactory(GSSCaller caller) {
         manager = new GSSManagerImpl(caller, false);
         Oid[] mechs = manager.getMechs();
--- a/jdk/test/javax/security/auth/kerberos/KerberosHashEqualsTest.java	Wed Apr 09 09:36:19 2014 -0700
+++ b/jdk/test/javax/security/auth/kerberos/KerberosHashEqualsTest.java	Thu Apr 10 10:31:05 2014 +0800
@@ -25,7 +25,6 @@
  * @test
  * @bug 4641821
  * @summary hashCode() and equals() for KerberosKey and KerberosTicket
- * @run main/manual KerberosHashEqualsTest
  */
 
 /*
@@ -60,8 +59,8 @@
 
     void check() throws Exception {
         KerberosKey k1, k2;
-        k1 = new KerberosKey(new KerberosPrincipal("A"), "pass".getBytes(), 1, 1);
-        k2 = new KerberosKey(new KerberosPrincipal("A"), "pass".getBytes(), 1, 1);
+        k1 = new KerberosKey(newKP("A"), "pass".getBytes(), 1, 1);
+        k2 = new KerberosKey(newKP("A"), "pass".getBytes(), 1, 1);
         checkSame(k1, k1);  // me to me
         checkSame(k1, k2);  // same
 
@@ -73,13 +72,13 @@
         checkSame(k2, k2);
 
         // a little different
-        k2 = new KerberosKey(new KerberosPrincipal("B"), "pass".getBytes(), 1, 1);
+        k2 = new KerberosKey(newKP("B"), "pass".getBytes(), 1, 1);
         checkNotSame(k1, k2);
-        k2 = new KerberosKey(new KerberosPrincipal("A"), "ssap".getBytes(), 1, 1);
+        k2 = new KerberosKey(newKP("A"), "ssap".getBytes(), 1, 1);
         checkNotSame(k1, k2);
-        k2 = new KerberosKey(new KerberosPrincipal("A"), "pass".getBytes(), 2, 1);
+        k2 = new KerberosKey(newKP("A"), "pass".getBytes(), 2, 1);
         checkNotSame(k1, k2);
-        k2 = new KerberosKey(new KerberosPrincipal("A"), "pass".getBytes(), 1, 2);
+        k2 = new KerberosKey(newKP("A"), "pass".getBytes(), 1, 2);
         checkNotSame(k1, k2);
 
         k1 = new KerberosKey(null, "pass".getBytes(), 1, 2);
@@ -90,33 +89,33 @@
         checkNotSame(k1, "Another Object");
 
         KerberosTicket t1, t2;
-        t1 = new KerberosTicket("asn1".getBytes(), new KerberosPrincipal("client"), new KerberosPrincipal("server"), "pass".getBytes(), 1, new boolean[] {true, true}, new Date(0), new Date(0), new Date(0), new Date(0), null);
-        t2 = new KerberosTicket("asn1".getBytes(), new KerberosPrincipal("client"), new KerberosPrincipal("server"), "pass".getBytes(), 1, new boolean[] {true, true}, new Date(0), new Date(0), new Date(0), new Date(0), null);
+        t1 = new KerberosTicket("asn1".getBytes(), newKP("client"), newKP("server"), "pass".getBytes(), 1, new boolean[] {true, true}, new Date(0), new Date(0), new Date(0), new Date(0), null);
+        t2 = new KerberosTicket("asn1".getBytes(), newKP("client"), newKP("server"), "pass".getBytes(), 1, new boolean[] {true, true}, new Date(0), new Date(0), new Date(0), new Date(0), null);
         checkSame(t1, t1);
         checkSame(t1, t2);
-        t2 = new KerberosTicket("asn11".getBytes(), new KerberosPrincipal("client"), new KerberosPrincipal("server"), "pass".getBytes(), 1, new boolean[] {true, true}, new Date(0), new Date(0), new Date(0), new Date(0), null);
+        t2 = new KerberosTicket("asn11".getBytes(), newKP("client"), newKP("server"), "pass".getBytes(), 1, new boolean[] {true, true}, new Date(0), new Date(0), new Date(0), new Date(0), null);
         checkNotSame(t1, t2);
-        t2 = new KerberosTicket("asn1".getBytes(), new KerberosPrincipal("client1"), new KerberosPrincipal("server"), "pass".getBytes(), 1, new boolean[] {true, true}, new Date(0), new Date(0), new Date(0), new Date(0), null);
+        t2 = new KerberosTicket("asn1".getBytes(), newKP("client1"), newKP("server"), "pass".getBytes(), 1, new boolean[] {true, true}, new Date(0), new Date(0), new Date(0), new Date(0), null);
         checkNotSame(t1, t2);
-        t2 = new KerberosTicket("asn1".getBytes(), new KerberosPrincipal("client"), new KerberosPrincipal("server1"), "pass".getBytes(), 1, new boolean[] {true, true}, new Date(0), new Date(0), new Date(0), new Date(0), null);
+        t2 = new KerberosTicket("asn1".getBytes(), newKP("client"), newKP("server1"), "pass".getBytes(), 1, new boolean[] {true, true}, new Date(0), new Date(0), new Date(0), new Date(0), null);
         checkNotSame(t1, t2);
-        t2 = new KerberosTicket("asn1".getBytes(), new KerberosPrincipal("client"), new KerberosPrincipal("server"), "pass1".getBytes(), 1, new boolean[] {true, true}, new Date(0), new Date(0), new Date(0), new Date(0), null);
+        t2 = new KerberosTicket("asn1".getBytes(), newKP("client"), newKP("server"), "pass1".getBytes(), 1, new boolean[] {true, true}, new Date(0), new Date(0), new Date(0), new Date(0), null);
         checkNotSame(t1, t2);
-        t2 = new KerberosTicket("asn1".getBytes(), new KerberosPrincipal("client"), new KerberosPrincipal("server"), "pass".getBytes(), 2, new boolean[] {true, true}, new Date(0), new Date(0), new Date(0), new Date(0), null);
+        t2 = new KerberosTicket("asn1".getBytes(), newKP("client"), newKP("server"), "pass".getBytes(), 2, new boolean[] {true, true}, new Date(0), new Date(0), new Date(0), new Date(0), null);
         checkNotSame(t1, t2);
-        t2 = new KerberosTicket("asn1".getBytes(), new KerberosPrincipal("client"), new KerberosPrincipal("server"), "pass".getBytes(), 1, new boolean[] {false, true}, new Date(0), new Date(0), new Date(0), new Date(0), null);
+        t2 = new KerberosTicket("asn1".getBytes(), newKP("client"), newKP("server"), "pass".getBytes(), 1, new boolean[] {false, true}, new Date(0), new Date(0), new Date(0), new Date(0), null);
         checkNotSame(t1, t2);
-        t2 = new KerberosTicket("asn1".getBytes(), new KerberosPrincipal("client"), new KerberosPrincipal("server"), "pass".getBytes(), 1, new boolean[] {true, true}, new Date(1), new Date(0), new Date(0), new Date(0), null);
+        t2 = new KerberosTicket("asn1".getBytes(), newKP("client"), newKP("server"), "pass".getBytes(), 1, new boolean[] {true, true}, new Date(1), new Date(0), new Date(0), new Date(0), null);
         checkNotSame(t1, t2);
-        t2 = new KerberosTicket("asn1".getBytes(), new KerberosPrincipal("client"), new KerberosPrincipal("server"), "pass".getBytes(), 1, new boolean[] {true, true}, new Date(0), new Date(1), new Date(0), new Date(0), null);
+        t2 = new KerberosTicket("asn1".getBytes(), newKP("client"), newKP("server"), "pass".getBytes(), 1, new boolean[] {true, true}, new Date(0), new Date(1), new Date(0), new Date(0), null);
         checkNotSame(t1, t2);
-        t2 = new KerberosTicket("asn1".getBytes(), new KerberosPrincipal("client"), new KerberosPrincipal("server"), "pass".getBytes(), 1, new boolean[] {true, true}, new Date(0), new Date(0), new Date(1), new Date(0), null);
+        t2 = new KerberosTicket("asn1".getBytes(), newKP("client"), newKP("server"), "pass".getBytes(), 1, new boolean[] {true, true}, new Date(0), new Date(0), new Date(1), new Date(0), null);
         checkNotSame(t1, t2);
-        t2 = new KerberosTicket("asn1".getBytes(), new KerberosPrincipal("client"), new KerberosPrincipal("server"), "pass".getBytes(), 1, new boolean[] {true, true}, new Date(0), new Date(0), new Date(0), new Date(0), new InetAddress[2]);
+        t2 = new KerberosTicket("asn1".getBytes(), newKP("client"), newKP("server"), "pass".getBytes(), 1, new boolean[] {true, true}, new Date(0), new Date(0), new Date(0), new Date(0), new InetAddress[2]);
         checkNotSame(t1, t2);
 
-        t2 = new KerberosTicket("asn1".getBytes(), new KerberosPrincipal("client"), new KerberosPrincipal("server"), "pass".getBytes(), 1, new boolean[] {true, true}, new Date(0), new Date(0), new Date(0), new Date(1), null);
-        t1 = new KerberosTicket("asn1".getBytes(), new KerberosPrincipal("client"), new KerberosPrincipal("server"), "pass".getBytes(), 1, new boolean[] {true, true}, new Date(0), new Date(0), new Date(0), new Date(2), null);
+        t2 = new KerberosTicket("asn1".getBytes(), newKP("client"), newKP("server"), "pass".getBytes(), 1, new boolean[] {true, true}, new Date(0), new Date(0), new Date(0), new Date(1), null);
+        t1 = new KerberosTicket("asn1".getBytes(), newKP("client"), newKP("server"), "pass".getBytes(), 1, new boolean[] {true, true}, new Date(0), new Date(0), new Date(0), new Date(2), null);
         checkSame(t1, t2);  // renewtill is useless
 
         t2.destroy();
@@ -126,11 +125,15 @@
         checkNotSame(t2, t1);
         checkSame(t2, t2);
 
-        t2 = new KerberosTicket("asn1".getBytes(), new KerberosPrincipal("client"), new KerberosPrincipal("server"), "pass".getBytes(), 1, new boolean[] {true, true, true, true, true, true, true, true, true, true}, new Date(0), new Date(0), new Date(0), new Date(1), null);
-        t1 = new KerberosTicket("asn1".getBytes(), new KerberosPrincipal("client"), new KerberosPrincipal("server"), "pass".getBytes(), 1, new boolean[] {true, true, true, true, true, true, true, true, true, true}, new Date(0), new Date(0), new Date(0), new Date(2), null);
+        t2 = new KerberosTicket("asn1".getBytes(), newKP("client"), newKP("server"), "pass".getBytes(), 1, new boolean[] {true, true, true, true, true, true, true, true, true, true}, new Date(0), new Date(0), new Date(0), new Date(1), null);
+        t1 = new KerberosTicket("asn1".getBytes(), newKP("client"), newKP("server"), "pass".getBytes(), 1, new boolean[] {true, true, true, true, true, true, true, true, true, true}, new Date(0), new Date(0), new Date(0), new Date(2), null);
         checkNotSame(t1, t2);  // renewtill is useful
 
         checkNotSame(t1, "Another Object");
         System.out.println("Good!");
     }
+
+    KerberosPrincipal newKP(String s) {
+        return new KerberosPrincipal(s + "@JLABS.SFBAY.SUN.COM");
+    }
 }
--- a/jdk/test/javax/security/auth/kerberos/KerberosTixDateTest.java	Wed Apr 09 09:36:19 2014 -0700
+++ b/jdk/test/javax/security/auth/kerberos/KerberosTixDateTest.java	Thu Apr 10 10:31:05 2014 +0800
@@ -25,7 +25,6 @@
  * @test
  * @bug 6659990
  * @summary test the immutability of the Date fields in KerberosTicket class.
- * @run main/manual KerberosTixDateTest
  */
 
 /*
@@ -64,8 +63,8 @@
 
     public static void main(String[] args) throws Exception {
         byte[] asn1Bytes = "asn1".getBytes();
-        KerberosPrincipal client = new KerberosPrincipal("client");
-        KerberosPrincipal server = new KerberosPrincipal("server");
+        KerberosPrincipal client = new KerberosPrincipal("client@JLABS.SFBAY.SUN.COM");
+        KerberosPrincipal server = new KerberosPrincipal("server@JLABS.SFBAY.SUN.COM");
         byte[] keyBytes = "sessionKey".getBytes();
         long originalTime = 12345678L;
         Date inDate = new Date(originalTime);