Merge
authorwetmore
Sun, 29 Jun 2008 00:25:59 -0700
changeset 795 b4e3c4974723
parent 789 218b7e32fe38 (current diff)
parent 794 2ba8b05f177a (diff)
child 797 e655898cbaec
child 901 7c3638e8ff31
Merge
--- a/jdk/src/share/classes/com/sun/security/auth/module/Krb5LoginModule.java	Fri Jun 27 12:09:37 2008 -0700
+++ b/jdk/src/share/classes/com/sun/security/auth/module/Krb5LoginModule.java	Sun Jun 29 00:25:59 2008 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2006 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2000-2008 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1145,6 +1145,10 @@
                 sharedState.put(NAME, username);
                 sharedState.put(PWD, password);
             }
+        } else {
+            // remove temp results for the next try
+            encKeys = null;
+            principal = null;
         }
         username = null;
         password = null;
--- a/jdk/src/share/classes/sun/security/provider/certpath/ConstraintsChecker.java	Fri Jun 27 12:09:37 2008 -0700
+++ b/jdk/src/share/classes/sun/security/provider/certpath/ConstraintsChecker.java	Sun Jun 29 00:25:59 2008 -0700
@@ -59,7 +59,7 @@
     private int i;
     private NameConstraintsExtension prevNC;
 
-    private static Set<String> supportedExts;
+    private Set<String> supportedExts;
 
     /**
      * Creates a ConstraintsChecker.
--- a/jdk/src/share/classes/sun/security/provider/certpath/ForwardBuilder.java	Fri Jun 27 12:09:37 2008 -0700
+++ b/jdk/src/share/classes/sun/security/provider/certpath/ForwardBuilder.java	Sun Jun 29 00:25:59 2008 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2000-2008 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -198,6 +198,11 @@
         X509CertSelector sel = null;
 
         if (currentState.isInitial()) {
+            if (targetCertConstraints.getBasicConstraints() == -2) {
+                // no need to continue: this means we never can match a CA cert
+                return;
+            }
+
             /* This means a CA is the target, so match on same stuff as
              * getMatchingEECerts
              */
--- a/jdk/src/share/classes/sun/security/provider/certpath/KeyChecker.java	Fri Jun 27 12:09:37 2008 -0700
+++ b/jdk/src/share/classes/sun/security/provider/certpath/KeyChecker.java	Sun Jun 29 00:25:59 2008 -0700
@@ -50,7 +50,7 @@
     private CertSelector targetConstraints;
     private int remainingCerts;
 
