--- a/jdk/make/common/shared/Sanity.gmk Wed Jul 05 17:07:54 2017 +0200
+++ b/jdk/make/common/shared/Sanity.gmk Thu Mar 04 13:40:03 2010 -0800
@@ -687,13 +687,13 @@
######################################################
sane-alt_outputdir:
ifdef ALT_OUTPUTDIR
- @if [ `$(ECHO) $(subst \,/,$(ALT_OUTPUTDIR)) | $(EGREP) -ci '^([a-z]:)?/'` -ne 1 ]; then \
+ @if [ `$(ECHO) $(subst \,/,$(ALT_OUTPUTDIR)) | $(EGREP) -c '^([A-Za-z]:)?/'` -ne 1 ]; then \
$(ECHO) "ERROR: ALT_OUTPUTDIR must be an Absolute Path Name, \n" \
" not a Relative Path Name. \n" \
"" >> $(ERROR_FILE) ; \
fi
ifeq ($(PLATFORM), windows)
- @if [ `$(ECHO) $(subst \,/,$(ALT_OUTPUTDIR)) | $(EGREP) -ci '^([a-z]:)'` -ne 1 ]; then \
+ @if [ `$(ECHO) $(subst \,/,$(ALT_OUTPUTDIR)) | $(EGREP) -c '^([A-Za-z]:)'` -ne 1 ]; then \
$(ECHO) "ERROR: On windows, ALT_OUTPUTDIR must contain the drive letter. \n" \
"" >> $(ERROR_FILE) ; \
fi
@@ -742,7 +742,7 @@
######################################################
sane-alt_bootdir:
ifdef ALT_BOOTDIR
- @if [ `$(ECHO) $(subst \,/,$(ALT_BOOTDIR)) | $(EGREP) -ci '^([a-z]:)?/'` -ne 1 ]; then \
+ @if [ `$(ECHO) $(subst \,/,$(ALT_BOOTDIR)) | $(EGREP) -c '^([A-Za-z]:)?/'` -ne 1 ]; then \
$(ECHO) "ERROR: ALT_BOOTDIR must be an Absolute Path Name, \n" \
" not a Relative Path Name. \n" \
" The current value of ALT_BOOTDIR is \n" \
@@ -772,7 +772,7 @@
######################################################
sane-local-bootdir:
ifeq ($(PLATFORM), windows)
- @if [ `$(ECHO) $(BOOTDIR) | $(EGREP) -ci '^J:'` -ne 0 ]; then \
+ @if [ `$(ECHO) $(BOOTDIR) | $(EGREP) -c '^[jJ]:'` -ne 0 ]; then \
$(ECHO) "WARNING: Your BOOTDIR is located on the J: drive. Often the J:\n" \
" drive is mapped over a network. Using a mapped drive for\n" \
" the BOOTDIR may significantly slow down the build process.\n" \
@@ -789,7 +789,7 @@
######################################################
sane-cacerts:
ifdef ALT_CACERTS_FILE
- @if [ `$(ECHO) $(subst \,/,$(ALT_CACERTS_FILE)) | $(EGREP) -ci '^([a-z]:)?/'` -ne 1 ]; then \
+ @if [ `$(ECHO) $(subst \,/,$(ALT_CACERTS_FILE)) | $(EGREP) -c '^([A-Za-z]:)?/'` -ne 1 ]; then \
$(ECHO) "ERROR: ALT_CACERTS_FILE must be an Absolute Path Name, \n" \
" not a Relative Path Name. \n" \
" The current value of ALT_CACERTS_FILE is \n" \
@@ -1538,7 +1538,7 @@
sane-mozilla:
ifeq ($(ARCH_DATA_MODEL), 32)
ifdef ALT_MOZILLA_HEADERS_PATH
- @if [ `$(ECHO) $(subst \,/,$(ALT_MOZILLA_HEADERS_PATH)) | $(EGREP) -ci '^([a-z]:)?/'` -ne 1 ]; then \
+ @if [ `$(ECHO) $(subst \,/,$(ALT_MOZILLA_HEADERS_PATH)) | $(EGREP) -c '^([A-Za-z]:)?/'` -ne 1 ]; then \
$(ECHO) "ERROR: ALT_MOZILLA_HEADERS_PATH must be an Absolute Path Name, \n" \
" not a Relative Path Name. \n" \
" The current value of ALT_MOZILLA_HEADERS_PATH is \n" \
--- a/jdk/make/modules/tools/Makefile Wed Jul 05 17:07:54 2017 +0200
+++ b/jdk/make/modules/tools/Makefile Thu Mar 04 13:40:03 2010 -0800
@@ -135,9 +135,8 @@
$(CLASSANALYZER_JAR_FILE): $(BUILDTOOL_MANIFEST_FILE) $(FILES_class)
@$(prep-target)
- $(CD) $(BUILDTOOLCLASSDIR) && \
- $(BOOT_JAR_CMD) cfm $@ $(BUILDTOOL_MANIFEST_FILE) \
- $(PKGDIR) $(BOOT_JAR_JFLAGS) || $(RM) $@
+ $(BOOT_JAR_CMD) cfm $@ $(BUILDTOOL_MANIFEST_FILE) \
+ -C $(BUILDTOOLCLASSDIR) $(PKGDIR) $(BOOT_JAR_JFLAGS) || $(RM) $@
@$(java-vm-cleanup)
$(BUILDTOOLJARDIR)/classfile.jar: $(FILES_classfile_class)
--- a/jdk/src/share/classes/com/sun/jndi/ldap/Filter.java Wed Jul 05 17:07:54 2017 +0200
+++ b/jdk/src/share/classes/com/sun/jndi/ldap/Filter.java Thu Mar 04 13:40:03 2010 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1999-2010 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
@@ -33,6 +33,7 @@
/**
* LDAP (RFC-1960) and LDAPv3 (RFC-2254) search filters.
*
+ * @author Xuelei Fan
* @author Vincent Ryan
* @author Jagane Sundar
* @author Rosanna Lee
@@ -258,7 +259,7 @@
byte[] answer = new byte[j];
System.arraycopy(tbuf, 0, answer, 0, j);
if (dbg) {
- Ber.dumpBER(System.err, null, answer, 0, j);
+ Ber.dumpBER(System.err, "", answer, 0, j);
}
return answer;
}
@@ -330,7 +331,7 @@
}
- valueStart = eq + 1; // value starts after equal sign
+ valueStart = eq + 1; // value starts after equal sign
valueEnd = filtEnd;
typeStart = filtStart; // beginning of string
@@ -355,20 +356,199 @@
break;
default:
typeEnd = eq;
+ //initializing ftype to make the compiler happy
+ ftype = 0x00;
+ break;
+ }
+
+ if (dbg) {
+ System.err.println("type: " + typeStart + ", " + typeEnd);
+ System.err.println("value: " + valueStart + ", " + valueEnd);
+ }
+
+ // check validity of type
+ //
+ // RFC4512 defines the type as the following ABNF:
+ // attr = attributedescription
+ // attributedescription = attributetype options
+ // attributetype = oid
+ // oid = descr / numericoid
+ // descr = keystring
+ // keystring = leadkeychar *keychar
+ // leadkeychar = ALPHA
+ // keychar = ALPHA / DIGIT / HYPHEN
+ // numericoid = number 1*( DOT number )
+ // number = DIGIT / ( LDIGIT 1*DIGIT )
+ // options = *( SEMI option )
+ // option = 1*keychar
+ //
+ // And RFC4515 defines the extensible type as the following ABNF:
+ // attr [dnattrs] [matchingrule] / [dnattrs] matchingrule
+ int optionsStart = -1;
+ int extensibleStart = -1;
+ if ((filter[typeStart] >= '0' && filter[typeStart] <= '9') ||
+ (filter[typeStart] >= 'A' && filter[typeStart] <= 'Z') ||
+ (filter[typeStart] >= 'a' && filter[typeStart] <= 'z')) {
+
+ boolean isNumericOid =
+ filter[typeStart] >= '0' && filter[typeStart] <= '9';
+ for (int i = typeStart + 1; i < typeEnd; i++) {
+ // ';' is an indicator of attribute options
+ if (filter[i] == ';') {
+ if (isNumericOid && filter[i - 1] == '.') {
+ throw new InvalidSearchFilterException(
+ "invalid attribute description");
+ }
+
+ // attribute options
+ optionsStart = i;
+ break;
+ }
+
+ // ':' is an indicator of extensible rules
+ if (filter[i] == ':' && ftype == LDAP_FILTER_EXT) {
+ if (isNumericOid && filter[i - 1] == '.') {
+ throw new InvalidSearchFilterException(
+ "invalid attribute description");
+ }
+
+ // extensible matching
+ extensibleStart = i;
+ break;
+ }
+
+ if (isNumericOid) {
+ // numeric object identifier
+ if ((filter[i] == '.' && filter[i - 1] == '.') ||
+ (filter[i] != '.' &&
+ !(filter[i] >= '0' && filter[i] <= '9'))) {
+ throw new InvalidSearchFilterException(
+ "invalid attribute description");
+ }
+ } else {
+ // descriptor
+ if (filter[i] != '-' &&
+ !(filter[i] >= '0' && filter[i] <= '9') &&
+ !(filter[i] >= 'A' && filter[i] <= 'Z') &&
+ !(filter[i] >= 'a' && filter[i] <= 'z')) {
+ throw new InvalidSearchFilterException(
+ "invalid attribute description");
+ }
+ }
+ }
+ } else if (ftype == LDAP_FILTER_EXT && filter[typeStart] == ':') {
+ // extensible matching
+ extensibleStart = typeStart;
+ } else {
+ throw new InvalidSearchFilterException(
+ "invalid attribute description");
+ }
+
+ // check attribute options
+ if (optionsStart > 0) {
+ for (int i = optionsStart + 1; i < typeEnd; i++) {
+ if (filter[i] == ';') {
+ if (filter[i - 1] == ';') {
+ throw new InvalidSearchFilterException(
+ "invalid attribute description");
+ }
+ continue;
+ }
+
+ // ':' is an indicator of extensible rules
+ if (filter[i] == ':' && ftype == LDAP_FILTER_EXT) {
+ if (filter[i - 1] == ';') {
+ throw new InvalidSearchFilterException(
+ "invalid attribute description");
+ }
+
+ // extensible matching
+ extensibleStart = i;
+ break;
+ }
+
+ if (filter[i] != '-' &&
+ !(filter[i] >= '0' && filter[i] <= '9') &&
+ !(filter[i] >= 'A' && filter[i] <= 'Z') &&
+ !(filter[i] >= 'a' && filter[i] <= 'z')) {
+ throw new InvalidSearchFilterException(
+ "invalid attribute description");
+ }
+ }
+ }
+
+ // check extensible matching
+ if (extensibleStart > 0) {
+ boolean isMatchingRule = false;
+ for (int i = extensibleStart + 1; i < typeEnd; i++) {
+ if (filter[i] == ':') {
+ throw new InvalidSearchFilterException(
+ "invalid attribute description");
+ } else if ((filter[i] >= '0' && filter[i] <= '9') ||
+ (filter[i] >= 'A' && filter[i] <= 'Z') ||
+ (filter[i] >= 'a' && filter[i] <= 'z')) {
+ boolean isNumericOid = filter[i] >= '0' && filter[i] <= '9';
+ i++;
+ for (int j = i; j < typeEnd; j++, i++) {
+ // allows no more than two extensible rules
+ if (filter[j] == ':') {
+ if (isMatchingRule) {
+ throw new InvalidSearchFilterException(
+ "invalid attribute description");
+ }
+ if (isNumericOid && filter[j - 1] == '.') {
+ throw new InvalidSearchFilterException(
+ "invalid attribute description");
+ }
+
+ isMatchingRule = true;
+ break;
+ }
+
+ if (isNumericOid) {
+ // numeric object identifier
+ if ((filter[j] == '.' && filter[j - 1] == '.') ||
+ (filter[j] != '.' &&
+ !(filter[j] >= '0' && filter[j] <= '9'))) {
+ throw new InvalidSearchFilterException(
+ "invalid attribute description");
+ }
+ } else {
+ // descriptor
+ if (filter[j] != '-' &&
+ !(filter[j] >= '0' && filter[j] <= '9') &&
+ !(filter[j] >= 'A' && filter[j] <= 'Z') &&
+ !(filter[j] >= 'a' && filter[j] <= 'z')) {
+ throw new InvalidSearchFilterException(
+ "invalid attribute description");
+ }
+ }
+ }
+ } else {
+ throw new InvalidSearchFilterException(
+ "invalid attribute description");
+ }
+ }
+ }
+
+ // ensure the latest byte is not isolated
+ if (filter[typeEnd - 1] == '.' || filter[typeEnd - 1] == ';' ||
+ filter[typeEnd - 1] == ':') {
+ throw new InvalidSearchFilterException(
+ "invalid attribute description");
+ }
+
+ if (typeEnd == eq) { // filter type is of "equal"
if (findUnescaped(filter, '*', valueStart, valueEnd) == -1) {
ftype = LDAP_FILTER_EQUALITY;
- } else if (filter[valueStart] == '*' && valueStart == (valueEnd - 1)) {
+ } else if (filter[valueStart] == '*' &&
+ valueStart == (valueEnd - 1)) {
ftype = LDAP_FILTER_PRESENT;
} else {
encodeSubstringFilter(ber, filter,
typeStart, typeEnd, valueStart, valueEnd);
return;
}
- break;
- }
- if (dbg) {
- System.err.println("type: " + typeStart + ", " + typeEnd);
- System.err.println("value: " + valueStart + ", " + valueEnd);
}
if (ftype == LDAP_FILTER_PRESENT) {
@@ -379,7 +559,7 @@
} else {
ber.beginSeq(ftype);
ber.encodeOctetString(filter, Ber.ASN_OCTET_STR,
- typeStart, typeEnd-typeStart);
+ typeStart, typeEnd - typeStart);
ber.encodeOctetString(
unescapeFilterValue(filter, valueStart, valueEnd),
Ber.ASN_OCTET_STR);
@@ -623,7 +803,8 @@
//
////////////////////////////////////////////////////////////////////////////
- private static final boolean dbg = false;
+ // private static final boolean dbg = false;
+ private static final boolean dbg = true;
private static int dbgIndent = 0;
private static void dprint(String msg) {
--- a/jdk/src/share/classes/java/lang/Iterable.java Wed Jul 05 17:07:54 2017 +0200
+++ b/jdk/src/share/classes/java/lang/Iterable.java Thu Mar 04 13:40:03 2010 -0800
@@ -27,8 +27,12 @@
import java.util.Iterator;
-/** Implementing this interface allows an object to be the target of
- * the "foreach" statement.
+/**
+ * Implementing this interface allows an object to be the target of
+ * the "foreach" statement.
+ *
+ * @param <T> the type of elements returned by the iterator
+ *
* @since 1.5
*/
public interface Iterable<T> {
--- a/jdk/src/share/classes/java/lang/String.java Wed Jul 05 17:07:54 2017 +0200
+++ b/jdk/src/share/classes/java/lang/String.java Thu Mar 04 13:40:03 2010 -0800
@@ -1492,7 +1492,7 @@
*/
public int hashCode() {
int h = hash;
- if (h == 0) {
+ if (h == 0 && count > 0) {
int off = offset;
char val[] = value;
int len = count;
--- a/jdk/src/share/classes/java/security/IdentityScope.java Wed Jul 05 17:07:54 2017 +0200
+++ b/jdk/src/share/classes/java/security/IdentityScope.java Thu Mar 04 13:40:03 2010 -0800
@@ -129,7 +129,8 @@
/**
* Returns the system's identity scope.
*
- * @return the system's identity scope.
+ * @return the system's identity scope, or {@code null} if none has been
+ * set.
*
* @see #setSystemScope
*/
--- a/jdk/src/share/classes/java/util/Collection.java Wed Jul 05 17:07:54 2017 +0200
+++ b/jdk/src/share/classes/java/util/Collection.java Thu Mar 04 13:40:03 2010 -0800
@@ -103,6 +103,8 @@
* <a href="{@docRoot}/../technotes/guides/collections/index.html">
* Java Collections Framework</a>.
*
+ * @param <E> the type of elements in this collection
+ *
* @author Josh Bloch
* @author Neal Gafter
* @see Set
--- a/jdk/src/share/classes/java/util/DualPivotQuicksort.java Wed Jul 05 17:07:54 2017 +0200
+++ b/jdk/src/share/classes/java/util/DualPivotQuicksort.java Thu Mar 04 13:40:03 2010 -0800
@@ -253,7 +253,7 @@
a[less] = ak;
}
less++;
- } else { // (a[k] > pivot1) - Move a[k] to right part
+ } else { // (a[k] > pivot1) - Move a[k] to right part
/*
* We know that pivot1 == a[e3] == pivot2. Thus, we know
* that great will still be >= k when the following loop
@@ -531,7 +531,7 @@
a[less] = ak;
}
less++;
- } else { // (a[k] > pivot1) - Move a[k] to right part
+ } else { // (a[k] > pivot1) - Move a[k] to right part
/*
* We know that pivot1 == a[e3] == pivot2. Thus, we know
* that great will still be >= k when the following loop
@@ -826,7 +826,7 @@
a[less] = ak;
}
less++;
- } else { // (a[k] > pivot1) - Move a[k] to right part
+ } else { // (a[k] > pivot1) - Move a[k] to right part
/*
* We know that pivot1 == a[e3] == pivot2. Thus, we know
* that great will still be >= k when the following loop
@@ -1119,7 +1119,7 @@
a[less] = ak;
}
less++;
- } else { // (a[k] > pivot1) - Move a[k] to right part
+ } else { // (a[k] > pivot1) - Move a[k] to right part
/*
* We know that pivot1 == a[e3] == pivot2. Thus, we know
* that great will still be >= k when the following loop
@@ -1414,7 +1414,7 @@
a[less] = ak;
}
less++;
- } else { // (a[k] > pivot1) - Move a[k] to right part
+ } else { // (a[k] > pivot1) - Move a[k] to right part
/*
* We know that pivot1 == a[e3] == pivot2. Thus, we know
* that great will still be >= k when the following loop
@@ -1531,7 +1531,7 @@
* Sorts the specified range of the array into ascending order. The range
* to be sorted extends from the index {@code fromIndex}, inclusive, to
* the index {@code toIndex}, exclusive. If {@code fromIndex == toIndex},
- * the range to be sorted is empty and the call is a no-op).
+ * the range to be sorted is empty and the call is a no-op).
*
* <p>The {@code <} relation does not provide a total order on all float
* values: {@code -0.0f == 0.0f} is {@code true} and a {@code Float.NaN}
@@ -1787,7 +1787,7 @@
a[less] = ak;
}
less++;
- } else { // (a[k] > pivot1) - Move a[k] to right part
+ } else { // (a[k] > pivot1) - Move a[k] to right part
/*
* We know that pivot1 == a[e3] == pivot2. Thus, we know
* that great will still be >= k when the following loop
@@ -2160,7 +2160,7 @@
a[less] = ak;
}
less++;
- } else { // (a[k] > pivot1) - Move a[k] to right part
+ } else { // (a[k] > pivot1) - Move a[k] to right part
/*
* We know that pivot1 == a[e3] == pivot2. Thus, we know
* that great will still be >= k when the following loop
--- a/jdk/src/share/classes/java/util/Iterator.java Wed Jul 05 17:07:54 2017 +0200
+++ b/jdk/src/share/classes/java/util/Iterator.java Thu Mar 04 13:40:03 2010 -0800
@@ -41,6 +41,8 @@
* <a href="{@docRoot}/../technotes/guides/collections/index.html">
* Java Collections Framework</a>.
*
+ * @param <E> the type of elements returned by this iterator
+ *
* @author Josh Bloch
* @see Collection
* @see ListIterator
--- a/jdk/src/share/classes/java/util/List.java Wed Jul 05 17:07:54 2017 +0200
+++ b/jdk/src/share/classes/java/util/List.java Thu Mar 04 13:40:03 2010 -0800
@@ -89,6 +89,8 @@
* <a href="{@docRoot}/../technotes/guides/collections/index.html">
* Java Collections Framework</a>.
*
+ * @param <E> the type of elements in this list
+ *
* @author Josh Bloch
* @author Neal Gafter
* @see Collection
--- a/jdk/src/share/classes/sun/nio/fs/AbstractWatchKey.java Wed Jul 05 17:07:54 2017 +0200
+++ b/jdk/src/share/classes/sun/nio/fs/AbstractWatchKey.java Thu Mar 04 13:40:03 2010 -0800
@@ -59,10 +59,15 @@
// pending events
private List<WatchEvent<?>> events;
+ // maps a context to the last event for the context (iff the last queued
+ // event for the context is an ENTRY_MODIFY event).
+ private Map<Object,WatchEvent<?>> lastModifyEvents;
+
protected AbstractWatchKey(AbstractWatchService watcher) {
this.watcher = watcher;
this.state = State.READY;
this.events = new ArrayList<WatchEvent<?>>();
+ this.lastModifyEvents = new HashMap<Object,WatchEvent<?>>();
}
final AbstractWatchService watcher() {
@@ -86,6 +91,7 @@
*/
@SuppressWarnings("unchecked")
final void signalEvent(WatchEvent.Kind<?> kind, Object context) {
+ boolean isModify = (kind == StandardWatchEventKind.ENTRY_MODIFY);
synchronized (this) {
int size = events.size();
if (size > 0) {
@@ -100,17 +106,43 @@
return;
}
+ // if this is a modify event and the last entry for the context
+ // is a modify event then we simply increment the count
+ if (!lastModifyEvents.isEmpty()) {
+ if (isModify) {
+ WatchEvent<?> ev = lastModifyEvents.get(context);
+ if (ev != null) {
+ assert ev.kind() == StandardWatchEventKind.ENTRY_MODIFY;
+ ((Event<?>)ev).increment();
+ return;
+ }
+ } else {
+ // not a modify event so remove from the map as the
+ // last event will no longer be a modify event.
+ lastModifyEvents.remove(context);
+ }
+ }
+
// if the list has reached the limit then drop pending events
// and queue an OVERFLOW event
if (size >= MAX_EVENT_LIST_SIZE) {
- events.clear();
kind = StandardWatchEventKind.OVERFLOW;
+ isModify = false;
context = null;
}
}
// non-repeated event
- events.add(new Event<Object>((WatchEvent.Kind<Object>)kind, context));
+ Event<Object> ev =
+ new Event<Object>((WatchEvent.Kind<Object>)kind, context);
+ if (isModify) {
+ lastModifyEvents.put(context, ev);
+ } else if (kind == StandardWatchEventKind.OVERFLOW) {
+ // drop all pending events
+ events.clear();
+ lastModifyEvents.clear();
+ }
+ events.add(ev);
signal();
}
}
@@ -120,6 +152,7 @@
synchronized (this) {
List<WatchEvent<?>> result = events;
events = new ArrayList<WatchEvent<?>>();
+ lastModifyEvents.clear();
return result;
}
}
--- a/jdk/src/share/classes/sun/security/krb5/internal/crypto/EType.java Wed Jul 05 17:07:54 2017 +0200
+++ b/jdk/src/share/classes/sun/security/krb5/internal/crypto/EType.java Thu Mar 04 13:40:03 2010 -0800
@@ -1,5 +1,5 @@
/*
- * Portions Copyright 2000-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Portions Copyright 2000-2010 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
@@ -36,9 +36,9 @@
import sun.security.krb5.EncryptedData;
import sun.security.krb5.EncryptionKey;
import sun.security.krb5.KrbException;
-import sun.security.krb5.Asn1Exception;
import sun.security.krb5.KrbCryptoException;
import javax.crypto.*;
+import java.util.Arrays;
import java.util.List;
import java.util.ArrayList;
@@ -48,6 +48,23 @@
public abstract class EType {
private static final boolean DEBUG = Krb5.DEBUG;
+ private static final boolean ALLOW_WEAK_CRYPTO;
+
+ static {
+ boolean allowed = true;
+ try {
+ Config cfg = Config.getInstance();
+ String temp = cfg.getDefault("allow_weak_crypto", "libdefaults");
+ if (temp != null && temp.equals("false")) allowed = false;
+ } catch (Exception exc) {
+ if (DEBUG) {
+ System.out.println ("Exception in getting allow_weak_crypto, " +
+ "using default value " +
+ exc.getMessage());
+ }
+ }
+ ALLOW_WEAK_CRYPTO = allowed;
+ }
public static EType getInstance (int eTypeConst)
throws KdcErrException {
@@ -163,6 +180,10 @@
return result;
}
+ // Note: the first 2 entries of BUILTIN_ETYPES and BUILTIN_ETYPES_NOAES256
+ // should be kept DES-related. They will be removed when allow_weak_crypto
+ // is set to false.
+
private static final int[] BUILTIN_ETYPES = new int[] {
EncryptedData.ETYPE_DES_CBC_MD5,
EncryptedData.ETYPE_DES_CBC_CRC,
@@ -189,10 +210,17 @@
} catch (Exception e) {
// should not happen
}
+ int[] result;
if (allowed < 256) {
- return BUILTIN_ETYPES_NOAES256;
+ result = BUILTIN_ETYPES_NOAES256;
+ } else {
+ result = BUILTIN_ETYPES;
}
- return BUILTIN_ETYPES;
+ if (!ALLOW_WEAK_CRYPTO) {
+ // The first 2 etypes are now weak ones
+ return Arrays.copyOfRange(result, 2, result.length);
+ }
+ return result;
}
/**
@@ -207,9 +235,7 @@
if (DEBUG) {
System.out.println("Exception while getting " +
configName + exc.getMessage());
- System.out.println("Using defaults " +
- "des-cbc-md5, des-cbc-crc, des3-cbc-sha1," +
- " aes128cts, aes256cts, rc4-hmac");
+ System.out.println("Using default builtin etypes");
}
return getBuiltInDefaults();
}
--- a/jdk/src/share/classes/sun/security/provider/JavaKeyStore.java Wed Jul 05 17:07:54 2017 +0200
+++ b/jdk/src/share/classes/sun/security/provider/JavaKeyStore.java Thu Mar 04 13:40:03 2010 -0800
@@ -29,9 +29,9 @@
import java.security.*;
import java.security.cert.Certificate;
import java.security.cert.CertificateFactory;
-import java.security.cert.X509Certificate;
import java.security.cert.CertificateException;
import java.util.*;
+import sun.misc.IOUtils;
import sun.security.pkcs.EncryptedPrivateKeyInfo;
@@ -677,50 +677,39 @@
entry.date = new Date(dis.readLong());
// Read the private key
- try {
- entry.protectedPrivKey = new byte[dis.readInt()];
- } catch (OutOfMemoryError e) {
- throw new IOException("Keysize too big");
- }
- dis.readFully(entry.protectedPrivKey);
+ entry.protectedPrivKey =
+ IOUtils.readFully(dis, dis.readInt(), true);
// Read the certificate chain
int numOfCerts = dis.readInt();
- try {
- if (numOfCerts > 0) {
- entry.chain = new Certificate[numOfCerts];
+ if (numOfCerts > 0) {
+ List<Certificate> certs = new ArrayList<>(
+ numOfCerts > 10 ? 10 : numOfCerts);
+ for (int j = 0; j < numOfCerts; j++) {
+ if (xVersion == 2) {
+ // read the certificate type, and instantiate a
+ // certificate factory of that type (reuse
+ // existing factory if possible)
+ String certType = dis.readUTF();
+ if (cfs.containsKey(certType)) {
+ // reuse certificate factory
+ cf = cfs.get(certType);
+ } else {
+ // create new certificate factory
+ cf = CertificateFactory.getInstance(certType);
+ // store the certificate factory so we can
+ // reuse it later
+ cfs.put(certType, cf);
+ }
+ }
+ // instantiate the certificate
+ encoded = IOUtils.readFully(dis, dis.readInt(), true);
+ bais = new ByteArrayInputStream(encoded);
+ certs.add(cf.generateCertificate(bais));
+ bais.close();
}
- } catch (OutOfMemoryError e) {
- throw new IOException
- ("Too many certificates in chain");
- }
- for (int j = 0; j < numOfCerts; j++) {
- if (xVersion == 2) {
- // read the certificate type, and instantiate a
- // certificate factory of that type (reuse
- // existing factory if possible)
- String certType = dis.readUTF();
- if (cfs.containsKey(certType)) {
- // reuse certificate factory
- cf = cfs.get(certType);
- } else {
- // create new certificate factory
- cf = CertificateFactory.getInstance(certType);
- // store the certificate factory so we can
- // reuse it later
- cfs.put(certType, cf);
- }
- }
- // instantiate the certificate
- try {
- encoded = new byte[dis.readInt()];
- } catch (OutOfMemoryError e) {
- throw new IOException("Certificate too big");
- }
- dis.readFully(encoded);
- bais = new ByteArrayInputStream(encoded);
- entry.chain[j] = cf.generateCertificate(bais);
- bais.close();
+ // We can be sure now that numOfCerts of certs are read
+ entry.chain = certs.toArray(new Certificate[numOfCerts]);
}
// Add the entry to the list
@@ -753,12 +742,7 @@
cfs.put(certType, cf);
}
}
- try {
- encoded = new byte[dis.readInt()];
- } catch (OutOfMemoryError e) {
- throw new IOException("Certificate too big");
- }
- dis.readFully(encoded);
+ encoded = IOUtils.readFully(dis, dis.readInt(), true);
bais = new ByteArrayInputStream(encoded);
entry.cert = cf.generateCertificate(bais);
bais.close();
--- a/jdk/src/share/classes/sun/security/tools/TimestampedSigner.java Wed Jul 05 17:07:54 2017 +0200
+++ b/jdk/src/share/classes/sun/security/tools/TimestampedSigner.java Thu Mar 04 13:40:03 2010 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007-2009 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2007-2010 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
@@ -375,7 +375,8 @@
}
if (!isSigner) {
keyPurposes = cert.getExtendedKeyUsage();
- if (! keyPurposes.contains(KP_TIMESTAMPING_OID)) {
+ if (keyPurposes == null ||
+ ! keyPurposes.contains(KP_TIMESTAMPING_OID)) {
throw new CertificateException(
"Certificate is not valid for timestamping");
}
--- a/jdk/src/share/lib/security/java.security Wed Jul 05 17:07:54 2017 +0200
+++ b/jdk/src/share/lib/security/java.security Thu Mar 04 13:40:03 2010 -0800
@@ -118,11 +118,6 @@
keystore.type=jks
#
-# Class to instantiate as the system scope:
-#
-system.scope=sun.security.provider.IdentityDatabase
-
-#
# List of comma-separated packages that start with or equal this string
# will cause a security exception to be thrown when
# passed to checkPackageAccess unless the
--- a/jdk/src/solaris/classes/sun/nio/fs/UnixPath.java Wed Jul 05 17:07:54 2017 +0200
+++ b/jdk/src/solaris/classes/sun/nio/fs/UnixPath.java Thu Mar 04 13:40:03 2010 -0800
@@ -624,8 +624,11 @@
public boolean endsWith(Path other) {
UnixPath that = checkPath(other);
+ int thisLen = path.length;
+ int thatLen = that.path.length;
+
// other path is longer
- if (that.path.length > path.length)
+ if (thatLen > thisLen)
return false;
// other path is absolute so this path must be absolute
@@ -643,10 +646,10 @@
if (thatOffsetCount == thisOffsetCount) {
if (thisOffsetCount == 0)
return true;
- int expectedLen = path.length;
+ int expectedLen = thisLen;
if (this.isAbsolute() && !that.isAbsolute())
expectedLen--;
- if (that.path.length != expectedLen)
+ if (thatLen != expectedLen)
return false;
} else {
// this path has more elements so given path must be relative
@@ -658,7 +661,9 @@
// compare bytes
int thisPos = offsets[thisOffsetCount - thatOffsetCount];
int thatPos = that.offsets[0];
- while (thatPos < that.path.length) {
+ if ((thatLen - thatPos) != (thisLen - thisPos))
+ return false;
+ while (thatPos < thatLen) {
if (this.path[thisPos++] != that.path[thatPos++])
return false;
}
--- a/jdk/src/solaris/native/java/io/UnixFileSystem_md.c Wed Jul 05 17:07:54 2017 +0200
+++ b/jdk/src/solaris/native/java/io/UnixFileSystem_md.c Thu Mar 04 13:40:03 2010 -0800
@@ -414,9 +414,9 @@
jlong rv = 0L;
WITH_FIELD_PLATFORM_STRING(env, file, ids.path, path) {
- struct statvfs fsstat;
- memset(&fsstat, 0, sizeof(struct statvfs));
- if (statvfs(path, &fsstat) == 0) {
+ struct statvfs64 fsstat;
+ memset(&fsstat, 0, sizeof(fsstat));
+ if (statvfs64(path, &fsstat) == 0) {
switch(t) {
case java_io_FileSystem_SPACE_TOTAL:
rv = jlong_mul(long_to_jlong(fsstat.f_frsize),
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/com/sun/jndi/ldap/InvalidLdapFilters.java Thu Mar 04 13:40:03 2010 -0800
@@ -0,0 +1,311 @@
+/*
+ * Copyright 2010 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 6916202
+ * @summary More cases of invalid ldap filters accepted and processed
+ * @run main/othervm InvalidLdapFilters valid (cn=Babs)
+ * @run main/othervm InvalidLdapFilters valid (&(cn=Bob))
+ * @run main/othervm InvalidLdapFilters valid (&(objectClass=*)(uid=*))
+ * @run main/othervm InvalidLdapFilters valid (|(cn=Bob))
+ * @run main/othervm InvalidLdapFilters valid (|(objectClass=*)(uid=*))
+ * @run main/othervm InvalidLdapFilters valid (!(cn=Tim))
+ * @run main/othervm InvalidLdapFilters valid (!(!(cn=Tim)))
+ * @run main/othervm InvalidLdapFilters valid (!(&(objectClass=*)(uid=*)))
+ * @run main/othervm InvalidLdapFilters valid (!(|(objectClass=*)(uid=*)))
+ * @run main/othervm InvalidLdapFilters valid (o=univ*of*mich*)
+ * @run main/othervm InvalidLdapFilters valid (seeAlso=)
+ * @run main/othervm InvalidLdapFilters valid (cn:caseExactMatch:=Flintstone)
+ * @run main/othervm InvalidLdapFilters valid (cn:=Betty)
+ * @run main/othervm InvalidLdapFilters valid (sn:dn:2.4.6.8.10:=Barney)
+ * @run main/othervm InvalidLdapFilters valid (o:dn:=Ace)
+ * @run main/othervm InvalidLdapFilters valid (:1.2.3:=Wilma)
+ * @run main/othervm InvalidLdapFilters valid (:DN:2.4.6.8.10:=Dino)
+ * @run main/othervm InvalidLdapFilters valid (1.2.3=abc)
+ * @run main/othervm InvalidLdapFilters valid (cn;lang-de;lang-en=abc)
+ * @run main/othervm InvalidLdapFilters valid (owner=abc)
+ * @run main/othervm InvalidLdapFilters valid (sn;lang-en:dn:2.4.6.8.10:=Barney)
+ * @run main/othervm InvalidLdapFilters valid
+ (&(objectClass=Person)(|(sn=Jensen)(cn=Bab*)))
+ * @run main/othervm InvalidLdapFilters invalid "(&(cn=Robert Dean)))"
+ * @run main/othervm InvalidLdapFilters invalid (&|(cn=Bob))
+ * @run main/othervm InvalidLdapFilters invalid (&&(cn=Bob))
+ * @run main/othervm InvalidLdapFilters invalid (|&(cn=Bob))
+ * @run main/othervm InvalidLdapFilters invalid (||(cn=Bob))
+ * @run main/othervm InvalidLdapFilters invalid (:1.2.:=Wilma)
+ * @run main/othervm InvalidLdapFilters invalid (::DN:2.4.6.8.10:=Dino)
+ * @run main/othervm InvalidLdapFilters invalid (:DN::2.4.6.8.10:=Dino)
+ * @run main/othervm InvalidLdapFilters invalid (:DN:2.4.6.8.10::=Dino)
+ * @run main/othervm InvalidLdapFilters invalid (:DN:2.4.6..8.10:=Dino)
+ * @run main/othervm InvalidLdapFilters invalid (:DN:2.4.6.8.:=Dino)
+ * @run main/othervm InvalidLdapFilters invalid (1.2.;::=abc)
+ * @run main/othervm InvalidLdapFilters invalid (1.2.3;::=abc)
+ * @run main/othervm InvalidLdapFilters invalid (1.2.3;x;=abc)
+ * @run main/othervm InvalidLdapFilters invalid (1.2.3:x::=abc)
+ * @run main/othervm InvalidLdapFilters invalid (1.2.3:x=abc)
+ * @run main/othervm InvalidLdapFilters invalid (sn;:dn:2.4.6.8.10:=Barney)
+ * @run main/othervm InvalidLdapFilters invalid "\"((objectClass=*)&(uid=*))\""
+ * @run main/othervm InvalidLdapFilters invalid "&(objectClass=*)(uid=*)"
+ * @run main/othervm InvalidLdapFilters invalid "(:DN:2.4.6.8.10:cn:=Dino)"
+ * @run main/othervm InvalidLdapFilters invalid "(:DN:2.4.6.8.10:cn=Dino)"
+ * @run main/othervm InvalidLdapFilters invalid
+ "((objectCategory=person)(cn=u)(!(cn=u2*)))"
+ * @run main/othervm InvalidLdapFilters invalid
+ "((&(objectClass=user)(cn=andy*)(cn=steve*)(cn=bob*)))"
+ *
+ * @author Xuelei Fan
+ */
+
+import java.io.*;
+import javax.naming.*;
+import javax.naming.directory.*;
+import java.util.Properties;
+import java.util.Hashtable;
+
+import java.net.Socket;
+import java.net.ServerSocket;
+
+public class InvalidLdapFilters {
+ // Should we run the client or server in a separate thread?
+ //
+ // Both sides can throw exceptions, but do you have a preference
+ // as to which side should be the main thread.
+ static boolean separateServerThread = true;
+
+ // use any free port by default
+ volatile int serverPort = 0;
+
+ // Is the server ready to serve?
+ volatile static boolean serverReady = false;
+
+ // Define the server side of the test.
+ //
+ // If the server prematurely exits, serverReady will be set to true
+ // to avoid infinite hangs.
+ void doServerSide() throws Exception {
+ ServerSocket serverSock = new ServerSocket(serverPort);
+
+ // signal client, it's ready to accecpt connection
+ serverPort = serverSock.getLocalPort();
+ serverReady = true;
+
+ // accept a connection
+ Socket socket = serverSock.accept();
+ System.out.println("Server: Connection accepted");
+
+ InputStream is = socket.getInputStream();
+ OutputStream os = socket.getOutputStream();
+
+ // read the bindRequest
+ while (is.read() != -1) {
+ // ignore
+ is.skip(is.available());
+ break;
+ }
+
+ byte[] bindResponse = {0x30, 0x0C, 0x02, 0x01, 0x01, 0x61, 0x07, 0x0A,
+ 0x01, 0x00, 0x04, 0x00, 0x04, 0x00};
+ // write bindResponse
+ os.write(bindResponse);
+ os.flush();
+
+ // ignore any more request.
+ while (is.read() != -1) {
+ // ignore
+ is.skip(is.available());
+ }
+
+ is.close();
+ os.close();
+ socket.close();
+ serverSock.close();
+ }
+
+ // Define the client side of the test.
+ //
+ // If the server prematurely exits, serverReady will be set to true
+ // to avoid infinite hangs.
+ void doClientSide() throws Exception {
+ // Wait for server to get started.
+ while (!serverReady) {
+ Thread.sleep(50);
+ }
+
+ // set up the environment for creating the initial context
+ Hashtable<Object, Object> env = new Hashtable<Object, Object>();
+ env.put(Context.INITIAL_CONTEXT_FACTORY,
+ "com.sun.jndi.ldap.LdapCtxFactory");
+ env.put(Context.PROVIDER_URL, "ldap://localhost:" + serverPort);
+ env.put("com.sun.jndi.ldap.read.timeout", "1000");
+
+ // env.put(Context.SECURITY_AUTHENTICATION, "simple");
+ // env.put(Context.SECURITY_PRINCIPAL,"cn=root");
+ // env.put(Context.SECURITY_CREDENTIALS,"root");
+
+ // create initial context
+ DirContext context = new InitialDirContext(env);
+
+ // searching
+ SearchControls scs = new SearchControls();
+ scs.setSearchScope(SearchControls.SUBTREE_SCOPE);
+
+ try {
+ NamingEnumeration answer =
+ context.search("o=sun,c=us", searchFilter, scs);
+ } catch (InvalidSearchFilterException isfe) {
+ if (filterIsValid) {
+ // unexpected filter exception.
+ throw new Exception("Unexpected ISFE", isfe);
+ } else {
+ // ignore, it is the expected filter exception.
+ System.out.println("Expected exception: " + isfe.getMessage());
+ }
+ } catch (NamingException ne) {
+ // maybe a read timeout exception, as the server does not response.
+ if (filterIsValid) {
+ System.out.println("Expected exception: " + ne.getMessage());
+ } else {
+ throw new Exception("Not an InvalidSearchFilterException", ne);
+ }
+ }
+
+ context.close();
+ }
+
+ private static boolean filterIsValid;
+ private static String searchFilter;
+
+ private static void parseArguments(String[] args) {
+ System.out.println("arguments length: " + args.length);
+ if (args[0].equals("valid")) {
+ filterIsValid = true;
+ }
+
+ searchFilter = args[1];
+ }
+
+ /*
+ * ============================================================
+ * The remainder is just support stuff
+ */
+
+ // client and server thread
+ Thread clientThread = null;
+ Thread serverThread = null;
+
+ // client and server exceptions
+ volatile Exception serverException = null;
+ volatile Exception clientException = null;
+
+ void startServer(boolean newThread) throws Exception {
+ if (newThread) {
+ serverThread = new Thread() {
+ public void run() {
+ try {
+ doServerSide();
+ } catch (Exception e) {
+ /*
+ * Our server thread just died.
+ *
+ * Release the client, if not active already...
+ */
+ System.err.println("Server died...");
+ System.err.println(e);
+ serverReady = true;
+ serverException = e;
+ }
+ }
+ };
+ serverThread.start();
+ } else {
+ doServerSide();
+ }
+ }
+
+ void startClient(boolean newThread) throws Exception {
+ if (newThread) {
+ clientThread = new Thread() {
+ public void run() {
+ try {
+ doClientSide();
+ } catch (Exception e) {
+ /*
+ * Our client thread just died.
+ */
+ System.err.println("Client died...");
+ clientException = e;
+ }
+ }
+ };
+ clientThread.start();
+ } else {
+ doClientSide();
+ }
+ }
+
+ // Primary constructor, used to drive remainder of the test.
+ InvalidLdapFilters() throws Exception {
+ if (separateServerThread) {
+ startServer(true);
+ startClient(false);
+ } else {
+ startClient(true);
+ startServer(false);
+ }
+
+ /*
+ * Wait for other side to close down.
+ */
+ if (separateServerThread) {
+ serverThread.join();
+ } else {
+ clientThread.join();
+ }
+
+ /*
+ * When we get here, the test is pretty much over.
+ *
+ * If the main thread excepted, that propagates back
+ * immediately. If the other thread threw an exception, we
+ * should report back.
+ */
+ if (serverException != null) {
+ System.out.print("Server Exception:");
+ throw serverException;
+ }
+ if (clientException != null) {
+ System.out.print("Client Exception:");
+ throw clientException;
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ // parse the customized arguments
+ parseArguments(args);
+
+ // start the test
+ new InvalidLdapFilters();
+ }
+
+}
--- a/jdk/test/java/nio/file/Files/PrintFileTree.java Wed Jul 05 17:07:54 2017 +0200
+++ b/jdk/test/java/nio/file/Files/PrintFileTree.java Thu Mar 04 13:40:03 2010 -0800
@@ -28,27 +28,33 @@
/**
* Invokes Files.walkFileTree to traverse a file tree and prints
- * each of the directories and files. The -L option causes symbolic
- * links to be followed.
+ * each of the directories and files. The -follow option causes symbolic
+ * links to be followed and the -printCycles option will print links
+ * where the target of the link is an ancestor directory.
*/
public class PrintFileTree {
public static void main(String[] args) throws Exception {
boolean followLinks = false;
- Path dir;
-
- if (args[0].equals("-L")) {
- followLinks = true;
- dir = Paths.get(args[1]);
- } else {
- dir = Paths.get(args[0]);
+ boolean printCycles = false;
+ int i = 0;
+ while (i < (args.length-1)) {
+ switch (args[i]) {
+ case "-follow" : followLinks = true; break;
+ case "-printCycles" : printCycles = true; break;
+ default:
+ throw new RuntimeException(args[i] + " not recognized");
+ }
+ i++;
}
+ Path dir = Paths.get(args[i]);
Set<FileVisitOption> options = new HashSet<FileVisitOption>();
if (followLinks)
options.add(FileVisitOption.FOLLOW_LINKS);
+ final boolean reportCycles = printCycles;
Files.walkFileTree(dir, options, Integer.MAX_VALUE, new FileVisitor<FileRef>() {
public FileVisitResult preVisitDirectory(FileRef dir) {
System.out.println(dir);
@@ -59,7 +65,8 @@
return FileVisitResult.CONTINUE;
}
public FileVisitResult visitFile(FileRef file, BasicFileAttributes attrs) {
- System.out.println(file);
+ if (!attrs.isDirectory() || reportCycles)
+ System.out.println(file);
return FileVisitResult.CONTINUE;
}
public FileVisitResult postVisitDirectory(FileRef dir, IOException exc) {
--- a/jdk/test/java/nio/file/Files/walk_file_tree.sh Wed Jul 05 17:07:54 2017 +0200
+++ b/jdk/test/java/nio/file/Files/walk_file_tree.sh Thu Mar 04 13:40:03 2010 -0800
@@ -61,12 +61,20 @@
diff out1 out2
if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
-# repeat test following links (use -follow instead of -L
-# to allow running on older systems)
-$JAVA PrintFileTree -L "$ROOT" > out1
-find "$ROOT" -follow > out2
+# repeat test following links. Some versions of find(1) output
+# cycles (sym links to ancestor directories), other versions do
+# not. For that reason we run PrintFileTree with the -printCycles
+# option when the output without this option differs to find(1).
+find "$ROOT" -follow > out1
+$JAVA PrintFileTree -follow "$ROOT" > out2
diff out1 out2
-if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
+if [ $? != 0 ];
+ then
+ # re-run printing cycles to stdout
+ $JAVA PrintFileTree -follow -printCycles "$ROOT" > out2
+ diff out1 out2
+ if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
+ fi
# test SKIP_SIBLINGS
$JAVA SkipSiblings "$ROOT"
--- a/jdk/test/java/nio/file/Path/CheckPermissions.java Wed Jul 05 17:07:54 2017 +0200
+++ b/jdk/test/java/nio/file/Path/CheckPermissions.java Thu Mar 04 13:40:03 2010 -0800
@@ -197,7 +197,7 @@
}
public static void main(String[] args) throws IOException {
- Path dir = Paths.get(System.getProperty("test.src", "."));
+ Path dir = Paths.get(System.getProperty("test.dir", "."));
Path file = dir.resolve("file1234").createFile();
try {
LoggingSecurityManager.install();
--- a/jdk/test/java/nio/file/Path/PathOps.java Wed Jul 05 17:07:54 2017 +0200
+++ b/jdk/test/java/nio/file/Path/PathOps.java Thu Mar 04 13:40:03 2010 -0800
@@ -22,7 +22,7 @@
*/
/* @test
- * @bug 4313887 6838333
+ * @bug 4313887 6838333 6925932
* @summary Unit test for java.nio.file.Path path operations
*/
@@ -614,17 +614,34 @@
test("/foo")
.ends("foo")
.ends("/foo")
- .notEnds("/");
+ .notEnds("fool");
test("/foo/bar")
.ends("bar")
.ends("foo/bar")
.ends("/foo/bar")
- .notEnds("/bar");
+ .notEnds("ar")
+ .notEnds("barack")
+ .notEnds("/bar")
+ .notEnds("o/bar");
test("foo")
- .ends("foo");
+ .ends("foo")
+ .notEnds("oo")
+ .notEnds("oola");
test("foo/bar")
.ends("bar")
- .ends("foo/bar");
+ .ends("foo/bar")
+ .notEnds("r")
+ .notEnds("barmaid")
+ .notEnds("/bar");
+ test("foo/bar/gus")
+ .ends("gus")
+ .ends("bar/gus")
+ .ends("foo/bar/gus")
+ .notEnds("g")
+ .notEnds("/gus")
+ .notEnds("r/gus")
+ .notEnds("barack/gus")
+ .notEnds("bar/gust");
// elements
test("a/b/c")
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/nio/file/WatchService/LotsOfEvents.java Thu Mar 04 13:40:03 2010 -0800
@@ -0,0 +1,222 @@
+/*
+ * Copyright 2010 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 6907760 6929532
+ * @summary Tests WatchService behavior when lots of events are pending
+ * @library ..
+ * @run main/timeout=180 LotsOfEvents
+ */
+
+import java.nio.file.*;
+import static java.nio.file.StandardWatchEventKind.*;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.*;
+import java.util.concurrent.TimeUnit;
+
+public class LotsOfEvents {
+
+ static final Random rand = new Random();
+
+ public static void main(String[] args) throws Exception {
+ Path dir = TestUtil.createTemporaryDirectory();
+ try {
+ testOverflowEvent(dir);
+ testModifyEventsQueuing(dir);
+ } finally {
+ TestUtil.removeAll(dir);
+ }
+ }
+
+ /**
+ * Tests that OVERFLOW events are not retreived with other events.
+ */
+ static void testOverflowEvent(Path dir)
+ throws IOException, InterruptedException
+ {
+ WatchService watcher = dir.getFileSystem().newWatchService();
+ try {
+ dir.register(watcher, ENTRY_CREATE, ENTRY_DELETE);
+
+ // create a lot of files
+ int n = 1024;
+ Path[] files = new Path[n];
+ for (int i=0; i<n; i++) {
+ files[i] = dir.resolve("foo" + i).createFile();
+ }
+
+ // give time for events to accumulate (improve chance of overflow)
+ Thread.sleep(1000);
+
+ // check that we see the create events (or overflow)
+ drainAndCheckOverflowEvents(watcher, ENTRY_CREATE, n);
+
+ // delete the files
+ for (int i=0; i<n; i++) {
+ files[i].delete();
+ }
+
+ // give time for events to accumulate (improve chance of overflow)
+ Thread.sleep(1000);
+
+ // check that we see the delete events (or overflow)
+ drainAndCheckOverflowEvents(watcher, ENTRY_DELETE, n);
+ } finally {
+ watcher.close();
+ }
+ }
+
+ static void drainAndCheckOverflowEvents(WatchService watcher,
+ WatchEvent.Kind<?> expectedKind,
+ int count)
+ throws IOException, InterruptedException
+ {
+ // wait for key to be signalled - the timeout is long to allow for
+ // polling implementations
+ WatchKey key = watcher.poll(15, TimeUnit.SECONDS);
+ if (key != null && count == 0)
+ throw new RuntimeException("Key was signalled (unexpected)");
+ if (key == null && count > 0)
+ throw new RuntimeException("Key not signalled (unexpected)");
+
+ int nread = 0;
+ boolean gotOverflow = false;
+ while (key != null) {
+ List<WatchEvent<?>> events = key.pollEvents();
+ for (WatchEvent<?> event: events) {
+ WatchEvent.Kind<?> kind = event.kind();
+ if (kind == expectedKind) {
+ // expected event kind
+ if (++nread > count)
+ throw new RuntimeException("More events than expected!!");
+ } else if (kind == OVERFLOW) {
+ // overflow event should not be retrieved with other events
+ if (events.size() > 1)
+ throw new RuntimeException("Overflow retrieved with other events");
+ gotOverflow = true;
+ } else {
+ throw new RuntimeException("Unexpected event '" + kind + "'");
+ }
+ }
+ if (!key.reset())
+ throw new RuntimeException("Key is no longer valid");
+ key = watcher.poll(2, TimeUnit.SECONDS);
+ }
+
+ // check that all expected events were received or there was an overflow
+ if (nread < count && !gotOverflow)
+ throw new RuntimeException("Insufficient events");
+ }
+
+ /**
+ * Tests that check that ENTRY_MODIFY events are queued efficiently
+ */
+ static void testModifyEventsQueuing(Path dir)
+ throws IOException, InterruptedException
+ {
+ // this test uses a random number of files
+ final int nfiles = 5 + rand.nextInt(10);
+ DirectoryEntry[] entries = new DirectoryEntry[nfiles];
+ for (int i=0; i<nfiles; i++) {
+ entries[i] = new DirectoryEntry(dir.resolve("foo" + i));
+
+ // "some" of the files exist, some do not.
+ entries[i].deleteIfExists();
+ if (rand.nextBoolean())
+ entries[i].create();
+ }
+
+ WatchService watcher = dir.getFileSystem().newWatchService();
+ try {
+ dir.register(watcher, ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY);
+
+ // do several rounds of noise and test
+ for (int round=0; round<10; round++) {
+
+ // make some noise!!!
+ for (int i=0; i<100; i++) {
+ DirectoryEntry entry = entries[rand.nextInt(nfiles)];
+ int action = rand.nextInt(10);
+ switch (action) {
+ case 0 : entry.create(); break;
+ case 1 : entry.deleteIfExists(); break;
+ default: entry.modifyIfExists();
+ }
+ }
+
+ // process events and ensure that we don't get repeated modify
+ // events for the same file.
+ WatchKey key = watcher.poll(15, TimeUnit.SECONDS);
+ while (key != null) {
+ Set<Path> modified = new HashSet<Path>();
+ for (WatchEvent<?> event: key.pollEvents()) {
+ WatchEvent.Kind<?> kind = event.kind();
+ Path file = (kind == OVERFLOW) ? null : (Path)event.context();
+ if (kind == ENTRY_MODIFY) {
+ boolean added = modified.add(file);
+ if (!added) {
+ throw new RuntimeException(
+ "ENTRY_MODIFY events not queued efficiently");
+ }
+ } else {
+ if (file != null) modified.remove(file);
+ }
+ }
+ if (!key.reset())
+ throw new RuntimeException("Key is no longer valid");
+ key = watcher.poll(2, TimeUnit.SECONDS);
+ }
+ }
+
+ } finally {
+ watcher.close();
+ }
+ }
+
+ static class DirectoryEntry {
+ private final Path file;
+ DirectoryEntry(Path file) {
+ this.file = file;
+ }
+ void create() throws IOException {
+ if (file.notExists())
+ file.createFile();
+
+ }
+ void deleteIfExists() throws IOException {
+ file.deleteIfExists();
+ }
+ void modifyIfExists() throws IOException {
+ if (file.exists()) {
+ OutputStream out = file.newOutputStream(StandardOpenOption.APPEND);
+ try {
+ out.write("message".getBytes());
+ } finally {
+ out.close();
+ }
+ }
+ }
+ }
+
+}
--- a/jdk/test/java/nio/file/WatchService/OverflowEventIsLoner.java Wed Jul 05 17:07:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,122 +0,0 @@
-/*
- * Copyright 2010 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 6907760
- * @summary Check that the OVERFLOW event is not retrieved with other events
- * @library ..
- */
-
-import java.nio.file.*;
-import static java.nio.file.StandardWatchEventKind.*;
-import java.io.IOException;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-
-public class OverflowEventIsLoner {
-
- static void drainEvents(WatchService watcher,
- WatchEvent.Kind<?> expectedKind,
- int count)
- throws IOException, InterruptedException
- {
- // wait for key to be signalled - the timeout is long to allow for
- // polling implementations
- WatchKey key = watcher.poll(15, TimeUnit.SECONDS);
- if (key != null && count == 0)
- throw new RuntimeException("Key was signalled (unexpected)");
- if (key == null && count > 0)
- throw new RuntimeException("Key not signalled (unexpected)");
-
- int nread = 0;
- boolean gotOverflow = false;
- do {
- List<WatchEvent<?>> events = key.pollEvents();
- for (WatchEvent<?> event: events) {
- WatchEvent.Kind<?> kind = event.kind();
- if (kind == expectedKind) {
- // expected event kind
- if (++nread > count)
- throw new RuntimeException("More events than expected!!");
- } else if (kind == OVERFLOW) {
- // overflow event should not be retrieved with other events
- if (events.size() > 1)
- throw new RuntimeException("Overflow retrieved with other events");
- gotOverflow = true;
- } else {
- throw new RuntimeException("Unexpected event '" + kind + "'");
- }
- }
- if (!key.reset())
- throw new RuntimeException("Key is no longer valid");
- key = watcher.poll(2, TimeUnit.SECONDS);
- } while (key != null);
-
- // check that all expected events were received or there was an overflow
- if (nread < count && !gotOverflow)
- throw new RuntimeException("Insufficient events");
- }
-
-
- static void test(Path dir) throws IOException, InterruptedException {
- WatchService watcher = dir.getFileSystem().newWatchService();
- try {
- WatchKey key = dir.register(watcher, ENTRY_CREATE, ENTRY_DELETE);
-
- // create a lot of files
- int n = 1024;
- Path[] files = new Path[n];
- for (int i=0; i<n; i++) {
- files[i] = dir.resolve("foo" + i).createFile();
- }
-
- // give time for events to accumulate (improve chance of overflow)
- Thread.sleep(1000);
-
- // check that we see the create events (or overflow)
- drainEvents(watcher, ENTRY_CREATE, n);
-
- // delete the files
- for (int i=0; i<n; i++) {
- files[i].delete();
- }
-
- // give time for events to accumulate (improve chance of overflow)
- Thread.sleep(1000);
-
- // check that we see the delete events (or overflow)
- drainEvents(watcher, ENTRY_DELETE, n);
- } finally {
- watcher.close();
- }
- }
-
- public static void main(String[] args) throws Exception {
- Path dir = TestUtil.createTemporaryDirectory();
- try {
- test(dir);
- } finally {
- TestUtil.removeAll(dir);
- }
- }
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/security/IdentityScope/NoDefaultSystemScope.java Thu Mar 04 13:40:03 2010 -0800
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2010 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 6921001
+ * @summary The default system identity scope is now null.
+ */
+import java.security.*;
+
+public class NoDefaultSystemScope {
+
+ public static void main(String args[]) throws Exception {
+ IdentityScope s = IdentityScope.getSystemScope();
+
+ if (s != null) {
+ throw new Exception("The default system scope should be null");
+ }
+ System.out.println("TEST PASSED");
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/krb5/etype/WeakCrypto.java Thu Mar 04 13:40:03 2010 -0800
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2010 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 6844909
+ * @run main/othervm WeakCrypto
+ * @summary support allow_weak_crypto in krb5.conf
+ */
+
+import java.io.File;
+import sun.security.krb5.internal.crypto.EType;
+import sun.security.krb5.EncryptedData;
+
+public class WeakCrypto {
+ public static void main(String[] args) throws Exception {
+ System.setProperty("java.security.krb5.conf",
+ System.getProperty("test.src", ".") +
+ File.separator +
+ "weakcrypto.conf");
+ int[] etypes = EType.getBuiltInDefaults();
+
+ for (int i=0, length = etypes.length; i<length; i++) {
+ if (etypes[i] == EncryptedData.ETYPE_DES_CBC_CRC ||
+ etypes[i] == EncryptedData.ETYPE_DES_CBC_MD4 ||
+ etypes[i] == EncryptedData.ETYPE_DES_CBC_MD5) {
+ throw new Exception("DES should not appear");
+ }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/krb5/etype/weakcrypto.conf Thu Mar 04 13:40:03 2010 -0800
@@ -0,0 +1,2 @@
+[libdefaults]
+allow_weak_crypto = false