提交 e488fbfe 编写于 作者: L lana

Merge

...@@ -159,3 +159,6 @@ ddfe5562f61f54ed2121ac0c73b688b94f3e66b5 jdk8-b32 ...@@ -159,3 +159,6 @@ ddfe5562f61f54ed2121ac0c73b688b94f3e66b5 jdk8-b32
2e3e1356ffbddb2ae95c08da72830ba9ab8b3181 jdk8-b35 2e3e1356ffbddb2ae95c08da72830ba9ab8b3181 jdk8-b35
45da9cb055ee258dc09e69c1718e27eadea38e45 jdk8-b36 45da9cb055ee258dc09e69c1718e27eadea38e45 jdk8-b36
9e82ac15ab80370d6e021aea7b98c7c9626adb5e jdk8-b37 9e82ac15ab80370d6e021aea7b98c7c9626adb5e jdk8-b37
c45f3509a70796c54b48f32910d1caf435763416 jdk8-b38
b6f52911752110a2889681923992c7a0baa52ccc jdk8-b39
b88fc3359dc7edabfa8a228855d8cebf8843c055 jdk8-b40
...@@ -139,7 +139,7 @@ ifndef OPENJDK ...@@ -139,7 +139,7 @@ ifndef OPENJDK
# #
CLASSDESTDIR = $(TEMPDIR)/classes CLASSDESTDIR = $(TEMPDIR)/classes
JAVAHFLAGS = -bootclasspath \ JAVAHFLAGS = -bootclasspath \
"$(CLASSDESTDIR)$(CLASSPATH_SEPARATOR)$(CLASSBINDIR)" "$(CLASSDESTDIR)$(CLASSPATH_SEPARATOR)$(CLASSBINDIR)$(JCE_PATH)"
include $(BUILDDIR)/common/Mapfile-vers.gmk include $(BUILDDIR)/common/Mapfile-vers.gmk
include $(BUILDDIR)/common/Library.gmk include $(BUILDDIR)/common/Library.gmk
......
...@@ -156,6 +156,7 @@ JDK_MAN_PAGES = \ ...@@ -156,6 +156,7 @@ JDK_MAN_PAGES = \
jstack.1 \ jstack.1 \
jstat.1 \ jstat.1 \
jstatd.1 \ jstatd.1 \
jvisualvm.1 \
native2ascii.1 \ native2ascii.1 \
rmic.1 \ rmic.1 \
schemagen.1 \ schemagen.1 \
...@@ -1311,8 +1312,8 @@ $(TEMP_PREV_JDK_COMPARISON): install-previous-jdk $(DIRDIFF_JARFILE) ...@@ -1311,8 +1312,8 @@ $(TEMP_PREV_JDK_COMPARISON): install-previous-jdk $(DIRDIFF_JARFILE)
@$(java-vm-cleanup) @$(java-vm-cleanup)
# Clean up names in the messages printed out # Clean up names in the messages printed out
CAT_FILTER = $(SED) -e "s@$(JDK_IMAGE_DIR)@JDK_IMAGE@g" \ CAT_FILTER = $(SED) -e "s|$(JDK_IMAGE_DIR)|JDK_IMAGE|g" \
-e "s@$(JRE_IMAGE_DIR)@JRE_IMAGE@g" -e "s|$(JRE_IMAGE_DIR)|JRE_IMAGE|g"
# Report on the jre image comparison # Report on the jre image comparison
compare-image-jre: $(TEMP_PREV_JRE_COMPARISON) compare-image-jre: $(TEMP_PREV_JRE_COMPARISON)
......
# #
# Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -139,7 +139,7 @@ JAVACFLAGS += $(JAVAC_LINT_OPTIONS) ...@@ -139,7 +139,7 @@ JAVACFLAGS += $(JAVAC_LINT_OPTIONS)
# built implicitly/explicitly. # built implicitly/explicitly.
# #
ifeq ($(wildcard $(SHARE_SRC)/classes/javax/crypto/Cipher.java),) ifeq ($(wildcard $(SHARE_SRC)/classes/javax/crypto/Cipher.java),)
JCEFLAGS = $(CLASSPATH_SEPARATOR)$(LIBDIR)/jce.jar JCE_PATH = $(CLASSPATH_SEPARATOR)$(LIBDIR)/jce.jar
endif endif
# Add the source level # Add the source level
...@@ -152,11 +152,11 @@ TARGET_CLASS_VERSION = 7 ...@@ -152,11 +152,11 @@ TARGET_CLASS_VERSION = 7
CLASS_VERSION = -target $(TARGET_CLASS_VERSION) CLASS_VERSION = -target $(TARGET_CLASS_VERSION)
JAVACFLAGS += $(CLASS_VERSION) JAVACFLAGS += $(CLASS_VERSION)
JAVACFLAGS += -encoding ascii JAVACFLAGS += -encoding ascii
JAVACFLAGS += "-Xbootclasspath:$(CLASSBINDIR)$(JCEFLAGS)" JAVACFLAGS += "-Xbootclasspath:$(CLASSBINDIR)$(JCE_PATH)"
JAVACFLAGS += $(OTHER_JAVACFLAGS) JAVACFLAGS += $(OTHER_JAVACFLAGS)
# Needed for javah # Needed for javah
JAVAHFLAGS += -bootclasspath "$(CLASSBINDIR)$(JCEFLAGS)" JAVAHFLAGS += -bootclasspath "$(CLASSBINDIR)$(JCE_PATH)"
# Needed for javadoc to ensure it builds documentation # Needed for javadoc to ensure it builds documentation
# against the newly built classes # against the newly built classes
......
...@@ -261,8 +261,7 @@ ifndef BUILD_CLIENT_ONLY ...@@ -261,8 +261,7 @@ ifndef BUILD_CLIENT_ONLY
ifeq ($(ZIP_DEBUGINFO_FILES),1) ifeq ($(ZIP_DEBUGINFO_FILES),1)
# the import JDK may not contain the target of the symlink # the import JDK may not contain the target of the symlink
ifneq ($(wildcard $(HOTSPOT_IMPORT_PATH)/$(ARCH_VM_SUBDIR)/$(LIBJSIG_DIZ_NAME)),) ifneq ($(wildcard $(HOTSPOT_IMPORT_PATH)/$(ARCH_VM_SUBDIR)/$(LIBJSIG_DIZ_NAME)),)
# check for the .diz file, but create the .debuginfo link IMPORT_LIST += $(LIB_LOCATION)/$(SERVER_LOCATION)/$(LIBJSIG_DIZ_NAME)
IMPORT_LIST += $(LIB_LOCATION)/$(SERVER_LOCATION)/$(LIBJSIG_DEBUGINFO_NAME)
endif endif
else else
# the import JDK may not contain the target of the symlink # the import JDK may not contain the target of the symlink
...@@ -319,8 +318,7 @@ ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) ...@@ -319,8 +318,7 @@ ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
ifeq ($(ZIP_DEBUGINFO_FILES),1) ifeq ($(ZIP_DEBUGINFO_FILES),1)
# the import JDK may not contain the target of the symlink # the import JDK may not contain the target of the symlink
ifneq ($(wildcard $(HOTSPOT_IMPORT_PATH)/$(ARCH_VM_SUBDIR)/$(LIBJSIG_DIZ_NAME)),) ifneq ($(wildcard $(HOTSPOT_IMPORT_PATH)/$(ARCH_VM_SUBDIR)/$(LIBJSIG_DIZ_NAME)),)
# check for the .diz file, but create the .debuginfo link IMPORT_LIST += $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(LIBJSIG_DIZ_NAME)
IMPORT_LIST += $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(LIBJSIG_DEBUGINFO_NAME)
endif endif
else else
# the import JDK may not contain the target of the symlink # the import JDK may not contain the target of the symlink
...@@ -472,11 +470,24 @@ $(LIB_LOCATION)/$(SERVER_LOCATION)/$(LIBJSIG_NAME): ...@@ -472,11 +470,24 @@ $(LIB_LOCATION)/$(SERVER_LOCATION)/$(LIBJSIG_NAME):
$(call install-sym-link, ../$(LIBJSIG_NAME)) $(call install-sym-link, ../$(LIBJSIG_NAME))
ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
# we don't create a symlink to a libjsig.diz file # We don't create a symlink to a libjsig.diz file, but we do put
# the libjsig.debuginfo symlink into a libjsig.diz file. The aurora
# system does not like dangling symlinks.
ifeq ($(ZIP_DEBUGINFO_FILES),1)
$(LIB_LOCATION)/$(CLIENT_LOCATION)/$(LIBJSIG_DIZ_NAME) \
$(LIB_LOCATION)/$(SERVER_LOCATION)/$(LIBJSIG_DIZ_NAME):
@$(prep-target)
$(LN) -s ../$(LIBJSIG_DEBUGINFO_NAME) $(@D)/$(LIBJSIG_DEBUGINFO_NAME)
( $(CD) $(@D) ; \
$(ZIPEXE) -y $(LIBJSIG_DIZ_NAME) $(LIBJSIG_DEBUGINFO_NAME) ; \
$(RM) $(LIBJSIG_DEBUGINFO_NAME) ; \
)
else
$(LIB_LOCATION)/$(CLIENT_LOCATION)/$(LIBJSIG_DEBUGINFO_NAME) \ $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(LIBJSIG_DEBUGINFO_NAME) \
$(LIB_LOCATION)/$(SERVER_LOCATION)/$(LIBJSIG_DEBUGINFO_NAME): $(LIB_LOCATION)/$(SERVER_LOCATION)/$(LIBJSIG_DEBUGINFO_NAME):
@$(prep-target) @$(prep-target)
$(call install-sym-link, ../$(LIBJSIG_DEBUGINFO_NAME)) $(call install-sym-link, ../$(LIBJSIG_DEBUGINFO_NAME))
endif
endif endif
else else
$(LIB_LOCATION)/$(CLIENT_LOCATION)/$(LIBJSIG_NAME): $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(LIBJSIG_NAME):
...@@ -484,10 +495,22 @@ $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(LIBJSIG_NAME): ...@@ -484,10 +495,22 @@ $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(LIBJSIG_NAME):
$(call install-sym-link, ../$(LIBJSIG_NAME)) $(call install-sym-link, ../$(LIBJSIG_NAME))
ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
# we don't create a symlink to a libjsig.diz file # We don't create a symlink to a libjsig.diz file, but we do put
# the libjsig.debuginfo symlink into a libjsig.diz file. The aurora
# system does not like dangling symlinks.
ifeq ($(ZIP_DEBUGINFO_FILES),1)
$(LIB_LOCATION)/$(CLIENT_LOCATION)/$(LIBJSIG_DIZ_NAME):
@$(prep-target)
$(LN) -s ../$(LIBJSIG_DEBUGINFO_NAME) $(@D)/$(LIBJSIG_DEBUGINFO_NAME)
( $(CD) $(@D) ; \
$(ZIPEXE) -y $(LIBJSIG_DIZ_NAME) $(LIBJSIG_DEBUGINFO_NAME) ; \
$(RM) $(LIBJSIG_DEBUGINFO_NAME) ; \
)
else
$(LIB_LOCATION)/$(CLIENT_LOCATION)/$(LIBJSIG_DEBUGINFO_NAME): $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(LIBJSIG_DEBUGINFO_NAME):
@$(prep-target) @$(prep-target)
$(call install-sym-link, ../$(LIBJSIG_DEBUGINFO_NAME)) $(call install-sym-link, ../$(LIBJSIG_DEBUGINFO_NAME))
endif
endif endif
endif endif
......
# #
# Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -160,7 +160,7 @@ ifeq ($(NATIVE_ECC_AVAILABLE), true) ...@@ -160,7 +160,7 @@ ifeq ($(NATIVE_ECC_AVAILABLE), true)
$(PKGDIR)/ECKeyPairGenerator.java $(PKGDIR)/ECKeyPairGenerator.java
JAVAHFLAGS = -bootclasspath \ JAVAHFLAGS = -bootclasspath \
"$(CLASSDESTDIR)$(CLASSPATH_SEPARATOR)$(CLASSBINDIR)" "$(CLASSDESTDIR)$(CLASSPATH_SEPARATOR)$(CLASSBINDIR)$(JCE_PATH)"
# #
......
...@@ -150,7 +150,7 @@ OTHER_INCLUDES += \ ...@@ -150,7 +150,7 @@ OTHER_INCLUDES += \
# #
CLASSDESTDIR = $(TEMPDIR)/classes CLASSDESTDIR = $(TEMPDIR)/classes
JAVAHFLAGS = -bootclasspath \ JAVAHFLAGS = -bootclasspath \
"$(CLASSDESTDIR)$(CLASSPATH_SEPARATOR)$(CLASSBINDIR)" "$(CLASSDESTDIR)$(CLASSPATH_SEPARATOR)$(CLASSBINDIR)$(JCE_PATH)"
include $(BUILDDIR)/common/Mapfile-vers.gmk include $(BUILDDIR)/common/Mapfile-vers.gmk
......
...@@ -151,7 +151,7 @@ OTHER_INCLUDES += \ ...@@ -151,7 +151,7 @@ OTHER_INCLUDES += \
# #
CLASSDESTDIR = $(TEMPDIR)/classes CLASSDESTDIR = $(TEMPDIR)/classes
JAVAHFLAGS = -bootclasspath \ JAVAHFLAGS = -bootclasspath \
"$(CLASSDESTDIR)$(CLASSPATH_SEPARATOR)$(CLASSBINDIR)" "$(CLASSDESTDIR)$(CLASSPATH_SEPARATOR)$(CLASSBINDIR)$(JCE_PATH)"
include $(BUILDDIR)/common/Mapfile-vers.gmk include $(BUILDDIR)/common/Mapfile-vers.gmk
......
...@@ -139,7 +139,7 @@ ifndef OPENJDK ...@@ -139,7 +139,7 @@ ifndef OPENJDK
# #
CLASSDESTDIR = $(TEMPDIR)/classes CLASSDESTDIR = $(TEMPDIR)/classes
JAVAHFLAGS = -bootclasspath \ JAVAHFLAGS = -bootclasspath \
"$(CLASSDESTDIR)$(CLASSPATH_SEPARATOR)$(CLASSBINDIR)" "$(CLASSDESTDIR)$(CLASSPATH_SEPARATOR)$(CLASSBINDIR)$(JCE_PATH)"
include $(BUILDDIR)/common/Mapfile-vers.gmk include $(BUILDDIR)/common/Mapfile-vers.gmk
include $(BUILDDIR)/common/Library.gmk include $(BUILDDIR)/common/Library.gmk
......
# #
# Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -141,7 +141,7 @@ JAVACFLAGS += $(JAVAC_LINT_OPTIONS) ...@@ -141,7 +141,7 @@ JAVACFLAGS += $(JAVAC_LINT_OPTIONS)
# built implicitly/explicitly. # built implicitly/explicitly.
# #
ifeq ($(wildcard $(SHARE_SRC)/classes/javax/crypto/Cipher.java),) ifeq ($(wildcard $(SHARE_SRC)/classes/javax/crypto/Cipher.java),)
JCEFLAGS = $(CLASSPATH_SEPARATOR)$(LIBDIR)/jce.jar JCE_PATH = $(CLASSPATH_SEPARATOR)$(LIBDIR)/jce.jar
endif endif
# Add the source level # Add the source level
...@@ -154,11 +154,11 @@ TARGET_CLASS_VERSION = 7 ...@@ -154,11 +154,11 @@ TARGET_CLASS_VERSION = 7
CLASS_VERSION = -target $(TARGET_CLASS_VERSION) CLASS_VERSION = -target $(TARGET_CLASS_VERSION)
JAVACFLAGS += $(CLASS_VERSION) JAVACFLAGS += $(CLASS_VERSION)
JAVACFLAGS += -encoding ascii JAVACFLAGS += -encoding ascii
JAVACFLAGS += "-Xbootclasspath:$(CLASSBINDIR)$(JCEFLAGS)" JAVACFLAGS += "-Xbootclasspath:$(CLASSBINDIR)$(JCE_PATH)"
JAVACFLAGS += $(OTHER_JAVACFLAGS) JAVACFLAGS += $(OTHER_JAVACFLAGS)
# Needed for javah # Needed for javah
JAVAHFLAGS += -bootclasspath "$(CLASSBINDIR)$(JCEFLAGS)" JAVAHFLAGS += -bootclasspath "$(CLASSBINDIR)$(JCE_PATH)"
# Needed for javadoc to ensure it builds documentation # Needed for javadoc to ensure it builds documentation
# against the newly built classes # against the newly built classes
......
# #
# Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -159,7 +159,8 @@ ifeq ($(NATIVE_ECC_AVAILABLE), true) ...@@ -159,7 +159,8 @@ ifeq ($(NATIVE_ECC_AVAILABLE), true)
$(PKGDIR)/ECDSASignature.java \ $(PKGDIR)/ECDSASignature.java \
$(PKGDIR)/ECKeyPairGenerator.java $(PKGDIR)/ECKeyPairGenerator.java
JAVAHFLAGS += -Xbootclasspath/p:$(CLASSDESTDIR) JAVAHFLAGS = -bootclasspath \
"$(CLASSDESTDIR)$(CLASSPATH_SEPARATOR)$(CLASSBINDIR)$(JCE_PATH)"
# #
# C and C++ files # C and C++ files
......
# #
# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -149,7 +149,8 @@ OTHER_INCLUDES += \ ...@@ -149,7 +149,8 @@ OTHER_INCLUDES += \
# Rules # Rules
# #
CLASSDESTDIR = $(TEMPDIR)/classes CLASSDESTDIR = $(TEMPDIR)/classes
JAVAHFLAGS += -Xbootclasspath/p:$(CLASSDESTDIR) JAVAHFLAGS = -bootclasspath \
"$(CLASSDESTDIR)$(CLASSPATH_SEPARATOR)$(CLASSBINDIR)$(JCE_PATH)"
include $(BUILDDIR)/common/Mapfile-vers.gmk include $(BUILDDIR)/common/Mapfile-vers.gmk
......
...@@ -150,7 +150,8 @@ OTHER_INCLUDES += \ ...@@ -150,7 +150,8 @@ OTHER_INCLUDES += \
# Rules # Rules
# #
CLASSDESTDIR = $(TEMPDIR)/classes CLASSDESTDIR = $(TEMPDIR)/classes
JAVAHFLAGS = -bootclasspath "$(CLASSDESTDIR)$(CLASSPATH_SEPARATOR)$(CLASSBINDIR)" JAVAHFLAGS = -bootclasspath \
"$(CLASSDESTDIR)$(CLASSPATH_SEPARATOR)$(CLASSBINDIR)$(JCE_PATH)"
include $(BUILDDIR)/common/Mapfile-vers.gmk include $(BUILDDIR)/common/Mapfile-vers.gmk
......
...@@ -135,18 +135,21 @@ class MacOSXPreferences extends AbstractPreferences { ...@@ -135,18 +135,21 @@ class MacOSXPreferences extends AbstractPreferences {
// AbstractPreferences implementation // AbstractPreferences implementation
@Override
protected void putSpi(String key, String value) protected void putSpi(String key, String value)
{ {
file.addKeyToNode(path, key, value); file.addKeyToNode(path, key, value);
} }
// AbstractPreferences implementation // AbstractPreferences implementation
@Override
protected String getSpi(String key) protected String getSpi(String key)
{ {
return file.getKeyFromNode(path, key); return file.getKeyFromNode(path, key);
} }
// AbstractPreferences implementation // AbstractPreferences implementation
@Override
protected void removeSpi(String key) protected void removeSpi(String key)
{ {
Objects.requireNonNull(key, "Specified key cannot be null"); Objects.requireNonNull(key, "Specified key cannot be null");
...@@ -155,6 +158,7 @@ class MacOSXPreferences extends AbstractPreferences { ...@@ -155,6 +158,7 @@ class MacOSXPreferences extends AbstractPreferences {
// AbstractPreferences implementation // AbstractPreferences implementation
@Override
protected void removeNodeSpi() protected void removeNodeSpi()
throws BackingStoreException throws BackingStoreException
{ {
...@@ -174,6 +178,7 @@ class MacOSXPreferences extends AbstractPreferences { ...@@ -174,6 +178,7 @@ class MacOSXPreferences extends AbstractPreferences {
// AbstractPreferences implementation // AbstractPreferences implementation
@Override
protected String[] childrenNamesSpi() protected String[] childrenNamesSpi()
throws BackingStoreException throws BackingStoreException
{ {
...@@ -183,6 +188,7 @@ class MacOSXPreferences extends AbstractPreferences { ...@@ -183,6 +188,7 @@ class MacOSXPreferences extends AbstractPreferences {
} }
// AbstractPreferences implementation // AbstractPreferences implementation
@Override
protected String[] keysSpi() protected String[] keysSpi()
throws BackingStoreException throws BackingStoreException
{ {
...@@ -192,6 +198,7 @@ class MacOSXPreferences extends AbstractPreferences { ...@@ -192,6 +198,7 @@ class MacOSXPreferences extends AbstractPreferences {
} }
// AbstractPreferences implementation // AbstractPreferences implementation
@Override
protected AbstractPreferences childSpi(String name) protected AbstractPreferences childSpi(String name)
{ {
// Add to parent's child list here and disallow sync // Add to parent's child list here and disallow sync
...@@ -203,6 +210,7 @@ class MacOSXPreferences extends AbstractPreferences { ...@@ -203,6 +210,7 @@ class MacOSXPreferences extends AbstractPreferences {
} }
// AbstractPreferences override // AbstractPreferences override
@Override
public void flush() public void flush()
throws BackingStoreException throws BackingStoreException
{ {
...@@ -217,6 +225,7 @@ class MacOSXPreferences extends AbstractPreferences { ...@@ -217,6 +225,7 @@ class MacOSXPreferences extends AbstractPreferences {
} }
// AbstractPreferences implementation // AbstractPreferences implementation
@Override
protected void flushSpi() protected void flushSpi()
throws BackingStoreException throws BackingStoreException
{ {
...@@ -224,6 +233,7 @@ class MacOSXPreferences extends AbstractPreferences { ...@@ -224,6 +233,7 @@ class MacOSXPreferences extends AbstractPreferences {
} }
// AbstractPreferences override // AbstractPreferences override
@Override
public void sync() public void sync()
throws BackingStoreException throws BackingStoreException
{ {
...@@ -244,6 +254,7 @@ class MacOSXPreferences extends AbstractPreferences { ...@@ -244,6 +254,7 @@ class MacOSXPreferences extends AbstractPreferences {
} }
// AbstractPreferences implementation // AbstractPreferences implementation
@Override
protected void syncSpi() protected void syncSpi()
throws BackingStoreException throws BackingStoreException
{ {
......
...@@ -26,10 +26,12 @@ ...@@ -26,10 +26,12 @@
package java.util.prefs; package java.util.prefs;
class MacOSXPreferencesFactory implements PreferencesFactory { class MacOSXPreferencesFactory implements PreferencesFactory {
@Override
public Preferences userRoot() { public Preferences userRoot() {
return MacOSXPreferences.getUserRoot(); return MacOSXPreferences.getUserRoot();
} }
@Override
public Preferences systemRoot() { public Preferences systemRoot() {
return MacOSXPreferences.getSystemRoot(); return MacOSXPreferences.getSystemRoot();
} }
......
...@@ -101,9 +101,10 @@ class MacOSXPreferencesFile { ...@@ -101,9 +101,10 @@ class MacOSXPreferencesFile {
} }
// Maps string -> weak reference to MacOSXPreferencesFile // Maps string -> weak reference to MacOSXPreferencesFile
private static HashMap cachedFiles = null; private static HashMap<String, WeakReference<MacOSXPreferencesFile>>
cachedFiles;
// Files that may have unflushed changes // Files that may have unflushed changes
private static HashSet changedFiles = null; private static HashSet<MacOSXPreferencesFile> changedFiles;
// Timer and pending sync and flush tasks (which are both scheduled // Timer and pending sync and flush tasks (which are both scheduled
...@@ -136,13 +137,14 @@ class MacOSXPreferencesFile { ...@@ -136,13 +137,14 @@ class MacOSXPreferencesFile {
{ {
MacOSXPreferencesFile result = null; MacOSXPreferencesFile result = null;
if (cachedFiles == null) cachedFiles = new HashMap(); if (cachedFiles == null)
cachedFiles = new HashMap<>();
String hashkey = String hashkey =
newName + String.valueOf(isUser); newName + String.valueOf(isUser);
WeakReference hashvalue = (WeakReference)cachedFiles.get(hashkey); WeakReference<MacOSXPreferencesFile> hashvalue = cachedFiles.get(hashkey);
if (hashvalue != null) { if (hashvalue != null) {
result = (MacOSXPreferencesFile)hashvalue.get(); result = hashvalue.get();
} }
if (result == null) { if (result == null) {
// Java user node == CF current user, any host // Java user node == CF current user, any host
...@@ -150,7 +152,7 @@ class MacOSXPreferencesFile { ...@@ -150,7 +152,7 @@ class MacOSXPreferencesFile {
result = new MacOSXPreferencesFile(newName, result = new MacOSXPreferencesFile(newName,
isUser ? cfCurrentUser : cfAnyUser, isUser ? cfCurrentUser : cfAnyUser,
isUser ? cfAnyHost : cfCurrentHost); isUser ? cfAnyHost : cfCurrentHost);
cachedFiles.put(hashkey, new WeakReference(result)); cachedFiles.put(hashkey, new WeakReference<MacOSXPreferencesFile>(result));
} }
// Don't schedule this file for flushing until some nodes or // Don't schedule this file for flushing until some nodes or
...@@ -171,10 +173,11 @@ class MacOSXPreferencesFile { ...@@ -171,10 +173,11 @@ class MacOSXPreferencesFile {
boolean ok = true; boolean ok = true;
if (cachedFiles != null && !cachedFiles.isEmpty()) { if (cachedFiles != null && !cachedFiles.isEmpty()) {
Iterator iter = cachedFiles.values().iterator(); Iterator<WeakReference<MacOSXPreferencesFile>> iter =
cachedFiles.values().iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
WeakReference ref = (WeakReference)iter.next(); WeakReference<MacOSXPreferencesFile> ref = iter.next();
MacOSXPreferencesFile f = (MacOSXPreferencesFile)ref.get(); MacOSXPreferencesFile f = ref.get();
if (f != null) { if (f != null) {
if (!f.synchronize()) ok = false; if (!f.synchronize()) ok = false;
} else { } else {
...@@ -202,10 +205,11 @@ class MacOSXPreferencesFile { ...@@ -202,10 +205,11 @@ class MacOSXPreferencesFile {
static synchronized boolean syncUser() { static synchronized boolean syncUser() {
boolean ok = true; boolean ok = true;
if (cachedFiles != null && !cachedFiles.isEmpty()) { if (cachedFiles != null && !cachedFiles.isEmpty()) {
Iterator<WeakReference> iter = cachedFiles.values().iterator(); Iterator<WeakReference<MacOSXPreferencesFile>> iter =
cachedFiles.values().iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
WeakReference ref = iter.next(); WeakReference<MacOSXPreferencesFile> ref = iter.next();
MacOSXPreferencesFile f = (MacOSXPreferencesFile)ref.get(); MacOSXPreferencesFile f = ref.get();
if (f != null && f.user == cfCurrentUser) { if (f != null && f.user == cfCurrentUser) {
if (!f.synchronize()) { if (!f.synchronize()) {
ok = false; ok = false;
...@@ -240,12 +244,10 @@ class MacOSXPreferencesFile { ...@@ -240,12 +244,10 @@ class MacOSXPreferencesFile {
boolean ok = true; boolean ok = true;
if (changedFiles != null && !changedFiles.isEmpty()) { if (changedFiles != null && !changedFiles.isEmpty()) {
Iterator iter = changedFiles.iterator(); for (MacOSXPreferencesFile f : changedFiles) {
while (iter.hasNext()) { if (!f.synchronize())
MacOSXPreferencesFile f = (MacOSXPreferencesFile)iter.next(); ok = false;
if (!f.synchronize()) ok = false;
} }
changedFiles.clear(); changedFiles.clear();
} }
...@@ -263,7 +265,8 @@ class MacOSXPreferencesFile { ...@@ -263,7 +265,8 @@ class MacOSXPreferencesFile {
private void markChanged() private void markChanged()
{ {
// Add this file to the changed file list // Add this file to the changed file list
if (changedFiles == null) changedFiles = new HashSet(); if (changedFiles == null)
changedFiles = new HashSet<>();
changedFiles.add(this); changedFiles.add(this);
// Schedule a new flush and a shutdown hook, if necessary // Schedule a new flush and a shutdown hook, if necessary
...@@ -309,7 +312,9 @@ class MacOSXPreferencesFile { ...@@ -309,7 +312,9 @@ class MacOSXPreferencesFile {
if (syncInterval > 0) { if (syncInterval > 0) {
timer().schedule(new TimerTask() { timer().schedule(new TimerTask() {
public void run() { MacOSXPreferencesFile.syncWorld();} @Override
public void run() {
MacOSXPreferencesFile.syncWorld();}
}, syncInterval * 1000, syncInterval * 1000); }, syncInterval * 1000, syncInterval * 1000);
} else { } else {
// syncInterval property not set. No sync timer ever. // syncInterval property not set. No sync timer ever.
...@@ -323,6 +328,7 @@ class MacOSXPreferencesFile { ...@@ -323,6 +328,7 @@ class MacOSXPreferencesFile {
if (timer == null) { if (timer == null) {
timer = new Timer(true); // daemon timer = new Timer(true); // daemon
Thread flushThread = new Thread() { Thread flushThread = new Thread() {
@Override
public void run() { public void run() {
flushWorld(); flushWorld();
} }
......
...@@ -40,7 +40,7 @@ public class CGraphicsDevice extends GraphicsDevice { ...@@ -40,7 +40,7 @@ public class CGraphicsDevice extends GraphicsDevice {
private final int displayID; private final int displayID;
// Array of all GraphicsConfig instances for this device // Array of all GraphicsConfig instances for this device
private final CGraphicsConfig[] configs; private final GraphicsConfiguration[] configs;
// Default config (temporarily hard coded) // Default config (temporarily hard coded)
private final int DEFAULT_CONFIG = 0; private final int DEFAULT_CONFIG = 0;
...@@ -49,7 +49,7 @@ public class CGraphicsDevice extends GraphicsDevice { ...@@ -49,7 +49,7 @@ public class CGraphicsDevice extends GraphicsDevice {
public CGraphicsDevice(int displayID) { public CGraphicsDevice(int displayID) {
this.displayID = displayID; this.displayID = displayID;
configs = new CGraphicsConfig[] { configs = new GraphicsConfiguration[] {
CGLGraphicsConfig.getConfig(this, 0) CGLGraphicsConfig.getConfig(this, 0)
}; };
} }
...@@ -66,7 +66,7 @@ public class CGraphicsDevice extends GraphicsDevice { ...@@ -66,7 +66,7 @@ public class CGraphicsDevice extends GraphicsDevice {
*/ */
@Override @Override
public GraphicsConfiguration[] getConfigurations() { public GraphicsConfiguration[] getConfigurations() {
return configs; return configs.clone();
} }
/** /**
......
...@@ -976,8 +976,8 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent> ...@@ -976,8 +976,8 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
@Override @Override
public Image createImage(int w, int h) { public Image createImage(int w, int h) {
// TODO: accelerated image CGraphicsConfig gc = (CGraphicsConfig)getGraphicsConfiguration();
return getGraphicsConfiguration().createCompatibleImage(w, h); return gc.createAcceleratedImage(getTarget(), w, h);
} }
@Override @Override
......
/* /*
* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -38,16 +38,16 @@ import java.security.spec.*; ...@@ -38,16 +38,16 @@ import java.security.spec.*;
* This class constitutes the core of HMAC-<MD> algorithms, where * This class constitutes the core of HMAC-<MD> algorithms, where
* <MD> can be SHA1 or MD5, etc. See RFC 2104 for spec. * <MD> can be SHA1 or MD5, etc. See RFC 2104 for spec.
* *
* It also contains the implementation classes for the SHA-256, * It also contains the implementation classes for SHA-224, SHA-256,
* SHA-384, and SHA-512 HMACs. * SHA-384, and SHA-512 HMACs.
* *
* @author Jan Luehe * @author Jan Luehe
*/ */
final class HmacCore implements Cloneable { abstract class HmacCore extends MacSpi implements Cloneable {
private final MessageDigest md; private MessageDigest md;
private final byte[] k_ipad; // inner padding - key XORd with ipad private byte[] k_ipad; // inner padding - key XORd with ipad
private final byte[] k_opad; // outer padding - key XORd with opad private byte[] k_opad; // outer padding - key XORd with opad
private boolean first; // Is this the first data to be processed? private boolean first; // Is this the first data to be processed?
private final int blockLen; private final int blockLen;
...@@ -72,23 +72,12 @@ final class HmacCore implements Cloneable { ...@@ -72,23 +72,12 @@ final class HmacCore implements Cloneable {
this(MessageDigest.getInstance(digestAlgorithm), bl); this(MessageDigest.getInstance(digestAlgorithm), bl);
} }
/**
* Constructor used for cloning.
*/
private HmacCore(HmacCore other) throws CloneNotSupportedException {
this.md = (MessageDigest)other.md.clone();
this.blockLen = other.blockLen;
this.k_ipad = other.k_ipad.clone();
this.k_opad = other.k_opad.clone();
this.first = other.first;
}
/** /**
* Returns the length of the HMAC in bytes. * Returns the length of the HMAC in bytes.
* *
* @return the HMAC length in bytes. * @return the HMAC length in bytes.
*/ */
int getDigestLength() { protected int engineGetMacLength() {
return this.md.getDigestLength(); return this.md.getDigestLength();
} }
...@@ -103,9 +92,8 @@ final class HmacCore implements Cloneable { ...@@ -103,9 +92,8 @@ final class HmacCore implements Cloneable {
* @exception InvalidAlgorithmParameterException if the given algorithm * @exception InvalidAlgorithmParameterException if the given algorithm
* parameters are inappropriate for this MAC. * parameters are inappropriate for this MAC.
*/ */
void init(Key key, AlgorithmParameterSpec params) protected void engineInit(Key key, AlgorithmParameterSpec params)
throws InvalidKeyException, InvalidAlgorithmParameterException { throws InvalidKeyException, InvalidAlgorithmParameterException {
if (params != null) { if (params != null) {
throw new InvalidAlgorithmParameterException throw new InvalidAlgorithmParameterException
("HMAC does not use parameters"); ("HMAC does not use parameters");
...@@ -140,7 +128,7 @@ final class HmacCore implements Cloneable { ...@@ -140,7 +128,7 @@ final class HmacCore implements Cloneable {
Arrays.fill(secret, (byte)0); Arrays.fill(secret, (byte)0);
secret = null; secret = null;
reset(); engineReset();
} }
/** /**
...@@ -148,7 +136,7 @@ final class HmacCore implements Cloneable { ...@@ -148,7 +136,7 @@ final class HmacCore implements Cloneable {
* *
* @param input the input byte to be processed. * @param input the input byte to be processed.
*/ */
void update(byte input) { protected void engineUpdate(byte input) {
if (first == true) { if (first == true) {
// compute digest for 1st pass; start with inner pad // compute digest for 1st pass; start with inner pad
md.update(k_ipad); md.update(k_ipad);
...@@ -167,7 +155,7 @@ final class HmacCore implements Cloneable { ...@@ -167,7 +155,7 @@ final class HmacCore implements Cloneable {
* @param offset the offset in <code>input</code> where the input starts. * @param offset the offset in <code>input</code> where the input starts.
* @param len the number of bytes to process. * @param len the number of bytes to process.
*/ */
void update(byte input[], int offset, int len) { protected void engineUpdate(byte input[], int offset, int len) {
if (first == true) { if (first == true) {
// compute digest for 1st pass; start with inner pad // compute digest for 1st pass; start with inner pad
md.update(k_ipad); md.update(k_ipad);
...@@ -178,7 +166,13 @@ final class HmacCore implements Cloneable { ...@@ -178,7 +166,13 @@ final class HmacCore implements Cloneable {
md.update(input, offset, len); md.update(input, offset, len);
} }
void update(ByteBuffer input) { /**
* Processes the <code>input.remaining()</code> bytes in the ByteBuffer
* <code>input</code>.
*
* @param input the input byte buffer.
*/
protected void engineUpdate(ByteBuffer input) {
if (first == true) { if (first == true) {
// compute digest for 1st pass; start with inner pad // compute digest for 1st pass; start with inner pad
md.update(k_ipad); md.update(k_ipad);
...@@ -194,7 +188,7 @@ final class HmacCore implements Cloneable { ...@@ -194,7 +188,7 @@ final class HmacCore implements Cloneable {
* *
* @return the HMAC result. * @return the HMAC result.
*/ */
byte[] doFinal() { protected byte[] engineDoFinal() {
if (first == true) { if (first == true) {
// compute digest for 1st pass; start with inner pad // compute digest for 1st pass; start with inner pad
md.update(k_ipad); md.update(k_ipad);
...@@ -223,7 +217,7 @@ final class HmacCore implements Cloneable { ...@@ -223,7 +217,7 @@ final class HmacCore implements Cloneable {
* Resets the HMAC for further use, maintaining the secret key that the * Resets the HMAC for further use, maintaining the secret key that the
* HMAC was initialized with. * HMAC was initialized with.
*/ */
void reset() { protected void engineReset() {
if (first == false) { if (first == false) {
md.reset(); md.reset();
first = true; first = true;
...@@ -234,115 +228,38 @@ final class HmacCore implements Cloneable { ...@@ -234,115 +228,38 @@ final class HmacCore implements Cloneable {
* Clones this object. * Clones this object.
*/ */
public Object clone() throws CloneNotSupportedException { public Object clone() throws CloneNotSupportedException {
return new HmacCore(this); HmacCore copy = (HmacCore) super.clone();
copy.md = (MessageDigest) md.clone();
copy.k_ipad = k_ipad.clone();
copy.k_opad = k_opad.clone();
return copy;
}
// nested static class for the HmacSHA224 implementation
public static final class HmacSHA224 extends HmacCore {
public HmacSHA224() throws NoSuchAlgorithmException {
super("SHA-224", 64);
}
} }
// nested static class for the HmacSHA256 implementation // nested static class for the HmacSHA256 implementation
public static final class HmacSHA256 extends MacSpi implements Cloneable { public static final class HmacSHA256 extends HmacCore {
private final HmacCore core;
public HmacSHA256() throws NoSuchAlgorithmException { public HmacSHA256() throws NoSuchAlgorithmException {
core = new HmacCore("SHA-256", 64); super("SHA-256", 64);
}
private HmacSHA256(HmacSHA256 base) throws CloneNotSupportedException {
core = (HmacCore)base.core.clone();
}
protected int engineGetMacLength() {
return core.getDigestLength();
}
protected void engineInit(Key key, AlgorithmParameterSpec params)
throws InvalidKeyException, InvalidAlgorithmParameterException {
core.init(key, params);
}
protected void engineUpdate(byte input) {
core.update(input);
}
protected void engineUpdate(byte input[], int offset, int len) {
core.update(input, offset, len);
}
protected void engineUpdate(ByteBuffer input) {
core.update(input);
}
protected byte[] engineDoFinal() {
return core.doFinal();
}
protected void engineReset() {
core.reset();
}
public Object clone() throws CloneNotSupportedException {
return new HmacSHA256(this);
} }
} }
// nested static class for the HmacSHA384 implementation // nested static class for the HmacSHA384 implementation
public static final class HmacSHA384 extends MacSpi implements Cloneable { public static final class HmacSHA384 extends HmacCore {
private final HmacCore core;
public HmacSHA384() throws NoSuchAlgorithmException { public HmacSHA384() throws NoSuchAlgorithmException {
core = new HmacCore("SHA-384", 128); super("SHA-384", 128);
}
private HmacSHA384(HmacSHA384 base) throws CloneNotSupportedException {
core = (HmacCore)base.core.clone();
}
protected int engineGetMacLength() {
return core.getDigestLength();
}
protected void engineInit(Key key, AlgorithmParameterSpec params)
throws InvalidKeyException, InvalidAlgorithmParameterException {
core.init(key, params);
}
protected void engineUpdate(byte input) {
core.update(input);
}
protected void engineUpdate(byte input[], int offset, int len) {
core.update(input, offset, len);
}
protected void engineUpdate(ByteBuffer input) {
core.update(input);
}
protected byte[] engineDoFinal() {
return core.doFinal();
}
protected void engineReset() {
core.reset();
}
public Object clone() throws CloneNotSupportedException {
return new HmacSHA384(this);
} }
} }
// nested static class for the HmacSHA512 implementation // nested static class for the HmacSHA512 implementation
public static final class HmacSHA512 extends MacSpi implements Cloneable { public static final class HmacSHA512 extends HmacCore {
private final HmacCore core;
public HmacSHA512() throws NoSuchAlgorithmException { public HmacSHA512() throws NoSuchAlgorithmException {
core = new HmacCore("SHA-512", 128); super("SHA-512", 128);
}
private HmacSHA512(HmacSHA512 base) throws CloneNotSupportedException {
core = (HmacCore)base.core.clone();
}
protected int engineGetMacLength() {
return core.getDigestLength();
}
protected void engineInit(Key key, AlgorithmParameterSpec params)
throws InvalidKeyException, InvalidAlgorithmParameterException {
core.init(key, params);
}
protected void engineUpdate(byte input) {
core.update(input);
}
protected void engineUpdate(byte input[], int offset, int len) {
core.update(input, offset, len);
}
protected void engineUpdate(ByteBuffer input) {
core.update(input);
}
protected byte[] engineDoFinal() {
return core.doFinal();
}
protected void engineReset() {
core.reset();
}
public Object clone() throws CloneNotSupportedException {
return new HmacSHA512(this);
} }
} }
} }
/* /*
* Copyright (c) 1998, 2009, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -37,97 +37,11 @@ import java.security.spec.*; ...@@ -37,97 +37,11 @@ import java.security.spec.*;
* *
* @author Jan Luehe * @author Jan Luehe
*/ */
public final class HmacMD5 extends MacSpi implements Cloneable { public final class HmacMD5 extends HmacCore {
private HmacCore hmac;
private static final int MD5_BLOCK_LENGTH = 64;
/** /**
* Standard constructor, creates a new HmacMD5 instance. * Standard constructor, creates a new HmacMD5 instance.
*/ */
public HmacMD5() throws NoSuchAlgorithmException { public HmacMD5() throws NoSuchAlgorithmException {
hmac = new HmacCore(MessageDigest.getInstance("MD5"), super("MD5", 64);
MD5_BLOCK_LENGTH);
}
/**
* Returns the length of the HMAC in bytes.
*
* @return the HMAC length in bytes.
*/
protected int engineGetMacLength() {
return hmac.getDigestLength();
}
/**
* Initializes the HMAC with the given secret key and algorithm parameters.
*
* @param key the secret key.
* @param params the algorithm parameters.
*
* @exception InvalidKeyException if the given key is inappropriate for
* initializing this MAC.
* @exception InvalidAlgorithmParameterException if the given algorithm
* parameters are inappropriate for this MAC.
*/
protected void engineInit(Key key, AlgorithmParameterSpec params)
throws InvalidKeyException, InvalidAlgorithmParameterException {
hmac.init(key, params);
}
/**
* Processes the given byte.
*
* @param input the input byte to be processed.
*/
protected void engineUpdate(byte input) {
hmac.update(input);
}
/**
* Processes the first <code>len</code> bytes in <code>input</code>,
* starting at <code>offset</code>.
*
* @param input the input buffer.
* @param offset the offset in <code>input</code> where the input starts.
* @param len the number of bytes to process.
*/
protected void engineUpdate(byte input[], int offset, int len) {
hmac.update(input, offset, len);
}
protected void engineUpdate(ByteBuffer input) {
hmac.update(input);
}
/**
* Completes the HMAC computation and resets the HMAC for further use,
* maintaining the secret key that the HMAC was initialized with.
*
* @return the HMAC result.
*/
protected byte[] engineDoFinal() {
return hmac.doFinal();
}
/**
* Resets the HMAC for further use, maintaining the secret key that the
* HMAC was initialized with.
*/
protected void engineReset() {
hmac.reset();
}
/*
* Clones this object.
*/
public Object clone() {
HmacMD5 that = null;
try {
that = (HmacMD5) super.clone();
that.hmac = (HmacCore) this.hmac.clone();
} catch (CloneNotSupportedException e) {
}
return that;
} }
} }
/* /*
* Copyright (c) 2003, 2009, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -41,26 +41,13 @@ import java.security.spec.*; ...@@ -41,26 +41,13 @@ import java.security.spec.*;
* *
* @author Valerie Peng * @author Valerie Peng
*/ */
public final class HmacPKCS12PBESHA1 extends MacSpi implements Cloneable { public final class HmacPKCS12PBESHA1 extends HmacCore {
private HmacCore hmac = null;
private static final int SHA1_BLOCK_LENGTH = 64;
/** /**
* Standard constructor, creates a new HmacSHA1 instance. * Standard constructor, creates a new HmacSHA1 instance.
*/ */
public HmacPKCS12PBESHA1() throws NoSuchAlgorithmException { public HmacPKCS12PBESHA1() throws NoSuchAlgorithmException {
this.hmac = new HmacCore(MessageDigest.getInstance("SHA1"), super("SHA1", 64);
SHA1_BLOCK_LENGTH);
}
/**
* Returns the length of the HMAC in bytes.
*
* @return the HMAC length in bytes.
*/
protected int engineGetMacLength() {
return hmac.getDigestLength();
} }
/** /**
...@@ -71,7 +58,7 @@ public final class HmacPKCS12PBESHA1 extends MacSpi implements Cloneable { ...@@ -71,7 +58,7 @@ public final class HmacPKCS12PBESHA1 extends MacSpi implements Cloneable {
* *
* @exception InvalidKeyException if the given key is inappropriate for * @exception InvalidKeyException if the given key is inappropriate for
* initializing this MAC. * initializing this MAC.
u* @exception InvalidAlgorithmParameterException if the given algorithm * @exception InvalidAlgorithmParameterException if the given algorithm
* parameters are inappropriate for this MAC. * parameters are inappropriate for this MAC.
*/ */
protected void engineInit(Key key, AlgorithmParameterSpec params) protected void engineInit(Key key, AlgorithmParameterSpec params)
...@@ -140,64 +127,8 @@ public final class HmacPKCS12PBESHA1 extends MacSpi implements Cloneable { ...@@ -140,64 +127,8 @@ public final class HmacPKCS12PBESHA1 extends MacSpi implements Cloneable {
("IterationCount must be a positive number"); ("IterationCount must be a positive number");
} }
byte[] derivedKey = PKCS12PBECipherCore.derive(passwdChars, salt, byte[] derivedKey = PKCS12PBECipherCore.derive(passwdChars, salt,
iCount, hmac.getDigestLength(), PKCS12PBECipherCore.MAC_KEY); iCount, engineGetMacLength(), PKCS12PBECipherCore.MAC_KEY);
SecretKey cipherKey = new SecretKeySpec(derivedKey, "HmacSHA1"); SecretKey cipherKey = new SecretKeySpec(derivedKey, "HmacSHA1");
hmac.init(cipherKey, null); super.engineInit(cipherKey, null);
}
/**
* Processes the given byte.
*
* @param input the input byte to be processed.
*/
protected void engineUpdate(byte input) {
hmac.update(input);
}
/**
* Processes the first <code>len</code> bytes in <code>input</code>,
* starting at <code>offset</code>.
*
* @param input the input buffer.
* @param offset the offset in <code>input</code> where the input starts.
* @param len the number of bytes to process.
*/
protected void engineUpdate(byte input[], int offset, int len) {
hmac.update(input, offset, len);
}
protected void engineUpdate(ByteBuffer input) {
hmac.update(input);
}
/**
* Completes the HMAC computation and resets the HMAC for further use,
* maintaining the secret key that the HMAC was initialized with.
*
* @return the HMAC result.
*/
protected byte[] engineDoFinal() {
return hmac.doFinal();
}
/**
* Resets the HMAC for further use, maintaining the secret key that the
* HMAC was initialized with.
*/
protected void engineReset() {
hmac.reset();
}
/*
* Clones this object.
*/
public Object clone() {
HmacPKCS12PBESHA1 that = null;
try {
that = (HmacPKCS12PBESHA1)super.clone();
that.hmac = (HmacCore)this.hmac.clone();
} catch (CloneNotSupportedException e) {
}
return that;
} }
} }
/* /*
* Copyright (c) 1998, 2009, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -37,97 +37,11 @@ import java.security.spec.*; ...@@ -37,97 +37,11 @@ import java.security.spec.*;
* *
* @author Jan Luehe * @author Jan Luehe
*/ */
public final class HmacSHA1 extends MacSpi implements Cloneable { public final class HmacSHA1 extends HmacCore {
private HmacCore hmac = null;
private static final int SHA1_BLOCK_LENGTH = 64;
/** /**
* Standard constructor, creates a new HmacSHA1 instance. * Standard constructor, creates a new HmacSHA1 instance.
*/ */
public HmacSHA1() throws NoSuchAlgorithmException { public HmacSHA1() throws NoSuchAlgorithmException {
this.hmac = new HmacCore(MessageDigest.getInstance("SHA1"), super("SHA1", 64);
SHA1_BLOCK_LENGTH);
}
/**
* Returns the length of the HMAC in bytes.
*
* @return the HMAC length in bytes.
*/
protected int engineGetMacLength() {
return hmac.getDigestLength();
}
/**
* Initializes the HMAC with the given secret key and algorithm parameters.
*
* @param key the secret key.
* @param params the algorithm parameters.
*
* @exception InvalidKeyException if the given key is inappropriate for
* initializing this MAC.
* @exception InvalidAlgorithmParameterException if the given algorithm
* parameters are inappropriate for this MAC.
*/
protected void engineInit(Key key, AlgorithmParameterSpec params)
throws InvalidKeyException, InvalidAlgorithmParameterException {
hmac.init(key, params);
}
/**
* Processes the given byte.
*
* @param input the input byte to be processed.
*/
protected void engineUpdate(byte input) {
hmac.update(input);
}
/**
* Processes the first <code>len</code> bytes in <code>input</code>,
* starting at <code>offset</code>.
*
* @param input the input buffer.
* @param offset the offset in <code>input</code> where the input starts.
* @param len the number of bytes to process.
*/
protected void engineUpdate(byte input[], int offset, int len) {
hmac.update(input, offset, len);
}
protected void engineUpdate(ByteBuffer input) {
hmac.update(input);
}
/**
* Completes the HMAC computation and resets the HMAC for further use,
* maintaining the secret key that the HMAC was initialized with.
*
* @return the HMAC result.
*/
protected byte[] engineDoFinal() {
return hmac.doFinal();
}
/**
* Resets the HMAC for further use, maintaining the secret key that the
* HMAC was initialized with.
*/
protected void engineReset() {
hmac.reset();
}
/*
* Clones this object.
*/
public Object clone() {
HmacSHA1 that = null;
try {
that = (HmacSHA1)super.clone();
that.hmac = (HmacCore)this.hmac.clone();
} catch (CloneNotSupportedException e) {
}
return that;
} }
} }
/* /*
* Copyright (c) 2003, 2009, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -105,11 +105,11 @@ final class KeyGeneratorCore { ...@@ -105,11 +105,11 @@ final class KeyGeneratorCore {
return new SecretKeySpec(b, name); return new SecretKeySpec(b, name);
} }
// nested static class for the HmacSHA256 key generator // nested static classes for the HmacSHA-2 family of key generator
public static final class HmacSHA256KG extends KeyGeneratorSpi { abstract static class HmacSHA2KG extends KeyGeneratorSpi {
private final KeyGeneratorCore core; private final KeyGeneratorCore core;
public HmacSHA256KG() { protected HmacSHA2KG(String algoName, int len) {
core = new KeyGeneratorCore("HmacSHA256", 256); core = new KeyGeneratorCore(algoName, len);
} }
protected void engineInit(SecureRandom random) { protected void engineInit(SecureRandom random) {
core.implInit(random); core.implInit(random);
...@@ -124,47 +124,26 @@ final class KeyGeneratorCore { ...@@ -124,47 +124,26 @@ final class KeyGeneratorCore {
protected SecretKey engineGenerateKey() { protected SecretKey engineGenerateKey() {
return core.implGenerateKey(); return core.implGenerateKey();
} }
}
// nested static class for the HmacSHA384 key generator public static final class SHA224 extends HmacSHA2KG {
public static final class HmacSHA384KG extends KeyGeneratorSpi { public SHA224() {
private final KeyGeneratorCore core; super("HmacSHA224", 224);
public HmacSHA384KG() { }
core = new KeyGeneratorCore("HmacSHA384", 384);
}
protected void engineInit(SecureRandom random) {
core.implInit(random);
}
protected void engineInit(AlgorithmParameterSpec params,
SecureRandom random) throws InvalidAlgorithmParameterException {
core.implInit(params, random);
}
protected void engineInit(int keySize, SecureRandom random) {
core.implInit(keySize, random);
}
protected SecretKey engineGenerateKey() {
return core.implGenerateKey();
}
}
// nested static class for the HmacSHA384 key generator
public static final class HmacSHA512KG extends KeyGeneratorSpi {
private final KeyGeneratorCore core;
public HmacSHA512KG() {
core = new KeyGeneratorCore("HmacSHA512", 512);
}
protected void engineInit(SecureRandom random) {
core.implInit(random);
} }
protected void engineInit(AlgorithmParameterSpec params, public static final class SHA256 extends HmacSHA2KG {
SecureRandom random) throws InvalidAlgorithmParameterException { public SHA256() {
core.implInit(params, random); super("HmacSHA256", 256);
}
} }
protected void engineInit(int keySize, SecureRandom random) { public static final class SHA384 extends HmacSHA2KG {
core.implInit(keySize, random); public SHA384() {
super("HmacSHA384", 384);
}
} }
protected SecretKey engineGenerateKey() { public static final class SHA512 extends HmacSHA2KG {
return core.implGenerateKey(); public SHA512() {
super("HmacSHA512", 512);
}
} }
} }
......
/* /*
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -108,6 +108,8 @@ public final class OAEPParameters extends AlgorithmParametersSpi { ...@@ -108,6 +108,8 @@ public final class OAEPParameters extends AlgorithmParametersSpi {
private static String convertToStandardName(String internalName) { private static String convertToStandardName(String internalName) {
if (internalName.equals("SHA")) { if (internalName.equals("SHA")) {
return "SHA-1"; return "SHA-1";
} else if (internalName.equals("SHA224")) {
return "SHA-224";
} else if (internalName.equals("SHA256")) { } else if (internalName.equals("SHA256")) {
return "SHA-256"; return "SHA-256";
} else if (internalName.equals("SHA384")) { } else if (internalName.equals("SHA384")) {
...@@ -143,6 +145,8 @@ public final class OAEPParameters extends AlgorithmParametersSpi { ...@@ -143,6 +145,8 @@ public final class OAEPParameters extends AlgorithmParametersSpi {
String mgfDigestName = convertToStandardName(params.getName()); String mgfDigestName = convertToStandardName(params.getName());
if (mgfDigestName.equals("SHA-1")) { if (mgfDigestName.equals("SHA-1")) {
mgfSpec = MGF1ParameterSpec.SHA1; mgfSpec = MGF1ParameterSpec.SHA1;
} else if (mgfDigestName.equals("SHA-224")) {
mgfSpec = MGF1ParameterSpec.SHA224;
} else if (mgfDigestName.equals("SHA-256")) { } else if (mgfDigestName.equals("SHA-256")) {
mgfSpec = MGF1ParameterSpec.SHA256; mgfSpec = MGF1ParameterSpec.SHA256;
} else if (mgfDigestName.equals("SHA-384")) { } else if (mgfDigestName.equals("SHA-384")) {
......
/* /*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -65,7 +65,7 @@ import java.security.SecureRandom; ...@@ -65,7 +65,7 @@ import java.security.SecureRandom;
* *
* - Diffie-Hellman Key Agreement * - Diffie-Hellman Key Agreement
* *
* - HMAC-MD5, HMAC-SHA1, HMAC-SHA-256, HMAC-SHA-384, HMAC-SHA-512 * - HMAC-MD5, HMAC-SHA1, HMAC-SHA-224, HMAC-SHA-256, HMAC-SHA-384, HMAC-SHA-512
* *
*/ */
...@@ -113,6 +113,7 @@ public final class SunJCE extends Provider { ...@@ -113,6 +113,7 @@ public final class SunJCE extends Provider {
"NOPADDING|PKCS1PADDING|OAEPWITHMD5ANDMGF1PADDING" "NOPADDING|PKCS1PADDING|OAEPWITHMD5ANDMGF1PADDING"
+ "|OAEPWITHSHA1ANDMGF1PADDING" + "|OAEPWITHSHA1ANDMGF1PADDING"
+ "|OAEPWITHSHA-1ANDMGF1PADDING" + "|OAEPWITHSHA-1ANDMGF1PADDING"
+ "|OAEPWITHSHA-224ANDMGF1PADDING"
+ "|OAEPWITHSHA-256ANDMGF1PADDING" + "|OAEPWITHSHA-256ANDMGF1PADDING"
+ "|OAEPWITHSHA-384ANDMGF1PADDING" + "|OAEPWITHSHA-384ANDMGF1PADDING"
+ "|OAEPWITHSHA-512ANDMGF1PADDING"); + "|OAEPWITHSHA-512ANDMGF1PADDING");
...@@ -221,12 +222,25 @@ public final class SunJCE extends Provider { ...@@ -221,12 +222,25 @@ public final class SunJCE extends Provider {
put("KeyGenerator.HmacSHA1", put("KeyGenerator.HmacSHA1",
"com.sun.crypto.provider.HmacSHA1KeyGenerator"); "com.sun.crypto.provider.HmacSHA1KeyGenerator");
put("KeyGenerator.HmacSHA224",
"com.sun.crypto.provider.KeyGeneratorCore$HmacSHA2KG$SHA224");
put("Alg.Alias.KeyGenerator.OID.1.2.840.113549.2.8", "HmacSHA224");
put("Alg.Alias.KeyGenerator.1.2.840.113549.2.8", "HmacSHA224");
put("KeyGenerator.HmacSHA256", put("KeyGenerator.HmacSHA256",
"com.sun.crypto.provider.KeyGeneratorCore$HmacSHA256KG"); "com.sun.crypto.provider.KeyGeneratorCore$HmacSHA2KG$SHA256");
put("Alg.Alias.KeyGenerator.OID.1.2.840.113549.2.9", "HmacSHA256");
put("Alg.Alias.KeyGenerator.1.2.840.113549.2.9", "HmacSHA256");
put("KeyGenerator.HmacSHA384", put("KeyGenerator.HmacSHA384",
"com.sun.crypto.provider.KeyGeneratorCore$HmacSHA384KG"); "com.sun.crypto.provider.KeyGeneratorCore$HmacSHA2KG$SHA384");
put("Alg.Alias.KeyGenerator.OID.1.2.840.113549.2.10", "HmacSHA384");
put("Alg.Alias.KeyGenerator.1.2.840.113549.2.10", "HmacSHA384");
put("KeyGenerator.HmacSHA512", put("KeyGenerator.HmacSHA512",
"com.sun.crypto.provider.KeyGeneratorCore$HmacSHA512KG"); "com.sun.crypto.provider.KeyGeneratorCore$HmacSHA2KG$SHA512");
put("Alg.Alias.KeyGenerator.OID.1.2.840.113549.2.11", "HmacSHA512");
put("Alg.Alias.KeyGenerator.1.2.840.113549.2.11", "HmacSHA512");
put("KeyPairGenerator.DiffieHellman", put("KeyPairGenerator.DiffieHellman",
"com.sun.crypto.provider.DHKeyPairGenerator"); "com.sun.crypto.provider.DHKeyPairGenerator");
...@@ -389,12 +403,23 @@ public final class SunJCE extends Provider { ...@@ -389,12 +403,23 @@ public final class SunJCE extends Provider {
*/ */
put("Mac.HmacMD5", "com.sun.crypto.provider.HmacMD5"); put("Mac.HmacMD5", "com.sun.crypto.provider.HmacMD5");
put("Mac.HmacSHA1", "com.sun.crypto.provider.HmacSHA1"); put("Mac.HmacSHA1", "com.sun.crypto.provider.HmacSHA1");
put("Mac.HmacSHA224",
"com.sun.crypto.provider.HmacCore$HmacSHA224");
put("Alg.Alias.Mac.OID.1.2.840.113549.2.8", "HmacSHA224");
put("Alg.Alias.Mac.1.2.840.113549.2.8", "HmacSHA224");
put("Mac.HmacSHA256", put("Mac.HmacSHA256",
"com.sun.crypto.provider.HmacCore$HmacSHA256"); "com.sun.crypto.provider.HmacCore$HmacSHA256");
put("Alg.Alias.Mac.OID.1.2.840.113549.2.9", "HmacSHA256");
put("Alg.Alias.Mac.1.2.840.113549.2.9", "HmacSHA256");
put("Mac.HmacSHA384", put("Mac.HmacSHA384",
"com.sun.crypto.provider.HmacCore$HmacSHA384"); "com.sun.crypto.provider.HmacCore$HmacSHA384");
put("Alg.Alias.Mac.OID.1.2.840.113549.2.10", "HmacSHA384");
put("Alg.Alias.Mac.1.2.840.113549.2.10", "HmacSHA384");
put("Mac.HmacSHA512", put("Mac.HmacSHA512",
"com.sun.crypto.provider.HmacCore$HmacSHA512"); "com.sun.crypto.provider.HmacCore$HmacSHA512");
put("Alg.Alias.Mac.OID.1.2.840.113549.2.11", "HmacSHA512");
put("Alg.Alias.Mac.1.2.840.113549.2.11", "HmacSHA512");
put("Mac.HmacPBESHA1", put("Mac.HmacPBESHA1",
"com.sun.crypto.provider.HmacPKCS12PBESHA1"); "com.sun.crypto.provider.HmacPKCS12PBESHA1");
...@@ -405,6 +430,7 @@ public final class SunJCE extends Provider { ...@@ -405,6 +430,7 @@ public final class SunJCE extends Provider {
put("Mac.HmacMD5 SupportedKeyFormats", "RAW"); put("Mac.HmacMD5 SupportedKeyFormats", "RAW");
put("Mac.HmacSHA1 SupportedKeyFormats", "RAW"); put("Mac.HmacSHA1 SupportedKeyFormats", "RAW");
put("Mac.HmacSHA224 SupportedKeyFormats", "RAW");
put("Mac.HmacSHA256 SupportedKeyFormats", "RAW"); put("Mac.HmacSHA256 SupportedKeyFormats", "RAW");
put("Mac.HmacSHA384 SupportedKeyFormats", "RAW"); put("Mac.HmacSHA384 SupportedKeyFormats", "RAW");
put("Mac.HmacSHA512 SupportedKeyFormats", "RAW"); put("Mac.HmacSHA512 SupportedKeyFormats", "RAW");
......
...@@ -128,7 +128,7 @@ public class FilteredRowSetImpl extends WebRowSetImpl implements Serializable, C ...@@ -128,7 +128,7 @@ public class FilteredRowSetImpl extends WebRowSetImpl implements Serializable, C
for(int rows=this.getRow(); rows<=this.size();rows++) { for(int rows=this.getRow(); rows<=this.size();rows++) {
bool = super.internalNext(); bool = super.internalNext();
if( p == null) { if( !bool || p == null) {
return bool; return bool;
} }
if(p.evaluate(this)){ if(p.evaluate(this)){
......
...@@ -780,6 +780,9 @@ public final class Integer extends Number implements Comparable<Integer> { ...@@ -780,6 +780,9 @@ public final class Integer extends Number implements Comparable<Integer> {
int j = low; int j = low;
for(int k = 0; k < cache.length; k++) for(int k = 0; k < cache.length; k++)
cache[k] = new Integer(j++); cache[k] = new Integer(j++);
// range [-128, 127] must be interned (JLS7 5.1.7)
assert IntegerCache.high >= 127;
} }
private IntegerCache() {} private IntegerCache() {}
...@@ -801,7 +804,6 @@ public final class Integer extends Number implements Comparable<Integer> { ...@@ -801,7 +804,6 @@ public final class Integer extends Number implements Comparable<Integer> {
* @since 1.5 * @since 1.5
*/ */
public static Integer valueOf(int i) { public static Integer valueOf(int i) {
assert IntegerCache.high >= 127;
if (i >= IntegerCache.low && i <= IntegerCache.high) if (i >= IntegerCache.low && i <= IntegerCache.high)
return IntegerCache.cache[i + (-IntegerCache.low)]; return IntegerCache.cache[i + (-IntegerCache.low)];
return new Integer(i); return new Integer(i);
......
...@@ -139,6 +139,9 @@ public abstract class MappedByteBuffer ...@@ -139,6 +139,9 @@ public abstract class MappedByteBuffer
return isLoaded0(mappingAddress(offset), length, Bits.pageCount(length)); return isLoaded0(mappingAddress(offset), length, Bits.pageCount(length));
} }
// not used, but a potential target for a store, see load() for details.
private static byte unused;
/** /**
* Loads this buffer's content into physical memory. * Loads this buffer's content into physical memory.
* *
...@@ -157,15 +160,20 @@ public abstract class MappedByteBuffer ...@@ -157,15 +160,20 @@ public abstract class MappedByteBuffer
long length = mappingLength(offset); long length = mappingLength(offset);
load0(mappingAddress(offset), length); load0(mappingAddress(offset), length);
// touch each page // Read a byte from each page to bring it into memory. A checksum
// is computed as we go along to prevent the compiler from otherwise
// considering the loop as dead code.
Unsafe unsafe = Unsafe.getUnsafe(); Unsafe unsafe = Unsafe.getUnsafe();
int ps = Bits.pageSize(); int ps = Bits.pageSize();
int count = Bits.pageCount(length); int count = Bits.pageCount(length);
long a = mappingAddress(offset); long a = mappingAddress(offset);
byte x = 0;
for (int i=0; i<count; i++) { for (int i=0; i<count; i++) {
unsafe.getByte(a); x ^= unsafe.getByte(a);
a += ps; a += ps;
} }
if (unused != 0)
unused = x;
return this; return this;
} }
......
/* /*
* Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -42,6 +42,7 @@ import java.security.spec.AlgorithmParameterSpec; ...@@ -42,6 +42,7 @@ import java.security.spec.AlgorithmParameterSpec;
* <pre> * <pre>
* OAEP-PSSDigestAlgorithms ALGORITHM-IDENTIFIER ::= { * OAEP-PSSDigestAlgorithms ALGORITHM-IDENTIFIER ::= {
* { OID id-sha1 PARAMETERS NULL }| * { OID id-sha1 PARAMETERS NULL }|
* { OID id-sha224 PARAMETERS NULL }|
* { OID id-sha256 PARAMETERS NULL }| * { OID id-sha256 PARAMETERS NULL }|
* { OID id-sha384 PARAMETERS NULL }| * { OID id-sha384 PARAMETERS NULL }|
* { OID id-sha512 PARAMETERS NULL }, * { OID id-sha512 PARAMETERS NULL },
...@@ -62,6 +63,11 @@ public class MGF1ParameterSpec implements AlgorithmParameterSpec { ...@@ -62,6 +63,11 @@ public class MGF1ParameterSpec implements AlgorithmParameterSpec {
*/ */
public static final MGF1ParameterSpec SHA1 = public static final MGF1ParameterSpec SHA1 =
new MGF1ParameterSpec("SHA-1"); new MGF1ParameterSpec("SHA-1");
/**
* The MGF1ParameterSpec which uses "SHA-224" message digest.
*/
public static final MGF1ParameterSpec SHA224 =
new MGF1ParameterSpec("SHA-224");
/** /**
* The MGF1ParameterSpec which uses "SHA-256" message digest. * The MGF1ParameterSpec which uses "SHA-256" message digest.
*/ */
......
/* /*
* Copyright (c) 2001, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -47,6 +47,7 @@ import java.security.spec.MGF1ParameterSpec; ...@@ -47,6 +47,7 @@ import java.security.spec.MGF1ParameterSpec;
* <pre> * <pre>
* OAEP-PSSDigestAlgorithms ALGORITHM-IDENTIFIER ::= { * OAEP-PSSDigestAlgorithms ALGORITHM-IDENTIFIER ::= {
* { OID id-sha1 PARAMETERS NULL }| * { OID id-sha1 PARAMETERS NULL }|
* { OID id-sha224 PARAMETERS NULL }|
* { OID id-sha256 PARAMETERS NULL }| * { OID id-sha256 PARAMETERS NULL }|
* { OID id-sha384 PARAMETERS NULL }| * { OID id-sha384 PARAMETERS NULL }|
* { OID id-sha512 PARAMETERS NULL }, * { OID id-sha512 PARAMETERS NULL },
......
/* /*
* Copyright (c) 1994, 2008, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1994, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -26,13 +26,12 @@ ...@@ -26,13 +26,12 @@
package java.util; package java.util;
/** /**
* Thrown by the <code>nextElement</code> method of an * Thrown by various accessor methods to indicate that the element being requested
* <code>Enumeration</code> to indicate that there are no more * does not exist.
* elements in the enumeration.
* *
* @author unascribed * @author unascribed
* @see java.util.Enumeration
* @see java.util.Enumeration#nextElement() * @see java.util.Enumeration#nextElement()
* @see java.util.Iterator#next()
* @since JDK1.0 * @since JDK1.0
*/ */
public public
......
...@@ -90,9 +90,11 @@ public final class UUID implements java.io.Serializable, Comparable<UUID> { ...@@ -90,9 +90,11 @@ public final class UUID implements java.io.Serializable, Comparable<UUID> {
/* /*
* The random number generator used by this class to create random * The random number generator used by this class to create random
* based UUIDs. * based UUIDs. In a holder class to defer initialization until needed.
*/ */
private static volatile SecureRandom numberGenerator = null; private static class Holder {
static final SecureRandom numberGenerator = new SecureRandom();
}
// Constructors and Factories // Constructors and Factories
...@@ -137,10 +139,7 @@ public final class UUID implements java.io.Serializable, Comparable<UUID> { ...@@ -137,10 +139,7 @@ public final class UUID implements java.io.Serializable, Comparable<UUID> {
* @return A randomly generated {@code UUID} * @return A randomly generated {@code UUID}
*/ */
public static UUID randomUUID() { public static UUID randomUUID() {
SecureRandom ng = numberGenerator; SecureRandom ng = Holder.numberGenerator;
if (ng == null) {
numberGenerator = ng = new SecureRandom();
}
byte[] randomBytes = new byte[16]; byte[] randomBytes = new byte[16];
ng.nextBytes(randomBytes); ng.nextBytes(randomBytes);
...@@ -255,7 +254,8 @@ public final class UUID implements java.io.Serializable, Comparable<UUID> { ...@@ -255,7 +254,8 @@ public final class UUID implements java.io.Serializable, Comparable<UUID> {
* The variant number has the following meaning: * The variant number has the following meaning:
* <p><ul> * <p><ul>
* <li>0 Reserved for NCS backward compatibility * <li>0 Reserved for NCS backward compatibility
* <li>2 The Leach-Salz variant (used by this class) * <li>2 <a href="http://www.ietf.org/rfc/rfc4122.txt">IETF&nbsp;RFC&nbsp;4122</a>
* (Leach-Salz), used by this class
* <li>6 Reserved, Microsoft Corporation backward compatibility * <li>6 Reserved, Microsoft Corporation backward compatibility
* <li>7 Reserved for future definition * <li>7 Reserved for future definition
* </ul> * </ul>
...@@ -265,7 +265,7 @@ public final class UUID implements java.io.Serializable, Comparable<UUID> { ...@@ -265,7 +265,7 @@ public final class UUID implements java.io.Serializable, Comparable<UUID> {
public int variant() { public int variant() {
// This field is composed of a varying number of bits. // This field is composed of a varying number of bits.
// 0 - - Reserved for NCS backward compatibility // 0 - - Reserved for NCS backward compatibility
// 1 0 - The Leach-Salz variant (used by this class) // 1 0 - The IETF aka Leach-Salz variant (used by this class)
// 1 1 0 Reserved, Microsoft backward compatibility // 1 1 0 Reserved, Microsoft backward compatibility
// 1 1 1 Reserved for future definition. // 1 1 1 Reserved for future definition.
return (int) ((leastSigBits >>> (64 - (leastSigBits >>> 62))) return (int) ((leastSigBits >>> (64 - (leastSigBits >>> 62)))
......
...@@ -35,7 +35,11 @@ ...@@ -35,7 +35,11 @@
package java.util.concurrent.atomic; package java.util.concurrent.atomic;
import sun.misc.Unsafe; import sun.misc.Unsafe;
import java.lang.reflect.*; import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.security.AccessController;
import java.security.PrivilegedExceptionAction;
import java.security.PrivilegedActionException;
/** /**
* A reflection-based utility that enables atomic updates to * A reflection-based utility that enables atomic updates to
...@@ -67,7 +71,9 @@ public abstract class AtomicIntegerFieldUpdater<T> { ...@@ -67,7 +71,9 @@ public abstract class AtomicIntegerFieldUpdater<T> {
* @throws IllegalArgumentException if the field is not a * @throws IllegalArgumentException if the field is not a
* volatile integer type * volatile integer type
* @throws RuntimeException with a nested reflection-based * @throws RuntimeException with a nested reflection-based
* exception if the class does not hold field or is the wrong type * exception if the class does not hold field or is the wrong type,
* or the field is inaccessible to the caller according to Java language
* access control
*/ */
public static <U> AtomicIntegerFieldUpdater<U> newUpdater(Class<U> tclass, String fieldName) { public static <U> AtomicIntegerFieldUpdater<U> newUpdater(Class<U> tclass, String fieldName) {
return new AtomicIntegerFieldUpdaterImpl<U>(tclass, fieldName); return new AtomicIntegerFieldUpdaterImpl<U>(tclass, fieldName);
...@@ -267,17 +273,29 @@ public abstract class AtomicIntegerFieldUpdater<T> { ...@@ -267,17 +273,29 @@ public abstract class AtomicIntegerFieldUpdater<T> {
private final Class<T> tclass; private final Class<T> tclass;
private final Class<?> cclass; private final Class<?> cclass;
AtomicIntegerFieldUpdaterImpl(Class<T> tclass, String fieldName) { AtomicIntegerFieldUpdaterImpl(final Class<T> tclass, final String fieldName) {
Field field = null; Field field = null;
Class<?> caller = null; Class<?> caller = null;
int modifiers = 0; int modifiers = 0;
try { try {
field = tclass.getDeclaredField(fieldName); field = AccessController.doPrivileged(
new PrivilegedExceptionAction<Field>() {
public Field run() throws NoSuchFieldException {
return tclass.getDeclaredField(fieldName);
}
});
caller = sun.reflect.Reflection.getCallerClass(3); caller = sun.reflect.Reflection.getCallerClass(3);
modifiers = field.getModifiers(); modifiers = field.getModifiers();
sun.reflect.misc.ReflectUtil.ensureMemberAccess( sun.reflect.misc.ReflectUtil.ensureMemberAccess(
caller, tclass, null, modifiers); caller, tclass, null, modifiers);
sun.reflect.misc.ReflectUtil.checkPackageAccess(tclass); ClassLoader cl = tclass.getClassLoader();
ClassLoader ccl = caller.getClassLoader();
if ((ccl != null) && (ccl != cl) &&
((cl == null) || !isAncestor(cl, ccl))) {
sun.reflect.misc.ReflectUtil.checkPackageAccess(tclass);
}
} catch (PrivilegedActionException pae) {
throw new RuntimeException(pae.getException());
} catch (Exception ex) { } catch (Exception ex) {
throw new RuntimeException(ex); throw new RuntimeException(ex);
} }
...@@ -295,6 +313,22 @@ public abstract class AtomicIntegerFieldUpdater<T> { ...@@ -295,6 +313,22 @@ public abstract class AtomicIntegerFieldUpdater<T> {
offset = unsafe.objectFieldOffset(field); offset = unsafe.objectFieldOffset(field);
} }
/**
* Returns true if the second classloader can be found in the first
* classloader's delegation chain.
* Equivalent to the inaccessible: first.isAncestor(second).
*/
private static boolean isAncestor(ClassLoader first, ClassLoader second) {
ClassLoader acl = first;
do {
acl = acl.getParent();
if (second == acl) {
return true;
}
} while (acl != null);
return false;
}
private void fullCheck(T obj) { private void fullCheck(T obj) {
if (!tclass.isInstance(obj)) if (!tclass.isInstance(obj))
throw new ClassCastException(); throw new ClassCastException();
......
...@@ -35,7 +35,11 @@ ...@@ -35,7 +35,11 @@
package java.util.concurrent.atomic; package java.util.concurrent.atomic;
import sun.misc.Unsafe; import sun.misc.Unsafe;
import java.lang.reflect.*; import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.security.AccessController;
import java.security.PrivilegedExceptionAction;
import java.security.PrivilegedActionException;
/** /**
* A reflection-based utility that enables atomic updates to * A reflection-based utility that enables atomic updates to
...@@ -67,7 +71,9 @@ public abstract class AtomicLongFieldUpdater<T> { ...@@ -67,7 +71,9 @@ public abstract class AtomicLongFieldUpdater<T> {
* @throws IllegalArgumentException if the field is not a * @throws IllegalArgumentException if the field is not a
* volatile long type. * volatile long type.
* @throws RuntimeException with a nested reflection-based * @throws RuntimeException with a nested reflection-based
* exception if the class does not hold field or is the wrong type. * exception if the class does not hold field or is the wrong type,
* or the field is inaccessible to the caller according to Java language
* access control
*/ */
public static <U> AtomicLongFieldUpdater<U> newUpdater(Class<U> tclass, String fieldName) { public static <U> AtomicLongFieldUpdater<U> newUpdater(Class<U> tclass, String fieldName) {
if (AtomicLong.VM_SUPPORTS_LONG_CAS) if (AtomicLong.VM_SUPPORTS_LONG_CAS)
...@@ -267,17 +273,29 @@ public abstract class AtomicLongFieldUpdater<T> { ...@@ -267,17 +273,29 @@ public abstract class AtomicLongFieldUpdater<T> {
private final Class<T> tclass; private final Class<T> tclass;
private final Class<?> cclass; private final Class<?> cclass;
CASUpdater(Class<T> tclass, String fieldName) { CASUpdater(final Class<T> tclass, final String fieldName) {
Field field = null; Field field = null;
Class<?> caller = null; Class<?> caller = null;
int modifiers = 0; int modifiers = 0;
try { try {
field = tclass.getDeclaredField(fieldName); field = AccessController.doPrivileged(
new PrivilegedExceptionAction<Field>() {
public Field run() throws NoSuchFieldException {
return tclass.getDeclaredField(fieldName);
}
});
caller = sun.reflect.Reflection.getCallerClass(3); caller = sun.reflect.Reflection.getCallerClass(3);
modifiers = field.getModifiers(); modifiers = field.getModifiers();
sun.reflect.misc.ReflectUtil.ensureMemberAccess( sun.reflect.misc.ReflectUtil.ensureMemberAccess(
caller, tclass, null, modifiers); caller, tclass, null, modifiers);
sun.reflect.misc.ReflectUtil.checkPackageAccess(tclass); ClassLoader cl = tclass.getClassLoader();
ClassLoader ccl = caller.getClassLoader();
if ((ccl != null) && (ccl != cl) &&
((cl == null) || !isAncestor(cl, ccl))) {
sun.reflect.misc.ReflectUtil.checkPackageAccess(tclass);
}
} catch (PrivilegedActionException pae) {
throw new RuntimeException(pae.getException());
} catch (Exception ex) { } catch (Exception ex) {
throw new RuntimeException(ex); throw new RuntimeException(ex);
} }
...@@ -350,17 +368,29 @@ public abstract class AtomicLongFieldUpdater<T> { ...@@ -350,17 +368,29 @@ public abstract class AtomicLongFieldUpdater<T> {
private final Class<T> tclass; private final Class<T> tclass;
private final Class<?> cclass; private final Class<?> cclass;
LockedUpdater(Class<T> tclass, String fieldName) { LockedUpdater(final Class<T> tclass, final String fieldName) {
Field field = null; Field field = null;
Class<?> caller = null; Class<?> caller = null;
int modifiers = 0; int modifiers = 0;
try { try {
field = tclass.getDeclaredField(fieldName); field = AccessController.doPrivileged(
new PrivilegedExceptionAction<Field>() {
public Field run() throws NoSuchFieldException {
return tclass.getDeclaredField(fieldName);
}
});
caller = sun.reflect.Reflection.getCallerClass(3); caller = sun.reflect.Reflection.getCallerClass(3);
modifiers = field.getModifiers(); modifiers = field.getModifiers();
sun.reflect.misc.ReflectUtil.ensureMemberAccess( sun.reflect.misc.ReflectUtil.ensureMemberAccess(
caller, tclass, null, modifiers); caller, tclass, null, modifiers);
sun.reflect.misc.ReflectUtil.checkPackageAccess(tclass); ClassLoader cl = tclass.getClassLoader();
ClassLoader ccl = caller.getClassLoader();
if ((ccl != null) && (ccl != cl) &&
((cl == null) || !isAncestor(cl, ccl))) {
sun.reflect.misc.ReflectUtil.checkPackageAccess(tclass);
}
} catch (PrivilegedActionException pae) {
throw new RuntimeException(pae.getException());
} catch (Exception ex) { } catch (Exception ex) {
throw new RuntimeException(ex); throw new RuntimeException(ex);
} }
...@@ -433,4 +463,20 @@ public abstract class AtomicLongFieldUpdater<T> { ...@@ -433,4 +463,20 @@ public abstract class AtomicLongFieldUpdater<T> {
); );
} }
} }
/**
* Returns true if the second classloader can be found in the first
* classloader's delegation chain.
* Equivalent to the inaccessible: first.isAncestor(second).
*/
private static boolean isAncestor(ClassLoader first, ClassLoader second) {
ClassLoader acl = first;
do {
acl = acl.getParent();
if (second == acl) {
return true;
}
} while (acl != null);
return false;
}
} }
...@@ -35,7 +35,11 @@ ...@@ -35,7 +35,11 @@
package java.util.concurrent.atomic; package java.util.concurrent.atomic;
import sun.misc.Unsafe; import sun.misc.Unsafe;
import java.lang.reflect.*; import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.security.AccessController;
import java.security.PrivilegedExceptionAction;
import java.security.PrivilegedActionException;
/** /**
* A reflection-based utility that enables atomic updates to * A reflection-based utility that enables atomic updates to
...@@ -86,7 +90,9 @@ public abstract class AtomicReferenceFieldUpdater<T, V> { ...@@ -86,7 +90,9 @@ public abstract class AtomicReferenceFieldUpdater<T, V> {
* @return the updater * @return the updater
* @throws IllegalArgumentException if the field is not a volatile reference type. * @throws IllegalArgumentException if the field is not a volatile reference type.
* @throws RuntimeException with a nested reflection-based * @throws RuntimeException with a nested reflection-based
* exception if the class does not hold field or is the wrong type. * exception if the class does not hold field or is the wrong type,
* or the field is inaccessible to the caller according to Java language
* access control
*/ */
public static <U, W> AtomicReferenceFieldUpdater<U,W> newUpdater(Class<U> tclass, Class<W> vclass, String fieldName) { public static <U, W> AtomicReferenceFieldUpdater<U,W> newUpdater(Class<U> tclass, Class<W> vclass, String fieldName) {
return new AtomicReferenceFieldUpdaterImpl<U,W>(tclass, return new AtomicReferenceFieldUpdaterImpl<U,W>(tclass,
...@@ -197,21 +203,33 @@ public abstract class AtomicReferenceFieldUpdater<T, V> { ...@@ -197,21 +203,33 @@ public abstract class AtomicReferenceFieldUpdater<T, V> {
* screenings fail. * screenings fail.
*/ */
AtomicReferenceFieldUpdaterImpl(Class<T> tclass, AtomicReferenceFieldUpdaterImpl(final Class<T> tclass,
Class<V> vclass, Class<V> vclass,
String fieldName) { final String fieldName) {
Field field = null; Field field = null;
Class<?> fieldClass = null; Class<?> fieldClass = null;
Class<?> caller = null; Class<?> caller = null;
int modifiers = 0; int modifiers = 0;
try { try {
field = tclass.getDeclaredField(fieldName); field = AccessController.doPrivileged(
new PrivilegedExceptionAction<Field>() {
public Field run() throws NoSuchFieldException {
return tclass.getDeclaredField(fieldName);
}
});
caller = sun.reflect.Reflection.getCallerClass(3); caller = sun.reflect.Reflection.getCallerClass(3);
modifiers = field.getModifiers(); modifiers = field.getModifiers();
sun.reflect.misc.ReflectUtil.ensureMemberAccess( sun.reflect.misc.ReflectUtil.ensureMemberAccess(
caller, tclass, null, modifiers); caller, tclass, null, modifiers);
sun.reflect.misc.ReflectUtil.checkPackageAccess(tclass); ClassLoader cl = tclass.getClassLoader();
ClassLoader ccl = caller.getClassLoader();
if ((ccl != null) && (ccl != cl) &&
((cl == null) || !isAncestor(cl, ccl))) {
sun.reflect.misc.ReflectUtil.checkPackageAccess(tclass);
}
fieldClass = field.getType(); fieldClass = field.getType();
} catch (PrivilegedActionException pae) {
throw new RuntimeException(pae.getException());
} catch (Exception ex) { } catch (Exception ex) {
throw new RuntimeException(ex); throw new RuntimeException(ex);
} }
...@@ -232,6 +250,22 @@ public abstract class AtomicReferenceFieldUpdater<T, V> { ...@@ -232,6 +250,22 @@ public abstract class AtomicReferenceFieldUpdater<T, V> {
offset = unsafe.objectFieldOffset(field); offset = unsafe.objectFieldOffset(field);
} }
/**
* Returns true if the second classloader can be found in the first
* classloader's delegation chain.
* Equivalent to the inaccessible: first.isAncestor(second).
*/
private static boolean isAncestor(ClassLoader first, ClassLoader second) {
ClassLoader acl = first;
do {
acl = acl.getParent();
if (second == acl) {
return true;
}
} while (acl != null);
return false;
}
void targetCheck(T obj) { void targetCheck(T obj) {
if (!tclass.isInstance(obj)) if (!tclass.isInstance(obj))
throw new ClassCastException(); throw new ClassCastException();
...@@ -281,7 +315,7 @@ public abstract class AtomicReferenceFieldUpdater<T, V> { ...@@ -281,7 +315,7 @@ public abstract class AtomicReferenceFieldUpdater<T, V> {
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public V get(T obj) { public V get(T obj) {
if (obj == null || obj.getClass() != tclass || cclass != null) if (obj == null || obj.getClass() != tclass || cclass != null)
targetCheck(obj); targetCheck(obj);
return (V)unsafe.getObjectVolatile(obj, offset); return (V)unsafe.getObjectVolatile(obj, offset);
...@@ -292,14 +326,14 @@ public abstract class AtomicReferenceFieldUpdater<T, V> { ...@@ -292,14 +326,14 @@ public abstract class AtomicReferenceFieldUpdater<T, V> {
return; return;
} }
throw new RuntimeException( throw new RuntimeException(
new IllegalAccessException("Class " + new IllegalAccessException("Class " +
cclass.getName() + cclass.getName() +
" can not access a protected member of class " + " can not access a protected member of class " +
tclass.getName() + tclass.getName() +
" using an instance of " + " using an instance of " +
obj.getClass().getName() obj.getClass().getName()
) )
); );
} }
} }
} }
...@@ -305,8 +305,10 @@ public abstract class AbstractPreferences extends Preferences { ...@@ -305,8 +305,10 @@ public abstract class AbstractPreferences extends Preferences {
* @param key key whose mapping is to be removed from the preference node. * @param key key whose mapping is to be removed from the preference node.
* @throws IllegalStateException if this node (or an ancestor) has been * @throws IllegalStateException if this node (or an ancestor) has been
* removed with the {@link #removeNode()} method. * removed with the {@link #removeNode()} method.
* @throws NullPointerException {@inheritDoc}.
*/ */
public void remove(String key) { public void remove(String key) {
Objects.requireNonNull(key, "Specified key cannot be null");
synchronized(lock) { synchronized(lock) {
if (removed) if (removed)
throw new IllegalStateException("Node has been removed."); throw new IllegalStateException("Node has been removed.");
......
...@@ -152,15 +152,24 @@ import java.util.Arrays; ...@@ -152,15 +152,24 @@ import java.util.Arrays;
* <td headers="matches">A digit: <tt>[0-9]</tt></td></tr> * <td headers="matches">A digit: <tt>[0-9]</tt></td></tr>
* <tr><td valign="top" headers="construct predef"><tt>\D</tt></td> * <tr><td valign="top" headers="construct predef"><tt>\D</tt></td>
* <td headers="matches">A non-digit: <tt>[^0-9]</tt></td></tr> * <td headers="matches">A non-digit: <tt>[^0-9]</tt></td></tr>
* <tr><td valign="top" headers="construct predef"><tt>\h</tt></td>
* <td headers="matches">A horizontal whitespace character:
* <tt>[ \t\xA0&#92;u1680&#92;u180e&#92;u2000-&#92;u200a&#92;u202f&#92;u205f&#92;u3000]</tt></td></tr>
* <tr><td valign="top" headers="construct predef"><tt>\H</tt></td>
* <td headers="matches">A non-horizontal whitespace character: <tt>[^\h]</tt></td></tr>
* <tr><td valign="top" headers="construct predef"><tt>\s</tt></td> * <tr><td valign="top" headers="construct predef"><tt>\s</tt></td>
* <td headers="matches">A whitespace character: <tt>[ \t\n\x0B\f\r]</tt></td></tr> * <td headers="matches">A whitespace character: <tt>[ \t\n\x0B\f\r]</tt></td></tr>
* <tr><td valign="top" headers="construct predef"><tt>\S</tt></td> * <tr><td valign="top" headers="construct predef"><tt>\S</tt></td>
* <td headers="matches">A non-whitespace character: <tt>[^\s]</tt></td></tr> * <td headers="matches">A non-whitespace character: <tt>[^\s]</tt></td></tr>
* <tr><td valign="top" headers="construct predef"><tt>\v</tt></td>
* <td headers="matches">A vertical whitespace character: <tt>[\n\x0B\f\r\x85&#92;u2028&#92;u2029]</tt>
* </td></tr>
* <tr><td valign="top" headers="construct predef"><tt>\V</tt></td>
* <td headers="matches">A non-vertical whitespace character: <tt>[^\v]</tt></td></tr>
* <tr><td valign="top" headers="construct predef"><tt>\w</tt></td> * <tr><td valign="top" headers="construct predef"><tt>\w</tt></td>
* <td headers="matches">A word character: <tt>[a-zA-Z_0-9]</tt></td></tr> * <td headers="matches">A word character: <tt>[a-zA-Z_0-9]</tt></td></tr>
* <tr><td valign="top" headers="construct predef"><tt>\W</tt></td> * <tr><td valign="top" headers="construct predef"><tt>\W</tt></td>
* <td headers="matches">A non-word character: <tt>[^\w]</tt></td></tr> * <td headers="matches">A non-word character: <tt>[^\w]</tt></td></tr>
*
* <tr><th>&nbsp;</th></tr> * <tr><th>&nbsp;</th></tr>
* <tr align="left"><th colspan="2" id="posix">POSIX character classes</b> (US-ASCII only)<b></th></tr> * <tr align="left"><th colspan="2" id="posix">POSIX character classes</b> (US-ASCII only)<b></th></tr>
* *
...@@ -244,6 +253,13 @@ import java.util.Arrays; ...@@ -244,6 +253,13 @@ import java.util.Arrays;
* <td headers="matches">The end of the input</td></tr> * <td headers="matches">The end of the input</td></tr>
* *
* <tr><th>&nbsp;</th></tr> * <tr><th>&nbsp;</th></tr>
* <tr align="left"><th colspan="2" id="lineending">Linebreak matcher</th></tr>
* <tr><td valign="top" headers="construct lineending"><tt>\R</tt></td>
* <td headers="matches">Any Unicode linebreak sequence, is equivalent to
* <tt>&#92;u000D&#92;u000A|[&#92;u000A&#92;u000B&#92;u000C&#92;u000D&#92;u0085&#92;u2028&#92;u2029]
* </tt></td></tr>
*
* <tr><th>&nbsp;</th></tr>
* <tr align="left"><th colspan="2" id="greedy">Greedy quantifiers</th></tr> * <tr align="left"><th colspan="2" id="greedy">Greedy quantifiers</th></tr>
* *
* <tr><td valign="top" headers="construct greedy"><i>X</i><tt>?</tt></td> * <tr><td valign="top" headers="construct greedy"><i>X</i><tt>?</tt></td>
...@@ -599,11 +615,9 @@ import java.util.Arrays; ...@@ -599,11 +615,9 @@ import java.util.Arrays;
* <li> Noncharacter_Code_Point * <li> Noncharacter_Code_Point
* <li> Assigned * <li> Assigned
* </ul> * </ul>
* <p> * <p>
* <b>Predefined Character classes</b> and <b>POSIX character classes</b> are in * The following <b>Predefined Character classes</b> and <b>POSIX character classes</b>
* conformance with the recommendation of <i>Annex C: Compatibility Properties</i> * are in conformance with the recommendation of <i>Annex C: Compatibility Properties</i>
* of <a href="http://www.unicode.org/reports/tr18/"><i>Unicode Regular Expression * of <a href="http://www.unicode.org/reports/tr18/"><i>Unicode Regular Expression
* </i></a>, when {@link #UNICODE_CHARACTER_CLASS} flag is specified. * </i></a>, when {@link #UNICODE_CHARACTER_CLASS} flag is specified.
* <p> * <p>
...@@ -668,12 +682,6 @@ import java.util.Arrays; ...@@ -668,12 +682,6 @@ import java.util.Arrays;
* *
* <ul> * <ul>
* <li><p> Predefined character classes (Unicode character) * <li><p> Predefined character classes (Unicode character)
* <p><tt>\h&nbsp;&nbsp;&nbsp;&nbsp;</tt>A horizontal whitespace
* <p><tt>\H&nbsp;&nbsp;&nbsp;&nbsp;</tt>A non horizontal whitespace
* <p><tt>\v&nbsp;&nbsp;&nbsp;&nbsp;</tt>A vertical whitespace
* <p><tt>\V&nbsp;&nbsp;&nbsp;&nbsp;</tt>A non vertical whitespace
* <p><tt>\R&nbsp;&nbsp;&nbsp;&nbsp;</tt>Any Unicode linebreak sequence
* <tt>\u005cu000D\u005cu000A|[\u005cu000A\u005cu000B\u005cu000C\u005cu000D\u005cu0085\u005cu2028\u005cu2029]</tt>
* <p><tt>\X&nbsp;&nbsp;&nbsp;&nbsp;</tt>Match Unicode * <p><tt>\X&nbsp;&nbsp;&nbsp;&nbsp;</tt>Match Unicode
* <a href="http://www.unicode.org/reports/tr18/#Default_Grapheme_Clusters"> * <a href="http://www.unicode.org/reports/tr18/#Default_Grapheme_Clusters">
* <i>extended grapheme cluster</i></a> * <i>extended grapheme cluster</i></a>
...@@ -2178,7 +2186,7 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) { ...@@ -2178,7 +2186,7 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
} }
unread(); unread();
prev = cursor; prev = cursor;
ch = escape(false, first == 0); ch = escape(false, first == 0, false);
if (ch >= 0) { if (ch >= 0) {
append(ch, first); append(ch, first);
first++; first++;
...@@ -2276,7 +2284,7 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) { ...@@ -2276,7 +2284,7 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
* If the returned value is greater than zero, it is the value that * If the returned value is greater than zero, it is the value that
* matches the escape sequence. * matches the escape sequence.
*/ */
private int escape(boolean inclass, boolean create) { private int escape(boolean inclass, boolean create, boolean isrange) {
int ch = skip(); int ch = skip();
switch (ch) { switch (ch) {
case '0': case '0':
...@@ -2318,6 +2326,8 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) { ...@@ -2318,6 +2326,8 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
if (create) root = new LastMatch(); if (create) root = new LastMatch();
return -1; return -1;
case 'H': case 'H':
if (create) root = new HorizWS().complement();
return -1;
case 'I': case 'I':
case 'J': case 'J':
case 'K': case 'K':
...@@ -2327,8 +2337,11 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) { ...@@ -2327,8 +2337,11 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
case 'O': case 'O':
case 'P': case 'P':
case 'Q': case 'Q':
case 'R':
break; break;
case 'R':
if (inclass) break;
if (create) root = new LineEnding();
return -1;
case 'S': case 'S':
if (create) root = has(UNICODE_CHARACTER_CLASS) if (create) root = has(UNICODE_CHARACTER_CLASS)
? new Utype(UnicodeProp.WHITE_SPACE).complement() ? new Utype(UnicodeProp.WHITE_SPACE).complement()
...@@ -2336,8 +2349,10 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) { ...@@ -2336,8 +2349,10 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
return -1; return -1;
case 'T': case 'T':
case 'U': case 'U':
case 'V':
break; break;
case 'V':
if (create) root = new VertWS().complement();
return -1;
case 'W': case 'W':
if (create) root = has(UNICODE_CHARACTER_CLASS) if (create) root = has(UNICODE_CHARACTER_CLASS)
? new Utype(UnicodeProp.WORD).complement() ? new Utype(UnicodeProp.WORD).complement()
...@@ -2373,7 +2388,10 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) { ...@@ -2373,7 +2388,10 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
case 'f': case 'f':
return '\f'; return '\f';
case 'g': case 'g':
break;
case 'h': case 'h':
if (create) root = new HorizWS();
return -1;
case 'i': case 'i':
case 'j': case 'j':
break; break;
...@@ -2413,7 +2431,18 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) { ...@@ -2413,7 +2431,18 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
case 'u': case 'u':
return u(); return u();
case 'v': case 'v':
return '\013'; // '\v' was implemented as VT/0x0B in releases < 1.8 (though
// undocumented). In JDK8 '\v' is specified as a predefined
// character class for all vertical whitespace characters.
// So [-1, root=VertWS node] pair is returned (instead of a
// single 0x0B). This breaks the range if '\v' is used as
// the start or end value, such as [\v-...] or [...-\v], in
// which a single definite value (0x0B) is expected. For
// compatiblity concern '\013'/0x0B is returned if isrange.
if (isrange)
return '\013';
if (create) root = new VertWS();
return -1;
case 'w': case 'w':
if (create) root = has(UNICODE_CHARACTER_CLASS) if (create) root = has(UNICODE_CHARACTER_CLASS)
? new Utype(UnicodeProp.WORD) ? new Utype(UnicodeProp.WORD)
...@@ -2590,13 +2619,14 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) { ...@@ -2590,13 +2619,14 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
oneLetter = false; oneLetter = false;
return family(oneLetter, comp); return family(oneLetter, comp);
} else { // ordinary escape } else { // ordinary escape
boolean isrange = temp[cursor+1] == '-';
unread(); unread();
ch = escape(true, true); ch = escape(true, true, isrange);
if (ch == -1) if (ch == -1)
return (CharProperty) root; return (CharProperty) root;
} }
} else { } else {
ch = single(); next();
} }
if (ch >= 0) { if (ch >= 0) {
if (peek() == '-') { if (peek() == '-') {
...@@ -2606,9 +2636,15 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) { ...@@ -2606,9 +2636,15 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
} }
if (endRange != ']') { if (endRange != ']') {
next(); next();
int m = single(); int m = peek();
if (m < ch) if (m == '\\') {
m = escape(true, false, true);
} else {
next();
}
if (m < ch) {
throw error("Illegal character range"); throw error("Illegal character range");
}
if (has(CASE_INSENSITIVE)) if (has(CASE_INSENSITIVE))
return caseInsensitiveRangeFor(ch, m); return caseInsensitiveRangeFor(ch, m);
else else
...@@ -2620,17 +2656,6 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) { ...@@ -2620,17 +2656,6 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
throw error("Unexpected character '"+((char)ch)+"'"); throw error("Unexpected character '"+((char)ch)+"'");
} }
private int single() {
int ch = peek();
switch (ch) {
case '\\':
return escape(true, false);
default:
next();
return ch;
}
}
/** /**
* Parses a Unicode character family and returns its representative node. * Parses a Unicode character family and returns its representative node.
*/ */
...@@ -3694,6 +3719,35 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) { ...@@ -3694,6 +3719,35 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
} }
} }
/**
* Node class that matches a Unicode line ending '\R'
*/
static final class LineEnding extends Node {
boolean match(Matcher matcher, int i, CharSequence seq) {
// (u+000Du+000A|[u+000Au+000Bu+000Cu+000Du+0085u+2028u+2029])
if (i < matcher.to) {
int ch = seq.charAt(i);
if (ch == 0x0A || ch == 0x0B || ch == 0x0C ||
ch == 0x85 || ch == 0x2028 || ch == 0x2029)
return next.match(matcher, i + 1, seq);
if (ch == 0x0D) {
i++;
if (i < matcher.to && seq.charAt(i) == 0x0A)
i++;
return next.match(matcher, i, seq);
}
} else {
matcher.hitEnd = true;
}
return false;
}
boolean study(TreeInfo info) {
info.minLength++;
info.maxLength += 2;
return next.study(info);
}
}
/** /**
* Abstract node class to match one character satisfying some * Abstract node class to match one character satisfying some
* boolean property. * boolean property.
...@@ -3789,7 +3843,6 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) { ...@@ -3789,7 +3843,6 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
} }
} }
/** /**
* Node class that matches a Unicode block. * Node class that matches a Unicode block.
*/ */
...@@ -3838,7 +3891,6 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) { ...@@ -3838,7 +3891,6 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
} }
} }
/** /**
* Node class that matches a POSIX type. * Node class that matches a POSIX type.
*/ */
...@@ -3850,6 +3902,28 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) { ...@@ -3850,6 +3902,28 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
} }
} }
/**
* Node class that matches a Perl vertical whitespace
*/
static final class VertWS extends BmpCharProperty {
boolean isSatisfiedBy(int cp) {
return (cp >= 0x0A && cp <= 0x0D) ||
cp == 0x85 || cp == 0x2028 || cp == 0x2029;
}
}
/**
* Node class that matches a Perl horizontal whitespace
*/
static final class HorizWS extends BmpCharProperty {
boolean isSatisfiedBy(int cp) {
return cp == 0x09 || cp == 0x20 || cp == 0xa0 ||
cp == 0x1680 || cp == 0x180e ||
cp >= 0x2000 && cp <= 0x200a ||
cp == 0x202f || cp == 0x205f || cp == 0x3000;
}
}
/** /**
* Base class for all Slice nodes * Base class for all Slice nodes
*/ */
......
...@@ -168,7 +168,10 @@ public class Agent { ...@@ -168,7 +168,10 @@ public class Agent {
// management properties can be overridden by system properties // management properties can be overridden by system properties
// which take precedence // which take precedence
configProps.putAll(System.getProperties()); Properties sysProps = System.getProperties();
synchronized(sysProps){
configProps.putAll(sysProps);
}
// if user specifies config file into command line for either // if user specifies config file into command line for either
// jcmd utilities or attach command it overrides properties set in // jcmd utilities or attach command it overrides properties set in
...@@ -264,7 +267,10 @@ public class Agent { ...@@ -264,7 +267,10 @@ public class Agent {
// management properties can be overridden by system properties // management properties can be overridden by system properties
// which take precedence // which take precedence
props.putAll(System.getProperties()); Properties sysProps = System.getProperties();
synchronized(sysProps){
props.putAll(sysProps);
}
return props; return props;
} }
......
...@@ -629,17 +629,6 @@ class SocketChannelImpl ...@@ -629,17 +629,6 @@ class SocketChannelImpl
break; break;
} }
synchronized (stateLock) {
if (isOpen() && (localAddress == null) ||
((InetSocketAddress)localAddress)
.getAddress().isAnyLocalAddress())
{
// Socket was not bound before connecting or
// Socket was bound with an "anyLocalAddress"
localAddress = Net.localAddress(fd);
}
}
} finally { } finally {
readerCleanup(); readerCleanup();
end((n > 0) || (n == IOStatus.UNAVAILABLE)); end((n > 0) || (n == IOStatus.UNAVAILABLE));
...@@ -659,6 +648,8 @@ class SocketChannelImpl ...@@ -659,6 +648,8 @@ class SocketChannelImpl
// Connection succeeded; disallow further // Connection succeeded; disallow further
// invocation // invocation
state = ST_CONNECTED; state = ST_CONNECTED;
if (isOpen())
localAddress = Net.localAddress(fd);
return true; return true;
} }
// If nonblocking and no exception then connection // If nonblocking and no exception then connection
...@@ -747,6 +738,8 @@ class SocketChannelImpl ...@@ -747,6 +738,8 @@ class SocketChannelImpl
if (n > 0) { if (n > 0) {
synchronized (stateLock) { synchronized (stateLock) {
state = ST_CONNECTED; state = ST_CONNECTED;
if (isOpen())
localAddress = Net.localAddress(fd);
} }
return true; return true;
} }
......
/* /*
* Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -41,6 +41,7 @@ import sun.security.util.*; ...@@ -41,6 +41,7 @@ import sun.security.util.*;
* *
* . "NONEwithECDSA" * . "NONEwithECDSA"
* . "SHA1withECDSA" * . "SHA1withECDSA"
* . "SHA224withECDSA"
* . "SHA256withECDSA" * . "SHA256withECDSA"
* . "SHA384withECDSA" * . "SHA384withECDSA"
* . "SHA512withECDSA" * . "SHA512withECDSA"
...@@ -162,6 +163,13 @@ abstract class ECDSASignature extends SignatureSpi { ...@@ -162,6 +163,13 @@ abstract class ECDSASignature extends SignatureSpi {
} }
} }
// Nested class for SHA224withECDSA signatures
public static final class SHA224 extends ECDSASignature {
public SHA224() {
super("SHA-224");
}
}
// Nested class for SHA256withECDSA signatures // Nested class for SHA256withECDSA signatures
public static final class SHA256 extends ECDSASignature { public static final class SHA256 extends ECDSASignature {
public SHA256() { public SHA256() {
......
/* /*
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -133,17 +133,31 @@ final class SunECEntries { ...@@ -133,17 +133,31 @@ final class SunECEntries {
"sun.security.ec.ECDSASignature$Raw"); "sun.security.ec.ECDSASignature$Raw");
map.put("Signature.SHA1withECDSA", map.put("Signature.SHA1withECDSA",
"sun.security.ec.ECDSASignature$SHA1"); "sun.security.ec.ECDSASignature$SHA1");
map.put("Signature.SHA224withECDSA",
"sun.security.ec.ECDSASignature$SHA224");
map.put("Alg.Alias.Signature.OID.1.2.840.10045.4.3.1", "SHA224withECDSA");
map.put("Alg.Alias.Signature.1.2.840.10045.4.3.1", "SHA224withECDSA");
map.put("Signature.SHA256withECDSA", map.put("Signature.SHA256withECDSA",
"sun.security.ec.ECDSASignature$SHA256"); "sun.security.ec.ECDSASignature$SHA256");
map.put("Alg.Alias.Signature.OID.1.2.840.10045.4.3.2", "SHA256withECDSA");
map.put("Alg.Alias.Signature.1.2.840.10045.4.3.2", "SHA256withECDSA");
map.put("Signature.SHA384withECDSA", map.put("Signature.SHA384withECDSA",
"sun.security.ec.ECDSASignature$SHA384"); "sun.security.ec.ECDSASignature$SHA384");
map.put("Alg.Alias.Signature.OID.1.2.840.10045.4.3.3", "SHA384withECDSA");
map.put("Alg.Alias.Signature.1.2.840.10045.4.3.3", "SHA384withECDSA");
map.put("Signature.SHA512withECDSA", map.put("Signature.SHA512withECDSA",
"sun.security.ec.ECDSASignature$SHA512"); "sun.security.ec.ECDSASignature$SHA512");
map.put("Alg.Alias.Signature.OID.1.2.840.10045.4.3.4", "SHA512withECDSA");
map.put("Alg.Alias.Signature.1.2.840.10045.4.3.4", "SHA512withECDSA");
String ecKeyClasses = "java.security.interfaces.ECPublicKey" + String ecKeyClasses = "java.security.interfaces.ECPublicKey" +
"|java.security.interfaces.ECPrivateKey"; "|java.security.interfaces.ECPrivateKey";
map.put("Signature.NONEwithECDSA SupportedKeyClasses", ecKeyClasses); map.put("Signature.NONEwithECDSA SupportedKeyClasses", ecKeyClasses);
map.put("Signature.SHA1withECDSA SupportedKeyClasses", ecKeyClasses); map.put("Signature.SHA1withECDSA SupportedKeyClasses", ecKeyClasses);
map.put("Signature.SHA224withECDSA SupportedKeyClasses", ecKeyClasses);
map.put("Signature.SHA256withECDSA SupportedKeyClasses", ecKeyClasses); map.put("Signature.SHA256withECDSA SupportedKeyClasses", ecKeyClasses);
map.put("Signature.SHA384withECDSA SupportedKeyClasses", ecKeyClasses); map.put("Signature.SHA384withECDSA SupportedKeyClasses", ecKeyClasses);
map.put("Signature.SHA512withECDSA SupportedKeyClasses", ecKeyClasses); map.put("Signature.SHA512withECDSA SupportedKeyClasses", ecKeyClasses);
...@@ -152,6 +166,7 @@ final class SunECEntries { ...@@ -152,6 +166,7 @@ final class SunECEntries {
map.put("Signature.NONEwithECDSA ImplementedIn", "Software"); map.put("Signature.NONEwithECDSA ImplementedIn", "Software");
map.put("Signature.SHA1withECDSA ImplementedIn", "Software"); map.put("Signature.SHA1withECDSA ImplementedIn", "Software");
map.put("Signature.SHA224withECDSA ImplementedIn", "Software");
map.put("Signature.SHA256withECDSA ImplementedIn", "Software"); map.put("Signature.SHA256withECDSA ImplementedIn", "Software");
map.put("Signature.SHA384withECDSA ImplementedIn", "Software"); map.put("Signature.SHA384withECDSA ImplementedIn", "Software");
map.put("Signature.SHA512withECDSA ImplementedIn", "Software"); map.put("Signature.SHA512withECDSA ImplementedIn", "Software");
......
...@@ -39,7 +39,7 @@ import static sun.security.pkcs11.wrapper.PKCS11Constants.*; ...@@ -39,7 +39,7 @@ import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
/** /**
* MessageDigest implementation class. This class currently supports * MessageDigest implementation class. This class currently supports
* MD2, MD5, SHA-1, SHA-256, SHA-384, and SHA-512. * MD2, MD5, SHA-1, SHA-224, SHA-256, SHA-384, and SHA-512.
* *
* Note that many digest operations are on fairly small amounts of data * Note that many digest operations are on fairly small amounts of data
* (less than 100 bytes total). For example, the 2nd hashing in HMAC or * (less than 100 bytes total). For example, the 2nd hashing in HMAC or
...@@ -99,6 +99,9 @@ final class P11Digest extends MessageDigestSpi implements Cloneable { ...@@ -99,6 +99,9 @@ final class P11Digest extends MessageDigestSpi implements Cloneable {
case (int)CKM_SHA_1: case (int)CKM_SHA_1:
digestLength = 20; digestLength = 20;
break; break;
case (int)CKM_SHA224:
digestLength = 28;
break;
case (int)CKM_SHA256: case (int)CKM_SHA256:
digestLength = 32; digestLength = 32;
break; break;
......
/* /*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -40,8 +40,8 @@ import static sun.security.pkcs11.wrapper.PKCS11Constants.*; ...@@ -40,8 +40,8 @@ import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
/** /**
* MAC implementation class. This class currently supports HMAC using * MAC implementation class. This class currently supports HMAC using
* MD5, SHA-1, SHA-256, SHA-384, and SHA-512 and the SSL3 MAC using MD5 * MD5, SHA-1, SHA-224, SHA-256, SHA-384, and SHA-512 and the SSL3 MAC
* and SHA-1. * using MD5 and SHA-1.
* *
* Note that unlike other classes (e.g. Signature), this does not * Note that unlike other classes (e.g. Signature), this does not
* composite various operations if the token only supports part of the * composite various operations if the token only supports part of the
...@@ -107,6 +107,9 @@ final class P11Mac extends MacSpi { ...@@ -107,6 +107,9 @@ final class P11Mac extends MacSpi {
case (int)CKM_SHA_1_HMAC: case (int)CKM_SHA_1_HMAC:
macLength = 20; macLength = 20;
break; break;
case (int)CKM_SHA224_HMAC:
macLength = 28;
break;
case (int)CKM_SHA256_HMAC: case (int)CKM_SHA256_HMAC:
macLength = 32; macLength = 32;
break; break;
......
...@@ -53,12 +53,14 @@ import static sun.security.pkcs11.wrapper.PKCS11Constants.*; ...@@ -53,12 +53,14 @@ import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
* . MD2withRSA * . MD2withRSA
* . MD5withRSA * . MD5withRSA
* . SHA1withRSA * . SHA1withRSA
* . SHA224withRSA
* . SHA256withRSA * . SHA256withRSA
* . SHA384withRSA * . SHA384withRSA
* . SHA512withRSA * . SHA512withRSA
* . ECDSA * . ECDSA
* . NONEwithECDSA * . NONEwithECDSA
* . SHA1withECDSA * . SHA1withECDSA
* . SHA224withECDSA
* . SHA256withECDSA * . SHA256withECDSA
* . SHA384withECDSA * . SHA384withECDSA
* . SHA512withECDSA * . SHA512withECDSA
...@@ -143,6 +145,7 @@ final class P11Signature extends SignatureSpi { ...@@ -143,6 +145,7 @@ final class P11Signature extends SignatureSpi {
case (int)CKM_MD2_RSA_PKCS: case (int)CKM_MD2_RSA_PKCS:
case (int)CKM_MD5_RSA_PKCS: case (int)CKM_MD5_RSA_PKCS:
case (int)CKM_SHA1_RSA_PKCS: case (int)CKM_SHA1_RSA_PKCS:
case (int)CKM_SHA224_RSA_PKCS:
case (int)CKM_SHA256_RSA_PKCS: case (int)CKM_SHA256_RSA_PKCS:
case (int)CKM_SHA384_RSA_PKCS: case (int)CKM_SHA384_RSA_PKCS:
case (int)CKM_SHA512_RSA_PKCS: case (int)CKM_SHA512_RSA_PKCS:
...@@ -181,6 +184,8 @@ final class P11Signature extends SignatureSpi { ...@@ -181,6 +184,8 @@ final class P11Signature extends SignatureSpi {
String digestAlg; String digestAlg;
if (algorithm.equals("SHA1withECDSA")) { if (algorithm.equals("SHA1withECDSA")) {
digestAlg = "SHA-1"; digestAlg = "SHA-1";
} else if (algorithm.equals("SHA224withECDSA")) {
digestAlg = "SHA-224";
} else if (algorithm.equals("SHA256withECDSA")) { } else if (algorithm.equals("SHA256withECDSA")) {
digestAlg = "SHA-256"; digestAlg = "SHA-256";
} else if (algorithm.equals("SHA384withECDSA")) { } else if (algorithm.equals("SHA384withECDSA")) {
...@@ -207,6 +212,9 @@ final class P11Signature extends SignatureSpi { ...@@ -207,6 +212,9 @@ final class P11Signature extends SignatureSpi {
} else if (algorithm.equals("MD2withRSA")) { } else if (algorithm.equals("MD2withRSA")) {
md = MessageDigest.getInstance("MD2"); md = MessageDigest.getInstance("MD2");
digestOID = AlgorithmId.MD2_oid; digestOID = AlgorithmId.MD2_oid;
} else if (algorithm.equals("SHA224withRSA")) {
md = MessageDigest.getInstance("SHA-224");
digestOID = AlgorithmId.SHA224_oid;
} else if (algorithm.equals("SHA256withRSA")) { } else if (algorithm.equals("SHA256withRSA")) {
md = MessageDigest.getInstance("SHA-256"); md = MessageDigest.getInstance("SHA-256");
digestOID = AlgorithmId.SHA256_oid; digestOID = AlgorithmId.SHA256_oid;
...@@ -332,6 +340,8 @@ final class P11Signature extends SignatureSpi { ...@@ -332,6 +340,8 @@ final class P11Signature extends SignatureSpi {
encodedLength = 34; encodedLength = 34;
} else if (algorithm.equals("SHA1withRSA")) { } else if (algorithm.equals("SHA1withRSA")) {
encodedLength = 35; encodedLength = 35;
} else if (algorithm.equals("SHA224withRSA")) {
encodedLength = 47;
} else if (algorithm.equals("SHA256withRSA")) { } else if (algorithm.equals("SHA256withRSA")) {
encodedLength = 51; encodedLength = 51;
} else if (algorithm.equals("SHA384withRSA")) { } else if (algorithm.equals("SHA384withRSA")) {
......
...@@ -342,6 +342,7 @@ public final class SunPKCS11 extends AuthProvider { ...@@ -342,6 +342,7 @@ public final class SunPKCS11 extends AuthProvider {
System.out.println("Library info:"); System.out.println("Library info:");
System.out.println(p11Info); System.out.println(p11Info);
} }
if ((slotID < 0) || showInfo) { if ((slotID < 0) || showInfo) {
long[] slots = p11.C_GetSlotList(false); long[] slots = p11.C_GetSlotList(false);
if (showInfo) { if (showInfo) {
...@@ -520,24 +521,37 @@ public final class SunPKCS11 extends AuthProvider { ...@@ -520,24 +521,37 @@ public final class SunPKCS11 extends AuthProvider {
m(CKM_MD2)); m(CKM_MD2));
d(MD, "MD5", P11Digest, d(MD, "MD5", P11Digest,
m(CKM_MD5)); m(CKM_MD5));
d(MD, "SHA1", P11Digest, s("SHA", "SHA-1"), d(MD, "SHA1", P11Digest, s("SHA", "SHA-1"),
m(CKM_SHA_1)); m(CKM_SHA_1));
d(MD, "SHA-224", P11Digest,
s("2.16.840.1.101.3.4.2.4", "OID.2.16.840.1.101.3.4.2.4"),
m(CKM_SHA224));
d(MD, "SHA-256", P11Digest, d(MD, "SHA-256", P11Digest,
s("2.16.840.1.101.3.4.2.1", "OID.2.16.840.1.101.3.4.2.1"),
m(CKM_SHA256)); m(CKM_SHA256));
d(MD, "SHA-384", P11Digest, d(MD, "SHA-384", P11Digest,
s("2.16.840.1.101.3.4.2.2", "OID.2.16.840.1.101.3.4.2.2"),
m(CKM_SHA384)); m(CKM_SHA384));
d(MD, "SHA-512", P11Digest, d(MD, "SHA-512", P11Digest,
s("2.16.840.1.101.3.4.2.3", "OID.2.16.840.1.101.3.4.2.3"),
m(CKM_SHA512)); m(CKM_SHA512));
d(MAC, "HmacMD5", P11MAC, d(MAC, "HmacMD5", P11MAC,
m(CKM_MD5_HMAC)); m(CKM_MD5_HMAC));
d(MAC, "HmacSHA1", P11MAC, d(MAC, "HmacSHA1", P11MAC,
m(CKM_SHA_1_HMAC)); m(CKM_SHA_1_HMAC));
d(MAC, "HmacSHA224", P11MAC,
s("1.2.840.113549.2.8", "OID.1.2.840.113549.2.8"),
m(CKM_SHA224_HMAC));
d(MAC, "HmacSHA256", P11MAC, d(MAC, "HmacSHA256", P11MAC,
s("1.2.840.113549.2.9", "OID.1.2.840.113549.2.9"),
m(CKM_SHA256_HMAC)); m(CKM_SHA256_HMAC));
d(MAC, "HmacSHA384", P11MAC, d(MAC, "HmacSHA384", P11MAC,
s("1.2.840.113549.2.10", "OID.1.2.840.113549.2.10"),
m(CKM_SHA384_HMAC)); m(CKM_SHA384_HMAC));
d(MAC, "HmacSHA512", P11MAC, d(MAC, "HmacSHA512", P11MAC,
s("1.2.840.113549.2.11", "OID.1.2.840.113549.2.11"),
m(CKM_SHA512_HMAC)); m(CKM_SHA512_HMAC));
d(MAC, "SslMacMD5", P11MAC, d(MAC, "SslMacMD5", P11MAC,
m(CKM_SSL3_MD5_MAC)); m(CKM_SSL3_MD5_MAC));
...@@ -648,11 +662,17 @@ public final class SunPKCS11 extends AuthProvider { ...@@ -648,11 +662,17 @@ public final class SunPKCS11 extends AuthProvider {
m(CKM_ECDSA)); m(CKM_ECDSA));
d(SIG, "SHA1withECDSA", P11Signature, s("ECDSA"), d(SIG, "SHA1withECDSA", P11Signature, s("ECDSA"),
m(CKM_ECDSA_SHA1, CKM_ECDSA)); m(CKM_ECDSA_SHA1, CKM_ECDSA));
d(SIG, "SHA224withECDSA", P11Signature,
s("1.2.840.10045.4.3.1", "OID.1.2.840.10045.4.3.1"),
m(CKM_ECDSA));
d(SIG, "SHA256withECDSA", P11Signature, d(SIG, "SHA256withECDSA", P11Signature,
s("1.2.840.10045.4.3.2", "OID.1.2.840.10045.4.3.2"),
m(CKM_ECDSA)); m(CKM_ECDSA));
d(SIG, "SHA384withECDSA", P11Signature, d(SIG, "SHA384withECDSA", P11Signature,
s("1.2.840.10045.4.3.3", "OID.1.2.840.10045.4.3.3"),
m(CKM_ECDSA)); m(CKM_ECDSA));
d(SIG, "SHA512withECDSA", P11Signature, d(SIG, "SHA512withECDSA", P11Signature,
s("1.2.840.10045.4.3.4", "OID.1.2.840.10045.4.3.4"),
m(CKM_ECDSA)); m(CKM_ECDSA));
d(SIG, "MD2withRSA", P11Signature, d(SIG, "MD2withRSA", P11Signature,
m(CKM_MD2_RSA_PKCS, CKM_RSA_PKCS, CKM_RSA_X_509)); m(CKM_MD2_RSA_PKCS, CKM_RSA_PKCS, CKM_RSA_X_509));
...@@ -660,11 +680,17 @@ public final class SunPKCS11 extends AuthProvider { ...@@ -660,11 +680,17 @@ public final class SunPKCS11 extends AuthProvider {
m(CKM_MD5_RSA_PKCS, CKM_RSA_PKCS, CKM_RSA_X_509)); m(CKM_MD5_RSA_PKCS, CKM_RSA_PKCS, CKM_RSA_X_509));
d(SIG, "SHA1withRSA", P11Signature, d(SIG, "SHA1withRSA", P11Signature,
m(CKM_SHA1_RSA_PKCS, CKM_RSA_PKCS, CKM_RSA_X_509)); m(CKM_SHA1_RSA_PKCS, CKM_RSA_PKCS, CKM_RSA_X_509));
d(SIG, "SHA224withRSA", P11Signature,
s("1.2.840.113549.1.1.14", "OID.1.2.840.113549.1.1.14"),
m(CKM_SHA224_RSA_PKCS, CKM_RSA_PKCS, CKM_RSA_X_509));
d(SIG, "SHA256withRSA", P11Signature, d(SIG, "SHA256withRSA", P11Signature,
s("1.2.840.113549.1.1.11", "OID.1.2.840.113549.1.1.11"),
m(CKM_SHA256_RSA_PKCS, CKM_RSA_PKCS, CKM_RSA_X_509)); m(CKM_SHA256_RSA_PKCS, CKM_RSA_PKCS, CKM_RSA_X_509));
d(SIG, "SHA384withRSA", P11Signature, d(SIG, "SHA384withRSA", P11Signature,
s("1.2.840.113549.1.1.12", "OID.1.2.840.113549.1.1.12"),
m(CKM_SHA384_RSA_PKCS, CKM_RSA_PKCS, CKM_RSA_X_509)); m(CKM_SHA384_RSA_PKCS, CKM_RSA_PKCS, CKM_RSA_X_509));
d(SIG, "SHA512withRSA", P11Signature, d(SIG, "SHA512withRSA", P11Signature,
s("1.2.840.113549.1.1.13", "OID.1.2.840.113549.1.1.13"),
m(CKM_SHA512_RSA_PKCS, CKM_RSA_PKCS, CKM_RSA_X_509)); m(CKM_SHA512_RSA_PKCS, CKM_RSA_PKCS, CKM_RSA_X_509));
/* /*
......
/* /*
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
*/ */
/* Copyright (c) 2002 Graz University of Technology. All rights reserved. /* Copyright (c) 2002 Graz University of Technology. All rights reserved.
...@@ -630,6 +630,7 @@ public class Functions { ...@@ -630,6 +630,7 @@ public class Functions {
addMech(CKM_X9_42_DH_DERIVE, "CKM_X9_42_DH_DERIVE"); addMech(CKM_X9_42_DH_DERIVE, "CKM_X9_42_DH_DERIVE");
addMech(CKM_X9_42_DH_HYBRID_DERIVE, "CKM_X9_42_DH_HYBRID_DERIVE"); addMech(CKM_X9_42_DH_HYBRID_DERIVE, "CKM_X9_42_DH_HYBRID_DERIVE");
addMech(CKM_X9_42_MQV_DERIVE, "CKM_X9_42_MQV_DERIVE"); addMech(CKM_X9_42_MQV_DERIVE, "CKM_X9_42_MQV_DERIVE");
addMech(CKM_SHA224_RSA_PKCS, "CKM_SHA224_RSA_PKCS");
addMech(CKM_SHA256_RSA_PKCS, "CKM_SHA256_RSA_PKCS"); addMech(CKM_SHA256_RSA_PKCS, "CKM_SHA256_RSA_PKCS");
addMech(CKM_SHA384_RSA_PKCS, "CKM_SHA384_RSA_PKCS"); addMech(CKM_SHA384_RSA_PKCS, "CKM_SHA384_RSA_PKCS");
addMech(CKM_SHA512_RSA_PKCS, "CKM_SHA512_RSA_PKCS"); addMech(CKM_SHA512_RSA_PKCS, "CKM_SHA512_RSA_PKCS");
...@@ -675,6 +676,9 @@ public class Functions { ...@@ -675,6 +676,9 @@ public class Functions {
addMech(CKM_RIPEMD160, "CKM_RIPEMD160"); addMech(CKM_RIPEMD160, "CKM_RIPEMD160");
addMech(CKM_RIPEMD160_HMAC, "CKM_RIPEMD160_HMAC"); addMech(CKM_RIPEMD160_HMAC, "CKM_RIPEMD160_HMAC");
addMech(CKM_RIPEMD160_HMAC_GENERAL, "CKM_RIPEMD160_HMAC_GENERAL"); addMech(CKM_RIPEMD160_HMAC_GENERAL, "CKM_RIPEMD160_HMAC_GENERAL");
addMech(CKM_SHA224, "CKM_SHA224");
addMech(CKM_SHA224_HMAC, "CKM_SHA224_HMAC");
addMech(CKM_SHA224_HMAC_GENERAL, "CKM_SHA224_HMAC_GENERAL");
addMech(CKM_SHA256, "CKM_SHA256"); addMech(CKM_SHA256, "CKM_SHA256");
addMech(CKM_SHA256_HMAC, "CKM_SHA256_HMAC"); addMech(CKM_SHA256_HMAC, "CKM_SHA256_HMAC");
addMech(CKM_SHA256_HMAC_GENERAL, "CKM_SHA256_HMAC_GENERAL"); addMech(CKM_SHA256_HMAC_GENERAL, "CKM_SHA256_HMAC_GENERAL");
...@@ -734,6 +738,7 @@ public class Functions { ...@@ -734,6 +738,7 @@ public class Functions {
addMech(CKM_MD5_KEY_DERIVATION, "CKM_MD5_KEY_DERIVATION"); addMech(CKM_MD5_KEY_DERIVATION, "CKM_MD5_KEY_DERIVATION");
addMech(CKM_MD2_KEY_DERIVATION, "CKM_MD2_KEY_DERIVATION"); addMech(CKM_MD2_KEY_DERIVATION, "CKM_MD2_KEY_DERIVATION");
addMech(CKM_SHA1_KEY_DERIVATION, "CKM_SHA1_KEY_DERIVATION"); addMech(CKM_SHA1_KEY_DERIVATION, "CKM_SHA1_KEY_DERIVATION");
addMech(CKM_SHA224_KEY_DERIVATION, "CKM_SHA224_KEY_DERIVATION");
addMech(CKM_SHA256_KEY_DERIVATION, "CKM_SHA256_KEY_DERIVATION"); addMech(CKM_SHA256_KEY_DERIVATION, "CKM_SHA256_KEY_DERIVATION");
addMech(CKM_SHA384_KEY_DERIVATION, "CKM_SHA384_KEY_DERIVATION"); addMech(CKM_SHA384_KEY_DERIVATION, "CKM_SHA384_KEY_DERIVATION");
addMech(CKM_SHA512_KEY_DERIVATION, "CKM_SHA512_KEY_DERIVATION"); addMech(CKM_SHA512_KEY_DERIVATION, "CKM_SHA512_KEY_DERIVATION");
......
...@@ -39,7 +39,6 @@ import java.security.ProviderException; ...@@ -39,7 +39,6 @@ import java.security.ProviderException;
* . abstract void implCompress(byte[] b, int ofs); * . abstract void implCompress(byte[] b, int ofs);
* . abstract void implDigest(byte[] out, int ofs); * . abstract void implDigest(byte[] out, int ofs);
* . abstract void implReset(); * . abstract void implReset();
* . public abstract Object clone();
* *
* See the inline documentation for details. * See the inline documentation for details.
* *
...@@ -61,7 +60,7 @@ abstract class DigestBase extends MessageDigestSpi implements Cloneable { ...@@ -61,7 +60,7 @@ abstract class DigestBase extends MessageDigestSpi implements Cloneable {
// buffer to store partial blocks, blockSize bytes large // buffer to store partial blocks, blockSize bytes large
// Subclasses should not access this array directly except possibly in their // Subclasses should not access this array directly except possibly in their
// implDigest() method. See MD5.java as an example. // implDigest() method. See MD5.java as an example.
final byte[] buffer; byte[] buffer;
// offset into buffer // offset into buffer
private int bufOfs; private int bufOfs;
...@@ -83,18 +82,6 @@ abstract class DigestBase extends MessageDigestSpi implements Cloneable { ...@@ -83,18 +82,6 @@ abstract class DigestBase extends MessageDigestSpi implements Cloneable {
buffer = new byte[blockSize]; buffer = new byte[blockSize];
} }
/**
* Constructor for cloning. Replicates common data.
*/
DigestBase(DigestBase base) {
this.algorithm = base.algorithm;
this.digestLength = base.digestLength;
this.blockSize = base.blockSize;
this.buffer = base.buffer.clone();
this.bufOfs = base.bufOfs;
this.bytesProcessed = base.bytesProcessed;
}
// return digest length. See JCA doc. // return digest length. See JCA doc.
protected final int engineGetDigestLength() { protected final int engineGetDigestLength() {
return digestLength; return digestLength;
...@@ -206,12 +193,11 @@ abstract class DigestBase extends MessageDigestSpi implements Cloneable { ...@@ -206,12 +193,11 @@ abstract class DigestBase extends MessageDigestSpi implements Cloneable {
*/ */
abstract void implReset(); abstract void implReset();
/** public Object clone() throws CloneNotSupportedException {
* Clone this digest. Should be implemented as "return new MyDigest(this)". DigestBase copy = (DigestBase) super.clone();
* That constructor should first call "super(baseDigest)" and then copy copy.buffer = copy.buffer.clone();
* subclass specific data. return copy;
*/ }
public abstract Object clone();
// padding used for the MD5, and SHA-* message digests // padding used for the MD5, and SHA-* message digests
static final byte[] padding; static final byte[] padding;
...@@ -223,5 +209,4 @@ abstract class DigestBase extends MessageDigestSpi implements Cloneable { ...@@ -223,5 +209,4 @@ abstract class DigestBase extends MessageDigestSpi implements Cloneable {
padding = new byte[136]; padding = new byte[136];
padding[0] = (byte)0x80; padding[0] = (byte)0x80;
} }
} }
...@@ -39,14 +39,14 @@ import java.util.Arrays; ...@@ -39,14 +39,14 @@ import java.util.Arrays;
public final class MD2 extends DigestBase { public final class MD2 extends DigestBase {
// state, 48 ints // state, 48 ints
private final int[] X; private int[] X;
// checksum, 16 ints. they are really bytes, but byte arithmetic in // checksum, 16 ints. they are really bytes, but byte arithmetic in
// the JVM is much slower that int arithmetic. // the JVM is much slower that int arithmetic.
private final int[] C; private int[] C;
// temporary store for checksum C during final digest // temporary store for checksum C during final digest
private final byte[] cBytes; private byte[] cBytes;
/** /**
* Create a new MD2 digest. Called by the JCA framework * Create a new MD2 digest. Called by the JCA framework
...@@ -58,15 +58,12 @@ public final class MD2 extends DigestBase { ...@@ -58,15 +58,12 @@ public final class MD2 extends DigestBase {
cBytes = new byte[16]; cBytes = new byte[16];
} }
private MD2(MD2 base) { public Object clone() throws CloneNotSupportedException {
super(base); MD2 copy = (MD2) super.clone();
this.X = base.X.clone(); copy.X = copy.X.clone();
this.C = base.C.clone(); copy.C = copy.C.clone();
cBytes = new byte[16]; copy.cBytes = new byte[16];
} return copy;
public Object clone() {
return new MD2(this);
} }
// reset state and checksum // reset state and checksum
......
...@@ -44,9 +44,9 @@ import static sun.security.provider.ByteArrayAccess.*; ...@@ -44,9 +44,9 @@ import static sun.security.provider.ByteArrayAccess.*;
public final class MD4 extends DigestBase { public final class MD4 extends DigestBase {
// state of this object // state of this object
private final int[] state; private int[] state;
// temporary buffer, used by implCompress() // temporary buffer, used by implCompress()
private final int[] x; private int[] x;
// rotation constants // rotation constants
private static final int S11 = 3; private static final int S11 = 3;
...@@ -93,16 +93,12 @@ public final class MD4 extends DigestBase { ...@@ -93,16 +93,12 @@ public final class MD4 extends DigestBase {
implReset(); implReset();
} }
// Cloning constructor
private MD4(MD4 base) {
super(base);
this.state = base.state.clone();
this.x = new int[16];
}
// clone this object // clone this object
public Object clone() { public Object clone() throws CloneNotSupportedException {
return new MD4(this); MD4 copy = (MD4) super.clone();
copy.state = copy.state.clone();
copy.x = new int[16];
return copy;
} }
/** /**
......
...@@ -39,9 +39,9 @@ import static sun.security.provider.ByteArrayAccess.*; ...@@ -39,9 +39,9 @@ import static sun.security.provider.ByteArrayAccess.*;
public final class MD5 extends DigestBase { public final class MD5 extends DigestBase {
// state of this object // state of this object
private final int[] state; private int[] state;
// temporary buffer, used by implCompress() // temporary buffer, used by implCompress()
private final int[] x; private int[] x;
// rotation constants // rotation constants
private static final int S11 = 7; private static final int S11 = 7;
...@@ -69,16 +69,12 @@ public final class MD5 extends DigestBase { ...@@ -69,16 +69,12 @@ public final class MD5 extends DigestBase {
implReset(); implReset();
} }
// Cloning constructor
private MD5(MD5 base) {
super(base);
this.state = base.state.clone();
this.x = new int[16];
}
// clone this object // clone this object
public Object clone() { public Object clone() throws CloneNotSupportedException {
return new MD5(this); MD5 copy = (MD5) super.clone();
copy.state = copy.state.clone();
copy.x = new int[16];
return copy;
} }
/** /**
......
...@@ -47,10 +47,10 @@ public final class SHA extends DigestBase { ...@@ -47,10 +47,10 @@ public final class SHA extends DigestBase {
// 64 bytes are included in each hash block so the low order // 64 bytes are included in each hash block so the low order
// bits of count are used to know how to pack the bytes into ints // bits of count are used to know how to pack the bytes into ints
// and to know when to compute the block and start the next one. // and to know when to compute the block and start the next one.
private final int[] W; private int[] W;
// state of this // state of this
private final int[] state; private int[] state;
/** /**
* Creates a new SHA object. * Creates a new SHA object.
...@@ -62,19 +62,14 @@ public final class SHA extends DigestBase { ...@@ -62,19 +62,14 @@ public final class SHA extends DigestBase {
implReset(); implReset();
} }
/**
* Creates a SHA object.with state (for cloning) */
private SHA(SHA base) {
super(base);
this.state = base.state.clone();
this.W = new int[80];
}
/* /*
* Clones this object. * Clones this object.
*/ */
public Object clone() { public Object clone() throws CloneNotSupportedException {
return new SHA(this); SHA copy = (SHA) super.clone();
copy.state = copy.state.clone();
copy.W = new int[80];
return copy;
} }
/** /**
......
/* /*
* Copyright (c) 2002, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -40,7 +40,7 @@ import static sun.security.provider.ByteArrayAccess.*; ...@@ -40,7 +40,7 @@ import static sun.security.provider.ByteArrayAccess.*;
* @author Valerie Peng * @author Valerie Peng
* @author Andreas Sterbenz * @author Andreas Sterbenz
*/ */
public final class SHA2 extends DigestBase { abstract class SHA2 extends DigestBase {
private static final int ITERATION = 64; private static final int ITERATION = 64;
// Constants for each round // Constants for each round
...@@ -64,46 +64,30 @@ public final class SHA2 extends DigestBase { ...@@ -64,46 +64,30 @@ public final class SHA2 extends DigestBase {
}; };
// buffer used by implCompress() // buffer used by implCompress()
private final int[] W; private int[] W;
// state of this object // state of this object
private final int[] state; private int[] state;
// initial state value. different between SHA-224 and SHA-256
private final int[] initialHashes;
/** /**
* Creates a new SHA object. * Creates a new SHA object.
*/ */
public SHA2() { SHA2(String name, int digestLength, int[] initialHashes) {
super("SHA-256", 32, 64); super(name, digestLength, 64);
this.initialHashes = initialHashes;
state = new int[8]; state = new int[8];
W = new int[64]; W = new int[64];
implReset(); implReset();
} }
/**
* Creates a SHA2 object.with state (for cloning)
*/
private SHA2(SHA2 base) {
super(base);
this.state = base.state.clone();
this.W = new int[64];
}
public Object clone() {
return new SHA2(this);
}
/** /**
* Resets the buffers and hash value to start a new hash. * Resets the buffers and hash value to start a new hash.
*/ */
void implReset() { void implReset() {
state[0] = 0x6a09e667; System.arraycopy(initialHashes, 0, state, 0, state.length);
state[1] = 0xbb67ae85;
state[2] = 0x3c6ef372;
state[3] = 0xa54ff53a;
state[4] = 0x510e527f;
state[5] = 0x9b05688c;
state[6] = 0x1f83d9ab;
state[7] = 0x5be0cd19;
} }
void implDigest(byte[] out, int ofs) { void implDigest(byte[] out, int ofs) {
...@@ -242,4 +226,38 @@ public final class SHA2 extends DigestBase { ...@@ -242,4 +226,38 @@ public final class SHA2 extends DigestBase {
state[7] += h; state[7] += h;
} }
public Object clone() throws CloneNotSupportedException {
SHA2 copy = (SHA2) super.clone();
copy.state = copy.state.clone();
copy.W = new int[64];
return copy;
}
/**
* SHA-224 implementation class.
*/
public static final class SHA224 extends SHA2 {
private static final int[] INITIAL_HASHES = {
0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4
};
public SHA224() {
super("SHA-224", 28, INITIAL_HASHES);
}
}
/**
* SHA-256 implementation class.
*/
public static final class SHA256 extends SHA2 {
private static final int[] INITIAL_HASHES = {
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
};
public SHA256() {
super("SHA-256", 32, INITIAL_HASHES);
}
}
} }
...@@ -82,10 +82,10 @@ abstract class SHA5 extends DigestBase { ...@@ -82,10 +82,10 @@ abstract class SHA5 extends DigestBase {
}; };
// buffer used by implCompress() // buffer used by implCompress()
private final long[] W; private long[] W;
// state of this object // state of this object
private final long[] state; private long[] state;
// initial state value. different between SHA-384 and SHA-512 // initial state value. different between SHA-384 and SHA-512
private final long[] initialHashes; private final long[] initialHashes;
...@@ -101,16 +101,6 @@ abstract class SHA5 extends DigestBase { ...@@ -101,16 +101,6 @@ abstract class SHA5 extends DigestBase {
implReset(); implReset();
} }
/**
* Creates a SHA object with state (for cloning)
*/
SHA5(SHA5 base) {
super(base);
this.initialHashes = base.initialHashes;
this.state = base.state.clone();
this.W = new long[80];
}
final void implReset() { final void implReset() {
System.arraycopy(initialHashes, 0, state, 0, state.length); System.arraycopy(initialHashes, 0, state, 0, state.length);
} }
...@@ -255,6 +245,13 @@ abstract class SHA5 extends DigestBase { ...@@ -255,6 +245,13 @@ abstract class SHA5 extends DigestBase {
state[7] += h; state[7] += h;
} }
public Object clone() throws CloneNotSupportedException {
SHA5 copy = (SHA5) super.clone();
copy.state = copy.state.clone();
copy.W = new long[80];
return copy;
}
/** /**
* SHA-512 implementation class. * SHA-512 implementation class.
*/ */
...@@ -270,14 +267,6 @@ abstract class SHA5 extends DigestBase { ...@@ -270,14 +267,6 @@ abstract class SHA5 extends DigestBase {
public SHA512() { public SHA512() {
super("SHA-512", 64, INITIAL_HASHES); super("SHA-512", 64, INITIAL_HASHES);
} }
private SHA512(SHA512 base) {
super(base);
}
public Object clone() {
return new SHA512(this);
}
} }
/** /**
...@@ -295,14 +284,5 @@ abstract class SHA5 extends DigestBase { ...@@ -295,14 +284,5 @@ abstract class SHA5 extends DigestBase {
public SHA384() { public SHA384() {
super("SHA-384", 48, INITIAL_HASHES); super("SHA-384", 48, INITIAL_HASHES);
} }
private SHA384(SHA384 base) {
super(base);
}
public Object clone() {
return new SHA384(this);
}
} }
} }
/* /*
* Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -102,7 +102,7 @@ implements java.io.Serializable { ...@@ -102,7 +102,7 @@ implements java.io.Serializable {
try { try {
digest = MessageDigest.getInstance ("SHA"); digest = MessageDigest.getInstance ("SHA");
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
throw new InternalError("internal error: SHA-1 not available."); throw new InternalError("internal error: SHA-1 not available.", e);
} }
if (seed != null) { if (seed != null) {
......
/* /*
* Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -43,6 +43,10 @@ import java.security.*; ...@@ -43,6 +43,10 @@ import java.security.*;
* identifier strings "OID.1.3.14.3.2.13", "OID.1.3.14.3.2.27" and * identifier strings "OID.1.3.14.3.2.13", "OID.1.3.14.3.2.27" and
* "OID.1.2.840.10040.4.3". * "OID.1.2.840.10040.4.3".
* *
* - SHA-2 is a set of message digest schemes described in FIPS 180-2.
* SHA-2 family of hash functions includes SHA-224, SHA-256, SHA-384,
* and SHA-512.
*
* - DSA is the key generation scheme as described in FIPS 186. * - DSA is the key generation scheme as described in FIPS 186.
* Aliases for DSA include the OID strings "OID.1.3.14.3.2.12" * Aliases for DSA include the OID strings "OID.1.3.14.3.2.12"
* and "OID.1.2.840.10040.4.1". * and "OID.1.2.840.10040.4.1".
...@@ -140,9 +144,19 @@ final class SunEntries { ...@@ -140,9 +144,19 @@ final class SunEntries {
map.put("Alg.Alias.MessageDigest.SHA-1", "SHA"); map.put("Alg.Alias.MessageDigest.SHA-1", "SHA");
map.put("Alg.Alias.MessageDigest.SHA1", "SHA"); map.put("Alg.Alias.MessageDigest.SHA1", "SHA");
map.put("MessageDigest.SHA-256", "sun.security.provider.SHA2"); map.put("MessageDigest.SHA-224", "sun.security.provider.SHA2$SHA224");
map.put("Alg.Alias.MessageDigest.2.16.840.1.101.3.4.2.4", "SHA-224");
map.put("Alg.Alias.MessageDigest.OID.2.16.840.1.101.3.4.2.4", "SHA-224");
map.put("MessageDigest.SHA-256", "sun.security.provider.SHA2$SHA256");
map.put("Alg.Alias.MessageDigest.2.16.840.1.101.3.4.2.1", "SHA-256");
map.put("Alg.Alias.MessageDigest.OID.2.16.840.1.101.3.4.2.1", "SHA-256");
map.put("MessageDigest.SHA-384", "sun.security.provider.SHA5$SHA384"); map.put("MessageDigest.SHA-384", "sun.security.provider.SHA5$SHA384");
map.put("Alg.Alias.MessageDigest.2.16.840.1.101.3.4.2.2", "SHA-384");
map.put("Alg.Alias.MessageDigest.OID.2.16.840.1.101.3.4.2.2", "SHA-384");
map.put("MessageDigest.SHA-512", "sun.security.provider.SHA5$SHA512"); map.put("MessageDigest.SHA-512", "sun.security.provider.SHA5$SHA512");
map.put("Alg.Alias.MessageDigest.2.16.840.1.101.3.4.2.3", "SHA-512");
map.put("Alg.Alias.MessageDigest.OID.2.16.840.1.101.3.4.2.3", "SHA-512");
/* /*
* Algorithm Parameter Generator engines * Algorithm Parameter Generator engines
......
...@@ -318,7 +318,9 @@ public final class SunCertPathBuilder extends CertPathBuilderSpi { ...@@ -318,7 +318,9 @@ public final class SunCertPathBuilder extends CertPathBuilderSpi {
} }
// break out of loop if search is successful // break out of loop if search is successful
break; if (pathCompleted) {
break;
}
} }
if (debug != null) { if (debug != null) {
......
/* /*
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -39,8 +39,8 @@ import sun.security.x509.AlgorithmId; ...@@ -39,8 +39,8 @@ import sun.security.x509.AlgorithmId;
* PKCS#1 RSA signatures with the various message digest algorithms. * PKCS#1 RSA signatures with the various message digest algorithms.
* This file contains an abstract base class with all the logic plus * This file contains an abstract base class with all the logic plus
* a nested static class for each of the message digest algorithms * a nested static class for each of the message digest algorithms
* (see end of the file). We support MD2, MD5, SHA-1, SHA-256, SHA-384, * (see end of the file). We support MD2, MD5, SHA-1, SHA-224, SHA-256,
* and SHA-512. * SHA-384, and SHA-512.
* *
* @since 1.5 * @since 1.5
* @author Andreas Sterbenz * @author Andreas Sterbenz
...@@ -276,6 +276,13 @@ public abstract class RSASignature extends SignatureSpi { ...@@ -276,6 +276,13 @@ public abstract class RSASignature extends SignatureSpi {
} }
} }
// Nested class for SHA224withRSA signatures
public static final class SHA224withRSA extends RSASignature {
public SHA224withRSA() {
super("SHA-224", AlgorithmId.SHA224_oid, 11);
}
}
// Nested class for SHA256withRSA signatures // Nested class for SHA256withRSA signatures
public static final class SHA256withRSA extends RSASignature { public static final class SHA256withRSA extends RSASignature {
public SHA256withRSA() { public SHA256withRSA() {
......
/* /*
* Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -52,6 +52,8 @@ public final class SunRsaSignEntries { ...@@ -52,6 +52,8 @@ public final class SunRsaSignEntries {
"sun.security.rsa.RSASignature$MD5withRSA"); "sun.security.rsa.RSASignature$MD5withRSA");
map.put("Signature.SHA1withRSA", map.put("Signature.SHA1withRSA",
"sun.security.rsa.RSASignature$SHA1withRSA"); "sun.security.rsa.RSASignature$SHA1withRSA");
map.put("Signature.SHA224withRSA",
"sun.security.rsa.RSASignature$SHA224withRSA");
map.put("Signature.SHA256withRSA", map.put("Signature.SHA256withRSA",
"sun.security.rsa.RSASignature$SHA256withRSA"); "sun.security.rsa.RSASignature$SHA256withRSA");
map.put("Signature.SHA384withRSA", map.put("Signature.SHA384withRSA",
...@@ -66,6 +68,7 @@ public final class SunRsaSignEntries { ...@@ -66,6 +68,7 @@ public final class SunRsaSignEntries {
map.put("Signature.MD2withRSA SupportedKeyClasses", rsaKeyClasses); map.put("Signature.MD2withRSA SupportedKeyClasses", rsaKeyClasses);
map.put("Signature.MD5withRSA SupportedKeyClasses", rsaKeyClasses); map.put("Signature.MD5withRSA SupportedKeyClasses", rsaKeyClasses);
map.put("Signature.SHA1withRSA SupportedKeyClasses", rsaKeyClasses); map.put("Signature.SHA1withRSA SupportedKeyClasses", rsaKeyClasses);
map.put("Signature.SHA224withRSA SupportedKeyClasses", rsaKeyClasses);
map.put("Signature.SHA256withRSA SupportedKeyClasses", rsaKeyClasses); map.put("Signature.SHA256withRSA SupportedKeyClasses", rsaKeyClasses);
map.put("Signature.SHA384withRSA SupportedKeyClasses", rsaKeyClasses); map.put("Signature.SHA384withRSA SupportedKeyClasses", rsaKeyClasses);
map.put("Signature.SHA512withRSA SupportedKeyClasses", rsaKeyClasses); map.put("Signature.SHA512withRSA SupportedKeyClasses", rsaKeyClasses);
...@@ -88,6 +91,9 @@ public final class SunRsaSignEntries { ...@@ -88,6 +91,9 @@ public final class SunRsaSignEntries {
map.put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.5", "SHA1withRSA"); map.put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.5", "SHA1withRSA");
map.put("Alg.Alias.Signature.1.3.14.3.2.29", "SHA1withRSA"); map.put("Alg.Alias.Signature.1.3.14.3.2.29", "SHA1withRSA");
map.put("Alg.Alias.Signature.1.2.840.113549.1.1.14", "SHA224withRSA");
map.put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.14", "SHA224withRSA");
map.put("Alg.Alias.Signature.1.2.840.113549.1.1.11", "SHA256withRSA"); map.put("Alg.Alias.Signature.1.2.840.113549.1.1.11", "SHA256withRSA");
map.put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.11", "SHA256withRSA"); map.put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.11", "SHA256withRSA");
......
...@@ -267,36 +267,42 @@ public abstract class SSLContextImpl extends SSLContextSpi { ...@@ -267,36 +267,42 @@ public abstract class SSLContextImpl extends SSLContextSpi {
// Get suported CipherSuiteList. // Get suported CipherSuiteList.
CipherSuiteList getSuportedCipherSuiteList() { CipherSuiteList getSuportedCipherSuiteList() {
// Clear cache of available ciphersuites. // The maintenance of cipher suites needs to be synchronized.
clearAvailableCache(); synchronized (this) {
// Clear cache of available ciphersuites.
clearAvailableCache();
if (supportedCipherSuiteList == null) {
supportedCipherSuiteList = getApplicableCipherSuiteList(
getSuportedProtocolList(), false);
}
if (supportedCipherSuiteList == null) { return supportedCipherSuiteList;
supportedCipherSuiteList =
getApplicableCipherSuiteList(getSuportedProtocolList(), false);
} }
return supportedCipherSuiteList;
} }
// Get default CipherSuiteList. // Get default CipherSuiteList.
CipherSuiteList getDefaultCipherSuiteList(boolean roleIsServer) { CipherSuiteList getDefaultCipherSuiteList(boolean roleIsServer) {
// Clear cache of available ciphersuites. // The maintenance of cipher suites needs to be synchronized.
clearAvailableCache(); synchronized (this) {
// Clear cache of available ciphersuites.
if (roleIsServer) { clearAvailableCache();
if (defaultServerCipherSuiteList == null) {
defaultServerCipherSuiteList = getApplicableCipherSuiteList( if (roleIsServer) {
if (defaultServerCipherSuiteList == null) {
defaultServerCipherSuiteList = getApplicableCipherSuiteList(
getDefaultProtocolList(true), true); getDefaultProtocolList(true), true);
} }
return defaultServerCipherSuiteList; return defaultServerCipherSuiteList;
} else { } else {
if (defaultClientCipherSuiteList == null) { if (defaultClientCipherSuiteList == null) {
defaultClientCipherSuiteList = getApplicableCipherSuiteList( defaultClientCipherSuiteList = getApplicableCipherSuiteList(
getDefaultProtocolList(false), true); getDefaultProtocolList(false), true);
} }
return defaultClientCipherSuiteList; return defaultClientCipherSuiteList;
}
} }
} }
...@@ -364,8 +370,11 @@ public abstract class SSLContextImpl extends SSLContextSpi { ...@@ -364,8 +370,11 @@ public abstract class SSLContextImpl extends SSLContextSpi {
* Clear cache of available ciphersuites. If we support all ciphers * Clear cache of available ciphersuites. If we support all ciphers
* internally, there is no need to clear the cache and calling this * internally, there is no need to clear the cache and calling this
* method has no effect. * method has no effect.
*
* Note that every call to clearAvailableCache() and the maintenance of
* cipher suites need to be synchronized with this instance.
*/ */
synchronized void clearAvailableCache() { private void clearAvailableCache() {
if (CipherSuite.DYNAMIC_AVAILABILITY) { if (CipherSuite.DYNAMIC_AVAILABILITY) {
supportedCipherSuiteList = null; supportedCipherSuiteList = null;
defaultServerCipherSuiteList = null; defaultServerCipherSuiteList = null;
......
...@@ -311,7 +311,7 @@ public final class SimpleValidator extends Validator { ...@@ -311,7 +311,7 @@ public final class SimpleValidator extends Validator {
// if the certificate is self-issued, ignore the pathLenConstraint // if the certificate is self-issued, ignore the pathLenConstraint
// checking. // checking.
if (!X509CertImpl.isSelfIssued(cert)) { if (!X509CertImpl.isSelfIssued(cert)) {
if (maxPathLen <= 1) { // reserved one for end-entity certificate if (maxPathLen <= 0) {
throw new ValidatorException("Violated path length constraints", throw new ValidatorException("Violated path length constraints",
ValidatorException.T_CA_EXTENSIONS, cert); ValidatorException.T_CA_EXTENSIONS, cert);
} }
......
/* /*
* Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -175,9 +175,9 @@ public class AlgorithmId implements Serializable, DerEncoder { ...@@ -175,9 +175,9 @@ public class AlgorithmId implements Serializable, DerEncoder {
// it's NULL. They are --- // it's NULL. They are ---
// rfc3370 2.1: Implementations SHOULD generate SHA-1 // rfc3370 2.1: Implementations SHOULD generate SHA-1
// AlgorithmIdentifiers with absent parameters. // AlgorithmIdentifiers with absent parameters.
// rfc3447 C1: When id-sha1, id-sha256, id-sha384 and id-sha512 // rfc3447 C1: When id-sha1, id-sha224, id-sha256, id-sha384 and
// are used in an AlgorithmIdentifier the parameters (which are // id-sha512 are used in an AlgorithmIdentifier the parameters
// optional) SHOULD be omitted. // (which are optional) SHOULD be omitted.
// rfc3279 2.3.2: The id-dsa algorithm syntax includes optional // rfc3279 2.3.2: The id-dsa algorithm syntax includes optional
// domain parameters... When omitted, the parameters component // domain parameters... When omitted, the parameters component
// MUST be omitted entirely // MUST be omitted entirely
...@@ -185,6 +185,7 @@ public class AlgorithmId implements Serializable, DerEncoder { ...@@ -185,6 +185,7 @@ public class AlgorithmId implements Serializable, DerEncoder {
// is used, the AlgorithmIdentifier parameters field MUST be absent. // is used, the AlgorithmIdentifier parameters field MUST be absent.
/*if ( /*if (
algid.equals((Object)SHA_oid) || algid.equals((Object)SHA_oid) ||
algid.equals((Object)SHA224_oid) ||
algid.equals((Object)SHA256_oid) || algid.equals((Object)SHA256_oid) ||
algid.equals((Object)SHA384_oid) || algid.equals((Object)SHA384_oid) ||
algid.equals((Object)SHA512_oid) || algid.equals((Object)SHA512_oid) ||
...@@ -488,7 +489,10 @@ public class AlgorithmId implements Serializable, DerEncoder { ...@@ -488,7 +489,10 @@ public class AlgorithmId implements Serializable, DerEncoder {
name.equalsIgnoreCase("SHA512")) { name.equalsIgnoreCase("SHA512")) {
return AlgorithmId.SHA512_oid; return AlgorithmId.SHA512_oid;
} }
if (name.equalsIgnoreCase("SHA-224") ||
name.equalsIgnoreCase("SHA224")) {
return AlgorithmId.SHA224_oid;
}
// Various public key algorithms // Various public key algorithms
if (name.equalsIgnoreCase("RSA")) { if (name.equalsIgnoreCase("RSA")) {
...@@ -625,6 +629,9 @@ public class AlgorithmId implements Serializable, DerEncoder { ...@@ -625,6 +629,9 @@ public class AlgorithmId implements Serializable, DerEncoder {
public static final ObjectIdentifier SHA_oid = public static final ObjectIdentifier SHA_oid =
ObjectIdentifier.newInternal(new int[] {1, 3, 14, 3, 2, 26}); ObjectIdentifier.newInternal(new int[] {1, 3, 14, 3, 2, 26});
public static final ObjectIdentifier SHA224_oid =
ObjectIdentifier.newInternal(new int[] {2, 16, 840, 1, 101, 3, 4, 2, 4});
public static final ObjectIdentifier SHA256_oid = public static final ObjectIdentifier SHA256_oid =
ObjectIdentifier.newInternal(new int[] {2, 16, 840, 1, 101, 3, 4, 2, 1}); ObjectIdentifier.newInternal(new int[] {2, 16, 840, 1, 101, 3, 4, 2, 1});
...@@ -664,6 +671,8 @@ public class AlgorithmId implements Serializable, DerEncoder { ...@@ -664,6 +671,8 @@ public class AlgorithmId implements Serializable, DerEncoder {
{ 1, 2, 840, 113549, 1, 1, 5 }; { 1, 2, 840, 113549, 1, 1, 5 };
private static final int sha1WithRSAEncryption_OIW_data[] = private static final int sha1WithRSAEncryption_OIW_data[] =
{ 1, 3, 14, 3, 2, 29 }; { 1, 3, 14, 3, 2, 29 };
private static final int sha224WithRSAEncryption_data[] =
{ 1, 2, 840, 113549, 1, 1, 14 };
private static final int sha256WithRSAEncryption_data[] = private static final int sha256WithRSAEncryption_data[] =
{ 1, 2, 840, 113549, 1, 1, 11 }; { 1, 2, 840, 113549, 1, 1, 11 };
private static final int sha384WithRSAEncryption_data[] = private static final int sha384WithRSAEncryption_data[] =
...@@ -681,6 +690,7 @@ public class AlgorithmId implements Serializable, DerEncoder { ...@@ -681,6 +690,7 @@ public class AlgorithmId implements Serializable, DerEncoder {
public static final ObjectIdentifier md5WithRSAEncryption_oid; public static final ObjectIdentifier md5WithRSAEncryption_oid;
public static final ObjectIdentifier sha1WithRSAEncryption_oid; public static final ObjectIdentifier sha1WithRSAEncryption_oid;
public static final ObjectIdentifier sha1WithRSAEncryption_OIW_oid; public static final ObjectIdentifier sha1WithRSAEncryption_OIW_oid;
public static final ObjectIdentifier sha224WithRSAEncryption_oid;
public static final ObjectIdentifier sha256WithRSAEncryption_oid; public static final ObjectIdentifier sha256WithRSAEncryption_oid;
public static final ObjectIdentifier sha384WithRSAEncryption_oid; public static final ObjectIdentifier sha384WithRSAEncryption_oid;
public static final ObjectIdentifier sha512WithRSAEncryption_oid; public static final ObjectIdentifier sha512WithRSAEncryption_oid;
...@@ -809,6 +819,14 @@ public class AlgorithmId implements Serializable, DerEncoder { ...@@ -809,6 +819,14 @@ public class AlgorithmId implements Serializable, DerEncoder {
sha1WithRSAEncryption_OIW_oid = sha1WithRSAEncryption_OIW_oid =
ObjectIdentifier.newInternal(sha1WithRSAEncryption_OIW_data); ObjectIdentifier.newInternal(sha1WithRSAEncryption_OIW_data);
/**
* Identifies a signing algorithm where a SHA224 digest is
* encrypted using an RSA private key; defined by PKCS #1.
* OID = 1.2.840.113549.1.1.14
*/
sha224WithRSAEncryption_oid =
ObjectIdentifier.newInternal(sha224WithRSAEncryption_data);
/** /**
* Identifies a signing algorithm where a SHA256 digest is * Identifies a signing algorithm where a SHA256 digest is
* encrypted using an RSA private key; defined by PKCS #1. * encrypted using an RSA private key; defined by PKCS #1.
...@@ -859,6 +877,7 @@ public class AlgorithmId implements Serializable, DerEncoder { ...@@ -859,6 +877,7 @@ public class AlgorithmId implements Serializable, DerEncoder {
nameTable.put(MD5_oid, "MD5"); nameTable.put(MD5_oid, "MD5");
nameTable.put(MD2_oid, "MD2"); nameTable.put(MD2_oid, "MD2");
nameTable.put(SHA_oid, "SHA"); nameTable.put(SHA_oid, "SHA");
nameTable.put(SHA224_oid, "SHA224");
nameTable.put(SHA256_oid, "SHA256"); nameTable.put(SHA256_oid, "SHA256");
nameTable.put(SHA384_oid, "SHA384"); nameTable.put(SHA384_oid, "SHA384");
nameTable.put(SHA512_oid, "SHA512"); nameTable.put(SHA512_oid, "SHA512");
...@@ -881,6 +900,7 @@ public class AlgorithmId implements Serializable, DerEncoder { ...@@ -881,6 +900,7 @@ public class AlgorithmId implements Serializable, DerEncoder {
nameTable.put(shaWithDSA_OIW_oid, "SHA1withDSA"); nameTable.put(shaWithDSA_OIW_oid, "SHA1withDSA");
nameTable.put(sha1WithRSAEncryption_oid, "SHA1withRSA"); nameTable.put(sha1WithRSAEncryption_oid, "SHA1withRSA");
nameTable.put(sha1WithRSAEncryption_OIW_oid, "SHA1withRSA"); nameTable.put(sha1WithRSAEncryption_OIW_oid, "SHA1withRSA");
nameTable.put(sha224WithRSAEncryption_oid, "SHA224withRSA");
nameTable.put(sha256WithRSAEncryption_oid, "SHA256withRSA"); nameTable.put(sha256WithRSAEncryption_oid, "SHA256withRSA");
nameTable.put(sha384WithRSAEncryption_oid, "SHA384withRSA"); nameTable.put(sha384WithRSAEncryption_oid, "SHA384withRSA");
nameTable.put(sha512WithRSAEncryption_oid, "SHA512withRSA"); nameTable.put(sha512WithRSAEncryption_oid, "SHA512withRSA");
......
...@@ -142,8 +142,11 @@ public class JCmd { ...@@ -142,8 +142,11 @@ public class JCmd {
// Cast to HotSpotVirtualMachine as this is an // Cast to HotSpotVirtualMachine as this is an
// implementation specific method. // implementation specific method.
HotSpotVirtualMachine hvm = (HotSpotVirtualMachine) vm; HotSpotVirtualMachine hvm = (HotSpotVirtualMachine) vm;
String lines[] = command .split("\\n"); String lines[] = command.split("\\n");
for (String line : lines) { for (String line : lines) {
if (line.trim().equals("stop")) {
break;
}
try (InputStream in = hvm.executeJCmd(line);) { try (InputStream in = hvm.executeJCmd(line);) {
// read to EOF and just print output // read to EOF and just print output
byte b[] = new byte[256]; byte b[] = new byte[256];
......
...@@ -38,7 +38,7 @@ and plots the memory usage history graph. ...@@ -38,7 +38,7 @@ and plots the memory usage history graph.
To run the MemoryMonitor demo To run the MemoryMonitor demo
java -jar <JDK_HOME>/demo/management/MemoryMonitor.jar java -jar <JDK_HOME>/demo/management/MemoryMonitor/MemoryMonitor.jar
These instructions assume that this installation's version of the java These instructions assume that this installation's version of the java
command is in your path. If it isn't, then you should either command is in your path. If it isn't, then you should either
......
...@@ -651,7 +651,11 @@ public class ZipFileSystem extends FileSystem { ...@@ -651,7 +651,11 @@ public class ZipFileSystem extends FileSystem {
} }
public int read(ByteBuffer dst) throws IOException { public int read(ByteBuffer dst) throws IOException {
return rbc.read(dst); int n = rbc.read(dst);
if (n > 0) {
read += n;
}
return n;
} }
public SeekableByteChannel truncate(long size) public SeekableByteChannel truncate(long size)
......
/* /*
* Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -82,7 +82,11 @@ static unpacker* get_unpacker(JNIEnv *env, jobject pObj, bool noCreate=false) { ...@@ -82,7 +82,11 @@ static unpacker* get_unpacker(JNIEnv *env, jobject pObj, bool noCreate=false) {
static unpacker* get_unpacker() { static unpacker* get_unpacker() {
//fprintf(stderr, "get_unpacker()\n"); //fprintf(stderr, "get_unpacker()\n");
JavaVM* vm = null; JavaVM* vm = null;
JNI_GetCreatedJavaVMs(&vm, 1, null); jsize nVM = 0;
jint retval = JNI_GetCreatedJavaVMs(&vm, 1, &nVM);
// other VM implements may differ, thus for correctness, we need these checks
if (retval != JNI_OK || nVM != 1)
return null;
void* envRaw = null; void* envRaw = null;
vm->GetEnv(&envRaw, JNI_VERSION_1_1); vm->GetEnv(&envRaw, JNI_VERSION_1_1);
JNIEnv* env = (JNIEnv*) envRaw; JNIEnv* env = (JNIEnv*) envRaw;
......
...@@ -139,6 +139,9 @@ NET_IPv4MappedToIPv4(jbyte* caddr); ...@@ -139,6 +139,9 @@ NET_IPv4MappedToIPv4(jbyte* caddr);
int int
NET_IsEqual(jbyte* caddr1, jbyte* caddr2); NET_IsEqual(jbyte* caddr1, jbyte* caddr2);
int
NET_IsZeroAddr(jbyte* caddr);
/* Socket operations /* Socket operations
* *
* These work just like the JVM_* procedures, except that they may do some * These work just like the JVM_* procedures, except that they may do some
......
...@@ -671,12 +671,19 @@ ping4(JNIEnv *env, jint fd, struct sockaddr_in* him, jint timeout, ...@@ -671,12 +671,19 @@ ping4(JNIEnv *env, jint fd, struct sockaddr_in* him, jint timeout,
* We did receive something, but is it what we were expecting? * We did receive something, but is it what we were expecting?
* I.E.: A ICMP_ECHOREPLY packet with the proper PID. * I.E.: A ICMP_ECHOREPLY packet with the proper PID.
*/ */
if (icmplen >= 8 && icmp->icmp_type == ICMP_ECHOREPLY && if (icmplen >= 8 && icmp->icmp_type == ICMP_ECHOREPLY
(ntohs(icmp->icmp_id) == pid) && && (ntohs(icmp->icmp_id) == pid)) {
(him->sin_addr.s_addr == sa_recv.sin_addr.s_addr)) { if ((him->sin_addr.s_addr == sa_recv.sin_addr.s_addr)) {
close(fd); close(fd);
return JNI_TRUE; return JNI_TRUE;
} }
if (him->sin_addr.s_addr == 0) {
close(fd);
return JNI_TRUE;
}
}
} }
} while (tmout2 > 0); } while (tmout2 > 0);
timeout -= 1000; timeout -= 1000;
......
/* /*
* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -73,7 +73,7 @@ Java_java_net_Inet6AddressImpl_getLocalHostName(JNIEnv *env, jobject this) { ...@@ -73,7 +73,7 @@ Java_java_net_Inet6AddressImpl_getLocalHostName(JNIEnv *env, jobject this) {
} else { } else {
// ensure null-terminated // ensure null-terminated
hostname[NI_MAXHOST] = '\0'; hostname[NI_MAXHOST] = '\0';
#if defined(__linux__) && defined(_ALLBSD_SOURCE) #if defined(__linux__) || defined(_ALLBSD_SOURCE)
/* On Linux/FreeBSD gethostname() says "host.domain.sun.com". On /* On Linux/FreeBSD gethostname() says "host.domain.sun.com". On
* Solaris gethostname() says "host", so extra work is needed. * Solaris gethostname() says "host", so extra work is needed.
*/ */
...@@ -532,10 +532,15 @@ ping6(JNIEnv *env, jint fd, struct sockaddr_in6* him, jint timeout, ...@@ -532,10 +532,15 @@ ping6(JNIEnv *env, jint fd, struct sockaddr_in6* him, jint timeout,
* from the host that we are trying to determine is reachable. * from the host that we are trying to determine is reachable.
*/ */
if (n >= 8 && icmp6->icmp6_type == ICMP6_ECHO_REPLY && if (n >= 8 && icmp6->icmp6_type == ICMP6_ECHO_REPLY &&
(ntohs(icmp6->icmp6_id) == pid) && (ntohs(icmp6->icmp6_id) == pid)) {
NET_IsEqual(caddr, recv_caddr)) { if (NET_IsEqual(caddr, recv_caddr)) {
close(fd); close(fd);
return JNI_TRUE; return JNI_TRUE;
}
if (NET_IsZeroAddr(caddr)) {
close(fd);
return JNI_TRUE;
}
} }
} }
} while (tmout2 > 0); } while (tmout2 > 0);
......
...@@ -961,6 +961,16 @@ NET_IsEqual(jbyte* caddr1, jbyte* caddr2) { ...@@ -961,6 +961,16 @@ NET_IsEqual(jbyte* caddr1, jbyte* caddr2) {
return 1; return 1;
} }
int NET_IsZeroAddr(jbyte* caddr) {
int i;
for (i = 0; i < 16; i++) {
if (caddr[i] != 0) {
return 0;
}
}
return 1;
}
/* /*
* Map the Java level socket option to the platform specific * Map the Java level socket option to the platform specific
* level and option name. * level and option name.
......
...@@ -651,7 +651,7 @@ findJavaTZ_md(const char *java_home_dir, const char *country) ...@@ -651,7 +651,7 @@ findJavaTZ_md(const char *java_home_dir, const char *country)
} }
#ifdef __solaris__ #ifdef __solaris__
if (strcmp(tz, "localtime") == 0) { if (tz != NULL && strcmp(tz, "localtime") == 0) {
tz = getSolarisDefaultZoneID(); tz = getSolarisDefaultZoneID();
freetz = tz; freetz = tz;
} }
......
...@@ -30,40 +30,10 @@ ...@@ -30,40 +30,10 @@
#include "sun_nio_ch_EPollArrayWrapper.h" #include "sun_nio_ch_EPollArrayWrapper.h"
#include <dlfcn.h>
#include <unistd.h> #include <unistd.h>
#include <sys/resource.h> #include <sys/resource.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/epoll.h>
#ifdef __cplusplus
extern "C" {
#endif
/* epoll_wait(2) man page */
typedef union epoll_data {
void *ptr;
int fd;
__uint32_t u32;
__uint64_t u64;
} epoll_data_t;
/* x86-64 has same alignment as 32-bit */
#ifdef __x86_64__
#define EPOLL_PACKED __attribute__((packed))
#else
#define EPOLL_PACKED
#endif
struct epoll_event {
__uint32_t events; /* Epoll events */
epoll_data_t data; /* User data variable */
} EPOLL_PACKED;
#ifdef __cplusplus
}
#endif
#define RESTARTABLE(_cmd, _result) do { \ #define RESTARTABLE(_cmd, _result) do { \
do { \ do { \
...@@ -71,18 +41,6 @@ struct epoll_event { ...@@ -71,18 +41,6 @@ struct epoll_event {
} while((_result == -1) && (errno == EINTR)); \ } while((_result == -1) && (errno == EINTR)); \
} while(0) } while(0)
/*
* epoll event notification is new in 2.6 kernel. As the offical build
* platform for the JDK is on a 2.4-based distribution then we must
* obtain the addresses of the epoll functions dynamically.
*/
typedef int (*epoll_create_t)(int size);
typedef int (*epoll_ctl_t) (int epfd, int op, int fd, struct epoll_event *event);
typedef int (*epoll_wait_t) (int epfd, struct epoll_event *events, int maxevents, int timeout);
static epoll_create_t epoll_create_func;
static epoll_ctl_t epoll_ctl_func;
static epoll_wait_t epoll_wait_func;
static int static int
iepoll(int epfd, struct epoll_event *events, int numfds, jlong timeout) iepoll(int epfd, struct epoll_event *events, int numfds, jlong timeout)
...@@ -96,7 +54,7 @@ iepoll(int epfd, struct epoll_event *events, int numfds, jlong timeout) ...@@ -96,7 +54,7 @@ iepoll(int epfd, struct epoll_event *events, int numfds, jlong timeout)
start = t.tv_sec * 1000 + t.tv_usec / 1000; start = t.tv_sec * 1000 + t.tv_usec / 1000;
for (;;) { for (;;) {
int res = (*epoll_wait_func)(epfd, events, numfds, timeout); int res = epoll_wait(epfd, events, numfds, timeout);
if (res < 0 && errno == EINTR) { if (res < 0 && errno == EINTR) {
if (remaining >= 0) { if (remaining >= 0) {
gettimeofday(&t, NULL); gettimeofday(&t, NULL);
...@@ -117,14 +75,6 @@ iepoll(int epfd, struct epoll_event *events, int numfds, jlong timeout) ...@@ -117,14 +75,6 @@ iepoll(int epfd, struct epoll_event *events, int numfds, jlong timeout)
JNIEXPORT void JNICALL JNIEXPORT void JNICALL
Java_sun_nio_ch_EPollArrayWrapper_init(JNIEnv *env, jclass this) Java_sun_nio_ch_EPollArrayWrapper_init(JNIEnv *env, jclass this)
{ {
epoll_create_func = (epoll_create_t) dlsym(RTLD_DEFAULT, "epoll_create");
epoll_ctl_func = (epoll_ctl_t) dlsym(RTLD_DEFAULT, "epoll_ctl");
epoll_wait_func = (epoll_wait_t) dlsym(RTLD_DEFAULT, "epoll_wait");
if ((epoll_create_func == NULL) || (epoll_ctl_func == NULL) ||
(epoll_wait_func == NULL)) {
JNU_ThrowInternalError(env, "unable to get address of epoll functions, pre-2.6 kernel?");
}
} }
JNIEXPORT jint JNICALL JNIEXPORT jint JNICALL
...@@ -134,7 +84,7 @@ Java_sun_nio_ch_EPollArrayWrapper_epollCreate(JNIEnv *env, jobject this) ...@@ -134,7 +84,7 @@ Java_sun_nio_ch_EPollArrayWrapper_epollCreate(JNIEnv *env, jobject this)
* epoll_create expects a size as a hint to the kernel about how to * epoll_create expects a size as a hint to the kernel about how to
* dimension internal structures. We can't predict the size in advance. * dimension internal structures. We can't predict the size in advance.
*/ */
int epfd = (*epoll_create_func)(256); int epfd = epoll_create(256);
if (epfd < 0) { if (epfd < 0) {
JNU_ThrowIOExceptionWithLastError(env, "epoll_create failed"); JNU_ThrowIOExceptionWithLastError(env, "epoll_create failed");
} }
...@@ -173,7 +123,7 @@ Java_sun_nio_ch_EPollArrayWrapper_epollCtl(JNIEnv *env, jobject this, jint epfd, ...@@ -173,7 +123,7 @@ Java_sun_nio_ch_EPollArrayWrapper_epollCtl(JNIEnv *env, jobject this, jint epfd,
event.events = events; event.events = events;
event.data.fd = fd; event.data.fd = fd;
RESTARTABLE((*epoll_ctl_func)(epfd, (int)opcode, (int)fd, &event), res); RESTARTABLE(epoll_ctl(epfd, (int)opcode, (int)fd, &event), res);
/* /*
* A channel may be registered with several Selectors. When each Selector * A channel may be registered with several Selectors. When each Selector
...@@ -199,7 +149,7 @@ Java_sun_nio_ch_EPollArrayWrapper_epollWait(JNIEnv *env, jobject this, ...@@ -199,7 +149,7 @@ Java_sun_nio_ch_EPollArrayWrapper_epollWait(JNIEnv *env, jobject this,
int res; int res;
if (timeout <= 0) { /* Indefinite or no wait */ if (timeout <= 0) { /* Indefinite or no wait */
RESTARTABLE((*epoll_wait_func)(epfd, events, numfds, timeout), res); RESTARTABLE(epoll_wait(epfd, events, numfds, timeout), res);
} else { /* Bounded wait; bounded restarts */ } else { /* Bounded wait; bounded restarts */
res = iepoll(epfd, events, numfds, timeout); res = iepoll(epfd, events, numfds, timeout);
} }
......
...@@ -57,8 +57,8 @@ import sun.security.rsa.RSAKeyFactory; ...@@ -57,8 +57,8 @@ import sun.security.rsa.RSAKeyFactory;
* *
* NOTE: NONEwithRSA must be supplied with a pre-computed message digest. * NOTE: NONEwithRSA must be supplied with a pre-computed message digest.
* Only the following digest algorithms are supported: MD5, SHA-1, * Only the following digest algorithms are supported: MD5, SHA-1,
* SHA-256, SHA-384, SHA-512 and a special-purpose digest algorithm * SHA-256, SHA-384, SHA-512 and a special-purpose digest
* which is a concatenation of SHA-1 and MD5 digests. * algorithm which is a concatenation of SHA-1 and MD5 digests.
* *
* @since 1.6 * @since 1.6
* @author Stanley Man-Kit Ho * @author Stanley Man-Kit Ho
......
/* /*
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -81,18 +81,26 @@ public final class SunMSCAPI extends Provider { ...@@ -81,18 +81,26 @@ public final class SunMSCAPI extends Provider {
*/ */
// NONEwithRSA must be supplied with a pre-computed message digest. // NONEwithRSA must be supplied with a pre-computed message digest.
// Only the following digest algorithms are supported: MD5, SHA-1, // Only the following digest algorithms are supported: MD5, SHA-1,
// SHA-256, SHA-384, SHA-512 and a special-purpose digest algorithm // SHA-256, SHA-384, SHA-512 and a special-purpose digest
// which is a concatenation of SHA-1 and MD5 digests. // algorithm which is a concatenation of SHA-1 and MD5 digests.
map.put("Signature.NONEwithRSA", map.put("Signature.NONEwithRSA",
"sun.security.mscapi.RSASignature$Raw"); "sun.security.mscapi.RSASignature$Raw");
map.put("Signature.SHA1withRSA", map.put("Signature.SHA1withRSA",
"sun.security.mscapi.RSASignature$SHA1"); "sun.security.mscapi.RSASignature$SHA1");
map.put("Signature.SHA256withRSA", map.put("Signature.SHA256withRSA",
"sun.security.mscapi.RSASignature$SHA256"); "sun.security.mscapi.RSASignature$SHA256");
map.put("Alg.Alias.Signature.1.2.840.113549.1.1.11", "SHA256withRSA");
map.put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.11", "SHA256withRSA");
map.put("Signature.SHA384withRSA", map.put("Signature.SHA384withRSA",
"sun.security.mscapi.RSASignature$SHA384"); "sun.security.mscapi.RSASignature$SHA384");
map.put("Alg.Alias.Signature.1.2.840.113549.1.1.12", "SHA384withRSA");
map.put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.12", "SHA384withRSA");
map.put("Signature.SHA512withRSA", map.put("Signature.SHA512withRSA",
"sun.security.mscapi.RSASignature$SHA512"); "sun.security.mscapi.RSASignature$SHA512");
map.put("Alg.Alias.Signature.1.2.840.113549.1.1.13", "SHA512withRSA");
map.put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.13", "SHA512withRSA");
map.put("Signature.MD5withRSA", map.put("Signature.MD5withRSA",
"sun.security.mscapi.RSASignature$MD5"); "sun.security.mscapi.RSASignature$MD5");
map.put("Signature.MD2withRSA", map.put("Signature.MD2withRSA",
......
...@@ -466,7 +466,17 @@ JNIEXPORT void JNICALL Java_sun_tools_attach_WindowsVirtualMachine_enqueue ...@@ -466,7 +466,17 @@ JNIEXPORT void JNICALL Java_sun_tools_attach_WindowsVirtualMachine_enqueue
} }
CloseHandle(hThread); CloseHandle(hThread);
} else { } else {
JNU_ThrowIOExceptionWithLastError(env, "CreateRemoteThread failed"); if (GetLastError() == ERROR_NOT_ENOUGH_MEMORY) {
//
// This error will occur when attaching to a process belonging to
// another terminal session. See "Remarks":
// http://msdn.microsoft.com/en-us/library/ms682437%28VS.85%29.aspx
//
JNU_ThrowIOException(env,
"Insufficient memory or insufficient privileges to attach");
} else {
JNU_ThrowIOExceptionWithLastError(env, "CreateRemoteThread failed");
}
} }
VirtualFreeEx(hProcess, pCode, 0, MEM_RELEASE); VirtualFreeEx(hProcess, pCode, 0, MEM_RELEASE);
......
/* /*
* Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -58,6 +58,7 @@ public class TestOAEP { ...@@ -58,6 +58,7 @@ public class TestOAEP {
Cipher.getInstance("RSA/ECB/OAEPwithMD5andMGF1Padding"); Cipher.getInstance("RSA/ECB/OAEPwithMD5andMGF1Padding");
Cipher.getInstance("RSA/ECB/OAEPwithSHA1andMGF1Padding"); Cipher.getInstance("RSA/ECB/OAEPwithSHA1andMGF1Padding");
Cipher.getInstance("RSA/ECB/OAEPwithSHA-1andMGF1Padding"); Cipher.getInstance("RSA/ECB/OAEPwithSHA-1andMGF1Padding");
Cipher.getInstance("RSA/ECB/OAEPwithSHA-224andMGF1Padding");
Cipher.getInstance("RSA/ECB/OAEPwithSHA-256andMGF1Padding"); Cipher.getInstance("RSA/ECB/OAEPwithSHA-256andMGF1Padding");
Cipher.getInstance("RSA/ECB/OAEPwithSHA-384andMGF1Padding"); Cipher.getInstance("RSA/ECB/OAEPwithSHA-384andMGF1Padding");
Cipher.getInstance("RSA/ECB/OAEPwithSHA-512andMGF1Padding"); Cipher.getInstance("RSA/ECB/OAEPwithSHA-512andMGF1Padding");
...@@ -88,6 +89,18 @@ public class TestOAEP { ...@@ -88,6 +89,18 @@ public class TestOAEP {
// tests alias works // tests alias works
testEncryptDecrypt("SHA-1", 16); testEncryptDecrypt("SHA-1", 16);
// basic test using SHA-224
testEncryptDecrypt("SHA-224", 0);
testEncryptDecrypt("SHA-224", 16);
testEncryptDecrypt("SHA-224", 38);
try {
testEncryptDecrypt("SHA-224", 39);
throw new Exception("Unexpectedly completed call");
} catch (IllegalBlockSizeException e) {
// ok
System.out.println(e);
}
// basic test using SHA-256 // basic test using SHA-256
testEncryptDecrypt("SHA-256", 0); testEncryptDecrypt("SHA-256", 0);
testEncryptDecrypt("SHA-256", 16); testEncryptDecrypt("SHA-256", 16);
...@@ -195,6 +208,7 @@ public class TestOAEP { ...@@ -195,6 +208,7 @@ public class TestOAEP {
System.out.println("Done (" + (stop - start) + " ms)."); System.out.println("Done (" + (stop - start) + " ms).");
} }
// NOTE: OAEP can process up to (modLen - 2*digestLen - 2) bytes of data
private static void testEncryptDecrypt(String hashAlg, int dataLength) throws Exception { private static void testEncryptDecrypt(String hashAlg, int dataLength) throws Exception {
System.out.println("Testing OAEP with hash " + hashAlg + ", " + dataLength + " bytes"); System.out.println("Testing OAEP with hash " + hashAlg + ", " + dataLength + " bytes");
Cipher c = Cipher.getInstance("RSA/ECB/OAEPwith" + hashAlg + "andMGF1Padding", cp); Cipher c = Cipher.getInstance("RSA/ECB/OAEPwith" + hashAlg + "andMGF1Padding", cp);
......
/* /*
* Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -121,6 +121,7 @@ public class TestOAEPParameterSpec { ...@@ -121,6 +121,7 @@ public class TestOAEPParameterSpec {
public static void main(String[] argv) throws Exception { public static void main(String[] argv) throws Exception {
boolean status = true; boolean status = true;
byte[] p = { (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04 }; byte[] p = { (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04 };
status &= runTest("SHA-224", MGF1ParameterSpec.SHA224, p);
status &= runTest("SHA-256", MGF1ParameterSpec.SHA256, p); status &= runTest("SHA-256", MGF1ParameterSpec.SHA256, p);
status &= runTest("SHA-384", MGF1ParameterSpec.SHA384, p); status &= runTest("SHA-384", MGF1ParameterSpec.SHA384, p);
status &= runTest("SHA-512", MGF1ParameterSpec.SHA512, p); status &= runTest("SHA-512", MGF1ParameterSpec.SHA512, p);
......
/* /*
* Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -47,10 +47,10 @@ public class TestOAEPWithParams { ...@@ -47,10 +47,10 @@ public class TestOAEPWithParams {
private static Random random = new Random(); private static Random random = new Random();
private static String MD[] = { private static String MD[] = {
"MD5", "SHA1", "SHA-256" "MD5", "SHA1", "SHA-224", "SHA-256"
}; };
private static int DATA_LENGTH[] = { private static int DATA_LENGTH[] = {
62, 54, 30 62, 54, 34, 30
}; };
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
/* /*
* @test * @test
* @bug 4628062 * @bug 4628062 4963723
* @summary Verify that AES KeyGenerator supports default initialization * @summary Verify that AES KeyGenerator supports default initialization
* when init is not called * when init is not called
* @author Valerie Peng * @author Valerie Peng
...@@ -34,39 +34,45 @@ import java.util.*; ...@@ -34,39 +34,45 @@ import java.util.*;
public class Test4628062 { public class Test4628062 {
private static final String ALGO = "AES"; private static final int[] AES_SIZES = { 16, 24, 32 }; // in bytes
private static final int[] KEYSIZES = private static final int[] HMACSHA224_SIZES = { 28 };
{ 16, 24, 32 }; // in bytes private static final int[] HMACSHA256_SIZES = { 32 };
private static final int[] HMACSHA384_SIZES = { 48 };
private static final int[] HMACSHA512_SIZES = { 64 };
public boolean execute() throws Exception { public boolean execute(String algo, int[] keySizes) throws Exception {
KeyGenerator kg = KeyGenerator.getInstance(ALGO, "SunJCE"); KeyGenerator kg = KeyGenerator.getInstance(algo, "SunJCE");
// TEST FIX 4628062 // TEST FIX 4628062
Key keyWithDefaultSize = kg.generateKey(); Key keyWithDefaultSize = kg.generateKey();
byte[] encoding = keyWithDefaultSize.getEncoded(); byte[] encoding = keyWithDefaultSize.getEncoded();
if (encoding.length == 0) { int defKeyLen = encoding.length ;
if (defKeyLen == 0) {
throw new Exception("default key length is 0!"); throw new Exception("default key length is 0!");
} else if (defKeyLen != keySizes[0]) {
throw new Exception("default key length mismatch!");
} }
// BONUS TESTS // BONUS TESTS
// 1. call init(int keysize) with various valid key sizes if (keySizes.length > 1) {
// and see if the generated key is the right size. // 1. call init(int keysize) with various valid key sizes
for (int i=0; i<KEYSIZES.length; i++) { // and see if the generated key is the right size.
kg.init(KEYSIZES[i]*8); // in bits for (int i=0; i<keySizes.length; i++) {
Key key = kg.generateKey(); kg.init(keySizes[i]*8); // in bits
if (key.getEncoded().length != KEYSIZES[i]) { Key key = kg.generateKey();
throw new Exception("key is generated with the wrong length!"); if (key.getEncoded().length != keySizes[i]) {
throw new Exception("key is generated with the wrong length!");
}
}
// 2. call init(int keysize) with invalid key size and see
// if the expected InvalidParameterException is thrown.
try {
kg.init(keySizes[0]*8+1);
} catch (InvalidParameterException ex) {
} catch (Exception ex) {
throw new Exception("wrong exception is thrown for invalid key size!");
} }
} }
// 2. call init(int keysize) with invalid key size and see
// if the expected InvalidParameterException is thrown.
try {
kg.init(KEYSIZES[0]*8+1);
} catch (InvalidParameterException ex) {
} catch (Exception ex) {
throw new Exception("wrong exception is thrown for invalid key size!");
}
// passed all tests...hooray! // passed all tests...hooray!
return true; return true;
} }
...@@ -76,8 +82,20 @@ public class Test4628062 { ...@@ -76,8 +82,20 @@ public class Test4628062 {
Test4628062 test = new Test4628062(); Test4628062 test = new Test4628062();
String testName = test.getClass().getName(); String testName = test.getClass().getName();
if (test.execute()) { if (test.execute("AES", AES_SIZES)) {
System.out.println(testName + ": Passed!"); System.out.println(testName + ": AES Passed!");
}
if (test.execute("HmacSHA224", HMACSHA224_SIZES)) {
System.out.println(testName + ": HmacSHA224 Passed!");
}
if (test.execute("HmacSHA256", HMACSHA256_SIZES)) {
System.out.println(testName + ": HmacSHA256 Passed!");
}
if (test.execute("HmacSHA384", HMACSHA384_SIZES)) {
System.out.println(testName + ": HmacSHA384 Passed!");
}
if (test.execute("HmacSHA512", HMACSHA512_SIZES)) {
System.out.println(testName + ": HmacSHA512 Passed!");
} }
} }
} }
...@@ -28,15 +28,33 @@ ...@@ -28,15 +28,33 @@
* @author Jan Luehe * @author Jan Luehe
*/ */
import javax.crypto.*; import javax.crypto.*;
import javax.crypto.spec.SecretKeySpec;
public class MacClone { public class MacClone {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
String[] algos = { "HmacMD5", "HmacSHA1", "HmacSHA224", "HmacSHA256",
"HmacSHA384", "HmacSHA512" };
KeyGenerator kgen = KeyGenerator.getInstance("DES");
SecretKey skey = kgen.generateKey();
for (String algo : algos) {
doTest(algo, skey);
}
String[] algos2 = { "HmacPBESHA1" };
skey = new SecretKeySpec("whatever".getBytes(), "PBE");
for (String algo : algos2) {
doTest(algo, skey);
}
System.out.println("Test Passed");
}
private static void doTest(String algo, SecretKey skey) throws Exception {
// //
// Clone uninitialized Mac object // Clone an uninitialized Mac object
// //
Mac mac = Mac.getInstance("HmacSHA1", "SunJCE"); Mac mac = Mac.getInstance(algo, "SunJCE");
Mac macClone = (Mac)mac.clone(); Mac macClone = (Mac)mac.clone();
System.out.println(macClone.getProvider().toString()); System.out.println(macClone.getProvider().toString());
System.out.println(macClone.getAlgorithm()); System.out.println(macClone.getAlgorithm());
...@@ -51,12 +69,9 @@ public class MacClone { ...@@ -51,12 +69,9 @@ public class MacClone {
} }
// //
// Clone initialized Mac object // Clone an initialized Mac object
// //
KeyGenerator kgen = KeyGenerator.getInstance("DES"); mac = Mac.getInstance(algo, "SunJCE");
SecretKey skey = kgen.generateKey();
mac = Mac.getInstance("HmacSHA1", "SunJCE");
mac.init(skey); mac.init(skey);
macClone = (Mac)mac.clone(); macClone = (Mac)mac.clone();
System.out.println(macClone.getProvider().toString()); System.out.println(macClone.getProvider().toString());
...@@ -66,7 +81,20 @@ public class MacClone { ...@@ -66,7 +81,20 @@ public class MacClone {
byte[] macFinal = mac.doFinal(); byte[] macFinal = mac.doFinal();
byte[] macCloneFinal = macClone.doFinal(); byte[] macCloneFinal = macClone.doFinal();
if (!java.util.Arrays.equals(macFinal, macCloneFinal)) { if (!java.util.Arrays.equals(macFinal, macCloneFinal)) {
throw new Exception("MAC results are different"); throw new Exception("ERROR: MAC result of init clone is different");
} } else System.out.println("MAC check#1 passed");
//
// Clone an updated Mac object
//
mac.update((byte)0x12);
macClone = (Mac)mac.clone();
mac.update((byte)0x34);
macClone.update((byte)0x34);
macFinal = mac.doFinal();
macCloneFinal = macClone.doFinal();
if (!java.util.Arrays.equals(macFinal, macCloneFinal)) {
throw new Exception("ERROR: MAC result of updated clone is different");
} else System.out.println("MAC check#2 passed");
} }
} }
/* /*
* Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
/** /**
* @test * @test
* @bug 4846410 6313661 * @bug 4846410 6313661 4963723
* @summary Basic known-answer-test for Hmac and SslMac algorithms * @summary Basic known-answer-test for Hmac and SslMac algorithms
* @author Andreas Sterbenz * @author Andreas Sterbenz
*/ */
...@@ -147,7 +147,9 @@ public class MacKAT { ...@@ -147,7 +147,9 @@ public class MacKAT {
private static Test t(String alg, String input, String macvalue, String key) { private static Test t(String alg, String input, String macvalue, String key) {
return new MacTest(alg, b(input), b(macvalue), b(key)); return new MacTest(alg, b(input), b(macvalue), b(key));
} }
private static Test t(String alg, String input, String macvalue, byte[] key) {
return new MacTest(alg, b(input), b(macvalue), key);
}
private static Test t(String alg, byte[] input, String macvalue, String key) { private static Test t(String alg, byte[] input, String macvalue, String key) {
return new MacTest(alg, input, b(macvalue), b(key)); return new MacTest(alg, input, b(macvalue), b(key));
} }
...@@ -155,8 +157,8 @@ public class MacKAT { ...@@ -155,8 +157,8 @@ public class MacKAT {
private static Test t(String alg, byte[] input, String macvalue, byte[] key) { private static Test t(String alg, byte[] input, String macvalue, byte[] key) {
return new MacTest(alg, input, b(macvalue), key); return new MacTest(alg, input, b(macvalue), key);
} }
private final static byte[] ALONG, BLONG, BKEY; private final static byte[] ALONG, BLONG, BKEY;
private final static byte[] BKEY_20, DDDATA_50, AAKEY_20, CDDATA_50, AAKEY_131;
static { static {
ALONG = new byte[1024 * 128]; ALONG = new byte[1024 * 128];
...@@ -166,6 +168,16 @@ public class MacKAT { ...@@ -166,6 +168,16 @@ public class MacKAT {
random.nextBytes(BLONG); random.nextBytes(BLONG);
BKEY = new byte[128]; BKEY = new byte[128];
random.nextBytes(BKEY); random.nextBytes(BKEY);
BKEY_20 = new byte[20];
Arrays.fill(BKEY_20, (byte) 0x0b);
DDDATA_50 = new byte[50];
Arrays.fill(DDDATA_50, (byte) 0xdd);
AAKEY_20 = new byte[20];
Arrays.fill(AAKEY_20, (byte) 0xaa);
CDDATA_50 = new byte[50];
Arrays.fill(CDDATA_50, (byte) 0xcd);
AAKEY_131 = new byte[131];
Arrays.fill(AAKEY_131, (byte) 0xaa);
} }
private final static Test[] tests = { private final static Test[] tests = {
...@@ -203,15 +215,24 @@ public class MacKAT { ...@@ -203,15 +215,24 @@ public class MacKAT {
"1b:34:61:29:05:0d:73:db:25:d0:dd:64:06:29:f6:8a"), "1b:34:61:29:05:0d:73:db:25:d0:dd:64:06:29:f6:8a"),
t("HmacSHA512", BLONG, "fb:cf:4b:c6:d5:49:5a:5b:0b:d9:2a:32:f5:fa:68:d2:68:a4:0f:ae:53:fc:49:12:e6:1d:53:cf:b2:cb:c5:c5:f2:2d:86:bd:14:61:30:c3:a6:6f:44:1f:77:9b:aa:a1:22:48:a9:dd:d0:45:86:d1:a1:82:53:13:c4:03:06:a3", t("HmacSHA512", BLONG, "fb:cf:4b:c6:d5:49:5a:5b:0b:d9:2a:32:f5:fa:68:d2:68:a4:0f:ae:53:fc:49:12:e6:1d:53:cf:b2:cb:c5:c5:f2:2d:86:bd:14:61:30:c3:a6:6f:44:1f:77:9b:aa:a1:22:48:a9:dd:d0:45:86:d1:a1:82:53:13:c4:03:06:a3",
BKEY), BKEY),
// Test vectors From RFC4231
t("HmacSHA224", s("Hi There"), "89:6f:b1:12:8a:bb:df:19:68:32:10:7c:d4:9d:f3:3f:47:b4:b1:16:99:12:ba:4f:53:68:4b:22", BKEY_20),
t("HmacSHA224", s("what do ya want for nothing?"), "a3:0e:01:09:8b:c6:db:bf:45:69:0f:3a:7e:9e:6d:0f:8b:be:a2:a3:9e:61:48:00:8f:d0:5e:44", s("Jefe")),
t("HmacSHA224", DDDATA_50, "7f:b3:cb:35:88:c6:c1:f6:ff:a9:69:4d:7d:6a:d2:64:93:65:b0:c1:f6:5d:69:d1:ec:83:33:ea", AAKEY_20),
t("HmacSHA224", CDDATA_50, "6c:11:50:68:74:01:3c:ac:6a:2a:bc:1b:b3:82:62:7c:ec:6a:90:d8:6e:fc:01:2d:e7:af:ec:5a", "01:02:03:04:05:06:07:08:09:0a:0b:0c:0d:0e:0f:10:11:12:13:14:15:16:17:18:19"),
t("HmacSHA224", s("Test Using Larger Than Block-Size Key - Hash Key First"), "95:e9:a0:db:96:20:95:ad:ae:be:9b:2d:6f:0d:bc:e2:d4:99:f1:12:f2:d2:b7:27:3f:a6:87:0e", AAKEY_131),
t("HmacSHA224", s("This is a test using a larger than block-size key and a larger than block-size data. The key needs to be hashed before being used by the HMAC algorithm."), "3a:85:41:66:ac:5d:9f:02:3f:54:d5:17:d0:b3:9d:bd:94:67:70:db:9c:2b:95:c9:f6:f5:65:d1", AAKEY_131),
}; };
static void runTests(Test[] tests) throws Exception { static void runTests(Test[] tests) throws Exception {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
Provider p = Security.getProvider("SunJCE"); Provider p = Security.getProvider("SunJCE");
System.out.println("Testing provider " + p.getName() + "..."); System.out.println("Testing provider " + p.getName() + "...");
Mac.getInstance("HmacSHA224", p);
Mac.getInstance("HmacSHA256", p); Mac.getInstance("HmacSHA256", p);
Mac.getInstance("HmacSHA384", p); Mac.getInstance("HmacSHA384", p);
Mac.getInstance("HmacSHA512", p); Mac.getInstance("HmacSHA512", p);
KeyGenerator.getInstance("HmacSHA224", p);
KeyGenerator.getInstance("HmacSHA256", p); KeyGenerator.getInstance("HmacSHA256", p);
KeyGenerator.getInstance("HmacSHA384", p); KeyGenerator.getInstance("HmacSHA384", p);
KeyGenerator.getInstance("HmacSHA512", p); KeyGenerator.getInstance("HmacSHA512", p);
......
...@@ -540,6 +540,20 @@ public class ZipFSTester { ...@@ -540,6 +540,20 @@ public class ZipFSTester {
bbSrc.flip(); bbSrc.flip();
bbDst.flip(); bbDst.flip();
} }
// Check if source read position is at the end
if (chSrc.position() != chSrc.size()) {
System.out.printf("src[%s]: size=%d, position=%d%n",
chSrc.toString(), chSrc.size(), chSrc.position());
throw new RuntimeException("CHECK FAILED!");
}
// Check if destination read position is at the end
if (chDst.position() != chDst.size()) {
System.out.printf("dst[%s]: size=%d, position=%d%n",
chDst.toString(), chDst.size(), chDst.position());
throw new RuntimeException("CHECK FAILED!");
}
} catch (IOException x) { } catch (IOException x) {
x.printStackTrace(); x.printStackTrace();
} }
...@@ -587,6 +601,20 @@ public class ZipFSTester { ...@@ -587,6 +601,20 @@ public class ZipFSTester {
dstCh.write(bb); dstCh.write(bb);
bb.clear(); bb.clear();
} }
// Check if source read position is at the end
if (srcCh.position() != srcCh.size()) {
System.out.printf("src[%s]: size=%d, position=%d%n",
srcCh.toString(), srcCh.size(), srcCh.position());
throw new RuntimeException("CHECK FAILED!");
}
// Check if destination write position is at the end
if (dstCh.position() != dstCh.size()) {
System.out.printf("dst[%s]: size=%d, position=%d%n",
dstCh.toString(), dstCh.size(), dstCh.position());
throw new RuntimeException("CHECK FAILED!");
}
} }
} }
...@@ -616,10 +644,17 @@ public class ZipFSTester { ...@@ -616,10 +644,17 @@ public class ZipFSTester {
try (SeekableByteChannel sbc = Files.newByteChannel(path)) { try (SeekableByteChannel sbc = Files.newByteChannel(path)) {
System.out.printf(" sbc[0]: pos=%d, size=%d%n", sbc.position(), sbc.size()); System.out.printf(" sbc[0]: pos=%d, size=%d%n", sbc.position(), sbc.size());
if (sbc.position() != 0) {
throw new RuntimeException("CHECK FAILED!");
}
bb = ByteBuffer.allocate((int)sbc.size()); bb = ByteBuffer.allocate((int)sbc.size());
n = sbc.read(bb); n = sbc.read(bb);
System.out.printf(" sbc[1]: read=%d, pos=%d, size=%d%n", System.out.printf(" sbc[1]: read=%d, pos=%d, size=%d%n",
n, sbc.position(), sbc.size()); n, sbc.position(), sbc.size());
if (sbc.position() != sbc.size()) {
throw new RuntimeException("CHECK FAILED!");
}
bb2 = ByteBuffer.allocate((int)sbc.size()); bb2 = ByteBuffer.allocate((int)sbc.size());
} }
...@@ -629,10 +664,16 @@ public class ZipFSTester { ...@@ -629,10 +664,16 @@ public class ZipFSTester {
sbc.position(N); sbc.position(N);
System.out.printf(" sbc[2]: pos=%d, size=%d%n", System.out.printf(" sbc[2]: pos=%d, size=%d%n",
sbc.position(), sbc.size()); sbc.position(), sbc.size());
if (sbc.position() != N) {
throw new RuntimeException("CHECK FAILED!");
}
bb2.limit(100); bb2.limit(100);
n = sbc.read(bb2); n = sbc.read(bb2);
System.out.printf(" sbc[3]: read=%d, pos=%d, size=%d%n", System.out.printf(" sbc[3]: read=%d, pos=%d, size=%d%n",
n, sbc.position(), sbc.size()); n, sbc.position(), sbc.size());
if (n < 0 || sbc.position() != (N + n)) {
throw new RuntimeException("CHECK FAILED!");
}
System.out.printf(" sbc[4]: bb[%d]=%d, bb1[0]=%d%n", System.out.printf(" sbc[4]: bb[%d]=%d, bb1[0]=%d%n",
N, bb.get(N) & 0xff, bb2.get(0) & 0xff); N, bb.get(N) & 0xff, bb2.get(0) & 0xff);
} }
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
# #
# @test # @test
# @bug 6990846 7009092 7009085 7015391 7014948 7005986 7017840 7007596 # @bug 6990846 7009092 7009085 7015391 7014948 7005986 7017840 7007596
# 7157656
# @summary Test ZipFileSystem demo # @summary Test ZipFileSystem demo
# @build Basic PathOps ZipFSTester # @build Basic PathOps ZipFSTester
# @run shell basic.sh # @run shell basic.sh
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
/* /*
* @test * @test
* @bug 6822057 * @bug 6822057 7124400
* *
* @summary Test verifies that list of supported graphics configurations * @summary Test verifies that list of supported graphics configurations
* can not be changed via modification of elements of an array * can not be changed via modification of elements of an array
......
/*
* Copyright (c) 2012 Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Portions Copyright (c) 2012 IBM Corporation
*/
/* @test
* @bug 7163874
* @summary InetAddress.isReachable is returning false
* for InetAdress 0.0.0.0 and ::0
* @run main PingThis
* @run main/othervm -Djava.net.preferIPv4Stack=true PingThis
*/
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
public class PingThis {
private static boolean hasIPv6() throws Exception {
List<NetworkInterface> nics = Collections.list(NetworkInterface
.getNetworkInterfaces());
for (NetworkInterface nic : nics) {
List<InetAddress> addrs = Collections.list(nic.getInetAddresses());
for (InetAddress addr : addrs) {
if (addr instanceof Inet6Address)
return true;
}
}
return false;
}
public static void main(String args[]) throws Exception {
if (System.getProperty("os.name").startsWith("Windows")) {
return;
}
boolean preferIPv4Stack = "true".equals(System
.getProperty("java.net.preferIPv4Stack"));
List<String> addrs = new ArrayList<String>();
InetAddress inetAddress = null;
addrs.add("0.0.0.0");
if (!preferIPv4Stack) {
if (hasIPv6()) {
addrs.add("::0");
}
}
for (String addr : addrs) {
inetAddress = InetAddress.getByName(addr);
System.out.println("The target ip is "
+ inetAddress.getHostAddress());
boolean isReachable = inetAddress.isReachable(3000);
System.out.println("the target is reachable: " + isReachable);
if (isReachable) {
System.out.println("Test passed ");
} else {
System.out.println("Test failed ");
throw new Exception("address " + inetAddress.getHostAddress()
+ " can not be reachable!");
}
}
}
}
...@@ -88,6 +88,11 @@ public class Truncate { ...@@ -88,6 +88,11 @@ public class Truncate {
} }
}; };
Thread t = new Thread(r); Thread t = new Thread(r);
t.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
public void uncaughtException(Thread t, Throwable e) {
e.printStackTrace();
}
});
t.start(); t.start();
try { t.join(); } catch (InterruptedException ignore) { } try { t.join(); } catch (InterruptedException ignore) { }
} }
......
...@@ -53,12 +53,9 @@ public class CheckUsage { ...@@ -53,12 +53,9 @@ public class CheckUsage {
rmidVM.start(); rmidVM.start();
// wait for registry exit // wait for registry exit
int rmidVMExitStatus = rmidVM.getVM().waitFor();
System.err.println("rmid exited with status: " + System.err.println("rmid exited with status: " +
rmidVM.getVM().waitFor()); rmidVMExitStatus);
try {
Thread.sleep(7000);
} catch (InterruptedException ie) {
}
String usage = new String(berr.toByteArray()); String usage = new String(berr.toByteArray());
......
...@@ -63,19 +63,30 @@ public class ActivationLibrary { ...@@ -63,19 +63,30 @@ public class ActivationLibrary {
*/ */
public static void deactivate(Remote remote, public static void deactivate(Remote remote,
ActivationID id) { ActivationID id) {
for (int i = 0; i < 5; i ++) { // We do as much as 50 deactivation trials, each separated by
// at least 100 milliseconds sleep time (max sleep time of 5 secs).
final long deactivateSleepTime = 100;
for (int i = 0; i < 50; i ++) {
try { try {
if (Activatable.inactive(id) == true) { if (Activatable.inactive(id) == true) {
mesg("inactive successful"); mesg("inactive successful");
return; return;
} else { } else {
Thread.sleep(1000); mesg("inactive trial failed. Sleeping " +
deactivateSleepTime +
" milliseconds before next trial");
Thread.sleep(deactivateSleepTime);
} }
} catch (InterruptedException e) { } catch (InterruptedException e) {
continue; Thread.currentThread().interrupt();
mesg("Thread interrupted while trying to deactivate activatable. Exiting deactivation");
return;
} catch (Exception e) { } catch (Exception e) {
try { try {
// forcibly unexport the object // forcibly unexport the object
mesg("Unexpected exception. Have to forcibly unexport the object." +
" Exception was :");
e.printStackTrace();
Activatable.unexportObject(remote, true); Activatable.unexportObject(remote, true);
} catch (NoSuchObjectException ex) { } catch (NoSuchObjectException ex) {
} }
...@@ -99,37 +110,61 @@ public class ActivationLibrary { ...@@ -99,37 +110,61 @@ public class ActivationLibrary {
* activation system. * activation system.
*/ */
public static boolean rmidRunning(int port) { public static boolean rmidRunning(int port) {
int allowedNotReady = 10; int allowedNotReady = 50;
int connectionRefusedExceptions = 0; int connectionRefusedExceptions = 0;
for (int i = 0; i < 15 ; i++) { /* We wait as much as a total of 7.5 secs trying to see Rmid running.
* We do this by pausing steps of 100 milliseconds (so up to 75 steps),
* right after trying to lookup and find RMID running in the other vm.
*/
final long rmidWaitingStepTime = 100;
for (int i = 0; i <= 74; i++) {
try { try {
Thread.sleep(500);
LocateRegistry.getRegistry(port).lookup(SYSTEM_NAME); LocateRegistry.getRegistry(port).lookup(SYSTEM_NAME);
mesg("Activation System available after " +
(i * rmidWaitingStepTime) + " milliseconds");
return true; return true;
} catch (java.rmi.ConnectException e) { } catch (java.rmi.ConnectException e) {
// ignore connect exceptions until we decide rmid is not up mesg("Remote connection refused after " +
(i * rmidWaitingStepTime) + " milliseconds");
// ignore connect exceptions until we decide rmid is not up
if ((connectionRefusedExceptions ++) >= allowedNotReady) { if ((connectionRefusedExceptions ++) >= allowedNotReady) {
return false; return false;
} }
} catch (NotBoundException e) { } catch (java.rmi.NoSuchObjectException nsoe) {
/* Activation System still unavailable.
* Ignore this since we are just waiting for its availibility.
* Just signal unavailibility.
*/
mesg("Activation System still unavailable after more than " +
(i * rmidWaitingStepTime) + " milliseconds");
} catch (NotBoundException e) {
return false; return false;
} catch (Exception e) { } catch (Exception e) {
// print out other types of exceptions as an FYI. /* print out other types of exceptions as an FYI.
// test should not fail as rmid is likely to be in an * test should not fail as rmid is likely to be in an
// undetermined state at this point. * undetermined state at this point.
*/
mesg("caught an exception trying to" + mesg("caught an exception trying to" +
" start rmid, last exception was: " + " start rmid, last exception was: " +
e.getMessage()); e.getMessage());
e.printStackTrace(); e.printStackTrace();
} }
// Waiting for another 100 milliseconds.
try {
Thread.sleep(100);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
mesg("Thread interrupted while checking if Activation System is running. Exiting check");
return false;
}
} }
return false; return false;
} }
......
...@@ -36,7 +36,6 @@ import java.util.StringTokenizer; ...@@ -36,7 +36,6 @@ import java.util.StringTokenizer;
*/ */
public class JavaVM { public class JavaVM {
// need to
protected Process vm = null; protected Process vm = null;
private String classname = ""; private String classname = "";
...@@ -46,6 +45,10 @@ public class JavaVM { ...@@ -46,6 +45,10 @@ public class JavaVM {
private OutputStream errorStream = System.err; private OutputStream errorStream = System.err;
private String policyFileName = null; private String policyFileName = null;
// This is used to shorten waiting time at startup.
private volatile boolean started = false;
private boolean forcesOutput = true; // default behavior
private static void mesg(Object mesg) { private static void mesg(Object mesg) {
System.err.println("JAVAVM: " + mesg.toString()); System.err.println("JAVAVM: " + mesg.toString());
} }
...@@ -79,6 +82,25 @@ public class JavaVM { ...@@ -79,6 +82,25 @@ public class JavaVM {
this.errorStream = err; this.errorStream = err;
} }
/* This constructor will instantiate a JavaVM object for which caller
* can ask for forcing initial version output on child vm process
* (if forcesVersionOutput is true), or letting the started vm behave freely
* (when forcesVersionOutput is false).
*/
public JavaVM(String classname,
String options, String args,
OutputStream out, OutputStream err,
boolean forcesVersionOutput) {
this(classname, options, args, out, err);
this.forcesOutput = forcesVersionOutput;
}
public void setStarted() {
started = true;
}
// Prepends passed opts array to current options
public void addOptions(String[] opts) { public void addOptions(String[] opts) {
String newOpts = ""; String newOpts = "";
for (int i = 0 ; i < opts.length ; i ++) { for (int i = 0 ; i < opts.length ; i ++) {
...@@ -87,6 +109,8 @@ public class JavaVM { ...@@ -87,6 +109,8 @@ public class JavaVM {
newOpts += " "; newOpts += " ";
options = newOpts + options; options = newOpts + options;
} }
// Prepends passed arguments array to current args
public void addArguments(String[] arguments) { public void addArguments(String[] arguments) {
String newArgs = ""; String newArgs = "";
for (int i = 0 ; i < arguments.length ; i ++) { for (int i = 0 ; i < arguments.length ; i ++) {
...@@ -127,6 +151,18 @@ public class JavaVM { ...@@ -127,6 +151,18 @@ public class JavaVM {
addOptions(new String[] { getCodeCoverageOptions() }); addOptions(new String[] { getCodeCoverageOptions() });
/*
* If forcesOutput is true :
* We force the new starting vm to output something so that we can know
* when it is effectively started by redirecting standard output through
* the next StreamPipe call (the vm is considered started when a first
* output has been streamed out).
* We do this by prepnding a "-showversion" option in the command line.
*/
if (forcesOutput) {
addOptions(new String[] {"-showversion"});
}
StringTokenizer optionsTokenizer = new StringTokenizer(options); StringTokenizer optionsTokenizer = new StringTokenizer(options);
StringTokenizer argsTokenizer = new StringTokenizer(args); StringTokenizer argsTokenizer = new StringTokenizer(args);
int optionsCount = optionsTokenizer.countTokens(); int optionsCount = optionsTokenizer.countTokens();
...@@ -150,15 +186,43 @@ public class JavaVM { ...@@ -150,15 +186,43 @@ public class JavaVM {
vm = Runtime.getRuntime().exec(javaCommand); vm = Runtime.getRuntime().exec(javaCommand);
/* output from the execed process may optionally be captured. */ /* output from the execed process may optionally be captured. */
StreamPipe.plugTogether(vm.getInputStream(), this.outputStream); StreamPipe.plugTogether(this, vm.getInputStream(), this.outputStream);
StreamPipe.plugTogether(vm.getErrorStream(), this.errorStream); StreamPipe.plugTogether(this, vm.getErrorStream(), this.errorStream);
try { try {
Thread.sleep(2000); if (forcesOutput) {
} catch (Exception ignore) { // Wait distant vm to start, by using waiting time slices of 100 ms.
// Wait at most for 2secs, after it considers the vm to be started.
final long vmStartSleepTime = 100;
final int maxTrials = 20;
int numTrials = 0;
while (!started && numTrials < maxTrials) {
numTrials++;
Thread.sleep(vmStartSleepTime);
}
// Outputs running status of distant vm
String message =
"after " + (numTrials * vmStartSleepTime) + " milliseconds";
if (started) {
mesg("distant vm process running, " + message);
}
else {
mesg("unknown running status of distant vm process, " + message);
}
}
else {
// Since we have no way to know if the distant vm is started,
// we just consider the vm to be started after a 2secs waiting time.
Thread.sleep(2000);
mesg("distant vm considered to be started after a waiting time of 2 secs");
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
mesg("Thread interrupted while checking if distant vm is started. Giving up check.");
mesg("Distant vm state unknown");
return;
} }
mesg("finished starting vm.");
} }
public void destroy() { public void destroy() {
......
...@@ -218,20 +218,30 @@ public class RMID extends JavaVM { ...@@ -218,20 +218,30 @@ public class RMID extends JavaVM {
} catch (NumberFormatException ignore) {} } catch (NumberFormatException ignore) {}
waitTime = waitTime * slopFactor; waitTime = waitTime * slopFactor;
// give rmid time to come up // We check several times (as many as provides passed waitTime) to
// see if Rmid is currently running. Waiting steps last 100 msecs.
final long rmidStartSleepTime = 100;
do { do {
// Sleeping for another rmidStartSleepTime time slice.
try { try {
Thread.sleep(Math.min(waitTime, 10000)); Thread.sleep(Math.min(waitTime, rmidStartSleepTime));
} catch (InterruptedException ie) { } catch (InterruptedException ie) {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
mesg("Thread interrupted while checking for start of Activation System. Giving up check.");
mesg("Activation System state unknown");
return;
} }
waitTime -= 10000; waitTime -= rmidStartSleepTime;
// is rmid present? // Checking if rmid is present
if (ActivationLibrary.rmidRunning(port)) { if (ActivationLibrary.rmidRunning(port)) {
mesg("finished starting rmid."); mesg("finished starting rmid.");
return; return;
} }
else {
mesg("rmid still not started");
}
} while (waitTime > 0); } while (waitTime > 0);
TestLibrary.bomb("start rmid failed... giving up", null); TestLibrary.bomb("start rmid failed... giving up", null);
} }
...@@ -264,6 +274,8 @@ public class RMID extends JavaVM { ...@@ -264,6 +274,8 @@ public class RMID extends JavaVM {
port + port +
"/java.rmi.activation.ActivationSystem"); "/java.rmi.activation.ActivationSystem");
mesg("obtained a reference to the activation system"); mesg("obtained a reference to the activation system");
} catch (RemoteException re) {
mesg("could not contact registry while trying to shutdown activation system");
} catch (java.net.MalformedURLException mue) { } catch (java.net.MalformedURLException mue) {
} }
...@@ -272,19 +284,14 @@ public class RMID extends JavaVM { ...@@ -272,19 +284,14 @@ public class RMID extends JavaVM {
} }
system.shutdown(); system.shutdown();
} catch (RemoteException re) {
mesg("shutting down the activation daemon failed");
} catch (Exception e) { } catch (Exception e) {
mesg("caught exception trying to shutdown rmid"); mesg("caught exception trying to shutdown rmid");
mesg(e.getMessage()); mesg(e.getMessage());
e.printStackTrace(); e.printStackTrace();
} }
try {
// wait for the shutdown to happen
Thread.sleep(5000);
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
}
mesg("testlibrary finished shutting down rmid"); mesg("testlibrary finished shutting down rmid");
} }
...@@ -301,18 +308,47 @@ public class RMID extends JavaVM { ...@@ -301,18 +308,47 @@ public class RMID extends JavaVM {
if (vm != null) { if (vm != null) {
try { try {
// destroy rmid if it is still running... /* Waiting for distant RMID process to shutdown.
try { * Waiting is bounded at a hardcoded max of 60 secs (1 min).
vm.exitValue(); * Waiting by steps of 200 msecs, thus at most 300 such attempts
mesg("rmid exited on shutdown request"); * for termination of distant RMID process. If process is not
} catch (IllegalThreadStateException illegal) { * known to be terminated properly after that time,
mesg("Had to destroy RMID's process " + * we give up for a gracefull termination, and thus go for
"using Process.destroy()"); * forcibly destroying the process.
*/
boolean vmEnded = false;
int waitingTrials = 0;
final int maxTrials = 300;
final long vmProcessEndWaitInterval = 200;
int vmExitValue;
do {
try {
Thread.sleep(vmProcessEndWaitInterval);
waitingTrials++;
vmExitValue = vm.exitValue();
mesg("rmid exited on shutdown request");
vmEnded = true;
} catch (IllegalThreadStateException illegal) {
mesg("RMID's process still not terminated after more than " +
(waitingTrials * vmProcessEndWaitInterval) + " milliseconds");
}
}
while (!vmEnded &&
(waitingTrials < maxTrials));
if (waitingTrials >= maxTrials) {
mesg("RMID's process still not terminated after more than " +
(waitingTrials * vmProcessEndWaitInterval) + " milliseconds." +
"Givinp up gracefull termination...");
mesg("destroying RMID's process using Process.destroy()");
super.destroy(); super.destroy();
} }
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
mesg("Thread interrupted while checking for termination of distant rmid vm. Giving up check.");
} catch (Exception e) { } catch (Exception e) {
mesg("caught exception trying to destroy rmid: " + mesg("caught unexpected exception trying to destroy rmid: " +
e.getMessage()); e.getMessage());
e.printStackTrace(); e.printStackTrace();
} }
......
...@@ -35,46 +35,89 @@ public class StreamPipe extends Thread { ...@@ -35,46 +35,89 @@ public class StreamPipe extends Thread {
private InputStream in; private InputStream in;
private OutputStream out; private OutputStream out;
private String preamble; private String preamble;
private JavaVM javaVM;
private static Object lock = new Object(); private static Object lock = new Object();
private static int count = 0; private static int count = 0;
public StreamPipe(InputStream in, OutputStream out, String name) {
/* StreamPipe constructor : should only be called by plugTogether() method !!
* If passed vm is not null :
* - This is StreamPipe usage when streams to pipe come from a given
* vm (JavaVM) process (the vm process must be started with a prefixed
* "-showversion" option to be able to determine as soon as possible when
* the vm process is started through the redirection of the streams).
* There must be a close connection between the StreamPipe instance and
* the JavaVM object on which a start() call has been done.
* run() method will flag distant JavaVM as started.
* If passed vm is null :
* - We don't have control on the process which we want to redirect the passed
* streams.
* run() method will ignore distant process.
*/
private StreamPipe(JavaVM vm, InputStream in, OutputStream out, String name) {
super(name); super(name);
this.in = in; this.in = in;
this.out = out; this.out = out;
this.preamble = "# "; this.preamble = "# ";
this.javaVM = vm;
}
// Install redirection of passed InputStream and OutputStream from passed JavaVM
// to this vm standard output and input streams.
public static void plugTogether(JavaVM vm, InputStream in, OutputStream out) {
String name = null;
synchronized (lock) {
name = "TestLibrary: StreamPipe-" + (count ++ );
}
Thread pipe = new StreamPipe(vm, in, out, name);
pipe.setDaemon(true);
pipe.start();
}
/* Redirects the InputStream and OutputStream passed by caller to this
* vm standard output and input streams.
* (we just have to use fully parametered plugTogether() call with a null
* JavaVM input to do this).
*/
public static void plugTogether(InputStream in, OutputStream out) {
plugTogether(null, in, out);
} }
// Starts redirection of streams.
public void run() { public void run() {
BufferedReader r = new BufferedReader(new InputStreamReader(in), 1); BufferedReader r = new BufferedReader(new InputStreamReader(in), 1);
BufferedWriter w = new BufferedWriter(new OutputStreamWriter(out)); BufferedWriter w = new BufferedWriter(new OutputStreamWriter(out));
byte[] buf = new byte[256]; byte[] buf = new byte[256];
boolean bol = true; // beginning-of-line
int count;
try { try {
String line; String line;
while ((line = r.readLine()) != null) {
/* This is to check that the distant vm has started,
* if such a vm has been provided at construction :
* - As soon as we can read something from r BufferedReader,
* that means the distant vm is already started.
* Thus we signal associated JavaVM object that it is now started.
*/
if (((line = r.readLine()) != null) &&
(javaVM != null)) {
javaVM.setStarted();
}
// Redirects r on w.
while (line != null) {
w.write(preamble); w.write(preamble);
w.write(line); w.write(line);
w.newLine(); w.newLine();
w.flush(); w.flush();
line = r.readLine();
} }
} catch (IOException e) { } catch (IOException e) {
System.err.println("*** IOException in StreamPipe.run:"); System.err.println("*** IOException in StreamPipe.run:");
e.printStackTrace(); e.printStackTrace();
} }
} }
public static void plugTogether(InputStream in, OutputStream out) {
String name = null;
synchronized (lock) {
name = "TestLibrary: StreamPipe-" + (count ++ );
}
Thread pipe = new StreamPipe(in, out, name);
pipe.setDaemon(true);
pipe.start();
}
} }
...@@ -58,6 +58,12 @@ public class UUIDTest { ...@@ -58,6 +58,12 @@ public class UUIDTest {
List list = new LinkedList(); List list = new LinkedList();
for (int i=0; i<100; i++) { for (int i=0; i<100; i++) {
UUID u1 = UUID.randomUUID(); UUID u1 = UUID.randomUUID();
if (4 != u1.version()) {
throw new Exception("bad version");
}
if (2 != u1.variant()) {
throw new Exception("bad variant");
}
if (list.contains(u1)) if (list.contains(u1))
throw new Exception("random UUID collision very unlikely"); throw new Exception("random UUID collision very unlikely");
list.add(u1); list.add(u1);
...@@ -70,10 +76,16 @@ public class UUIDTest { ...@@ -70,10 +76,16 @@ public class UUIDTest {
List list = new LinkedList(); List list = new LinkedList();
for (int i=0; i<100; i++) { for (int i=0; i<100; i++) {
byteSource.nextBytes(someBytes); byteSource.nextBytes(someBytes);
UUID test = UUID.nameUUIDFromBytes(someBytes); UUID u1 = UUID.nameUUIDFromBytes(someBytes);
if (list.contains(test)) if (3 != u1.version()) {
throw new Exception("bad version");
}
if (2 != u1.variant()) {
throw new Exception("bad variant");
}
if (list.contains(u1))
throw new Exception("byte UUID collision very unlikely"); throw new Exception("byte UUID collision very unlikely");
list.add(test); list.add(u1);
} }
} }
......
/*
* Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 7103570
* @author David Holmes
* @run main/othervm AtomicUpdaters
* @run main/othervm AtomicUpdaters UseSM
* @summary Checks the (in)ability to create field updaters for differently
* accessible fields in different locations with/without a security
* manager
*/
import java.util.concurrent.atomic.*;
import java.lang.reflect.*;
import java.security.AccessControlException;
public class AtomicUpdaters {
enum TYPE { INT, LONG, REF }
static class Config {
final Class<?> clazz;
final String field;
final String access;
final boolean reflectOk;
final boolean updaterOk;
final String desc;
final TYPE type;
Config(Class<?> clazz, String field, String access,
boolean reflectOk, boolean updaterOk, String desc, TYPE type) {
this.clazz = clazz;
this.field = field;
this.access = access;
this.reflectOk = reflectOk;
this.updaterOk = updaterOk;
this.desc = desc;
this.type =type;
}
public String toString() {
return desc + ": " + access + " " + clazz.getName() + "." + field;
}
}
static Config[] tests;
static void initTests(boolean hasSM) {
tests = new Config[] {
new Config(AtomicUpdaters.class, "pub_int", "public", true, true, "public int field of current class", TYPE.INT),
new Config(AtomicUpdaters.class, "priv_int", "private", true, true, "private int field of current class", TYPE.INT),
new Config(AtomicUpdaters.class, "pub_long", "public", true, true, "public long field of current class", TYPE.LONG),
new Config(AtomicUpdaters.class, "priv_long", "private", true, true, "private long field of current class", TYPE.LONG),
new Config(AtomicUpdaters.class, "pub_ref", "public", true, true, "public ref field of current class", TYPE.REF),
new Config(AtomicUpdaters.class, "priv_ref", "private", true, true, "private ref field of current class", TYPE.REF),
// Would like to test a public volatile in a class in another
// package - but of course there aren't any
new Config(java.util.concurrent.atomic.AtomicInteger.class, "value", "private", hasSM ? false : true, false, "private int field of class in different package", TYPE.INT),
new Config(java.util.concurrent.atomic.AtomicLong.class, "value", "private", hasSM ? false : true, false, "private long field of class in different package", TYPE.LONG),
new Config(java.util.concurrent.atomic.AtomicReference.class, "value", "private", hasSM ? false : true, false, "private reference field of class in different package", TYPE.REF),
};
}
public volatile int pub_int;
private volatile int priv_int;
public volatile long pub_long;
private volatile long priv_long;
public volatile Object pub_ref;
private volatile Object priv_ref;
// This should be set dynamically at runtime using a System property, but
// ironically we get a SecurityException if we try to do that with a
// SecurityManager installed
static boolean verbose;
public static void main(String[] args) throws Throwable {
boolean hasSM = false;
for (String arg : args) {
if ("-v".equals(arg)) {
verbose = true;
}
else if ("UseSM".equals(arg)) {
SecurityManager m = System.getSecurityManager();
if (m != null)
throw new RuntimeException("No security manager should initially be installed");
System.setSecurityManager(new java.lang.SecurityManager());
hasSM = true;
}
else {
throw new IllegalArgumentException("Unexpected option: " + arg);
}
}
initTests(hasSM);
int failures = 0;
System.out.printf("Testing with%s a SecurityManager present\n", hasSM ? "" : "out");
for (Config c : tests) {
System.out.println("Testing: " + c);
Error reflectionFailure = null;
Error updaterFailure = null;
Class<?> clazz = c.clazz;
// See if we can reflectively access the field
System.out.println(" - testing getDeclaredField");
try {
Field f = clazz.getDeclaredField(c.field);
if (!c.reflectOk)
reflectionFailure = new Error("Unexpected reflective access: " + c);
}
catch (AccessControlException e) {
if (c.reflectOk)
reflectionFailure = new Error("Unexpected reflective access failure: " + c, e);
else if (verbose) {
System.out.println("Got expected reflection exception: " + e);
e.printStackTrace(System.out);
}
}
if (reflectionFailure != null) {
reflectionFailure.printStackTrace(System.out);
}
// see if we can create an atomic updater for the field
Object u = null;
try {
switch (c.type) {
case INT:
System.out.println(" - testing AtomicIntegerFieldUpdater");
u = AtomicIntegerFieldUpdater.newUpdater(clazz, c.field);
break;
case LONG:
System.out.println(" - testing AtomicLongFieldUpdater");
u = AtomicLongFieldUpdater.newUpdater(clazz, c.field);
break;
case REF:
System.out.println(" - testing AtomicReferenceFieldUpdater");
u = AtomicReferenceFieldUpdater.newUpdater(clazz, Object.class, c.field);
break;
}
if (!c.updaterOk)
updaterFailure = new Error("Unexpected updater access: " + c);
}
catch (Exception e) {
if (c.updaterOk)
updaterFailure = new Error("Unexpected updater access failure: " + c, e);
else if (verbose) {
System.out.println("Got expected updater exception: " + e);
e.printStackTrace(System.out);
}
}
if (updaterFailure != null) {
updaterFailure.printStackTrace(System.out);
}
if (updaterFailure != null || reflectionFailure != null) {
failures++;
}
}
if (failures > 0) {
throw new Error("Some tests failed - see previous stacktraces");
}
}
}
...@@ -22,23 +22,77 @@ ...@@ -22,23 +22,77 @@
*/ */
/* @test /* @test
* @bug 7160242 * @bug 7160242 7165118
* @summary Check if NullPointerException is thrown if the key passed * @summary Check if NullPointerException is thrown if the key passed
* to remove() is null. * to remove() is null.
*/ */
import java.util.prefs.Preferences; import java.util.prefs.Preferences;
import java.util.prefs.AbstractPreferences;
import java.util.prefs.BackingStoreException;
public class RemoveNullKeyCheck { public class RemoveNullKeyCheck {
private static boolean failed = false;
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
try { checkPreferencesRemove();
Preferences node = Preferences.userRoot().node("N1"); checkAbstractPreferencesRemove();
node.remove(null); if (failed) {
throw new RuntimeException("Expected NullPointerException " + throw new RuntimeException("Expected NullPointerException " +
"not thrown"); "not thrown");
} catch (NullPointerException npe) { }
System.out.println("NullPointerException thrown"); }
}
public static void checkPreferencesRemove() {
try {
Preferences node = Preferences.userRoot().node("N1");
node.remove(null);
failed = true;
} catch (NullPointerException npe) {
}
}
public static void checkAbstractPreferencesRemove() {
Preferences abstrPrefs = new AbstractPreferences(null, "") {
@Override
protected void putSpi(String key, String value) {
}
@Override
protected String getSpi(String key) {
return null;
}
@Override
protected void removeSpi(String key) {
}
@Override
protected void removeNodeSpi() throws BackingStoreException {
}
@Override
protected String[] keysSpi() throws BackingStoreException {
return new String[0];
}
@Override
protected String[] childrenNamesSpi() throws BackingStoreException {
return new String[0];
}
@Override
protected AbstractPreferences childSpi(String name) {
return null;
}
@Override
protected void syncSpi() throws BackingStoreException {
}
@Override
protected void flushSpi() throws BackingStoreException {
}
};
try {
abstrPrefs.remove(null);
failed = true;
} catch(NullPointerException npe) {
}
} }
} }
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
* 5013885 5003322 4988891 5098443 5110268 6173522 4829857 5027748 6376940 * 5013885 5003322 4988891 5098443 5110268 6173522 4829857 5027748 6376940
* 6358731 6178785 6284152 6231989 6497148 6486934 6233084 6504326 6635133 * 6358731 6178785 6284152 6231989 6497148 6486934 6233084 6504326 6635133
* 6350801 6676425 6878475 6919132 6931676 6948903 6990617 7014645 7039066 * 6350801 6676425 6878475 6919132 6931676 6948903 6990617 7014645 7039066
* 7067045 * 7067045 7014640
*/ */
import java.util.regex.*; import java.util.regex.*;
...@@ -141,6 +141,8 @@ public class RegExTest { ...@@ -141,6 +141,8 @@ public class RegExTest {
unicodePropertiesTest(); unicodePropertiesTest();
unicodeHexNotationTest(); unicodeHexNotationTest();
unicodeClassesTest(); unicodeClassesTest();
horizontalAndVerticalWSTest();
linebreakTest();
if (failure) { if (failure) {
throw new throw new
RuntimeException("RegExTest failed, 1st failure: " + RuntimeException("RegExTest failed, 1st failure: " +
...@@ -857,13 +859,18 @@ public class RegExTest { ...@@ -857,13 +859,18 @@ public class RegExTest {
// in replacement string // in replacement string
try { try {
"\uac00".replaceAll("\uac00", "$"); "\uac00".replaceAll("\uac00", "$");
failCount++;
} catch (IllegalArgumentException iie) {
} catch (Exception e) {
failCount++;
}
try {
"\uac00".replaceAll("\uac00", "\\"); "\uac00".replaceAll("\uac00", "\\");
failCount++; failCount++;
} catch (IllegalArgumentException iie) { } catch (IllegalArgumentException iie) {
} catch (Exception e) { } catch (Exception e) {
failCount++; failCount++;
} }
report("Literal replacement"); report("Literal replacement");
} }
...@@ -3838,4 +3845,77 @@ public class RegExTest { ...@@ -3838,4 +3845,77 @@ public class RegExTest {
failCount++; failCount++;
report("unicodePredefinedClasses"); report("unicodePredefinedClasses");
} }
private static void horizontalAndVerticalWSTest() throws Exception {
String hws = new String (new char[] {
0x09, 0x20, 0xa0, 0x1680, 0x180e,
0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005,
0x2006, 0x2007, 0x2008, 0x2009, 0x200a,
0x202f, 0x205f, 0x3000 });
String vws = new String (new char[] {
0x0a, 0x0b, 0x0c, 0x0d, 0x85, 0x2028, 0x2029 });
if (!Pattern.compile("\\h+").matcher(hws).matches() ||
!Pattern.compile("[\\h]+").matcher(hws).matches())
failCount++;
if (Pattern.compile("\\H").matcher(hws).find() ||
Pattern.compile("[\\H]").matcher(hws).find())
failCount++;
if (!Pattern.compile("\\v+").matcher(vws).matches() ||
!Pattern.compile("[\\v]+").matcher(vws).matches())
failCount++;
if (Pattern.compile("\\V").matcher(vws).find() ||
Pattern.compile("[\\V]").matcher(vws).find())
failCount++;
String prefix = "abcd";
String suffix = "efgh";
String ng = "A";
for (int i = 0; i < hws.length(); i++) {
String c = String.valueOf(hws.charAt(i));
Matcher m = Pattern.compile("\\h").matcher(prefix + c + suffix);
if (!m.find() || !c.equals(m.group()))
failCount++;
m = Pattern.compile("[\\h]").matcher(prefix + c + suffix);
if (!m.find() || !c.equals(m.group()))
failCount++;
m = Pattern.compile("\\H").matcher(hws.substring(0, i) + ng + hws.substring(i));
if (!m.find() || !ng.equals(m.group()))
failCount++;
m = Pattern.compile("[\\H]").matcher(hws.substring(0, i) + ng + hws.substring(i));
if (!m.find() || !ng.equals(m.group()))
failCount++;
}
for (int i = 0; i < vws.length(); i++) {
String c = String.valueOf(vws.charAt(i));
Matcher m = Pattern.compile("\\v").matcher(prefix + c + suffix);
if (!m.find() || !c.equals(m.group()))
failCount++;
m = Pattern.compile("[\\v]").matcher(prefix + c + suffix);
if (!m.find() || !c.equals(m.group()))
failCount++;
m = Pattern.compile("\\V").matcher(vws.substring(0, i) + ng + vws.substring(i));
if (!m.find() || !ng.equals(m.group()))
failCount++;
m = Pattern.compile("[\\V]").matcher(vws.substring(0, i) + ng + vws.substring(i));
if (!m.find() || !ng.equals(m.group()))
failCount++;
}
// \v in range is interpreted as 0x0B. This is the undocumented behavior
if (!Pattern.compile("[\\v-\\v]").matcher(String.valueOf((char)0x0B)).matches())
failCount++;
report("horizontalAndVerticalWSTest");
}
private static void linebreakTest() throws Exception {
String linebreaks = new String (new char[] {
0x0A, 0x0B, 0x0C, 0x0D, 0x85, 0x2028, 0x2029 });
String crnl = "\r\n";
if (!Pattern.compile("\\R+").matcher(linebreaks).matches() ||
!Pattern.compile("\\R").matcher(crnl).matches() ||
Pattern.compile("\\R\\R").matcher(crnl).matches())
failCount++;
report("linebreakTest");
}
} }
/*
* Copyright (c) 2012 Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Portions Copyright (c) 2012 IBM Corporation
*/
/**
* @test
* @bug 7164191
* @summary properties.putAll API may fail with ConcurrentModifcationException on multi-thread scenario
* @author Deven You
*/
import java.util.Properties;
import sun.management.Agent;
public class AgentCMETest {
static Class<?> agentClass;
/**
* In sun.management.Agent.loadManagementProperties(), call
* properties.putAll API may fail with ConcurrentModifcationException if the
* system properties are modified simultaneously by another thread
*
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
System.out.println("Start...");
final Properties properties = System.getProperties();
Thread t1 = new Thread(new Runnable() {
public void run() {
for (int i = 0; i < 100; i++) {
properties.put(String.valueOf(i), "");
try {
Thread.sleep(1);
} catch (InterruptedException e) {
// do nothing
}
}
}
});
t1.start();
for (int i = 0; i < 10000; i++) {
Agent.loadManagementProperties();
}
System.out.println("Finished...");
}
}
...@@ -60,9 +60,12 @@ public class NoConsoleOutput { ...@@ -60,9 +60,12 @@ public class NoConsoleOutput {
File.separatorChar + "logging.properties"; File.separatorChar + "logging.properties";
ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayOutputStream out = new ByteArrayOutputStream();
ByteArrayOutputStream err = new ByteArrayOutputStream(); ByteArrayOutputStream err = new ByteArrayOutputStream();
// We instantiate a JavaVM that should not produce any console output
// (neither on standard output, nor on standard err streams).
JavaVM vm = new JavaVM(DoRMIStuff.class.getName(), JavaVM vm = new JavaVM(DoRMIStuff.class.getName(),
"-Djava.util.logging.config.file=" + loggingPropertiesFile, "-Djava.util.logging.config.file=" + loggingPropertiesFile,
"", out, err); "", out, err, false);
vm.start(); vm.start();
vm.getVM().waitFor(); vm.getVM().waitFor();
......
...@@ -53,6 +53,9 @@ public class SSL { ...@@ -53,6 +53,9 @@ public class SSL {
private static volatile String server; private static volatile String server;
private static volatile int port; private static volatile int port;
// 0-Not started, 1-Start OK, 2-Failure
private static volatile int serverState = 0;
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
krb5Cipher = args[0]; krb5Cipher = args[0];
...@@ -109,14 +112,20 @@ public class SSL { ...@@ -109,14 +112,20 @@ public class SSL {
s.doAs(new JsseServerAction(), null); s.doAs(new JsseServerAction(), null);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
serverState = 2;
} }
} }
}); });
server.setDaemon(true); server.setDaemon(true);
server.start(); server.start();
// Warm the server while (serverState == 0) {
Thread.sleep(2000); Thread.sleep(50);
}
if (serverState == 2) {
throw new Exception("Server already failed");
}
// Now create the keytab // Now create the keytab
...@@ -214,6 +223,7 @@ public class SSL { ...@@ -214,6 +223,7 @@ public class SSL {
(SSLServerSocket) sslssf.createServerSocket(0); // any port (SSLServerSocket) sslssf.createServerSocket(0); // any port
port = sslServerSocket.getLocalPort(); port = sslServerSocket.getLocalPort();
System.out.println("Listening on " + port); System.out.println("Listening on " + port);
serverState = 1;
// Enable only a KRB5 cipher suite. // Enable only a KRB5 cipher suite.
String enabledSuites[] = {krb5Cipher}; String enabledSuites[] = {krb5Cipher};
......
...@@ -46,11 +46,20 @@ if [ "${TESTJAVA}" = "" ] ; then ...@@ -46,11 +46,20 @@ if [ "${TESTJAVA}" = "" ] ; then
fi fi
OS=`uname -s` OS=`uname -s`
case "$OS" in
SunOS | Linux | Darwin | CYGWIN* )
FS="/"
;;
Windows_* )
FS="\\"
;;
esac
case "$OS" in case "$OS" in
Windows* | CYGWIN* ) Windows* | CYGWIN* )
echo "Creating a temporary RSA keypair in the Windows-My store..." echo "Creating a temporary RSA keypair in the Windows-My store..."
${TESTJAVA}/bin/keytool \ ${TESTJAVA}${FS}bin${FS}keytool \
-genkeypair \ -genkeypair \
-storetype Windows-My \ -storetype Windows-My \
-keyalg RSA \ -keyalg RSA \
...@@ -59,22 +68,28 @@ case "$OS" in ...@@ -59,22 +68,28 @@ case "$OS" in
-dname "cn=localhost,c=US" \ -dname "cn=localhost,c=US" \
-noprompt -noprompt
if [ "$?" -ne "0" ]; then
echo "Unable to generate key pair in Windows-My keystore"
exit 1
fi
echo echo
echo "Running the test..." echo "Running the test..."
${TESTJAVA}/bin/javac -d . ${TESTSRC}\\ShortRSAKeyWithinTLS.java ${TESTJAVA}${FS}bin${FS}javac -d . \
${TESTJAVA}/bin/java ShortRSAKeyWithinTLS 7106773.1024 1024 \ ${TESTSRC}${FS}ShortRSAKeyWithinTLS.java
${TESTJAVA}${FS}bin${FS}java ShortRSAKeyWithinTLS 7106773.1024 1024 \
TLSv1.2 TLS_DHE_RSA_WITH_AES_128_CBC_SHA TLSv1.2 TLS_DHE_RSA_WITH_AES_128_CBC_SHA
rc=$? rc=$?
echo echo
echo "Removing the temporary RSA keypair from the Windows-My store..." echo "Removing the temporary RSA keypair from the Windows-My store..."
${TESTJAVA}/bin/keytool \ ${TESTJAVA}${FS}bin${FS}keytool \
-delete \ -delete \
-storetype Windows-My \ -storetype Windows-My \
-alias 7106773.1024 -alias 7106773.1024
echo done. echo "Done".
exit $rc exit $rc
;; ;;
......
...@@ -46,11 +46,20 @@ if [ "${TESTJAVA}" = "" ] ; then ...@@ -46,11 +46,20 @@ if [ "${TESTJAVA}" = "" ] ; then
fi fi
OS=`uname -s` OS=`uname -s`
case "$OS" in
SunOS | Linux | Darwin | CYGWIN* )
FS="/"
;;
Windows_* )
FS="\\"
;;
esac
case "$OS" in case "$OS" in
Windows* | CYGWIN* ) Windows* | CYGWIN* )
echo "Creating a temporary RSA keypair in the Windows-My store..." echo "Creating a temporary RSA keypair in the Windows-My store..."
${TESTJAVA}/bin/keytool \ ${TESTJAVA}${FS}bin${FS}keytool \
-genkeypair \ -genkeypair \
-storetype Windows-My \ -storetype Windows-My \
-keyalg RSA \ -keyalg RSA \
...@@ -59,10 +68,16 @@ case "$OS" in ...@@ -59,10 +68,16 @@ case "$OS" in
-dname "cn=localhost,c=US" \ -dname "cn=localhost,c=US" \
-noprompt -noprompt
if [ "$?" -ne "0" ]; then
echo "Unable to generate key pair in Windows-My keystore"
exit 1
fi
echo echo
echo "Running the test..." echo "Running the test..."
${TESTJAVA}/bin/javac -d . ${TESTSRC}\\ShortRSAKeyWithinTLS.java ${TESTJAVA}${FS}bin${FS}javac -d . \
${TESTJAVA}/bin/java ShortRSAKeyWithinTLS 7106773.512 512 \ ${TESTSRC}${FS}ShortRSAKeyWithinTLS.java
${TESTJAVA}${FS}bin${FS}java ShortRSAKeyWithinTLS 7106773.512 512 \
TLSv1.2 TLS_DHE_RSA_WITH_AES_128_CBC_SHA TLSv1.2 TLS_DHE_RSA_WITH_AES_128_CBC_SHA
...@@ -70,12 +85,12 @@ case "$OS" in ...@@ -70,12 +85,12 @@ case "$OS" in
echo echo
echo "Removing the temporary RSA keypair from the Windows-My store..." echo "Removing the temporary RSA keypair from the Windows-My store..."
${TESTJAVA}/bin/keytool \ ${TESTJAVA}${FS}bin${FS}keytool \
-delete \ -delete \
-storetype Windows-My \ -storetype Windows-My \
-alias 7106773.512 -alias 7106773.512
echo done. echo "Done".
exit $rc exit $rc
;; ;;
......
...@@ -46,11 +46,20 @@ if [ "${TESTJAVA}" = "" ] ; then ...@@ -46,11 +46,20 @@ if [ "${TESTJAVA}" = "" ] ; then
fi fi
OS=`uname -s` OS=`uname -s`
case "$OS" in
SunOS | Linux | Darwin | CYGWIN* )
FS="/"
;;
Windows_* )
FS="\\"
;;
esac
case "$OS" in case "$OS" in
Windows* | CYGWIN* ) Windows* | CYGWIN* )
echo "Creating a temporary RSA keypair in the Windows-My store..." echo "Creating a temporary RSA keypair in the Windows-My store..."
${TESTJAVA}/bin/keytool \ ${TESTJAVA}${FS}bin${FS}keytool \
-genkeypair \ -genkeypair \
-storetype Windows-My \ -storetype Windows-My \
-keyalg RSA \ -keyalg RSA \
...@@ -59,22 +68,28 @@ case "$OS" in ...@@ -59,22 +68,28 @@ case "$OS" in
-dname "cn=localhost,c=US" \ -dname "cn=localhost,c=US" \
-noprompt -noprompt
if [ "$?" -ne "0" ]; then
echo "Unable to generate key pair in Windows-My keystore"
exit 1
fi
echo echo
echo "Running the test..." echo "Running the test..."
${TESTJAVA}/bin/javac -d . ${TESTSRC}\\ShortRSAKeyWithinTLS.java ${TESTJAVA}${FS}bin${FS}javac -d . \
${TESTJAVA}/bin/java ShortRSAKeyWithinTLS 7106773.768 768 \ ${TESTSRC}${FS}ShortRSAKeyWithinTLS.java
${TESTJAVA}${FS}bin${FS}java ShortRSAKeyWithinTLS 7106773.768 768 \
TLSv1.2 TLS_DHE_RSA_WITH_AES_128_CBC_SHA TLSv1.2 TLS_DHE_RSA_WITH_AES_128_CBC_SHA
rc=$? rc=$?
echo echo
echo "Removing the temporary RSA keypair from the Windows-My store..." echo "Removing the temporary RSA keypair from the Windows-My store..."
${TESTJAVA}/bin/keytool \ ${TESTJAVA}${FS}bin${FS}keytool \
-delete \ -delete \
-storetype Windows-My \ -storetype Windows-My \
-alias 7106773.768 -alias 7106773.768
echo done. echo "Done".
exit $rc exit $rc
;; ;;
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册