keyPurposes = cert.getExtendedKeyUsage();
@@ -360,6 +358,43 @@ class OCSPResponse {
"OCSP responses");
}
+ // check the validity
+ try {
+ Date dateCheckedAgainst = params.getDate();
+ if (dateCheckedAgainst == null) {
+ cert.checkValidity();
+ } else {
+ cert.checkValidity(dateCheckedAgainst);
+ }
+ } catch (GeneralSecurityException e) {
+ if (DEBUG != null) {
+ DEBUG.println("Responder's certificate is not " +
+ "within the validity period.");
+ }
+ throw new CertPathValidatorException(
+ "Responder's certificate not within the " +
+ "validity period");
+ }
+
+ // check for revocation
+ //
+ // A CA may specify that an OCSP client can trust a
+ // responder for the lifetime of the responder's
+ // certificate. The CA does so by including the
+ // extension id-pkix-ocsp-nocheck.
+ //
+ Extension noCheck =
+ cert.getExtension(PKIXExtensions.OCSPNoCheck_Id);
+ if (noCheck != null) {
+ if (DEBUG != null) {
+ DEBUG.println("Responder's certificate includes " +
+ "the extension id-pkix-ocsp-nocheck.");
+ }
+ } else {
+ // we should do the revocating checking of the
+ // authorized responder in a future update.
+ }
+
// verify the signature
try {
cert.verify(responderCert.getPublicKey());
@@ -369,6 +404,14 @@ class OCSPResponse {
} catch (GeneralSecurityException e) {
responderCert = null;
}
+ } else {
+ if (DEBUG != null) {
+ DEBUG.println("Responder's certificate is not " +
+ "authorized to sign OCSP responses.");
+ }
+ throw new CertPathValidatorException(
+ "Responder's certificate not authorized to sign " +
+ "OCSP responses");
}
}
diff --git a/jdk/src/share/classes/sun/security/provider/certpath/PKIXMasterCertPathValidator.java b/jdk/src/share/classes/sun/security/provider/certpath/PKIXMasterCertPathValidator.java
index d5f12168dda..7c3bfc37843 100644
--- a/jdk/src/share/classes/sun/security/provider/certpath/PKIXMasterCertPathValidator.java
+++ b/jdk/src/share/classes/sun/security/provider/certpath/PKIXMasterCertPathValidator.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2009 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
@@ -143,11 +143,15 @@ class PKIXMasterCertPathValidator {
}
} catch (CertPathValidatorException cpve) {
- // Throw the saved OCSP exception
- // (when the CRL check has also failed)
+ // Throw the saved OCSP exception unless the CRL
+ // checker has determined that the cert is revoked
if (ocspCause != null &&
- currChecker instanceof CrlRevocationChecker) {
- throw ocspCause;
+ currChecker instanceof CrlRevocationChecker) {
+ if (cpve.getReason() == BasicReason.REVOKED) {
+ throw cpve;
+ } else {
+ throw ocspCause;
+ }
}
/*
* Handle failover from OCSP to CRLs
diff --git a/jdk/src/share/classes/sun/security/tools/KeyTool.java b/jdk/src/share/classes/sun/security/tools/KeyTool.java
index ca2d6a384ab..a3aa50f435d 100644
--- a/jdk/src/share/classes/sun/security/tools/KeyTool.java
+++ b/jdk/src/share/classes/sun/security/tools/KeyTool.java
@@ -875,6 +875,18 @@ public final class KeyTool {
if (filename != null) {
inStream = new FileInputStream(filename);
}
+ // Read the full stream before feeding to X509Factory,
+ // otherwise, keytool -gencert | keytool -importcert
+ // might not work properly, since -gencert is slow
+ // and there's no data in the pipe at the beginning.
+ ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ byte[] b = new byte[4096];
+ while (true) {
+ int len = inStream.read(b);
+ if (len < 0) break;
+ bout.write(b, 0, len);
+ }
+ inStream = new ByteArrayInputStream(bout.toByteArray());
try {
String importAlias = (alias!=null)?alias:keyAlias;
if (keyStore.entryInstanceOf(importAlias, KeyStore.PrivateKeyEntry.class)) {
diff --git a/jdk/src/share/classes/sun/security/x509/OCSPNoCheckExtension.java b/jdk/src/share/classes/sun/security/x509/OCSPNoCheckExtension.java
new file mode 100644
index 00000000000..b721439d5c9
--- /dev/null
+++ b/jdk/src/share/classes/sun/security/x509/OCSPNoCheckExtension.java
@@ -0,0 +1,132 @@
+/*
+ * Copyright 2009 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. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * 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.
+ */
+
+package sun.security.x509;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Enumeration;
+
+import sun.security.util.*;
+
+/**
+ * Represent the OCSP NoCheck Extension from RFC2560.
+ *
+ * A CA may specify that an OCSP client can trust a responder for the
+ * lifetime of the responder's certificate. The CA does so by including
+ * the extension id-pkix-ocsp-nocheck. This SHOULD be a non-critical
+ * extension. The value of the extension should be NULL. CAs issuing
+ * such a certificate should realized that a compromise of the
+ * responder's key, is as serious as the compromise of a CA key used to
+ * sign CRLs, at least for the validity period of this certificate. CA's
+ * may choose to issue this type of certificate with a very short
+ * lifetime and renew it frequently.
+ *
+ * id-pkix-ocsp-nocheck OBJECT IDENTIFIER ::= { id-pkix-ocsp 5 }
+ *
+ *
+ * @author Xuelei Fan
+ * @see Extension
+ * @see CertAttrSet
+ */
+public class OCSPNoCheckExtension extends Extension
+ implements CertAttrSet {
+
+ /**
+ * Identifier for this attribute, to be used with the
+ * get, set, delete methods of Certificate, x509 type.
+ */
+ public static final String IDENT =
+ "x509.info.extensions.OCSPNoCheck";
+ /**
+ * Attribute names.
+ */
+ public static final String NAME = "OCSPNoCheck";
+
+ /**
+ * Create a OCSPNoCheckExtension
+ */
+ public OCSPNoCheckExtension() throws IOException {
+ this.extensionId = PKIXExtensions.OCSPNoCheck_Id;
+ this.critical = false;
+ this.extensionValue = new byte[0];
+ }
+
+ /**
+ * Create the extension from the passed DER encoded value.
+ *
+ * @param critical true if the extension is to be treated as critical.
+ * @param value an array of DER encoded bytes of the actual value.
+ * @exception IOException on error.
+ */
+ public OCSPNoCheckExtension(Boolean critical, Object value)
+ throws IOException {
+
+ this.extensionId = PKIXExtensions.OCSPNoCheck_Id;
+ this.critical = critical.booleanValue();
+
+ // the value should be null, just ignore it here.
+ this.extensionValue = new byte[0];
+ }
+
+ /**
+ * Set the attribute value.
+ */
+ public void set(String name, Object obj) throws IOException {
+ throw new IOException("No attribute is allowed by " +
+ "CertAttrSet:OCSPNoCheckExtension.");
+ }
+
+ /**
+ * Get the attribute value.
+ */
+ public Object get(String name) throws IOException {
+ throw new IOException("No attribute is allowed by " +
+ "CertAttrSet:OCSPNoCheckExtension.");
+ }
+
+ /**
+ * Delete the attribute value.
+ */
+ public void delete(String name) throws IOException {
+ throw new IOException("No attribute is allowed by " +
+ "CertAttrSet:OCSPNoCheckExtension.");
+ }
+
+ /**
+ * Return an enumeration of names of attributes existing within this
+ * attribute.
+ */
+ public Enumeration getElements() {
+ return (new AttributeNameEnumeration()).elements();
+ }
+
+ /**
+ * Return the name of this attribute.
+ */
+ public String getName() {
+ return NAME;
+ }
+}
diff --git a/jdk/src/share/classes/sun/security/x509/OIDMap.java b/jdk/src/share/classes/sun/security/x509/OIDMap.java
index bb7cffef343..f52fab3eeef 100644
--- a/jdk/src/share/classes/sun/security/x509/OIDMap.java
+++ b/jdk/src/share/classes/sun/security/x509/OIDMap.java
@@ -100,6 +100,8 @@ public class OIDMap {
DeltaCRLIndicatorExtension.NAME;
private static final String FRESHEST_CRL = ROOT + "." +
FreshestCRLExtension.NAME;
+ private static final String OCSPNOCHECK = ROOT + "." +
+ OCSPNoCheckExtension.NAME;
private static final int NetscapeCertType_data[] =
{ 2, 16, 840, 1, 113730, 1, 1 };
@@ -161,6 +163,8 @@ public class OIDMap {
"sun.security.x509.DeltaCRLIndicatorExtension");
addInternal(FRESHEST_CRL, PKIXExtensions.FreshestCRL_Id,
"sun.security.x509.FreshestCRLExtension");
+ addInternal(OCSPNOCHECK, PKIXExtensions.OCSPNoCheck_Id,
+ "sun.security.x509.OCSPNoCheckExtension");
}
/**
diff --git a/jdk/src/share/classes/sun/security/x509/PKIXExtensions.java b/jdk/src/share/classes/sun/security/x509/PKIXExtensions.java
index 78177944c08..f140c548551 100644
--- a/jdk/src/share/classes/sun/security/x509/PKIXExtensions.java
+++ b/jdk/src/share/classes/sun/security/x509/PKIXExtensions.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 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
@@ -74,6 +74,8 @@ public class PKIXExtensions {
private static final int AuthInfoAccess_data [] = { 1, 3, 6, 1, 5, 5, 7, 1, 1};
private static final int SubjectInfoAccess_data [] = { 1, 3, 6, 1, 5, 5, 7, 1, 11};
private static final int FreshestCRL_data [] = { 2, 5, 29, 46 };
+ private static final int OCSPNoCheck_data [] = { 1, 3, 6, 1, 5, 5, 7,
+ 48, 1, 5};
/**
* Identifies the particular public key used to sign the certificate.
@@ -216,6 +218,12 @@ public class PKIXExtensions {
*/
public static final ObjectIdentifier FreshestCRL_Id;
+ /**
+ * Identifies the OCSP client can trust the responder for the
+ * lifetime of the responder's certificate.
+ */
+ public static final ObjectIdentifier OCSPNoCheck_Id;
+
static {
AuthorityKey_Id = ObjectIdentifier.newInternal(AuthorityKey_data);
SubjectKey_Id = ObjectIdentifier.newInternal(SubjectKey_data);
@@ -257,5 +265,6 @@ public class PKIXExtensions {
SubjectInfoAccess_Id =
ObjectIdentifier.newInternal(SubjectInfoAccess_data);
FreshestCRL_Id = ObjectIdentifier.newInternal(FreshestCRL_data);
+ OCSPNoCheck_Id = ObjectIdentifier.newInternal(OCSPNoCheck_data);
}
}
diff --git a/jdk/src/solaris/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java b/jdk/src/solaris/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java
index 702b28cbbeb..78ed152d3a1 100644
--- a/jdk/src/solaris/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java
+++ b/jdk/src/solaris/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java
@@ -16,7 +16,7 @@
*
* 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 conne02110-1301 USA.
+ * 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
diff --git a/jdk/src/windows/classes/sun/nio/ch/WindowsAsynchronousSocketChannelImpl.java b/jdk/src/windows/classes/sun/nio/ch/WindowsAsynchronousSocketChannelImpl.java
index fe9920c15cc..d1f8c9307d5 100644
--- a/jdk/src/windows/classes/sun/nio/ch/WindowsAsynchronousSocketChannelImpl.java
+++ b/jdk/src/windows/classes/sun/nio/ch/WindowsAsynchronousSocketChannelImpl.java
@@ -16,7 +16,7 @@
*
* 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 conne02110-1301 USA.
+ * 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
diff --git a/jdk/test/com/sun/jmx/snmp/SnmpOidHashCode.java b/jdk/test/com/sun/jmx/snmp/SnmpOidHashCode.java
index 907d00913f4..4a815de0386 100644
--- a/jdk/test/com/sun/jmx/snmp/SnmpOidHashCode.java
+++ b/jdk/test/com/sun/jmx/snmp/SnmpOidHashCode.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-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
@@ -28,7 +28,8 @@
* @build SnmpOidHashCode
* @run main SnmpOidHashCode
*/
-import com.sun.jmx.snmp.SnmpOid;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
public class SnmpOidHashCode {
public static final String[] oids = {
@@ -57,16 +58,81 @@ public class SnmpOidHashCode {
".39."+0xFFFFFFFFL
};
+ // We use an SnmpOidBuilder in order to adapt this test case to a
+ // configuration where the SNMP packages are not present in rt.jar.
+ //
+ public static final class SnmpOidBuilder {
+ public static final String SNMP_OID_CLASS_NAME =
+ "com.sun.jmx.snmp.SnmpOid";
+ private static final Class> SNMP_OID_CLASS;
+ private static final Constructor> SNMP_OID_CTOR;
+ static {
+ Class> snmpOidClass;
+ try {
+ snmpOidClass =
+ Class.forName(SNMP_OID_CLASS_NAME, true, null);
+ } catch (ClassNotFoundException x) {
+ snmpOidClass = null;
+ System.err.println("WARNING: can't load "+SNMP_OID_CLASS_NAME);
+ } catch (NoClassDefFoundError x) {
+ snmpOidClass = null;
+ System.err.println("WARNING: can't load "+SNMP_OID_CLASS_NAME);
+ }
+ SNMP_OID_CLASS = snmpOidClass;
+ if (SNMP_OID_CLASS != null) {
+ try {
+ SNMP_OID_CTOR = snmpOidClass.getConstructor(String.class);
+ } catch (Exception x) {
+ throw new ExceptionInInitializerError(x);
+ }
+ } else {
+ SNMP_OID_CTOR = null;
+ }
+ }
+
+ public static boolean isSnmpPresent() {
+ System.out.println(SnmpOidHashCode.class.getName()+
+ ": Testing for SNMP Packages...");
+ return SNMP_OID_CLASS != null;
+ }
+
+ public static Object newSnmpOid(String oid)
+ throws InstantiationException,
+ IllegalAccessException,
+ InvocationTargetException {
+ return SNMP_OID_CTOR.newInstance(oid);
+ }
+
+ }
+
+ private static Object newSnmpOid(String oid) throws Exception {
+ try {
+ return SnmpOidBuilder.newSnmpOid(oid);
+ } catch (InvocationTargetException x) {
+ final Throwable cause = x.getCause();
+ if (cause instanceof Exception) throw (Exception)cause;
+ if (cause instanceof Error) throw (Error)cause;
+ throw x;
+ }
+ }
+
public static void main(String args[]) {
+ if (!SnmpOidBuilder.isSnmpPresent()) {
+ System.err.println("WARNING: "+
+ SnmpOidBuilder.SNMP_OID_CLASS_NAME+" not present.");
+ System.err.println(SnmpOidHashCode.class.getName()+
+ ": test skipped.");
+ return;
+ }
try {
int errCount=0;
int collisions=0;
for (int i=0;i SNMP_TIME_TICKS_CLASS;
+ private static final Constructor> SNMP_long_CTOR;
+ private static final Constructor> SNMP_LONG_CTOR;
+ private static final Method SNMP_LONG_VALUE;
+ static {
+ Class> snmpTimeTicksClass;
+ try {
+ snmpTimeTicksClass =
+ Class.forName(SNMP_TIME_TICKS_CLASS_NAME, true, null);
+ } catch (ClassNotFoundException x) {
+ snmpTimeTicksClass = null;
+ System.err.println("WARNING: can't load "+
+ SNMP_TIME_TICKS_CLASS_NAME);
+ } catch (NoClassDefFoundError x) {
+ snmpTimeTicksClass = null;
+ System.err.println("WARNING: can't load "+
+ SNMP_TIME_TICKS_CLASS_NAME);
+ }
+ SNMP_TIME_TICKS_CLASS = snmpTimeTicksClass;
+ if (SNMP_TIME_TICKS_CLASS != null) {
+ try {
+ SNMP_long_CTOR =
+ SNMP_TIME_TICKS_CLASS.getConstructor(long.class);
+ } catch (Exception x) {
+ throw new ExceptionInInitializerError(x);
+ }
+ } else {
+ SNMP_long_CTOR = null;
+ }
+ if (SNMP_TIME_TICKS_CLASS != null) {
+ try {
+ SNMP_LONG_CTOR =
+ SNMP_TIME_TICKS_CLASS.getConstructor(Long.class);
+ } catch (Exception x) {
+ throw new ExceptionInInitializerError(x);
+ }
+ } else {
+ SNMP_LONG_CTOR = null;
+ }
+ if (SNMP_TIME_TICKS_CLASS != null) {
+ try {
+ SNMP_LONG_VALUE =
+ SNMP_TIME_TICKS_CLASS.getMethod("longValue");
+ } catch (Exception x) {
+ throw new ExceptionInInitializerError(x);
+ }
+ } else {
+ SNMP_LONG_VALUE = null;
+ }
+
+ }
+
+ private final Object timeticks;
+
+ public SnmpTimeticksBuilder(long ticks) throws Exception {
+ timeticks = newSnmpTimeticks(ticks);
+ }
+ public SnmpTimeticksBuilder(Long ticks) throws Exception {
+ timeticks = newSnmpTimeticks(ticks);
+ }
+ public long longValue() throws Exception {
+ return longValue(timeticks);
+ }
+
+ public static boolean isSnmpPresent() {
+ System.out.println(TimeTicksWrapping.class.getName()+
+ ": Testing for SNMP Packages...");
+ return SNMP_TIME_TICKS_CLASS != null;
+ }
+
+ private static Object newSnmpTimeticks(long time)
+ throws Exception {
+ try {
+ return SNMP_long_CTOR.newInstance(time);
+ } catch (InvocationTargetException x) {
+ final Throwable cause = x.getCause();
+ if (cause instanceof Exception) throw (Exception) cause;
+ if (cause instanceof Error) throw (Error) cause;
+ throw x;
+ }
+ }
+
+ private static Object newSnmpTimeticks(Long time)
+ throws Exception {
+ try {
+ return SNMP_LONG_CTOR.newInstance(time);
+ } catch (InvocationTargetException x) {
+ final Throwable cause = x.getCause();
+ if (cause instanceof Exception) throw (Exception) cause;
+ if (cause instanceof Error) throw (Error) cause;
+ throw x;
+ }
+ }
+
+ private static long longValue(Object o)
+ throws Exception {
+ try {
+ return ((Long)SNMP_LONG_VALUE.invoke(o)).longValue();
+ } catch (InvocationTargetException x) {
+ final Throwable cause = x.getCause();
+ if (cause instanceof Exception) throw (Exception) cause;
+ if (cause instanceof Error) throw (Error) cause;
+ throw x;
+ }
+ }
+
+ }
+
public static final long[] oks = {
0L, 1L, (long)Integer.MAX_VALUE, (long)Integer.MAX_VALUE*2,
(long)Integer.MAX_VALUE*2+1L, (long)Integer.MAX_VALUE*2+2L,
(long)Integer.MAX_VALUE*3,
- SnmpUnsignedInt.MAX_VALUE, SnmpUnsignedInt.MAX_VALUE+1L,
- SnmpUnsignedInt.MAX_VALUE*3-1L, Long.MAX_VALUE
+ SnmpTimeticksBuilder.MAX_VALUE, SnmpTimeticksBuilder.MAX_VALUE+1L,
+ SnmpTimeticksBuilder.MAX_VALUE*3-1L, Long.MAX_VALUE
};
public static final long[] kos = {
-1L, (long)Integer.MIN_VALUE, (long)Integer.MIN_VALUE*2,
(long)Integer.MIN_VALUE*2-1L, (long)Integer.MIN_VALUE*3,
- -SnmpUnsignedInt.MAX_VALUE, -(SnmpUnsignedInt.MAX_VALUE+1L),
- -(SnmpUnsignedInt.MAX_VALUE*3-1L), Long.MIN_VALUE
+ -SnmpTimeticksBuilder.MAX_VALUE, -(SnmpTimeticksBuilder.MAX_VALUE+1L),
+ -(SnmpTimeticksBuilder.MAX_VALUE*3-1L), Long.MIN_VALUE
};
+
public static void main(String args[]) {
+ if (!SnmpTimeticksBuilder.isSnmpPresent()) {
+ System.err.println("WARNING: "+
+ SnmpTimeticksBuilder.SNMP_TIME_TICKS_CLASS_NAME+
+ " not present.");
+ System.err.println(TimeTicksWrapping.class.getName()+
+ ": test skipped.");
+ return;
+ }
try {
- SnmpTimeticks t;
+ SnmpTimeticksBuilder t = null;
for (int i=0;i SnmpUnsignedInt.MAX_VALUE)
+ if (t1 > SnmpTimeticksBuilder.MAX_VALUE)
throw new Exception("Value should have wrapped " +
"for " + oks[i] + ": " +
t1 + " exceeds max: " +
- SnmpUnsignedInt.MAX_VALUE);
- if (t2 > SnmpUnsignedInt.MAX_VALUE)
+ SnmpTimeticksBuilder.MAX_VALUE);
+ if (t2 > SnmpTimeticksBuilder.MAX_VALUE)
throw new Exception("Value should have wrapped " +
"for " + oks[i] + ": " +
t2 + " exceeds max: " +
- SnmpUnsignedInt.MAX_VALUE);
+ SnmpTimeticksBuilder.MAX_VALUE);
if (t1 < 0)
throw new Exception("Value should have wrapped: " +
@@ -90,14 +215,14 @@ public class TimeTicksWrapping {
for (int i=0;i list = Arrays.asList(new Certificate[] {targetCert});
+
+ return cf.generateCertPath(list);
+ }
+
+ private static Set generateTrustAnchors()
+ throws CertificateException {
+ // generate certificate from cert string
+ CertificateFactory cf = CertificateFactory.getInstance("X.509");
+
+ ByteArrayInputStream is =
+ new ByteArrayInputStream(trusedCertStr.getBytes());
+ Certificate trusedCert = cf.generateCertificate(is);
+
+ // generate a trust anchor
+ TrustAnchor anchor = new TrustAnchor((X509Certificate)trusedCert, null);
+
+ return Collections.singleton(anchor);
+ }
+
+ private static CertStore generateCertificateStore() throws Exception {
+ // generate CRL from CRL string
+ CertificateFactory cf = CertificateFactory.getInstance("X.509");
+
+ ByteArrayInputStream is =
+ new ByteArrayInputStream(crlStr.getBytes());
+
+ // generate a cert store
+ Collection extends CRL> crls = cf.generateCRLs(is);
+ return CertStore.getInstance("Collection",
+ new CollectionCertStoreParameters(crls));
+ }
+
+ public static void main(String args[]) throws Exception {
+ CertPath path = generateCertificatePath();
+ Set anchors = generateTrustAnchors();
+ CertStore crls = generateCertificateStore();
+
+ PKIXParameters params = new PKIXParameters(anchors);
+
+ // add the CRL store
+ params.addCertStore(crls);
+
+ // Activate certificate revocation checking
+ params.setRevocationEnabled(true);
+
+ // Activate OCSP
+ Security.setProperty("ocsp.enable", "true");
+ System.setProperty("com.sun.security.enableCRLDP", "true");
+
+ // Ensure that the ocsp.responderURL property is not set.
+ if (Security.getProperty("ocsp.responderURL") != null) {
+ throw new
+ Exception("The ocsp.responderURL property must not be set");
+ }
+
+ CertPathValidator validator = CertPathValidator.getInstance("PKIX");
+
+ try {
+ validator.validate(path, params);
+ } catch (CertPathValidatorException cpve) {
+ if (cpve.getReason() != BasicReason.REVOKED) {
+ throw new Exception(
+ "unexpect exception, should be a REVOKED CPVE", cpve);
+ }
+ }
+ }
+}
diff --git a/jdk/test/java/util/regex/RegExTest.java b/jdk/test/java/util/regex/RegExTest.java
index 29d8b55c437..17621184a53 100644
--- a/jdk/test/java/util/regex/RegExTest.java
+++ b/jdk/test/java/util/regex/RegExTest.java
@@ -3389,6 +3389,11 @@ public class RegExTest {
"gname",
"yyy");
+ check(Pattern.compile("x+(?<8gname>y+)z+"),
+ "xxxyyyzzz",
+ "8gname",
+ "yyy");
+
//backref
Pattern pattern = Pattern.compile("(a*)bc\\1");
check(pattern, "zzzaabcazzz", true); // found "abca"
diff --git a/jdk/test/javax/script/Test3.java b/jdk/test/javax/script/Test3.java
index 8aa876ba24a..66fa23af07a 100644
--- a/jdk/test/javax/script/Test3.java
+++ b/jdk/test/javax/script/Test3.java
@@ -4,7 +4,6 @@
*
* 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
diff --git a/jdk/test/sun/security/krb5/auto/SpnegoReqFlags.java b/jdk/test/sun/security/krb5/auto/SpnegoReqFlags.java
new file mode 100644
index 00000000000..a94a2b5d1ac
--- /dev/null
+++ b/jdk/test/sun/security/krb5/auto/SpnegoReqFlags.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2009 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 6815182
+ * @summary GSSAPI/SPNEGO does not work with server using MIT Kerberos library
+ */
+
+import sun.security.jgss.GSSUtil;
+import sun.security.util.BitArray;
+import sun.security.util.DerInputStream;
+import sun.security.util.DerValue;
+
+public class SpnegoReqFlags {
+
+ public static void main(String[] args)
+ throws Exception {
+
+ // Create and start the KDC
+ new OneKDC(null).writeJAASConf();
+ new SpnegoReqFlags().go();
+ }
+
+ void go() throws Exception {
+ Context c = Context.fromJAAS("client");
+ c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_SPNEGO_MECH_OID);
+
+ byte[] token = c.doAs(new Action() {
+ @Override
+ public byte[] run(Context me, byte[] input) throws Exception {
+ me.x().requestCredDeleg(true);
+ me.x().requestReplayDet(false);
+ me.x().requestSequenceDet(false);
+ return me.x().initSecContext(new byte[0], 0, 0);
+ }
+ }, null);
+
+ DerValue d = new DerValue(token); // GSSToken
+ DerInputStream ins = d.data; // OID + mech token
+ d.data.getDerValue(); // skip OID
+ d = d.data.getDerValue(); // NegTokenInit
+ d = d.data.getDerValue(); // The SEQUENCE inside
+
+ boolean found = false;
+
+ // Go through all fields inside NegTokenInit. The reqFlags field
+ // is optional. It's even not recommended in RFC 4178.
+ while (d.data.available() > 0) {
+ DerValue d2 = d.data.getDerValue();
+ if (d2.isContextSpecific((byte)1)) {
+ found = true;
+ System.out.println("regFlags field located.");
+ BitArray ba = d2.data.getUnalignedBitString();
+ if (ba.length() != 7) {
+ throw new Exception("reqFlags should contain 7 bits");
+ }
+ if (!ba.get(0)) {
+ throw new Exception("delegFlag should be true");
+ }
+ if (ba.get(2) || ba.get(3)) {
+ throw new Exception("replay/sequenceFlag should be false");
+ }
+ }
+ }
+
+ if (!found) {
+ System.out.println("Warning: regFlags field not found, too new?");
+ }
+ c.dispose();
+ }
+}
diff --git a/jdk/test/sun/security/tools/keytool/importreadall.sh b/jdk/test/sun/security/tools/keytool/importreadall.sh
new file mode 100644
index 00000000000..6c0c65dedc7
--- /dev/null
+++ b/jdk/test/sun/security/tools/keytool/importreadall.sh
@@ -0,0 +1,62 @@
+#
+# Copyright 2009 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 6819272
+# @summary keytool -importcert should read the whole input
+#
+# @run shell importreadall.sh
+
+# set a few environment variables so that the shell-script can run stand-alone
+# in the source directory
+if [ "${TESTSRC}" = "" ] ; then
+ TESTSRC="."
+fi
+
+if [ "${TESTJAVA}" = "" ] ; then
+ JAVA_CMD=`which java`
+ TESTJAVA=`dirname $JAVA_CMD`/..
+fi
+
+# set platform-dependent variables
+OS=`uname -s`
+case "$OS" in
+ Windows_* )
+ FS="\\"
+ ;;
+ * )
+ FS="/"
+ ;;
+esac
+
+KEYTOOL="${TESTJAVA}${FS}bin${FS}keytool -keystore importreadall.jks -storepass changeit -keypass changeit"
+
+# In case the test is run twice in the same directory
+
+$KEYTOOL -delete -alias a
+$KEYTOOL -delete -alias ca
+$KEYTOOL -genkeypair -alias a -dname CN=a || exit 1
+$KEYTOOL -genkeypair -alias ca -dname CN=ca || exit 2
+$KEYTOOL -certreq -alias a | $KEYTOOL -gencert -alias ca | $KEYTOOL -importcert -alias a
+
+exit $?