-    private static Set<String> supportedExts;
+    private Set<String> supportedExts;
 
     /**
      * Default Constructor
--- a/jdk/src/share/classes/sun/security/provider/certpath/PolicyChecker.java	Fri Jun 27 12:09:37 2008 -0700
+++ b/jdk/src/share/classes/sun/security/provider/certpath/PolicyChecker.java	Sun Jun 29 00:25:59 2008 -0700
@@ -68,7 +68,7 @@
     private int inhibitAnyPolicy;
     private int certIndex;
 
-    private static Set<String> supportedExts;
+    private Set<String> supportedExts;
 
     private static final Debug debug = Debug.getInstance("certpath");
     static final String ANY_POLICY = "2.5.29.32.0";
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/security/cert/CertPathBuilder/targetConstraints/BuildEEBasicConstraints.java	Sun Jun 29 00:25:59 2008 -0700
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/**
+ * @test
+ * @bug 6714842
+ * @library ../../../testlibrary
+ * @build CertUtils
+ * @run main BuildEEBasicConstraints
+ * @summary make sure a PKIX CertPathBuilder builds a path to an
+ *      end entity certificate when the setBasicConstraints method of the
+ *      X509CertSelector of the targetConstraints PKIXBuilderParameters
+ *      parameter is set to -2.
+ */
+
+import java.security.cert.Certificate;
+import java.security.cert.CertPath;
+import java.security.cert.CertStore;
+import java.security.cert.CollectionCertStoreParameters;
+import java.security.cert.PKIXBuilderParameters;
+import java.security.cert.PKIXCertPathBuilderResult;
+import java.security.cert.TrustAnchor;
+import java.security.cert.X509Certificate;
+import java.security.cert.X509CertSelector;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public final class BuildEEBasicConstraints {
+
+    public static void main(String[] args) throws Exception {
+
+        X509Certificate rootCert = CertUtils.getCertFromFile("anchor.cer");
+        TrustAnchor anchor = new TrustAnchor
+            (rootCert.getSubjectX500Principal(), rootCert.getPublicKey(), null);
+        X509CertSelector sel = new X509CertSelector();
+        sel.setBasicConstraints(-2);
+        PKIXBuilderParameters params = new PKIXBuilderParameters
+            (Collections.singleton(anchor), sel);
+        params.setRevocationEnabled(false);
+        X509Certificate eeCert = CertUtils.getCertFromFile("ee.cer");
+        X509Certificate caCert = CertUtils.getCertFromFile("ca.cer");
+        ArrayList<X509Certificate> certs = new ArrayList<X509Certificate>();
+        certs.add(caCert);
+        certs.add(eeCert);
+        CollectionCertStoreParameters ccsp =
+            new CollectionCertStoreParameters(certs);
+        CertStore cs = CertStore.getInstance("Collection", ccsp);
+        params.addCertStore(cs);
+        PKIXCertPathBuilderResult res = CertUtils.build(params);
+        CertPath cp = res.getCertPath();
+        // check that first certificate is an EE cert
+        List<? extends Certificate> certList = cp.getCertificates();
+        X509Certificate cert = (X509Certificate) certList.get(0);
+        if (cert.getBasicConstraints() != -1) {
+            throw new Exception("Target certificate is not an EE certificate");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/security/cert/CertPathBuilder/targetConstraints/anchor.cer	Sun Jun 29 00:25:59 2008 -0700
@@ -0,0 +1,8 @@
+-----BEGIN CERTIFICATE-----
+MIIBFzCBwgIBATANBgkqhkiG9w0BAQQFADAXMRUwEwYDVQQDEwxUcnVzdCBBbmNo
+b3IwHhcNMDIxMTA3MTE1NzAzWhcNMjIxMTA3MTE1NzAzWjAXMRUwEwYDVQQDEwxU
+cnVzdCBBbmNob3IwXDANBgkqhkiG9w0BAQEFAANLADBIAkEA9uCj12hwDgC1n9go
+0ozQAVMM+DfX0vpKOemyGNp+ycSLfAq3pxBcUKbQhjSRL7YjPkEL8XC6pRLwyEoF
+osWweQIDAQABMA0GCSqGSIb3DQEBBAUAA0EAzZta5M1qbbozj7jWnNyTgB4HUpzv
+4eP0VYQb1pQY1/xEMczaRt+RuoIDnHCq5a1vOiwk6ZbdG6GlJKx9lj0oMQ==
+-----END CERTIFICATE-----
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/security/cert/CertPathBuilder/targetConstraints/ca.cer	Sun Jun 29 00:25:59 2008 -0700
@@ -0,0 +1,9 @@
+-----BEGIN CERTIFICATE-----
+MIIBSjCB9aADAgECAgECMA0GCSqGSIb3DQEBBAUAMBcxFTATBgNVBAMTDFRydXN0
+IEFuY2hvcjAeFw0wMjExMDcxMTU3MDNaFw0yMjExMDcxMTU3MDNaMA0xCzAJBgNV
+BAMTAkNBMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAJ8mP3x37PablDfwldGL5G0+
+l9NgMJSdxVNWBg+ySzQNsZklEFCxGfxPQW+EFYfafHbTbmnni2gsgU1mgPBTQDsC
+AwEAAaM2MDQwCwYDVR0PBAQDAgIEMBcGA1UdIAQQMA4wBgYEVR0gADAEBgIqADAM
+BgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBAUAA0EA9oCyzh0UKmNsKb+KpppbKYs8
+iA8sDm9oDCwyVSXBM46zrP38nRcx3EdKFvGTwbb/Np+lcZALUsKVYQy3rlU+cQ==
+-----END CERTIFICATE-----
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/security/cert/CertPathBuilder/targetConstraints/ee.cer	Sun Jun 29 00:25:59 2008 -0700
@@ -0,0 +1,9 @@
+-----BEGIN CERTIFICATE-----
+MIIBLTCB2KADAgECAgEDMA0GCSqGSIb3DQEBBAUAMA0xCzAJBgNVBAMTAkNBMB4X
+DTAyMTEwNzExNTcwM1oXDTIyMTEwNzExNTcwM1owFTETMBEGA1UEAxMKRW5kIEVu
+dGl0eTBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQDVBDfF+uBr5s5jzzDs1njKlZNt
+h8hHzEt3ASh67Peos+QrDzgpUyFXT6fdW2h7iPf0ifjM8eW2xa+3EnPjjU5jAgMB
+AAGjGzAZMBcGA1UdIAQQMA4wBgYEVR0gADAEBgIqADANBgkqhkiG9w0BAQQFAANB
+AFo//WOboCNOCcA1fvcWW9oc4MvV8ZPvFIAbyEbgyFd4id5lGDTRbRPvvNZRvdsN
+NM2gXYr+f87NHIXc9EF3pzw=
+-----END CERTIFICATE-----