diff options
author | mark <mark@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-08-14 23:12:35 +0000 |
---|---|---|
committer | mark <mark@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-08-14 23:12:35 +0000 |
commit | ffde862e033a0825e1e9972a89c0f1f80b261a8e (patch) | |
tree | 97037d2c09c8384d80531f67ec36a01205df6bdb /libjava/classpath/tools | |
parent | b415ff10527e977c3758234fd930e2c027bfa17d (diff) | |
download | gcc-ffde862e033a0825e1e9972a89c0f1f80b261a8e.tar.gz |
2006-08-14 Mark Wielaard <mark@klomp.org>
Imported GNU Classpath 0.92
* HACKING: Add more importing hints. Update automake version
requirement.
* configure.ac (gconf-peer): New enable AC argument.
Add --disable-gconf-peer and --enable-default-preferences-peer
to classpath configure when gconf is disabled.
* scripts/makemake.tcl: Set gnu/java/util/prefs/gconf and
gnu/java/awt/dnd/peer/gtk to bc. Classify
gnu/java/security/Configuration.java as generated source file.
* gnu/java/lang/management/VMGarbageCollectorMXBeanImpl.java,
gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java,
gnu/java/lang/management/VMClassLoadingMXBeanImpl.java,
gnu/java/lang/management/VMRuntimeMXBeanImpl.java,
gnu/java/lang/management/VMMemoryManagerMXBeanImpl.java,
gnu/java/lang/management/VMThreadMXBeanImpl.java,
gnu/java/lang/management/VMMemoryMXBeanImpl.java,
gnu/java/lang/management/VMCompilationMXBeanImpl.java: New VM stub
classes.
* java/lang/management/VMManagementFactory.java: Likewise.
* java/net/VMURLConnection.java: Likewise.
* gnu/java/nio/VMChannel.java: Likewise.
* java/lang/Thread.java (getState): Add stub implementation.
* java/lang/Class.java (isEnum): Likewise.
* java/lang/Class.h (isEnum): Likewise.
* gnu/awt/xlib/XToolkit.java (getClasspathTextLayoutPeer): Removed.
* javax/naming/spi/NamingManager.java: New override for StackWalker
functionality.
* configure, sources.am, Makefile.in, gcj/Makefile.in,
include/Makefile.in, testsuite/Makefile.in: Regenerated.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@116139 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/classpath/tools')
32 files changed, 1312 insertions, 461 deletions
diff --git a/libjava/classpath/tools/Makefile.am b/libjava/classpath/tools/Makefile.am index cabe77d2274..01364f2411d 100755 --- a/libjava/classpath/tools/Makefile.am +++ b/libjava/classpath/tools/Makefile.am @@ -26,8 +26,9 @@ endif ## gcc/libjava/Makefile.am. # if CREATE_WRAPPERS # bin_SCRIPTS = -# bin_PROGRAMS = gappletviewer gjarsigner gkeytool - +# bin_PROGRAMS = gappletviewer gjarsigner gkeytool \ +# gjar gnative2ascii gserialver +# # if FOUND_GCJ # LIBJVM = -lgcj # else @@ -37,34 +38,55 @@ endif # LIBJVM = # endif # endif - +# # AM_CPPFLAGS = -Wall \ # -I$(top_srcdir)/include \ # -DTOOLS_ZIP="\"$(TOOLSdir)/$(TOOLS_ZIP)\"" - +# # gappletviewer_SOURCES = toolwrapper.c # gappletviewer_CFLAGS = \ # -DTOOLPACKAGE="\"appletviewer\"" \ # -DTOOLNAME="\"gappletviewer\"" # gappletviewer_LDFLAGS = -L$(libdir) $(LIBJVM) - +# # gjarsigner_SOURCES = toolwrapper.c # gjarsigner_CFLAGS = \ # -DTOOLPACKAGE="\"jarsigner\"" \ # -DTOOLNAME="\"gjarsigner\"" # gjarsigner_LDFLAGS = -L$(libdir) $(LIBJVM) - +# # gkeytool_SOURCES = toolwrapper.c # gkeytool_CFLAGS = \ # -DTOOLPACKAGE="\"keytool\"" \ # -DTOOLNAME="\"gkeytool\"" # gkeytool_LDFLAGS = -L$(libdir) $(LIBJVM) - +# +# gjar_SOURCES = toolwrapper.c +# gjar_CFLAGS = \ +# -DTOOLPACKAGE="\"jar\"" \ +# -DTOOLNAME="\"gjar\"" +# gjar_LDFLAGS = -L$(libdir) $(LIBJVM) +# +# gnative2ascii_SOURCES = toolwrapper.c +# gnative2ascii_CFLAGS = \ +# -DTOOLPACKAGE="\"native2ascii\"" \ +# -DTOOLNAME="\"gnative2ascii\"" +# gnative2ascii_LDFLAGS = -L$(libdir) $(LIBJVM) +# +# gserialver_SOURCES = toolwrapper.c +# gserialver_CFLAGS = \ +# -DTOOLPACKAGE="\"serialver\"" \ +# -DTOOLNAME="\"gserialver\"" +# gserialver_LDFLAGS = -L$(libdir) $(LIBJVM) +# # else -# bin_SCRIPTS = gappletviewer gjarsigner gkeytool +# bin_SCRIPTS = gappletviewer gjarsigner gkeytool \ +# gjar gnative2ascii gserialver # bin_PROGRAMS = # endif -EXTRA_DIST = toolwrapper.c gappletviewer.in gjarsigner.in gkeytool.in +## END GCJ LOCAL +EXTRA_DIST = toolwrapper.c gappletviewer.in gjarsigner.in gkeytool.in \ + gjar.in gnative2ascii.in gserialver.in # All our example java source files TOOLS_JAVA_FILES = $(srcdir)/gnu/classpath/tools/*.java $(srcdir)/gnu/classpath/tools/*/*.java $(srcdir)/gnu/classpath/tools/*/*/*.java diff --git a/libjava/classpath/tools/Makefile.in b/libjava/classpath/tools/Makefile.in index 16001338dd6..a0a3471b9b7 100644 --- a/libjava/classpath/tools/Makefile.in +++ b/libjava/classpath/tools/Makefile.in @@ -39,7 +39,10 @@ host_triplet = @host@ target_triplet = @target@ subdir = tools DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ - $(srcdir)/appletviewer.in $(srcdir)/jarsigner.in \ + $(srcdir)/appletviewer.in $(srcdir)/gappletviewer.in \ + $(srcdir)/gjar.in $(srcdir)/gjarsigner.in \ + $(srcdir)/gkeytool.in $(srcdir)/gnative2ascii.in \ + $(srcdir)/gserialver.in $(srcdir)/jarsigner.in \ $(srcdir)/keytool.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/../../libtool.m4 \ @@ -53,7 +56,8 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/include/config.h -CONFIG_CLEAN_FILES = appletviewer jarsigner keytool +CONFIG_CLEAN_FILES = gappletviewer gjarsigner gkeytool gjar \ + gnative2ascii gserialver appletviewer jarsigner keytool SOURCES = DIST_SOURCES = DATA = $(noinst_DATA) @@ -88,6 +92,8 @@ CREATE_CORE_JNI_LIBRARIES_FALSE = @CREATE_CORE_JNI_LIBRARIES_FALSE@ CREATE_CORE_JNI_LIBRARIES_TRUE = @CREATE_CORE_JNI_LIBRARIES_TRUE@ CREATE_DSSI_LIBRARIES_FALSE = @CREATE_DSSI_LIBRARIES_FALSE@ CREATE_DSSI_LIBRARIES_TRUE = @CREATE_DSSI_LIBRARIES_TRUE@ +CREATE_GCONF_PEER_LIBRARIES_FALSE = @CREATE_GCONF_PEER_LIBRARIES_FALSE@ +CREATE_GCONF_PEER_LIBRARIES_TRUE = @CREATE_GCONF_PEER_LIBRARIES_TRUE@ CREATE_GTK_PEER_LIBRARIES_FALSE = @CREATE_GTK_PEER_LIBRARIES_FALSE@ CREATE_GTK_PEER_LIBRARIES_TRUE = @CREATE_GTK_PEER_LIBRARIES_TRUE@ CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@ @@ -108,6 +114,7 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DATE = @DATE@ +DEFAULT_PREFS_PEER = @DEFAULT_PREFS_PEER@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ @@ -138,6 +145,10 @@ FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@ FREETYPE2_LIBS = @FREETYPE2_LIBS@ GCJ = @GCJ@ GCJX = @GCJX@ +GCONF_CFLAGS = @GCONF_CFLAGS@ +GCONF_LIBS = @GCONF_LIBS@ +GDK_CFLAGS = @GDK_CFLAGS@ +GDK_LIBS = @GDK_LIBS@ GJDOC = @GJDOC@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_LIBS = @GLIB_LIBS@ @@ -188,6 +199,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@ PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@ PANGOFT2_LIBS = @PANGOFT2_LIBS@ PATH_SEPARATOR = @PATH_SEPARATOR@ +PATH_TO_ESCHER = @PATH_TO_ESCHER@ PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@ PERL = @PERL@ PKG_CONFIG = @PKG_CONFIG@ @@ -208,6 +220,8 @@ USER_SPECIFIED_CLASSLIB_FALSE = @USER_SPECIFIED_CLASSLIB_FALSE@ USER_SPECIFIED_CLASSLIB_TRUE = @USER_SPECIFIED_CLASSLIB_TRUE@ USER_SPECIFIED_JAVAH_FALSE = @USER_SPECIFIED_JAVAH_FALSE@ USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@ +USE_ESCHER_FALSE = @USE_ESCHER_FALSE@ +USE_ESCHER_TRUE = @USE_ESCHER_TRUE@ USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@ USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@ VERSION = @VERSION@ @@ -282,8 +296,9 @@ GLIBJ_CLASSPATH = '$(top_builddir)/lib':'$(top_builddir)/lib/glibj.zip' # if CREATE_WRAPPERS # bin_SCRIPTS = -# bin_PROGRAMS = gappletviewer gjarsigner gkeytool - +# bin_PROGRAMS = gappletviewer gjarsigner gkeytool \ +# gjar gnative2ascii gserialver +# # if FOUND_GCJ # LIBJVM = -lgcj # else @@ -293,34 +308,55 @@ GLIBJ_CLASSPATH = '$(top_builddir)/lib':'$(top_builddir)/lib/glibj.zip' # LIBJVM = # endif # endif - +# # AM_CPPFLAGS = -Wall \ # -I$(top_srcdir)/include \ # -DTOOLS_ZIP="\"$(TOOLSdir)/$(TOOLS_ZIP)\"" - +# # gappletviewer_SOURCES = toolwrapper.c # gappletviewer_CFLAGS = \ # -DTOOLPACKAGE="\"appletviewer\"" \ # -DTOOLNAME="\"gappletviewer\"" # gappletviewer_LDFLAGS = -L$(libdir) $(LIBJVM) - +# # gjarsigner_SOURCES = toolwrapper.c # gjarsigner_CFLAGS = \ # -DTOOLPACKAGE="\"jarsigner\"" \ # -DTOOLNAME="\"gjarsigner\"" # gjarsigner_LDFLAGS = -L$(libdir) $(LIBJVM) - +# # gkeytool_SOURCES = toolwrapper.c # gkeytool_CFLAGS = \ # -DTOOLPACKAGE="\"keytool\"" \ # -DTOOLNAME="\"gkeytool\"" # gkeytool_LDFLAGS = -L$(libdir) $(LIBJVM) - +# +# gjar_SOURCES = toolwrapper.c +# gjar_CFLAGS = \ +# -DTOOLPACKAGE="\"jar\"" \ +# -DTOOLNAME="\"gjar\"" +# gjar_LDFLAGS = -L$(libdir) $(LIBJVM) +# +# gnative2ascii_SOURCES = toolwrapper.c +# gnative2ascii_CFLAGS = \ +# -DTOOLPACKAGE="\"native2ascii\"" \ +# -DTOOLNAME="\"gnative2ascii\"" +# gnative2ascii_LDFLAGS = -L$(libdir) $(LIBJVM) +# +# gserialver_SOURCES = toolwrapper.c +# gserialver_CFLAGS = \ +# -DTOOLPACKAGE="\"serialver\"" \ +# -DTOOLNAME="\"gserialver\"" +# gserialver_LDFLAGS = -L$(libdir) $(LIBJVM) +# # else -# bin_SCRIPTS = gappletviewer gjarsigner gkeytool +# bin_SCRIPTS = gappletviewer gjarsigner gkeytool \ +# gjar gnative2ascii gserialver # bin_PROGRAMS = # endif -EXTRA_DIST = toolwrapper.c gappletviewer.in gjarsigner.in gkeytool.in +EXTRA_DIST = toolwrapper.c gappletviewer.in gjarsigner.in gkeytool.in \ + gjar.in gnative2ascii.in gserialver.in + # All our example java source files TOOLS_JAVA_FILES = $(srcdir)/gnu/classpath/tools/*.java $(srcdir)/gnu/classpath/tools/*/*.java $(srcdir)/gnu/classpath/tools/*/*/*.java @@ -383,6 +419,18 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +gappletviewer: $(top_builddir)/config.status $(srcdir)/gappletviewer.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +gjarsigner: $(top_builddir)/config.status $(srcdir)/gjarsigner.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +gkeytool: $(top_builddir)/config.status $(srcdir)/gkeytool.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +gjar: $(top_builddir)/config.status $(srcdir)/gjar.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +gnative2ascii: $(top_builddir)/config.status $(srcdir)/gnative2ascii.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +gserialver: $(top_builddir)/config.status $(srcdir)/gserialver.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ appletviewer: $(top_builddir)/config.status $(srcdir)/appletviewer.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ jarsigner: $(top_builddir)/config.status $(srcdir)/jarsigner.in diff --git a/libjava/classpath/tools/gappletviewer.in b/libjava/classpath/tools/gappletviewer.in new file mode 100644 index 00000000000..1057aba9733 --- /dev/null +++ b/libjava/classpath/tools/gappletviewer.in @@ -0,0 +1,46 @@ +#!/bin/sh + +## Copyright (C) 2006 Free Software Foundation, Inc. +## +## This file is a part of GNU Classpath. +## +## GNU Classpath is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or (at +## your option) any later version. +## +## GNU Classpath 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 for more details. +## +## You should have received a copy of the GNU General Public License +## along with GNU Classpath; if not, write to the Free Software +## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 +## USA. +## +## Linking this library statically or dynamically with other modules is +## making a combined work based on this library. Thus, the terms and +## conditions of the GNU General Public License cover the whole +## combination. +## +## As a special exception, the copyright holders of this library give you +## permission to link this library with independent modules to produce an +## executable, regardless of the license terms of these independent +## modules, and to copy and distribute the resulting executable under +## terms of your choice, provided that you also meet, for each linked +## independent module, the terms and conditions of the license of that +## module. An independent module is a module which is not derived from +## or based on this library. If you modify this library, you may extend +## this exception to your version of the library, but you are not +## obligated to do so. If you do not wish to do so, delete this +## exception statement from your version. +## +## A simple shell script to launch the GNU Classpath appletviewer tool. +## + +prefix=@prefix@ +tools_dir=@datadir@/@PACKAGE@ +tools_cp=${tools_dir}/tools.zip + +exec @VM_BINARY@ -Xbootclasspath/p:"${tools_cp}" gnu.classpath.tools.appletviewer.Main "$@" diff --git a/libjava/classpath/tools/gjar.in b/libjava/classpath/tools/gjar.in new file mode 100644 index 00000000000..df2da926c0c --- /dev/null +++ b/libjava/classpath/tools/gjar.in @@ -0,0 +1,47 @@ +#!/bin/sh + +## Copyright (C) 2006 Free Software Foundation, Inc. +## +## This file is a part of GNU Classpath. +## +## GNU Classpath is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or (at +## your option) any later version. +## +## GNU Classpath 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 for more details. +## +## You should have received a copy of the GNU General Public License +## along with GNU Classpath; if not, write to the Free Software +## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 +## USA. +## +## Linking this library statically or dynamically with other modules is +## making a combined work based on this library. Thus, the terms and +## conditions of the GNU General Public License cover the whole +## combination. +## +## As a special exception, the copyright holders of this library give you +## permission to link this library with independent modules to produce an +## executable, regardless of the license terms of these independent +## modules, and to copy and distribute the resulting executable under +## terms of your choice, provided that you also meet, for each linked +## independent module, the terms and conditions of the license of that +## module. An independent module is a module which is not derived from +## or based on this library. If you modify this library, you may extend +## this exception to your version of the library, but you are not +## obligated to do so. If you do not wish to do so, delete this +## exception statement from your version. +## +## +## A simple shell script to launch the GNU Classpath jar tool. +## + +prefix=@prefix@ +tools_dir=@datadir@/@PACKAGE@ +tools_cp=${tools_dir}/tools.zip + +exec @VM_BINARY@ -Xbootclasspath/p:"${tools_cp}" gnu.classpath.tools.jar.Main "$@" diff --git a/libjava/classpath/tools/jarsigner.sh.in b/libjava/classpath/tools/gjarsigner.in index cea95a28814..071b8a6477d 100644 --- a/libjava/classpath/tools/jarsigner.sh.in +++ b/libjava/classpath/tools/gjarsigner.in @@ -44,20 +44,4 @@ prefix=@prefix@ tools_dir=@datadir@/@PACKAGE@ tools_cp=${tools_dir}/tools.zip -# find the java executable... -if [ -z "${JAVA}" ] ; then - if [ -n "${JAVA_HOME}" ] ; then - if [ -x "${JAVA_HOME}/jre/sh/java" ] ; then - JAVA="${JAVA_HOME}/jre/sh/java" - else - JAVA="${JAVA_HOME}/bin/java" - fi - else - JAVA=`which java 2> /dev/null ` - if [ -z "${JAVA}" ] ; then - JAVA=java - fi - fi -fi - -exec "${JAVA}" -Xbootclasspath/p:"${tools_cp}" gnu.classpath.tools.jarsigner.Main $@ +exec @VM_BINARY@ -Xbootclasspath/p:"${tools_cp}" gnu.classpath.tools.jarsigner.Main "$@" diff --git a/libjava/classpath/tools/keytool.sh.in b/libjava/classpath/tools/gkeytool.in index 6c11dc407df..d35f08df7df 100644 --- a/libjava/classpath/tools/keytool.sh.in +++ b/libjava/classpath/tools/gkeytool.in @@ -44,20 +44,4 @@ prefix=@prefix@ tools_dir=@datadir@/@PACKAGE@ tools_cp=${tools_dir}/tools.zip -# find the java executable... -if [ -z "${JAVA}" ] ; then - if [ -n "${JAVA_HOME}" ] ; then - if [ -x "${JAVA_HOME}/jre/sh/java" ] ; then - JAVA="${JAVA_HOME}/jre/sh/java" - else - JAVA="${JAVA_HOME}/bin/java" - fi - else - JAVA=`which java 2> /dev/null ` - if [ -z "${JAVA}" ] ; then - JAVA=java - fi - fi -fi - -exec "${JAVA}" -Xbootclasspath/p:"${tools_cp}" gnu.classpath.tools.keytool.Main $@ +exec @VM_BINARY@ -Xbootclasspath/p:"${tools_cp}" gnu.classpath.tools.keytool.Main "$@" diff --git a/libjava/classpath/tools/gnative2ascii.in b/libjava/classpath/tools/gnative2ascii.in new file mode 100644 index 00000000000..ade13f057a2 --- /dev/null +++ b/libjava/classpath/tools/gnative2ascii.in @@ -0,0 +1,47 @@ +#!/bin/sh + +## Copyright (C) 2006 Free Software Foundation, Inc. +## +## This file is a part of GNU Classpath. +## +## GNU Classpath is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or (at +## your option) any later version. +## +## GNU Classpath 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 for more details. +## +## You should have received a copy of the GNU General Public License +## along with GNU Classpath; if not, write to the Free Software +## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 +## USA. +## +## Linking this library statically or dynamically with other modules is +## making a combined work based on this library. Thus, the terms and +## conditions of the GNU General Public License cover the whole +## combination. +## +## As a special exception, the copyright holders of this library give you +## permission to link this library with independent modules to produce an +## executable, regardless of the license terms of these independent +## modules, and to copy and distribute the resulting executable under +## terms of your choice, provided that you also meet, for each linked +## independent module, the terms and conditions of the license of that +## module. An independent module is a module which is not derived from +## or based on this library. If you modify this library, you may extend +## this exception to your version of the library, but you are not +## obligated to do so. If you do not wish to do so, delete this +## exception statement from your version. +## +## +## A simple shell script to launch the GNU Classpath native2ascii tool. +## + +prefix=@prefix@ +tools_dir=@datadir@/@PACKAGE@ +tools_cp=${tools_dir}/tools.zip + +exec @VM_BINARY@ -Xbootclasspath/p:"${tools_cp}" gnu.classpath.tools.native2ascii.Main "$@" diff --git a/libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletWindow.java b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletWindow.java index 3b337bf803c..fd2a7c0d832 100644 --- a/libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletWindow.java +++ b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletWindow.java @@ -199,7 +199,7 @@ class StandaloneAppletWindow menuApplet.add(closeItem); menuApplet.add(quitItem); setMenuBar(menuBar); - setTitle("GCJ Applet Viewer: " + tag.code); + setTitle("GNU Classpath Applet Viewer: " + tag.code); AppletContext context = (AppletContext) contexts.get(tag.codebase); ((StandaloneAppletContext) context).addApplet(applet); diff --git a/libjava/classpath/tools/gnu/classpath/tools/getopt/Parser.java b/libjava/classpath/tools/gnu/classpath/tools/getopt/Parser.java index 082cf89450b..3c6cf6f46ac 100644 --- a/libjava/classpath/tools/gnu/classpath/tools/getopt/Parser.java +++ b/libjava/classpath/tools/gnu/classpath/tools/getopt/Parser.java @@ -316,6 +316,9 @@ public class Parser int eq = option.indexOf('='); if (eq != - 1) justName = option.substring(0, eq); + char shortName = 0; + if (justName.length() == 1) + shortName = justName.charAt(0); Option found = null; for (int i = options.size() - 1; i >= 0; --i) { @@ -325,6 +328,11 @@ public class Parser found = opt; break; } + if (shortName != 0 && opt.getShortName() == shortName) + { + found = opt; + break; + } } if (found == null) { diff --git a/libjava/classpath/tools/gnu/classpath/tools/jarsigner/HashUtils.java b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/HashUtils.java index 2286063f153..a085ca0c943 100644 --- a/libjava/classpath/tools/gnu/classpath/tools/jarsigner/HashUtils.java +++ b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/HashUtils.java @@ -38,6 +38,7 @@ exception statement from your version. */ package gnu.classpath.tools.jarsigner; +import gnu.classpath.Configuration; import gnu.java.security.hash.Sha160; import gnu.java.security.util.Base64; import gnu.java.util.jar.JarUtils; @@ -76,9 +77,9 @@ class HashUtils sha.update(buffer, 0, n); count += n; } - byte[] hash = sha.digest(); - log.finest("Hashed " + count + " byte(s)"); + if (Configuration.DEBUG) + log.finest("Hashed " + count + " byte(s)"); String result = Base64.encode(hash); return result; } @@ -92,7 +93,8 @@ class HashUtils { sha.update(ba); byte[] hash = sha.digest(); - log.finest("Hashed " + ba.length + " byte(s)"); + if (Configuration.DEBUG) + log.finest("Hashed " + ba.length + " byte(s)"); String result = Base64.encode(hash); return result; } diff --git a/libjava/classpath/tools/gnu/classpath/tools/jarsigner/JarSigner.java b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/JarSigner.java index 8d3bc31af0a..87db8b95278 100644 --- a/libjava/classpath/tools/gnu/classpath/tools/jarsigner/JarSigner.java +++ b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/JarSigner.java @@ -38,6 +38,7 @@ exception statement from your version. */ package gnu.classpath.tools.jarsigner; +import gnu.classpath.Configuration; import gnu.classpath.SystemProperties; import gnu.java.util.jar.JarUtils; @@ -69,8 +70,8 @@ public class JarSigner void start() throws Exception { - log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$ JarFile jarFile = new JarFile(main.getJarFileName()); SFHelper sfHelper = new SFHelper(jarFile); @@ -119,19 +120,22 @@ public class JarSigner String signaturesFileName = main.getSigFileName(); String sfFileName = JarUtils.META_INF + signaturesFileName + JarUtils.SF_SUFFIX; - log.finest("Processing " + sfFileName); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.fine("Processing " + sfFileName); //$NON-NLS-1$ JarEntry sfEntry = new JarEntry(sfFileName); sfEntry.setTime(System.currentTimeMillis()); outSignedJarFile.putNextEntry(sfEntry); sfHelper.writeSF(outSignedJarFile); - log.finer("Created .SF file"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.fine("Created .SF file"); //$NON-NLS-1$ if (main.isVerbose()) System.out.println(Messages.getString("JarSigner.8") + sfFileName); //$NON-NLS-1$ // 4. create the .DSA file String dsaFileName = JarUtils.META_INF + signaturesFileName + JarUtils.DSA_SUFFIX; - log.finest("Processing " + dsaFileName); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.fine("Processing " + dsaFileName); //$NON-NLS-1$ JarEntry dsaEntry = new JarEntry(dsaFileName); dsaEntry.setTime(System.currentTimeMillis()); outSignedJarFile.putNextEntry(dsaEntry); @@ -139,7 +143,8 @@ public class JarSigner main.getSignerPrivateKey(), main.getSignerCertificateChain(), main.isInternalSF()); - log.finer("Created .DSA file"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.fine("Created .DSA file"); //$NON-NLS-1$ if (main.isVerbose()) System.out.println(Messages.getString("JarSigner.8") + dsaFileName); //$NON-NLS-1$ @@ -147,12 +152,13 @@ public class JarSigner outSignedJarFile.close(); fos.close(); signedJarFile.renameTo(new File(main.getSignedJarFileName())); - log.finer("Renamed signed JAR file"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.fine("Renamed signed JAR file"); //$NON-NLS-1$ if (main.isVerbose()) System.out.println(SystemProperties.getProperty("line.separator") //$NON-NLS-1$ + Messages.getString("JarSigner.14")); //$NON-NLS-1$ - - log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$ } private void copyFromTo(InputStream in, JarOutputStream out) diff --git a/libjava/classpath/tools/gnu/classpath/tools/jarsigner/JarVerifier.java b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/JarVerifier.java index f80147dfa5e..663f6906a9b 100644 --- a/libjava/classpath/tools/gnu/classpath/tools/jarsigner/JarVerifier.java +++ b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/JarVerifier.java @@ -38,6 +38,7 @@ exception statement from your version. */ package gnu.classpath.tools.jarsigner; +import gnu.classpath.Configuration; import gnu.java.security.OID; import gnu.java.security.Registry; import gnu.java.security.pkcs.PKCS7SignedData; @@ -94,8 +95,8 @@ public class JarVerifier void start() throws Exception { - log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$ String jarFileName = main.getJarFileName(); jarFile = new JarFile(jarFileName); @@ -144,8 +145,8 @@ public class JarVerifier System.out.println(Messages.getFormattedString("JarVerifier.7", //$NON-NLS-1$ Integer.valueOf(limit))); } - - log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$ } /** @@ -162,9 +163,11 @@ public class JarVerifier private boolean verifySF(String sigFileName) throws CRLException, CertificateException, ZipException, IOException { - log.entering(this.getClass().getName(), "verifySF"); //$NON-NLS-1$ - log.finest("About to verify signature of " + sigFileName + "..."); //$NON-NLS-1$ //$NON-NLS-2$ - + if (Configuration.DEBUG) + { + log.entering(this.getClass().getName(), "verifySF"); //$NON-NLS-1$ + log.fine("About to verify signature of " + sigFileName + "..."); //$NON-NLS-1$ //$NON-NLS-2$ + } // 1. find the corresponding .DSA file for this .SF file JarEntry dsaEntry = jarFile.getJarEntry(JarUtils.META_INF + sigFileName + JarUtils.DSA_SUFFIX); @@ -186,12 +189,14 @@ public class JarVerifier if (encryptedDigest == null) throw new SecurityException(Messages.getString("JarVerifier.16")); //$NON-NLS-1$ - log.finest("\n" + Util.dumpString(encryptedDigest, "--- signedSFBytes ")); //$NON-NLS-1$ //$NON-NLS-2$ + if (Configuration.DEBUG) + log.fine("\n" + Util.dumpString(encryptedDigest, "--- signedSFBytes ")); //$NON-NLS-1$ //$NON-NLS-2$ // 5. get the signer public key Certificate cert = pkcs7SignedData.getCertificates()[0]; PublicKey verifierKey = cert.getPublicKey(); - log.finest("--- verifier public key = " + verifierKey); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.fine("--- verifier public key = " + verifierKey); //$NON-NLS-1$ // 6. verify the signature file signature OID digestEncryptionAlgorithmOID = signerInfo.getDigestEncryptionAlgorithmId(); @@ -225,10 +230,12 @@ public class JarVerifier signatureAlgorithm.update(buffer, 0, n); boolean result = signatureAlgorithm.verify(herSignature); - log.finer("Signature block [" + sigFileName + "] is " //$NON-NLS-1$ //$NON-NLS-2$ - + (result ? "" : "NOT ") + "OK"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - - log.exiting(this.getClass().getName(), "verifySF", Boolean.valueOf(result)); //$NON-NLS-1$ + if (Configuration.DEBUG) + { + log.fine("Signature block [" + sigFileName + "] is " //$NON-NLS-1$ //$NON-NLS-2$ + + (result ? "" : "NOT ") + "OK"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + log.exiting(this.getClass().getName(), "verifySF", Boolean.valueOf(result)); //$NON-NLS-1$ + } return result; } @@ -250,8 +257,8 @@ public class JarVerifier */ private boolean verifySFEntries(String alias) throws IOException { - log.entering(this.getClass().getName(), "verifySFEntries"); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "verifySFEntries"); //$NON-NLS-1$ // 1. read the signature file JarEntry jarEntry = jarFile.getJarEntry(JarUtils.META_INF + alias + JarUtils.SF_SUFFIX); @@ -291,8 +298,9 @@ public class JarVerifier break; } - log.exiting(this.getClass().getName(), "verifySFEntries", - Boolean.valueOf(result)); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "verifySFEntries", //$NON-NLS-1$ + Boolean.valueOf(result)); return result; } @@ -319,7 +327,8 @@ public class JarVerifier { String expectedValue = getEntryHash(JarFile.MANIFEST_NAME); boolean result = expectedValue.equalsIgnoreCase(hash); - log.finest("Is " + name + " OK? " + result); //$NON-NLS-1$ //$NON-NLS-2$ + if (Configuration.DEBUG) + log.fine("Is " + name + " OK? " + result); //$NON-NLS-1$ //$NON-NLS-2$ return result; } diff --git a/libjava/classpath/tools/gnu/classpath/tools/jarsigner/Main.java b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/Main.java index 6928bce5945..b6b50e7417a 100644 --- a/libjava/classpath/tools/gnu/classpath/tools/jarsigner/Main.java +++ b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/Main.java @@ -38,6 +38,7 @@ exception statement from your version. */ package gnu.classpath.tools.jarsigner; +import gnu.classpath.Configuration; import gnu.classpath.SystemProperties; import gnu.classpath.tools.common.CallbackUtil; import gnu.classpath.tools.common.ProviderUtil; @@ -131,8 +132,8 @@ public class Main public static final void main(String[] args) { - log.entering(Main.class.getName(), "main", args); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(Main.class.getName(), "main", args); //$NON-NLS-1$ Main tool = new Main(); int result = 1; try @@ -143,20 +144,22 @@ public class Main } catch (SecurityException x) { - log.throwing(Main.class.getName(), "main", x); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.throwing(Main.class.getName(), "main", x); //$NON-NLS-1$ System.err.println(Messages.getString("Main.7") + x.getMessage()); //$NON-NLS-1$ } catch (Exception x) { - log.throwing(Main.class.getName(), "main", x); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.throwing(Main.class.getName(), "main", x); //$NON-NLS-1$ System.err.println(Messages.getString("Main.9") + x); //$NON-NLS-1$ } finally { tool.teardown(); } - - log.exiting(Main.class.getName(), "main", Integer.valueOf(result)); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(Main.class.getName(), "main", Integer.valueOf(result)); //$NON-NLS-1$ System.exit(result); } @@ -171,8 +174,8 @@ public class Main */ private void processArgs(String[] args) throws Exception { - log.entering(this.getClass().getName(), "processArgs", args); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "processArgs", args); //$NON-NLS-1$ cmdLineParser = new ToolParser(); cmdLineParser.initializeParser(); cmdLineParser.parse(args, new ToolParserCallback()); @@ -180,36 +183,41 @@ public class Main setupCommonParams(); if (verify) { - log.finer("Will verify with the following parameters:"); //$NON-NLS-1$ - log.finer(" jar-file = '" + jarFileName + "'"); //$NON-NLS-1$ //$NON-NLS-2$ - log.finer("Options:"); //$NON-NLS-1$ - log.finer(" provider = '" + providerClassName + "'"); //$NON-NLS-1$ //$NON-NLS-2$ - log.finer(" verbose ? " + verbose); //$NON-NLS-1$ - log.finer(" certs ? " + certs); //$NON-NLS-1$ - log.finer(" internalsf ? " + internalSF); //$NON-NLS-1$ - log.finer(" sectionsonly ? " + sectionsOnly); //$NON-NLS-1$ + if (Configuration.DEBUG) + { + log.fine("Will verify with the following parameters:"); //$NON-NLS-1$ + log.fine(" jar-file = '" + jarFileName + "'"); //$NON-NLS-1$ //$NON-NLS-2$ + log.fine("Options:"); //$NON-NLS-1$ + log.fine(" provider = '" + providerClassName + "'"); //$NON-NLS-1$ //$NON-NLS-2$ + log.fine(" verbose ? " + verbose); //$NON-NLS-1$ + log.fine(" certs ? " + certs); //$NON-NLS-1$ + log.fine(" internalsf ? " + internalSF); //$NON-NLS-1$ + log.fine(" sectionsonly ? " + sectionsOnly); //$NON-NLS-1$ + } } else // sign { setupSigningParams(); - - log.finer("Will sign with the following parameters:"); //$NON-NLS-1$ - log.finer(" jar-file = '" + jarFileName + "'"); //$NON-NLS-1$ //$NON-NLS-2$ - log.finer(" alias = '" + alias + "'"); //$NON-NLS-1$ //$NON-NLS-2$ - log.finer("Options:"); //$NON-NLS-1$ - log.finer(" keystore = '" + ksURL + "'"); //$NON-NLS-1$ //$NON-NLS-2$ - log.finer(" storetype = '" + ksType + "'"); //$NON-NLS-1$ //$NON-NLS-2$ - log.finer(" storepass = '" + ksPassword + "'"); //$NON-NLS-1$ //$NON-NLS-2$ - log.finer(" keypass = '" + password + "'"); //$NON-NLS-1$ //$NON-NLS-2$ - log.finer(" sigfile = '" + sigFileName + "'"); //$NON-NLS-1$ //$NON-NLS-2$ - log.finer(" signedjar = '" + signedJarFileName + "'"); //$NON-NLS-1$ //$NON-NLS-2$ - log.finer(" provider = '" + providerClassName + "'"); //$NON-NLS-1$ //$NON-NLS-2$ - log.finer(" verbose ? " + verbose); //$NON-NLS-1$ - log.finer(" internalsf ? " + internalSF); //$NON-NLS-1$ - log.finer(" sectionsonly ? " + sectionsOnly); //$NON-NLS-1$ + if (Configuration.DEBUG) + { + log.fine("Will sign with the following parameters:"); //$NON-NLS-1$ + log.fine(" jar-file = '" + jarFileName + "'"); //$NON-NLS-1$ //$NON-NLS-2$ + log.fine(" alias = '" + alias + "'"); //$NON-NLS-1$ //$NON-NLS-2$ + log.fine("Options:"); //$NON-NLS-1$ + log.fine(" keystore = '" + ksURL + "'"); //$NON-NLS-1$ //$NON-NLS-2$ + log.fine(" storetype = '" + ksType + "'"); //$NON-NLS-1$ //$NON-NLS-2$ + log.fine(" storepass = '" + ksPassword + "'"); //$NON-NLS-1$ //$NON-NLS-2$ + log.fine(" keypass = '" + password + "'"); //$NON-NLS-1$ //$NON-NLS-2$ + log.fine(" sigfile = '" + sigFileName + "'"); //$NON-NLS-1$ //$NON-NLS-2$ + log.fine(" signedjar = '" + signedJarFileName + "'"); //$NON-NLS-1$ //$NON-NLS-2$ + log.fine(" provider = '" + providerClassName + "'"); //$NON-NLS-1$ //$NON-NLS-2$ + log.fine(" verbose ? " + verbose); //$NON-NLS-1$ + log.fine(" internalsf ? " + internalSF); //$NON-NLS-1$ + log.fine(" sectionsonly ? " + sectionsOnly); //$NON-NLS-1$ + } } - - log.exiting(this.getClass().getName(), "processArgs"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "processArgs"); //$NON-NLS-1$ } /** @@ -222,8 +230,8 @@ public class Main */ private void start() throws Exception { - log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$ if (verify) { JarVerifier jv = new JarVerifier(this); @@ -234,8 +242,8 @@ public class Main JarSigner js = new JarSigner(this); js.start(); } - - log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$ } /** @@ -249,12 +257,13 @@ public class Main */ private void teardown() { - log.entering(this.getClass().getName(), "teardown"); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "teardown"); //$NON-NLS-1$ if (providerInstalled) ProviderUtil.removeProvider(provider.getName()); - log.exiting(this.getClass().getName(), "teardown"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "teardown"); //$NON-NLS-1$ } /** @@ -279,8 +288,8 @@ public class Main private void setupCommonParams() throws InstantiationException, IllegalAccessException, ClassNotFoundException, IOException { - log.entering(this.getClass().getName(), "setupCommonParams"); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "setupCommonParams"); //$NON-NLS-1$ File jar = new File(jarFileName); if (! jar.exists()) throw new FileNotFoundException(jarFileName); @@ -298,18 +307,23 @@ public class Main String providerName = provider.getName(); Provider installedProvider = Security.getProvider(providerName); if (installedProvider != null) - log.finer("Provider " + providerName + " is already installed"); //$NON-NLS-1$ //$NON-NLS-2$ + { + if (Configuration.DEBUG) + log.finer("Provider " + providerName + " is already installed"); //$NON-NLS-1$ //$NON-NLS-2$ + } else // install it installNewProvider(); } if (! verbose && certs) { - log.fine("Option <certs> is set but <verbose> is not. Ignored"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.fine("Option <certs> is set but <verbose> is not. Ignored"); //$NON-NLS-1$ certs = false; } - log.exiting(this.getClass().getName(), "setupCommonParams"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "setupCommonParams"); //$NON-NLS-1$ } /** @@ -319,11 +333,11 @@ public class Main */ private void installNewProvider() { - log.entering(this.getClass().getName(), "installNewProvider"); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "installNewProvider"); //$NON-NLS-1$ providerInstalled = ProviderUtil.addProvider(provider) != -1; - - log.exiting(this.getClass().getName(), "installNewProvider"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "installNewProvider"); //$NON-NLS-1$ } /** @@ -349,8 +363,8 @@ public class Main NoSuchAlgorithmException, CertificateException, UnsupportedCallbackException, UnrecoverableKeyException { - log.entering(this.getClass().getName(), "setupSigningParams"); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "setupSigningParams"); //$NON-NLS-1$ if (ksURL == null || ksURL.trim().length() == 0) { String userHome = SystemProperties.getProperty("user.home"); //$NON-NLS-1$ @@ -424,7 +438,8 @@ public class Main signerPrivateKey = (PrivateKey) key; signerCertificateChain = store.getCertificateChain(alias); - log.finest(String.valueOf(signerCertificateChain)); + if (Configuration.DEBUG) + log.fine(String.valueOf(signerCertificateChain)); if (sigFileName == null) sigFileName = alias; @@ -449,7 +464,8 @@ public class Main if (signedJarFileName == null) signedJarFileName = jarFileName; - log.exiting(this.getClass().getName(), "setupSigningParams"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "setupSigningParams"); //$NON-NLS-1$ } boolean isVerbose() @@ -547,7 +563,8 @@ public class Main if (! verify) // must have an ALIAS. use "mykey" if undefined if (fileAndAlias.size() < 2) { - log.finer("Missing ALIAS argument. Will use [mykey] instead"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.fine("Missing ALIAS argument. Will use [mykey] instead"); //$NON-NLS-1$ alias = "mykey"; //$NON-NLS-1$ } else diff --git a/libjava/classpath/tools/gnu/classpath/tools/jarsigner/Messages.java b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/Messages.java index 35f461669de..d5b8760ee9d 100644 --- a/libjava/classpath/tools/gnu/classpath/tools/jarsigner/Messages.java +++ b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/Messages.java @@ -38,6 +38,8 @@ package gnu.classpath.tools.jarsigner; +import gnu.classpath.Configuration; + import java.text.MessageFormat; import java.util.HashMap; import java.util.Map; @@ -99,8 +101,9 @@ class Messages } catch (IllegalArgumentException x) { - log.fine("Exception while rendering a message format keyed by [" - + key + "]: " + mf.toPattern()); + if (Configuration.DEBUG) + log.fine("Exception while rendering a message format keyed by [" + + key + "]: " + mf.toPattern()); return constructMessage(mf.toPattern(), args); } } diff --git a/libjava/classpath/tools/gnu/classpath/tools/jarsigner/SFHelper.java b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/SFHelper.java index b4e5cc19368..83e87b84385 100644 --- a/libjava/classpath/tools/gnu/classpath/tools/jarsigner/SFHelper.java +++ b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/SFHelper.java @@ -38,6 +38,7 @@ exception statement from your version. */ package gnu.classpath.tools.jarsigner; +import gnu.classpath.Configuration; import gnu.java.security.OID; import gnu.java.security.Registry; import gnu.java.security.der.DER; @@ -62,10 +63,13 @@ import java.security.PrivateKey; import java.security.cert.CRLException; import java.security.cert.Certificate; import java.security.cert.CertificateEncodingException; +import java.security.cert.CertificateExpiredException; +import java.security.cert.CertificateNotYetValidException; import java.security.cert.X509CRL; import java.security.interfaces.DSAPrivateKey; import java.security.interfaces.RSAPrivateKey; import java.util.ArrayList; +import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -142,7 +146,8 @@ public class SFHelper ByteArrayOutputStream baos = new ByteArrayOutputStream(); JarUtils.writeSFManifest(sfMainAttributes, sfEntries, baos); sfBytes = baos.toByteArray(); - log.finest("\n" + Util.dumpString(sfBytes, "+++ sfBytes ")); //$NON-NLS-1$ //$NON-NLS-2$ + if (Configuration.DEBUG) + log.fine("\n" + Util.dumpString(sfBytes, "+++ sfBytes ")); //$NON-NLS-1$ //$NON-NLS-2$ jar.write(sfBytes); jar.flush(); @@ -216,7 +221,8 @@ public class SFHelper if (this.state != SF_GENERATED) throw new IllegalStateException(Messages.getString("SFHelper.4")); //$NON-NLS-1$ - log.finest("+++ signer private key = " + signerKey); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.fine("+++ signer private key = " + signerKey); //$NON-NLS-1$ ISignature signatureAlgorithm; ISignatureCodec signatureCodec; OID digestEncryptionAlgorithmOID; @@ -241,7 +247,8 @@ public class SFHelper signatureAlgorithm.update(sfBytes, 0, sfBytes.length); Object signature = signatureAlgorithm.sign(); byte[] signedSFBytes = signatureCodec.encodeSignature(signature); - log.finest("\n" + Util.dumpString(signedSFBytes, "+++ signedSFBytes ")); //$NON-NLS-1$ //$NON-NLS-2$ + if (Configuration.DEBUG) + log.fine("\n" + Util.dumpString(signedSFBytes, "+++ signedSFBytes ")); //$NON-NLS-1$ //$NON-NLS-2$ Set digestAlgorithms = new HashSet(); List digestAlgorithm = new ArrayList(2); @@ -261,6 +268,30 @@ public class SFHelper Set signerInfos = new HashSet(); X509Certificate cert = (X509Certificate) certificates[0]; + try + { + cert.checkValidity(); + } + catch (CertificateExpiredException x) + { + String issuerName = getIssuerName(cert); + String subjectName = getSubjectName(cert); + Date notAfterDate = getNotAfterDate(cert); + System.out.println(Messages.getFormattedString("SFHelper.0", //$NON-NLS-1$ + new Object[] { issuerName, + subjectName, + notAfterDate })); + } + catch (CertificateNotYetValidException x) + { + String issuerName = getIssuerName(cert); + String subjectName = getSubjectName(cert); + Date notBeforeDate = getNotBeforeDate(cert); + System.out.println(Messages.getFormattedString("SFHelper.11", //$NON-NLS-1$ + new Object[] { issuerName, + subjectName, + notBeforeDate })); + } X500Principal issuer = cert.getIssuerX500Principal(); BigInteger serialNumber = cert.getSerialNumber(); byte[] authenticatedAttributes = null; @@ -322,7 +353,8 @@ public class SFHelper String name = entry.getName(); InputStream jeis = jar.getInputStream(entry); String hash = util.hashStream(jeis); - log.finer("Hash of " + name + " = " + hash); //$NON-NLS-1$ //$NON-NLS-2$ + if (Configuration.DEBUG) + log.fine("Hash of " + name + " = " + hash); //$NON-NLS-1$ //$NON-NLS-2$ Attributes mainfestAttributes = manifest.getAttributes(name); if (mainfestAttributes == null) @@ -344,9 +376,12 @@ public class SFHelper } sfAttributes.putValue(Main.DIGEST, sfHash); - log.finest("Name: " + name); //$NON-NLS-1$ - log.finest(Main.DIGEST + ": " + sfHash); //$NON-NLS-1$ - log.finest(""); //$NON-NLS-1$ + if (Configuration.DEBUG) + { + log.fine("Name: " + name); //$NON-NLS-1$ + log.fine(Main.DIGEST + ": " + sfHash); //$NON-NLS-1$ + log.fine(""); //$NON-NLS-1$ + } } /** @@ -365,9 +400,106 @@ public class SFHelper manifest.write(baos); baos.flush(); String manifestHash = util.hashByteArray(baos.toByteArray()); - log.fine("Hashed Manifest " + manifestHash); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.fine("Hashed Manifest " + manifestHash); //$NON-NLS-1$ sfMainAttributes.putValue(Main.DIGEST_MANIFEST, manifestHash); this.state = FINISHED; } + + /** + * Given an X.509 certificate this method returns the string representation of + * the Issuer Distinguished Name. + * + * @param cert an X.509 certificate. + * @return the string representation of the Issuer's DN. + */ + private String getIssuerName(X509Certificate cert) + { + X500Principal xp = cert.getIssuerX500Principal(); + if (xp == null) + { + if (Configuration.DEBUG) + log.fine("Certiticate, with serial number " + cert.getSerialNumber() //$NON-NLS-1$ + + ", has null Issuer. Return [unknown]"); //$NON-NLS-1$ + return Messages.getString("SFHelper.14"); //$NON-NLS-1$ + } + String result = xp.getName(); + if (result == null) + { + if (Configuration.DEBUG) + log.fine("Certiticate, with serial number " + cert.getSerialNumber() //$NON-NLS-1$ + + ", has an Issuer with null DN. Return [unnamed]"); //$NON-NLS-1$ + return Messages.getString("SFHelper.17"); //$NON-NLS-1$ + } + return result; + } + + /** + * Given an X.509 certificate this method returns the string representation of + * the Subject Distinguished Name. + * + * @param cert an X.509 certificate. + * @return the string representation of the Subject's DN. + */ + private String getSubjectName(X509Certificate cert) + { + X500Principal xp = cert.getSubjectX500Principal(); + if (xp == null) + { + if (Configuration.DEBUG) + log.fine("Certiticate, with serial number " + cert.getSerialNumber() //$NON-NLS-1$ + + ", has null Subject. Return [unknown]"); //$NON-NLS-1$ + return Messages.getString("SFHelper.14"); //$NON-NLS-1$ + } + String result = xp.getName(); + if (result == null) + { + if (Configuration.DEBUG) + log.fine("Certiticate, with serial number " + cert.getSerialNumber() //$NON-NLS-1$ + + ", has a Subject with null DN. Return [unnamed]"); //$NON-NLS-1$ + return Messages.getString("SFHelper.17"); //$NON-NLS-1$ + } + return result; + } + + /** + * Given an X.509 certificate this method returns the end validity date of + * this certificate. + * + * @param cert an X.509 certificate. + * @return the date when this certificate stops being valid. + */ + private Date getNotAfterDate(X509Certificate cert) + { + Date result = cert.getNotAfter(); + if (result == null) + { + if (Configuration.DEBUG) + log.fine("Certiticate, with serial number " + cert.getSerialNumber() //$NON-NLS-1$ + + ", has null start-validity date. Return epoch"); //$NON-NLS-1$ + return new Date(0); + } + return result; + } + + /** + * Given an X.509 certificate this method returns the start validity date of + * this certificate. + * + * @param cert an X.509 certificate. + * @return the date when this certificate starts being valid. + */ + private Date getNotBeforeDate(X509Certificate cert) + { + Date result = cert.getNotBefore(); + if (result == null) + { + if (Configuration.DEBUG) + log.fine("Certiticate, with serial number " + cert.getSerialNumber() //$NON-NLS-1$ + + ", has null end-validity date. Return epoch"); //$NON-NLS-1$ + return new Date(0); + } + return result; + } } diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/CACertCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/CACertCmd.java new file mode 100644 index 00000000000..2bf832beee0 --- /dev/null +++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/CACertCmd.java @@ -0,0 +1,313 @@ +/* CACertCmd.java -- GNU specific cacert handler + Copyright (C) 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath 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 for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.classpath.tools.keytool; + +import gnu.classpath.Configuration; +import gnu.classpath.tools.getopt.ClasspathToolParser; +import gnu.classpath.tools.getopt.Option; +import gnu.classpath.tools.getopt.OptionException; +import gnu.classpath.tools.getopt.OptionGroup; +import gnu.classpath.tools.getopt.Parser; + +import java.io.File; +import java.io.IOException; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.cert.Certificate; +import java.security.cert.CertificateException; +import java.security.cert.CertificateFactory; +import java.util.logging.Logger; + +/** + * The <code>-cacert</code> keytol command handler is used to import a CA + * trusted X.509 certificate into a key store. + * <p> + * Possible options for this command are: + * <p> + * <dl> + * <dt>-file FILE_NAME</dt> + * <dd>The fully qualified path of the file containing the trusted CA + * certificate to import. If omitted, the tool will process STDIN. + * <p></dd> + * + * <dt>-storetype STORE_TYPE</dt> + * <dd>Use this option to specify the type of the key store to use. The + * default value, if this option is omitted, is that of the property + * <code>keystore.type</code> in the security properties file, which is + * obtained by invoking the {@link java.security.KeyStore#getDefaultType()} + * static method. + * <p></dd> + * + * <dt>-keystore URL</dt> + * <dd>Use this option to specify the location of the key store to use. + * The default value is a file {@link java.net.URL} referencing the file + * named <code>.keystore</code> located in the path returned by the call to + * {@link java.lang.System#getProperty(String)} using <code>user.home</code> + * as argument. + * <p> + * If a URL was specified, but was found to be malformed --e.g. missing + * protocol element-- the tool will attempt to use the URL value as a file- + * name (with absolute or relative path-name) of a key store --as if the + * protocol was <code>file:</code>. + * <p></dd> + * + * <dt>-storepass PASSWORD</dt> + * <dd>Use this option to specify the password protecting the key store. If + * this option is omitted from the command line, you will be prompted to + * provide a password. + * <p></dd> + * + * <dt>-provider PROVIDER_CLASS_NAME</dt> + * <dd>A fully qualified class name of a Security Provider to add to the + * current list of Security Providers already installed in the JVM in-use. + * If a provider class is specified with this option, and was successfully + * added to the runtime --i.e. it was not already installed-- then the tool + * will attempt to removed this Security Provider before exiting. + * <p></dd> + * + * <dt>-v</dt> + * <dd>Use this option to enable more verbose output.</dd> + * </dl> + */ +public class CACertCmd + extends Command +{ + private static final Logger log = Logger.getLogger(CACertCmd.class.getName()); + /** Pathname of the file containing the CA certificate to import. */ + protected String _certFileName; + /** Type of the key store to use. */ + protected String _ksType; + /** The URL to the keystore where the trusted certificates will be added. */ + protected String _ksURL; + /** The password protecting the keystore. */ + protected String _ksPassword; + /** Class name of a security provider to use. */ + protected String _providerClassName; + /** Reference to the X.509 factory. */ + private CertificateFactory x509Factory; + + // default 0-arguments constructor + + // public setters ----------------------------------------------------------- + + /** @param pathName the fully qualified path name of the file to process. */ + public void setFile(String pathName) + { + this._certFileName = pathName; + } + + /** @param type the key-store type to use. */ + public void setStoretype(String type) + { + this._ksType = type; + } + + /** @param url the key-store URL to use. */ + public void setKeystore(String url) + { + this._ksURL = url; + } + + /** @param password the key-store password to use. */ + public void setStorepass(String password) + { + this._ksPassword = password; + } + + /** @param className a security provider fully qualified class name to use. */ + public void setProvider(String className) + { + this._providerClassName = className; + } + + // life-cycle methods ------------------------------------------------------- + + /* (non-Javadoc) + * @see gnu.classpath.tools.keytool.Command#setup() + */ + void setup() throws Exception + { + setInputStreamParam(_certFileName); + setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL); + if (Configuration.DEBUG) + { + log.fine("-cacert handler will use the following options:"); //$NON-NLS-1$ + log.fine(" -file=" + _certFileName); //$NON-NLS-1$ + log.fine(" -storetype=" + storeType); //$NON-NLS-1$ + log.fine(" -keystore=" + storeURL); //$NON-NLS-1$ + log.fine(" -provider=" + provider); //$NON-NLS-1$ + log.fine(" -v=" + verbose); //$NON-NLS-1$ + } + } + + void start() throws CertificateException, KeyStoreException, + NoSuchAlgorithmException, IOException + { + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$ + alias = getAliasFromFileName(_certFileName); + if (store.containsAlias(alias)) + throw new IllegalArgumentException(Messages.getFormattedString("CACertCmd.0", //$NON-NLS-1$ + alias)); + x509Factory = CertificateFactory.getInstance("X.509"); //$NON-NLS-1$ + Certificate certificate = x509Factory.generateCertificate(inStream); + if (Configuration.DEBUG) + log.fine("certificate = " + certificate); //$NON-NLS-1$ + store.setCertificateEntry(alias, certificate); + saveKeyStore(); + if (verbose) + System.out.println(Messages.getFormattedString("CACertCmd.1", //$NON-NLS-1$ + new Object[] { _certFileName, + alias })); + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$ + } + + // own methods -------------------------------------------------------------- + + /* (non-Javadoc) + * @see gnu.classpath.tools.keytool.Command#getParser() + */ + Parser getParser() + { + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$ + Parser result = new ClasspathToolParser(Main.CACERT_CMD, true); + result.setHeader(Messages.getString("CACertCmd.2")); //$NON-NLS-1$ + result.setFooter(Messages.getString("CACertCmd.3")); //$NON-NLS-1$ + OptionGroup options = new OptionGroup(Messages.getString("CACertCmd.4")); //$NON-NLS-1$ + options.add(new Option(Main.FILE_OPT, + Messages.getString("CACertCmd.5"), //$NON-NLS-1$ + Messages.getString("CACertCmd.6")) //$NON-NLS-1$ + { + public void parsed(String argument) throws OptionException + { + _certFileName = argument; + } + }); + options.add(new Option(Main.STORETYPE_OPT, + Messages.getString("CACertCmd.7"), //$NON-NLS-1$ + Messages.getString("CACertCmd.8")) //$NON-NLS-1$ + { + public void parsed(String argument) throws OptionException + { + _ksType = argument; + } + }); + options.add(new Option(Main.KEYSTORE_OPT, + Messages.getString("CACertCmd.9"), //$NON-NLS-1$ + Messages.getString("CACertCmd.10")) //$NON-NLS-1$ + { + public void parsed(String argument) throws OptionException + { + _ksURL = argument; + } + }); + options.add(new Option(Main.STOREPASS_OPT, + Messages.getString("CACertCmd.11"), //$NON-NLS-1$ + Messages.getString("CACertCmd.12")) //$NON-NLS-1$ + { + public void parsed(String argument) throws OptionException + { + _ksPassword = argument; + } + }); + options.add(new Option(Main.PROVIDER_OPT, + Messages.getString("CACertCmd.13"), //$NON-NLS-1$ + Messages.getString("CACertCmd.14")) //$NON-NLS-1$ + { + public void parsed(String argument) throws OptionException + { + _providerClassName = argument; + } + }); + options.add(new Option(Main.VERBOSE_OPT, + Messages.getString("CACertCmd.15")) //$NON-NLS-1$ + { + public void parsed(String argument) throws OptionException + { + verbose = true; + } + }); + result.add(options); + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$ + return result; + } + + /** + * Construct an Alias string from the name of the file containing the + * certificate to import. This method first removes the last dot (".") + * character and any subsequent characters from the input name, and then + * replaces any space and dot characters with underscores. For example the + * input string <code>brasil.gov.br.cert</code> will result in + * <code>brasil_gov_br</code> as its alias. + * + * @param fileName the name of the file containing the CA certificate + * @return a string which can, and will, be used as the Alias of this CA + * certificate. + */ + private String getAliasFromFileName(String fileName) + { + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "getAliasFromFileName", fileName); //$NON-NLS-1$ + // get the basename + fileName = new File(fileName).getName(); + // remove '.' if at start + if (fileName.startsWith(".")) //$NON-NLS-1$ + fileName = fileName.substring(1); + + // remove last \..+ + int ndx = fileName.lastIndexOf('.'); + if (ndx > 0) + fileName = fileName.substring(0, ndx); + // replace spaces and dots with underscores + char[] chars = fileName.toCharArray(); + for (int i = 0; i < chars.length; i++) + { + char c = chars[i]; + if (c == ' ' || c == '.') + chars[i] = '_'; + } + String result = new String(chars); + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "getAliasFromFileName", result); //$NON-NLS-1$ + return result; + } +} diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/CertReqCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/CertReqCmd.java index fc85e6abd15..692b1f69015 100644 --- a/libjava/classpath/tools/gnu/classpath/tools/keytool/CertReqCmd.java +++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/CertReqCmd.java @@ -38,6 +38,7 @@ exception statement from your version. */ package gnu.classpath.tools.keytool; +import gnu.classpath.Configuration; import gnu.classpath.tools.getopt.ClasspathToolParser; import gnu.classpath.tools.getopt.Option; import gnu.classpath.tools.getopt.OptionException; @@ -258,24 +259,26 @@ class CertReqCmd extends Command setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL); setAliasParam(_alias); setKeyPasswordNoPrompt(_password); - - log.finer("-certreq handler will use the following options:"); //$NON-NLS-1$ - log.finer(" -alias=" + alias); //$NON-NLS-1$ - log.finer(" -sigalg=" + _sigAlgorithm); //$NON-NLS-1$ - log.finer(" -file=" + _certReqFileName); //$NON-NLS-1$ - log.finer(" -storetype=" + storeType); //$NON-NLS-1$ - log.finer(" -keystore=" + storeURL); //$NON-NLS-1$ - log.finer(" -provider=" + provider); //$NON-NLS-1$ - log.finer(" -v=" + verbose); //$NON-NLS-1$ - log.finer(" -attributes=" + nullAttributes); //$NON-NLS-1$ + if (Configuration.DEBUG) + { + log.fine("-certreq handler will use the following options:"); //$NON-NLS-1$ + log.fine(" -alias=" + alias); //$NON-NLS-1$ + log.fine(" -sigalg=" + _sigAlgorithm); //$NON-NLS-1$ + log.fine(" -file=" + _certReqFileName); //$NON-NLS-1$ + log.fine(" -storetype=" + storeType); //$NON-NLS-1$ + log.fine(" -keystore=" + storeURL); //$NON-NLS-1$ + log.fine(" -provider=" + provider); //$NON-NLS-1$ + log.fine(" -v=" + verbose); //$NON-NLS-1$ + log.fine(" -attributes=" + nullAttributes); //$NON-NLS-1$ + } } void start() throws KeyStoreException, NoSuchAlgorithmException, IOException, UnsupportedCallbackException, UnrecoverableKeyException, InvalidKeyException, SignatureException { - log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$ // 1. get the key entry and certificate chain associated to alias Key privateKey = getAliasPrivateKey(); Certificate[] chain = store.getCertificateChain(alias); @@ -305,16 +308,16 @@ class CertReqCmd extends Command } writer.close(); - - log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$ } // own methods -------------------------------------------------------------- Parser getParser() { - log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$ Parser result = new ClasspathToolParser(Main.CERTREQ_CMD, true); result.setHeader(Messages.getString("CertReqCmd.25")); //$NON-NLS-1$ result.setFooter(Messages.getString("CertReqCmd.24")); //$NON-NLS-1$ @@ -408,8 +411,8 @@ class CertReqCmd extends Command } }); result.add(options); - - log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$ return result; } diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/Command.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/Command.java index 0811074b8c1..bc5cff2aaba 100644 --- a/libjava/classpath/tools/gnu/classpath/tools/keytool/Command.java +++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/Command.java @@ -38,6 +38,7 @@ exception statement from your version. */ package gnu.classpath.tools.keytool; +import gnu.classpath.Configuration; import gnu.classpath.SystemProperties; import gnu.classpath.tools.common.CallbackUtil; import gnu.classpath.tools.common.ProviderUtil; @@ -242,12 +243,12 @@ abstract class Command */ String[] processArgs(String[] args) { - log.entering(this.getClass().getName(), "processArgs", args); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "processArgs", args); //$NON-NLS-1$ Parser cmdOptionsParser = getParser(); String[] result = cmdOptionsParser.parse(args); - - log.exiting(this.getClass().getName(), "processArgs", result); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "processArgs", result); //$NON-NLS-1$ return result; } @@ -312,8 +313,8 @@ abstract class Command */ void teardown() { - log.entering(this.getClass().getName(), "teardown"); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "teardown"); //$NON-NLS-1$ if (storeStream != null) try { @@ -321,8 +322,9 @@ abstract class Command } catch (IOException ignored) { - log.fine("Exception while closing key store URL stream. Ignored: " //$NON-NLS-1$ - + ignored); + if (Configuration.DEBUG) + log.fine("Exception while closing key store URL stream. Ignored: " //$NON-NLS-1$ + + ignored); } if (outStream != null) @@ -357,7 +359,8 @@ abstract class Command if (providerNdx > 0) ProviderUtil.removeProvider(provider.getName()); - log.exiting(this.getClass().getName(), "teardown"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "teardown"); //$NON-NLS-1$ } // parameter setup and validation methods ----------------------------------- @@ -371,6 +374,11 @@ abstract class Command /** * Convenience method to setup the key store given its type, its password, its * location and portentially a specialized security provider. + * <p> + * Calls the method with the same name and 5 arguments passing + * <code>false</code> to the first argument implying that no attempt to + * create the keystore will be made if one was not found at the designated + * location. * * @param className the potentially null fully qualified class name of a * security provider to add at runtime, if no installed provider is @@ -385,10 +393,31 @@ abstract class Command throws IOException, UnsupportedCallbackException, KeyStoreException, NoSuchAlgorithmException, CertificateException { + setKeyStoreParams(false, className, type, password, url); + } + + /** + * Convenience method to setup the key store given its type, its password, its + * location and portentially a specialized security provider. + * + * @param createIfNotFound if <code>true</code> then create the keystore if + * it was not found; otherwise do not. + * @param className the potentially null fully qualified class name of a + * security provider to add at runtime, if no installed provider is + * able to provide a key store implementation of the desired type. + * @param type the potentially null type of the key store to request from the + * key store factory. + * @param password the potentially null password protecting the key store. + * @param url the URL of the key store. + */ + protected void setKeyStoreParams(boolean createIfNotFound, String className, + String type, String password, String url) + throws IOException, UnsupportedCallbackException, KeyStoreException, + NoSuchAlgorithmException, CertificateException + { setProviderClassNameParam(className); setKeystoreTypeParam(type); - setKeystorePasswordParam(password); - setKeystoreURLParam(url); + setKeystoreURLParam(createIfNotFound, url, password); } /** @@ -399,17 +428,20 @@ abstract class Command * security provider to add, if it is not already installed, to the * set of available providers. */ - protected void setProviderClassNameParam(String className) + private void setProviderClassNameParam(String className) { - log.finest("setProviderClassNameParam(" + className + ")"); //$NON-NLS-1$ //$NON-NLS-2$ + if (Configuration.DEBUG) + log.fine("setProviderClassNameParam(" + className + ")"); //$NON-NLS-1$ //$NON-NLS-2$ if (className != null && className.trim().length() > 0) { className = className.trim(); SecurityProviderInfo spi = ProviderUtil.addProvider(className); provider = spi.getProvider(); if (provider == null) - log.fine("Was unable to add provider from class " + className); - + { + if (Configuration.DEBUG) + log.fine("Was unable to add provider from class " + className); + } providerNdx = spi.getPosition(); } } @@ -424,9 +456,10 @@ abstract class Command * For GNU Classpath this is <i>gkr</i> which stands for the "Gnu * KeyRing" specifications. */ - protected void setKeystoreTypeParam(String type) + private void setKeystoreTypeParam(String type) { - log.finest("setKeystoreTypeParam(" + type + ")"); //$NON-NLS-1$ //$NON-NLS-2$ + if (Configuration.DEBUG) + log.fine("setKeystoreTypeParam(" + type + ")"); //$NON-NLS-1$ //$NON-NLS-2$ if (type == null || type.trim().length() == 0) storeType = KeyStore.getDefaultType(); else @@ -484,7 +517,7 @@ abstract class Command * @throws SecurityException if no password is available, even after prompting * the user. */ - protected void setKeyPasswordParam() throws IOException, + private void setKeyPasswordParam() throws IOException, UnsupportedCallbackException { String prompt = Messages.getFormattedString("Command.21", alias); //$NON-NLS-1$ @@ -496,7 +529,7 @@ abstract class Command throw new SecurityException(Messages.getString("Command.23")); //$NON-NLS-1$ } - protected void setKeystorePasswordParam(String password) throws IOException, + private void setKeystorePasswordParam(String password) throws IOException, UnsupportedCallbackException { if (password != null) @@ -514,18 +547,25 @@ abstract class Command /** * Set the key store URL to use. * - * @param url + * @param createIfNotFound when <code>true</code> an attempt to create a + * keystore at the designated location will be made. If + * <code>false</code> then no file creation is carried out, which + * may cause an exception to be thrown later. + * @param url the full, or partial, URL to the keystore location. + * @param password an eventually null string to use when loading the keystore. * @throws IOException * @throws KeyStoreException * @throws UnsupportedCallbackException * @throws NoSuchAlgorithmException * @throws CertificateException */ - protected void setKeystoreURLParam(String url) throws IOException, + private void setKeystoreURLParam(boolean createIfNotFound, String url, + String password) throws IOException, KeyStoreException, UnsupportedCallbackException, NoSuchAlgorithmException, CertificateException { - log.finest("setKeystoreURLParam(" + url + ")"); //$NON-NLS-1$ //$NON-NLS-2$ + if (Configuration.DEBUG) + log.fine("setKeystoreURLParam(" + url + ")"); //$NON-NLS-1$ //$NON-NLS-2$ if (url == null || url.trim().length() == 0) { String userHome = SystemProperties.getProperty("user.home"); //$NON-NLS-1$ @@ -533,16 +573,19 @@ abstract class Command throw new InvalidParameterException(Messages.getString("Command.36")); //$NON-NLS-1$ url = userHome.trim() + "/.keystore"; //$NON-NLS-1$ - // if it does not exist create it - new File(url).createNewFile(); + // if it does not exist create it if required + if (createIfNotFound) + new File(url).createNewFile(); url = "file:" + url; //$NON-NLS-1$ } else { url = url.trim(); if (url.indexOf(":") == -1) // if it does not exist create it //$NON-NLS-1$ - new File(url).createNewFile(); - + { + if (createIfNotFound) + new File(url).createNewFile(); + } url = "file:" + url; //$NON-NLS-1$ } @@ -551,7 +594,8 @@ abstract class Command storeStream = storeURL.openStream(); if (storeStream.available() == 0) { - log.fine("Store is empty. Will use <null> when loading, to create it"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.fine("Store is empty. Will use <null> when loading, to create it"); //$NON-NLS-1$ newKeyStore = true; } @@ -564,8 +608,9 @@ abstract class Command if (provider != null) throw x; - log.fine("Exception while getting key store with default provider(s)." //$NON-NLS-1$ - + " Will prompt user for another provider and continue"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.fine("Exception while getting key store with default provider(s)." //$NON-NLS-1$ + + " Will prompt user for another provider and continue"); //$NON-NLS-1$ String prompt = Messages.getString("Command.40"); //$NON-NLS-1$ NameCallback ncb = new NameCallback(prompt); getCallbackHandler().handle(new Callback[] { ncb }); @@ -580,6 +625,8 @@ abstract class Command store = KeyStore.getInstance(storeType, provider); } + setKeystorePasswordParam(password); + // now we have a KeyStore instance. load it // KeyStore public API claims: "...In order to create an empty keystore, // you pass null as the InputStream argument to the load method. @@ -596,8 +643,9 @@ abstract class Command } catch (IOException x) { - log.fine("Exception while closing the key store input stream: " + x //$NON-NLS-1$ - + ". Ignore"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.fine("Exception while closing the key store input stream: " + x //$NON-NLS-1$ + + ". Ignore"); //$NON-NLS-1$ } } @@ -818,9 +866,9 @@ abstract class Command PrivateKey privateKey) throws IOException, SignatureException, InvalidKeyException { - log.entering(this.getClass().getName(), "getSelfSignedCertificate", //$NON-NLS-1$ - new Object[] { distinguishedName, publicKey, privateKey }); - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "getSelfSignedCertificate", //$NON-NLS-1$ + new Object[] { distinguishedName, publicKey, privateKey }); byte[] versionBytes = new DERValue(DER.INTEGER, BigInteger.ZERO).getEncoded(); DERValue derVersion = new DERValue(DER.CONSTRUCTED | DER.CONTEXT | 0, versionBytes.length, versionBytes, null); @@ -901,8 +949,8 @@ abstract class Command ByteArrayOutputStream baos = new ByteArrayOutputStream(); DERWriter.write(baos, derCertificate); byte[] result = baos.toByteArray(); - - log.exiting(this.getClass().getName(), "getSelfSignedCertificate"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "getSelfSignedCertificate"); //$NON-NLS-1$ return result; } @@ -992,8 +1040,8 @@ abstract class Command protected void saveKeyStore(char[] password) throws IOException, KeyStoreException, NoSuchAlgorithmException, CertificateException { - log.entering(this.getClass().getName(), "saveKeyStore"); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "saveKeyStore"); //$NON-NLS-1$ URLConnection con = storeURL.openConnection(); con.setDoOutput(true); con.setUseCaches(false); @@ -1004,8 +1052,8 @@ abstract class Command store.store(out, password); out.flush(); out.close(); - - log.exiting(this.getClass().getName(), "saveKeyStore"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "saveKeyStore"); //$NON-NLS-1$ } /** diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/DeleteCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/DeleteCmd.java index 4c32ee1e697..8107055d02b 100644 --- a/libjava/classpath/tools/gnu/classpath/tools/keytool/DeleteCmd.java +++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/DeleteCmd.java @@ -38,6 +38,7 @@ exception statement from your version. */ package gnu.classpath.tools.keytool; +import gnu.classpath.Configuration; import gnu.classpath.tools.getopt.ClasspathToolParser; import gnu.classpath.tools.getopt.Option; import gnu.classpath.tools.getopt.OptionException; @@ -158,33 +159,35 @@ class DeleteCmd extends Command { setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL); setTheAlias(_alias); - - log.finer("-delete handler will use the following options:"); //$NON-NLS-1$ - log.finer(" -alias=" + alias); //$NON-NLS-1$ - log.finer(" -storetype=" + storeType); //$NON-NLS-1$ - log.finer(" -keystore=" + storeURL); //$NON-NLS-1$ - log.finer(" -provider=" + provider); //$NON-NLS-1$ - log.finer(" -v=" + verbose); //$NON-NLS-1$ + if (Configuration.DEBUG) + { + log.fine("-delete handler will use the following options:"); //$NON-NLS-1$ + log.fine(" -alias=" + alias); //$NON-NLS-1$ + log.fine(" -storetype=" + storeType); //$NON-NLS-1$ + log.fine(" -keystore=" + storeURL); //$NON-NLS-1$ + log.fine(" -provider=" + provider); //$NON-NLS-1$ + log.fine(" -v=" + verbose); //$NON-NLS-1$ + } } void start() throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException { - log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$ ensureStoreContainsAlias(); store.deleteEntry(alias); saveKeyStore(); - - log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$ } // own methods -------------------------------------------------------------- Parser getParser() { - log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$ Parser result = new ClasspathToolParser(Main.DELETE_CMD, true); result.setHeader(Messages.getString("DeleteCmd.18")); //$NON-NLS-1$ result.setFooter(Messages.getString("DeleteCmd.17")); //$NON-NLS-1$ @@ -243,8 +246,8 @@ class DeleteCmd extends Command } }); result.add(options); - - log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$ return result; } diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/ExportCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/ExportCmd.java index 46f7acdf013..75f71801c9a 100644 --- a/libjava/classpath/tools/gnu/classpath/tools/keytool/ExportCmd.java +++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/ExportCmd.java @@ -38,6 +38,7 @@ exception statement from your version. */ package gnu.classpath.tools.keytool; +import gnu.classpath.Configuration; import gnu.classpath.tools.getopt.ClasspathToolParser; import gnu.classpath.tools.getopt.Option; import gnu.classpath.tools.getopt.OptionException; @@ -188,32 +189,36 @@ class ExportCmd extends Command setOutputStreamParam(_certFileName); setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL); setAliasParam(_alias); - - log.finer("-export handler will use the following options:"); //$NON-NLS-1$ - log.finer(" -alias=" + alias); //$NON-NLS-1$ - log.finer(" -file=" + _certFileName); //$NON-NLS-1$ - log.finer(" -storetype=" + storeType); //$NON-NLS-1$ - log.finer(" -keystore=" + storeURL); //$NON-NLS-1$ - log.finer(" -provider=" + provider); //$NON-NLS-1$ - log.finer(" -rfc=" + rfc); //$NON-NLS-1$ - log.finer(" -v=" + verbose); //$NON-NLS-1$ + if (Configuration.DEBUG) + { + log.fine("-export handler will use the following options:"); //$NON-NLS-1$ + log.fine(" -alias=" + alias); //$NON-NLS-1$ + log.fine(" -file=" + _certFileName); //$NON-NLS-1$ + log.fine(" -storetype=" + storeType); //$NON-NLS-1$ + log.fine(" -keystore=" + storeURL); //$NON-NLS-1$ + log.fine(" -provider=" + provider); //$NON-NLS-1$ + log.fine(" -rfc=" + rfc); //$NON-NLS-1$ + log.fine(" -v=" + verbose); //$NON-NLS-1$ + } } void start() throws KeyStoreException, CertificateEncodingException, IOException { - log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$ ensureStoreContainsAlias(); Certificate certificate; if (store.isCertificateEntry(alias)) { - log.finer("Alias [" + alias + "] is a trusted certificate"); //$NON-NLS-1$ //$NON-NLS-2$ + if (Configuration.DEBUG) + log.fine("Alias [" + alias + "] is a trusted certificate"); //$NON-NLS-1$ //$NON-NLS-2$ certificate = store.getCertificate(alias); } else { - log.finer("Alias [" + alias + "] is a key entry"); //$NON-NLS-1$ //$NON-NLS-2$ + if (Configuration.DEBUG) + log.fine("Alias [" + alias + "] is a key entry"); //$NON-NLS-1$ //$NON-NLS-2$ Certificate[] chain = store.getCertificateChain(alias); certificate = chain[0]; } @@ -231,15 +236,16 @@ class ExportCmd extends Command outStream.write(derBytes); // stream is closed in Command.teardown() - log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$ } // own methods -------------------------------------------------------------- Parser getParser() { - log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$ Parser result = new ClasspathToolParser(Main.EXPORT_CMD, true); result.setHeader(Messages.getString("ExportCmd.17")); //$NON-NLS-1$ result.setFooter(Messages.getString("ExportCmd.18")); //$NON-NLS-1$ @@ -315,8 +321,8 @@ class ExportCmd extends Command } }); result.add(options); - - log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$ return result; } } diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/GenKeyCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/GenKeyCmd.java index 6da0f58b6fa..03a1555a8c6 100644 --- a/libjava/classpath/tools/gnu/classpath/tools/keytool/GenKeyCmd.java +++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/GenKeyCmd.java @@ -38,6 +38,7 @@ exception statement from your version. */ package gnu.classpath.tools.keytool; +import gnu.classpath.Configuration; import gnu.classpath.tools.getopt.ClasspathToolParser; import gnu.classpath.tools.getopt.Option; import gnu.classpath.tools.getopt.OptionException; @@ -302,68 +303,76 @@ class GenKeyCmd extends Command void setup() throws Exception { - setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL); + setKeyStoreParams(true, _providerClassName, _ksType, _ksPassword, _ksURL); setAliasParam(_alias); setKeyPasswordParam(_password); setAlgorithmParams(_keyAlgorithm, _sigAlgorithm); setKeySize(_keySizeStr); setDName(_dName); setValidityParam(_validityStr); - - log.finer("-genkey handler will use the following options:"); //$NON-NLS-1$ - log.finer(" -alias=" + alias); //$NON-NLS-1$ - log.finer(" -keyalg=" + keyPairGenerator.getAlgorithm()); //$NON-NLS-1$ - log.finer(" -keysize=" + keySize); //$NON-NLS-1$ - log.finer(" -sigalg=" + signatureAlgorithm.getAlgorithm()); //$NON-NLS-1$ - log.finer(" -dname=" + distinguishedName); //$NON-NLS-1$ - log.finer(" -validity=" + validityInDays); //$NON-NLS-1$ - log.finer(" -storetype=" + storeType); //$NON-NLS-1$ - log.finer(" -keystore=" + storeURL); //$NON-NLS-1$ - log.finer(" -provider=" + provider); //$NON-NLS-1$ - log.finer(" -v=" + verbose); //$NON-NLS-1$ + if (Configuration.DEBUG) + { + log.fine("-genkey handler will use the following options:"); //$NON-NLS-1$ + log.fine(" -alias=" + alias); //$NON-NLS-1$ + log.fine(" -keyalg=" + keyPairGenerator.getAlgorithm()); //$NON-NLS-1$ + log.fine(" -keysize=" + keySize); //$NON-NLS-1$ + log.fine(" -sigalg=" + signatureAlgorithm.getAlgorithm()); //$NON-NLS-1$ + log.fine(" -dname=" + distinguishedName); //$NON-NLS-1$ + log.fine(" -validity=" + validityInDays); //$NON-NLS-1$ + log.fine(" -storetype=" + storeType); //$NON-NLS-1$ + log.fine(" -keystore=" + storeURL); //$NON-NLS-1$ + log.fine(" -provider=" + provider); //$NON-NLS-1$ + log.fine(" -v=" + verbose); //$NON-NLS-1$ + } } void start() throws CertificateException, KeyStoreException, InvalidKeyException, SignatureException, IOException, NoSuchAlgorithmException { - log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$ - + if (Configuration.DEBUG) + { + log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$ + log.fine("About to generate key-pair..."); //$NON-NLS-1$ + } // 1. generate a new key-pair - log.finer("About to generate key-pair..."); //$NON-NLS-1$ keyPairGenerator.initialize(keySize); KeyPair kp = keyPairGenerator.generateKeyPair(); PublicKey publicKey = kp.getPublic(); PrivateKey privateKey = kp.getPrivate(); // 2. generate a self-signed certificate - log.finer("About to generate a self-signed certificate..."); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.fine("About to generate a self-signed certificate..."); //$NON-NLS-1$ byte[] derBytes = getSelfSignedCertificate(distinguishedName, publicKey, privateKey); - log.finest(Util.dumpString(derBytes, "derBytes ")); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.fine(Util.dumpString(derBytes, "derBytes ")); //$NON-NLS-1$ CertificateFactory x509Factory = CertificateFactory.getInstance(Main.X_509); ByteArrayInputStream bais = new ByteArrayInputStream(derBytes); Certificate certificate = x509Factory.generateCertificate(bais); - log.finest("certificate = " + certificate); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.fine("certificate = " + certificate); //$NON-NLS-1$ // 3. store it, w/ its private key, associating them to alias Certificate[] chain = new Certificate[] { certificate }; - log.finest("About to store newly generated material in key store..."); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.fine("About to store newly generated material in key store..."); //$NON-NLS-1$ store.setKeyEntry(alias, privateKey, keyPasswordChars, chain); // 4. persist the key store saveKeyStore(); - - log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$ } // own methods -------------------------------------------------------------- Parser getParser() { - log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$ Parser result = new ClasspathToolParser(Main.GENKEY_CMD, true); result.setHeader(Messages.getString("GenKeyCmd.57")); //$NON-NLS-1$ result.setFooter(Messages.getString("GenKeyCmd.58")); //$NON-NLS-1$ @@ -476,8 +485,8 @@ class GenKeyCmd extends Command } }); result.add(options); - - log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$ return result; } @@ -574,8 +583,8 @@ class GenKeyCmd extends Command name = sb.toString().trim(); } - - log.fine("dName=[" + name + "]"); //$NON-NLS-1$ //$NON-NLS-2$ + if (Configuration.DEBUG) + log.fine("dName=[" + name + "]"); //$NON-NLS-1$ //$NON-NLS-2$ distinguishedName = new X500DistinguishedName(name); } diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/IdentityDBCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/IdentityDBCmd.java index 46c5b97692b..d0de589d933 100644 --- a/libjava/classpath/tools/gnu/classpath/tools/keytool/IdentityDBCmd.java +++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/IdentityDBCmd.java @@ -38,6 +38,7 @@ exception statement from your version. */ package gnu.classpath.tools.keytool; +import gnu.classpath.Configuration; import gnu.classpath.tools.getopt.ClasspathToolParser; import gnu.classpath.tools.getopt.Option; import gnu.classpath.tools.getopt.OptionException; @@ -148,22 +149,24 @@ class IdentityDBCmd extends Command void setup() throws Exception { setInputStreamParam(_idbFileName); - setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL); - - log.finer("-identitydb handler will use the following options:"); //$NON-NLS-1$ - log.finer(" -file=" + _idbFileName); //$NON-NLS-1$ - log.finer(" -storetype=" + storeType); //$NON-NLS-1$ - log.finer(" -keystore=" + storeURL); //$NON-NLS-1$ - log.finer(" -provider=" + provider); //$NON-NLS-1$ - log.finer(" -v=" + verbose); //$NON-NLS-1$ + setKeyStoreParams(true, _providerClassName, _ksType, _ksPassword, _ksURL); + if (Configuration.DEBUG) + { + log.fine("-identitydb handler will use the following options:"); //$NON-NLS-1$ + log.fine(" -file=" + _idbFileName); //$NON-NLS-1$ + log.fine(" -storetype=" + storeType); //$NON-NLS-1$ + log.fine(" -keystore=" + storeURL); //$NON-NLS-1$ + log.fine(" -provider=" + provider); //$NON-NLS-1$ + log.fine(" -v=" + verbose); //$NON-NLS-1$ + } } // own methods -------------------------------------------------------------- Parser getParser() { - log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$ Parser result = new ClasspathToolParser(Main.IDENTITYDB_CMD, true); result.setHeader(Messages.getString("IdentityDBCmd.7")); //$NON-NLS-1$ result.setFooter(Messages.getString("IdentityDBCmd.8")); //$NON-NLS-1$ @@ -222,8 +225,8 @@ class IdentityDBCmd extends Command } }); result.add(options); - - log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$ return result; } } diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/ImportCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/ImportCmd.java index 2e01bc0e4f9..3a6ed872bfb 100644 --- a/libjava/classpath/tools/gnu/classpath/tools/keytool/ImportCmd.java +++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/ImportCmd.java @@ -38,6 +38,7 @@ exception statement from your version. */ package gnu.classpath.tools.keytool; +import gnu.classpath.Configuration; import gnu.classpath.SystemProperties; import gnu.classpath.tools.getopt.ClasspathToolParser; import gnu.classpath.tools.getopt.Option; @@ -291,27 +292,29 @@ class ImportCmd extends Command void setup() throws Exception { setInputStreamParam(_certFileName); - setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL); + setKeyStoreParams(true, _providerClassName, _ksType, _ksPassword, _ksURL); setAliasParam(_alias); setKeyPasswordNoPrompt(_password); - - log.finer("-import handler will use the following options:"); //$NON-NLS-1$ - log.finer(" -alias=" + alias); //$NON-NLS-1$ - log.finer(" -file=" + _certFileName); //$NON-NLS-1$ - log.finer(" -noprompt=" + noPrompt); //$NON-NLS-1$ - log.finer(" -trustcacerts=" + trustCACerts); //$NON-NLS-1$ - log.finer(" -storetype=" + storeType); //$NON-NLS-1$ - log.finer(" -keystore=" + storeURL); //$NON-NLS-1$ - log.finer(" -provider=" + provider); //$NON-NLS-1$ - log.finer(" -v=" + verbose); //$NON-NLS-1$ + if (Configuration.DEBUG) + { + log.fine("-import handler will use the following options:"); //$NON-NLS-1$ + log.fine(" -alias=" + alias); //$NON-NLS-1$ + log.fine(" -file=" + _certFileName); //$NON-NLS-1$ + log.fine(" -noprompt=" + noPrompt); //$NON-NLS-1$ + log.fine(" -trustcacerts=" + trustCACerts); //$NON-NLS-1$ + log.fine(" -storetype=" + storeType); //$NON-NLS-1$ + log.fine(" -keystore=" + storeURL); //$NON-NLS-1$ + log.fine(" -provider=" + provider); //$NON-NLS-1$ + log.fine(" -v=" + verbose); //$NON-NLS-1$ + } } void start() throws CertificateException, KeyStoreException, IOException, UnsupportedCallbackException, NoSuchAlgorithmException, CertPathValidatorException, UnrecoverableKeyException { - log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$ if (trustCACerts) { String fs = SystemProperties.getProperty("file.separator"); //$NON-NLS-1$ @@ -336,16 +339,16 @@ class ImportCmd extends Command ensureAliasIsKeyEntry(); importCertificateReply(); } - - log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$ } // own methods -------------------------------------------------------------- Parser getParser() { - log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$ Parser result = new ClasspathToolParser(Main.IMPORT_CMD, true); result.setHeader(Messages.getString("ImportCmd.27")); //$NON-NLS-1$ result.setFooter(Messages.getString("ImportCmd.26")); //$NON-NLS-1$ @@ -438,8 +441,8 @@ class ImportCmd extends Command } }); result.add(options); - - log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$ return result; } @@ -480,10 +483,11 @@ class ImportCmd extends Command UnsupportedCallbackException, CertPathValidatorException, UnrecoverableKeyException { - log.entering(this.getClass().getName(), "importNewTrustedCertificate"); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "importNewTrustedCertificate"); //$NON-NLS-1$ Certificate certificate = x509Factory.generateCertificate(inStream); - log.finest("certificate = " + certificate); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.fine("certificate = " + certificate); //$NON-NLS-1$ LinkedList orderedReply = new LinkedList(); orderedReply.addLast(certificate); @@ -495,8 +499,8 @@ class ImportCmd extends Command } else System.out.println(Messages.getString("ImportCmd.28")); //$NON-NLS-1$ - - log.exiting(this.getClass().getName(), "importNewTrustedCertificate"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "importNewTrustedCertificate"); //$NON-NLS-1$ } /** @@ -525,8 +529,8 @@ class ImportCmd extends Command NoSuchAlgorithmException, CertPathValidatorException, UnrecoverableKeyException { - log.entering(this.getClass().getName(), "importCertificateReply"); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "importCertificateReply"); //$NON-NLS-1$ Collection certificates = x509Factory.generateCertificates(inStream); ensureReplyIsOurs(certificates); // we now have established that the public keys are the same. @@ -535,8 +539,8 @@ class ImportCmd extends Command importCertificate((Certificate) certificates.iterator().next()); else importChain(certificates); - - log.exiting(this.getClass().getName(), "importCertificateReply"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "importCertificateReply"); //$NON-NLS-1$ } /** @@ -564,8 +568,8 @@ class ImportCmd extends Command KeyStoreException, UnrecoverableKeyException, IOException, UnsupportedCallbackException, CertificateException { - log.entering(this.getClass().getName(), "importCertificate", certificate); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "importCertificate", certificate); //$NON-NLS-1$ LinkedList reply = new LinkedList(); reply.addLast(certificate); @@ -576,8 +580,8 @@ class ImportCmd extends Command Key privateKey = getAliasPrivateKey(); store.setKeyEntry(alias, privateKey, keyPasswordChars, newChain); saveKeyStore(); - - log.exiting(this.getClass().getName(), "importCertificate"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "importCertificate"); //$NON-NLS-1$ } /** @@ -608,8 +612,8 @@ class ImportCmd extends Command CertPathValidatorException, KeyStoreException, UnrecoverableKeyException, IOException, UnsupportedCallbackException, CertificateException { - log.entering(this.getClass().getName(), "importChain", chain); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "importChain", chain); //$NON-NLS-1$ LinkedList reply = orderChain(chain); if (findTrustAndUpdate(reply, ! noPrompt)) { @@ -618,8 +622,8 @@ class ImportCmd extends Command store.setKeyEntry(alias, privateKey, keyPasswordChars, newChain); saveKeyStore(); } - - log.exiting(this.getClass().getName(), "importChain"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "importChain"); //$NON-NLS-1$ } /** @@ -638,10 +642,11 @@ class ImportCmd extends Command private void ensureReplyIsOurs(Collection certificates) throws IOException, UnsupportedCallbackException, KeyStoreException { - log.entering(this.getClass().getName(), "ensureReplyIsOurs"); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "ensureReplyIsOurs"); //$NON-NLS-1$ Certificate certificate = (Certificate) certificates.iterator().next(); - log.finest("certificate = " + certificate); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.fine("certificate = " + certificate); //$NON-NLS-1$ Certificate[] chain = store.getCertificateChain(alias); if (chain == null) throw new IllegalArgumentException(Messages.getFormattedString("ImportCmd.37", //$NON-NLS-1$ @@ -673,8 +678,8 @@ class ImportCmd extends Command anchorPublicKey.getClass().getName() })); if (! sameKey) throw new IllegalArgumentException(Messages.getString("ImportCmd.41")); //$NON-NLS-1$ - - log.exiting(this.getClass().getName(), "ensureReplyIsOurs"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "ensureReplyIsOurs"); //$NON-NLS-1$ } private boolean areEqual(DSAPublicKey pk1, DSAPublicKey pk2) @@ -726,7 +731,8 @@ class ImportCmd extends Command */ private LinkedList orderChain(Collection chain) { - log.entering(this.getClass().getName(), "orderChain"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "orderChain"); //$NON-NLS-1$ LinkedList in = new LinkedList(chain); int initialCount = in.size(); LinkedList result = new LinkedList(); @@ -750,7 +756,8 @@ class ImportCmd extends Command new Object[] { Integer.valueOf(result.size()), Integer.valueOf(initialCount) })); } - log.entering(this.getClass().getName(), "orderChain", result); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "orderChain", result); //$NON-NLS-1$ return result; } @@ -786,7 +793,8 @@ class ImportCmd extends Command KeyStoreException, UnrecoverableKeyException, UnsupportedCallbackException, CertificateEncodingException { - log.entering(this.getClass().getName(), "findTrustAndUpdate"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "findTrustAndUpdate"); //$NON-NLS-1$ CertPathValidator validator = CertPathValidator.getInstance("PKIX"); //$NON-NLS-1$ X509CertPath certPath = new X509CertPath(reply); PKIXCertPathValidatorResult cpvr = findTrustInStore(certPath, validator); @@ -824,16 +832,17 @@ class ImportCmd extends Command reply.addLast(trustedCert); result = true; } - log.entering(this.getClass().getName(), "findTrustAndUpdate", //$NON-NLS-1$ - Boolean.valueOf(result)); + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "findTrustAndUpdate", //$NON-NLS-1$ + Boolean.valueOf(result)); return result; } private PKIXCertPathValidatorResult findTrustInStore(X509CertPath certPath, CertPathValidator validator) { - log.entering(this.getClass().getName(), "findTrustInStore"); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "findTrustInStore"); //$NON-NLS-1$ PKIXCertPathValidatorResult result; try { @@ -847,8 +856,8 @@ class ImportCmd extends Command x); result = null; } - - log.exiting(this.getClass().getName(), "findTrustInStore", result); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "findTrustInStore", result); //$NON-NLS-1$ return result; } @@ -864,8 +873,9 @@ class ImportCmd extends Command */ private PKIXParameters getCertPathParameters(String type, String pathName) { - log.entering(this.getClass().getName(), "getCertPathParameters", //$NON-NLS-1$ - new Object[] { type, pathName }); + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "getCertPathParameters", //$NON-NLS-1$ + new Object[] { type, pathName }); FileInputStream stream = null; PKIXParameters result = null; try @@ -877,7 +887,8 @@ class ImportCmd extends Command } catch (Exception x) { - log.log(Level.FINE, "Exception in getCertPathParameters(). Ignore", x); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.log(Level.FINE, "Exception in getCertPathParameters(). Ignore", x); //$NON-NLS-1$ } finally { @@ -890,7 +901,8 @@ class ImportCmd extends Command { } } - log.exiting(this.getClass().getName(), "getCertPathParameters", result); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "getCertPathParameters", result); //$NON-NLS-1$ return result; } @@ -898,7 +910,8 @@ class ImportCmd extends Command X509CertPath certPath, PKIXParameters params) { - log.entering(this.getClass().getName(), "validate"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "validate"); //$NON-NLS-1$ PKIXCertPathValidatorResult result = null; if (params != null) try @@ -908,9 +921,11 @@ class ImportCmd extends Command } catch (Exception x) { - log.log(Level.FINE, "Exception in validate(). Ignore", x); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.log(Level.FINE, "Exception in validate(). Ignore", x); //$NON-NLS-1$ } - log.exiting(this.getClass().getName(), "validate", result); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "validate", result); //$NON-NLS-1$ return result; } } diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/KeyCloneCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/KeyCloneCmd.java index 61a8eb880f3..81549864b9e 100644 --- a/libjava/classpath/tools/gnu/classpath/tools/keytool/KeyCloneCmd.java +++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/KeyCloneCmd.java @@ -38,6 +38,7 @@ exception statement from your version. */ package gnu.classpath.tools.keytool; +import gnu.classpath.Configuration; import gnu.classpath.tools.getopt.ClasspathToolParser; import gnu.classpath.tools.getopt.Option; import gnu.classpath.tools.getopt.OptionException; @@ -209,22 +210,24 @@ class KeyCloneCmd extends Command setAliasParam(_alias); setKeyPasswordNoPrompt(_password); setDestinationAlias(_destAlias); - - log.finer("-keyclone handler will use the following options:"); //$NON-NLS-1$ - log.finer(" -alias=" + alias); //$NON-NLS-1$ - log.finer(" -dest=" + destinationAlias); //$NON-NLS-1$ - log.finer(" -storetype=" + storeType); //$NON-NLS-1$ - log.finer(" -keystore=" + storeURL); //$NON-NLS-1$ - log.finer(" -provider=" + provider); //$NON-NLS-1$ - log.finer(" -v=" + verbose); //$NON-NLS-1$ + if (Configuration.DEBUG) + { + log.fine("-keyclone handler will use the following options:"); //$NON-NLS-1$ + log.fine(" -alias=" + alias); //$NON-NLS-1$ + log.fine(" -dest=" + destinationAlias); //$NON-NLS-1$ + log.fine(" -storetype=" + storeType); //$NON-NLS-1$ + log.fine(" -keystore=" + storeURL); //$NON-NLS-1$ + log.fine(" -provider=" + provider); //$NON-NLS-1$ + log.fine(" -v=" + verbose); //$NON-NLS-1$ + } } void start() throws KeyStoreException, NoSuchAlgorithmException, IOException, UnsupportedCallbackException, UnrecoverableKeyException, CertificateException { - log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$ if (store.containsAlias(destinationAlias)) throw new SecurityException(Messages.getString("KeyCloneCmd.23")); //$NON-NLS-1$ @@ -236,16 +239,16 @@ class KeyCloneCmd extends Command store.setKeyEntry(destinationAlias, privateKey, newKeyPasswordChars, chain); saveKeyStore(); - - log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$ } // own methods -------------------------------------------------------------- Parser getParser() { - log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$ Parser result = new ClasspathToolParser(Main.KEYCLONE_CMD, true); result.setHeader(Messages.getString("KeyCloneCmd.22")); //$NON-NLS-1$ result.setFooter(Messages.getString("KeyCloneCmd.21")); //$NON-NLS-1$ @@ -331,8 +334,8 @@ class KeyCloneCmd extends Command } }); result.add(options); - - log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$ return result; } diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java index 83beb161b06..89e6daa0249 100644 --- a/libjava/classpath/tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java +++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java @@ -38,6 +38,7 @@ exception statement from your version. */ package gnu.classpath.tools.keytool; +import gnu.classpath.Configuration; import gnu.classpath.SystemProperties; import gnu.classpath.tools.getopt.ClasspathToolParser; import gnu.classpath.tools.getopt.Option; @@ -195,22 +196,24 @@ class KeyPasswdCmd extends Command setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL); setAliasParam(_alias); setKeyPasswordNoPrompt(_password); - - log.finer("-keypasswd handler will use the following options:"); //$NON-NLS-1$ - log.finer(" -alias=" + alias); //$NON-NLS-1$ - log.finer(" -new=" + _newPassword); //$NON-NLS-1$ - log.finer(" -storetype=" + storeType); //$NON-NLS-1$ - log.finer(" -keystore=" + storeURL); //$NON-NLS-1$ - log.finer(" -provider=" + provider); //$NON-NLS-1$ - log.finer(" -v=" + verbose); //$NON-NLS-1$ + if (Configuration.DEBUG) + { + log.fine("-keypasswd handler will use the following options:"); //$NON-NLS-1$ + log.fine(" -alias=" + alias); //$NON-NLS-1$ + log.fine(" -new=" + _newPassword); //$NON-NLS-1$ + log.fine(" -storetype=" + storeType); //$NON-NLS-1$ + log.fine(" -keystore=" + storeURL); //$NON-NLS-1$ + log.fine(" -provider=" + provider); //$NON-NLS-1$ + log.fine(" -v=" + verbose); //$NON-NLS-1$ + } } void start() throws KeyStoreException, NoSuchAlgorithmException, IOException, UnsupportedCallbackException, UnrecoverableKeyException, CertificateException { - log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$ // 1. get the key entry and certificate chain associated to alias Key privateKey = getAliasPrivateKey(); Certificate[] chain = store.getCertificateChain(alias); @@ -221,16 +224,16 @@ class KeyPasswdCmd extends Command // 3. persist the key store saveKeyStore(); - - log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$ } // own methods -------------------------------------------------------------- Parser getParser() { - log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$ Parser result = new ClasspathToolParser(Main.KEYPASSWD_CMD, true); result.setHeader(Messages.getString("KeyPasswdCmd.23")); //$NON-NLS-1$ result.setFooter(Messages.getString("KeyPasswdCmd.22")); //$NON-NLS-1$ @@ -307,8 +310,8 @@ class KeyPasswdCmd extends Command } }); result.add(options); - - log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$ return result; } diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/ListCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/ListCmd.java index 99fcfa2cf9a..61cec01a4dc 100644 --- a/libjava/classpath/tools/gnu/classpath/tools/keytool/ListCmd.java +++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/ListCmd.java @@ -38,6 +38,7 @@ exception statement from your version. */ package gnu.classpath.tools.keytool; +import gnu.classpath.Configuration; import gnu.classpath.tools.getopt.ClasspathToolParser; import gnu.classpath.tools.getopt.Option; import gnu.classpath.tools.getopt.OptionException; @@ -181,32 +182,36 @@ class ListCmd extends Command if (verbose & rfc) { - log.warning("Both -v and -rfc options were found on the command line. " //$NON-NLS-1$ - + "Only the former will be considered"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.fine("Both -v and -rfc options were found on the command line. " //$NON-NLS-1$ + + "Only the former will be considered"); //$NON-NLS-1$ rfc = false; } - - log.finer("-list handler will use the following options:"); //$NON-NLS-1$ - log.finer(" -alias=" + alias); //$NON-NLS-1$ - log.finer(" -storetype=" + storeType); //$NON-NLS-1$ - log.finer(" -keystore=" + storeURL); //$NON-NLS-1$ - log.finer(" -provider=" + provider); //$NON-NLS-1$ - log.finer(" -v=" + verbose); //$NON-NLS-1$ - log.finer(" -rfc=" + rfc); //$NON-NLS-1$ + if (Configuration.DEBUG) + { + log.fine("-list handler will use the following options:"); //$NON-NLS-1$ + log.fine(" -alias=" + alias); //$NON-NLS-1$ + log.fine(" -storetype=" + storeType); //$NON-NLS-1$ + log.fine(" -keystore=" + storeURL); //$NON-NLS-1$ + log.fine(" -provider=" + provider); //$NON-NLS-1$ + log.fine(" -v=" + verbose); //$NON-NLS-1$ + log.fine(" -rfc=" + rfc); //$NON-NLS-1$ + } } void start() throws KeyStoreException, CertificateEncodingException, IOException { - log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$ PrintWriter writer = new PrintWriter(outStream, true); writer.println(Messages.getFormattedString("ListCmd.21", store.getType())); //$NON-NLS-1$ writer.println(Messages.getFormattedString("ListCmd.22", //$NON-NLS-1$ store.getProvider().getName())); if (all) { - log.finest("About to list all aliases in key store..."); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.fine("About to list all aliases in key store..."); //$NON-NLS-1$ writer.println(); writer.println(Messages.getFormattedString("ListCmd.24", //$NON-NLS-1$ Integer.valueOf(store.size()))); @@ -219,16 +224,16 @@ class ListCmd extends Command } else list1Alias(alias, writer); - - log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$ } // own methods -------------------------------------------------------------- Parser getParser() { - log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$ Parser result = new ClasspathToolParser(Main.LIST_CMD, true); result.setHeader(Messages.getString("ListCmd.20")); //$NON-NLS-1$ result.setFooter(Messages.getString("ListCmd.19")); //$NON-NLS-1$ @@ -295,8 +300,8 @@ class ListCmd extends Command } }); result.add(options); - - log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$ return result; } @@ -314,12 +319,12 @@ class ListCmd extends Command private void list1Alias(String anAlias, PrintWriter writer) throws KeyStoreException, CertificateEncodingException, IOException { - log.entering(this.getClass().getName(), "list1Alias", anAlias); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "list1Alias", anAlias); //$NON-NLS-1$ writer.println(); writer.println(Messages.getFormattedString("ListCmd.30", anAlias)); //$NON-NLS-1$ - writer.println(Messages.getFormattedString("ListCmd.31", store.getCreationDate(anAlias))); //$NON-NLS-1$ - + writer.println(Messages.getFormattedString("ListCmd.31", //$NON-NLS-1$ + store.getCreationDate(anAlias))); if (store.isCertificateEntry(anAlias)) { writer.println(Messages.getString("ListCmd.32")); //$NON-NLS-1$ @@ -335,7 +340,8 @@ class ListCmd extends Command else throw new IllegalArgumentException(Messages.getFormattedString("ListCmd.34", //$NON-NLS-1$ anAlias)); - log.exiting(this.getClass().getName(), "list1Alias"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "list1Alias"); //$NON-NLS-1$ } /** diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/Main.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/Main.java index 582aba08228..08d55556efd 100644 --- a/libjava/classpath/tools/gnu/classpath/tools/keytool/Main.java +++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/Main.java @@ -38,6 +38,7 @@ exception statement from your version. */ package gnu.classpath.tools.keytool; +import gnu.classpath.Configuration; import gnu.classpath.tools.common.ProviderUtil; import gnu.classpath.tools.getopt.ClasspathToolParser; import gnu.classpath.tools.getopt.Option; @@ -74,6 +75,7 @@ public class Main static final String STOREPASSWD_CMD = "storepasswd"; //$NON-NLS-1$ static final String KEYPASSWD_CMD = "keypasswd"; //$NON-NLS-1$ static final String DELETE_CMD = "delete"; //$NON-NLS-1$ + static final String CACERT_CMD = "cacert"; //$NON-NLS-1$ static final String _GENKEY = "-" + GENKEY_CMD; //$NON-NLS-1$ static final String _IMPORT = "-" + IMPORT_CMD; //$NON-NLS-1$ @@ -88,6 +90,7 @@ public class Main static final String _KEYPASSWD = "-" + KEYPASSWD_CMD; //$NON-NLS-1$ static final String _DELETE = "-" + DELETE_CMD; //$NON-NLS-1$ static final String _HELP = "-help"; //$NON-NLS-1$ + static final String _CACERT = "-" + CACERT_CMD; //$NON-NLS-1$ static final String ALIAS_OPT = "alias"; //$NON-NLS-1$ static final String SIGALG_OPT = "sigalg"; //$NON-NLS-1$ @@ -119,16 +122,20 @@ public class Main private int gnuCallbacksNdx = -2; /** The command line parser. */ private Parser cmdLineParser; + /** The shutdown hook. */ + private ShutdownHook shutdownThread; private Main() { super(); + shutdownThread = new ShutdownHook(); + Runtime.getRuntime().addShutdownHook(shutdownThread); } public static final void main(String[] args) { - log.entering(Main.class.getName(), "main", args); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(Main.class.getName(), "main", args); //$NON-NLS-1$ Main tool = new Main(); int result = 1; try @@ -145,21 +152,25 @@ public class Main } catch (SecurityException x) { - log.throwing(Main.class.getName(), "main", x); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.throwing(Main.class.getName(), "main", x); //$NON-NLS-1$ System.err.println(Messages.getFormattedString("Main.6", //$NON-NLS-1$ x.getMessage())); } catch (Exception x) { - log.throwing(Main.class.getName(), "main", x); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.throwing(Main.class.getName(), "main", x); //$NON-NLS-1$ System.err.println(Messages.getFormattedString("Main.8", x)); //$NON-NLS-1$ } finally { tool.teardown(); + if (tool.shutdownThread != null) + Runtime.getRuntime().removeShutdownHook(tool.shutdownThread); } - - log.exiting(Main.class.getName(), "main", Integer.valueOf(result)); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(Main.class.getName(), "main", Integer.valueOf(result)); //$NON-NLS-1$ System.exit(result); } @@ -167,19 +178,19 @@ public class Main private void setup() { - log.entering(this.getClass().getName(), "setup"); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "setup"); //$NON-NLS-1$ cmdLineParser = getParser(); gnuCryptoProviderNdx = ProviderUtil.addProvider(new GnuCrypto()); gnuCallbacksNdx = ProviderUtil.addProvider(new GnuCallbacks()); - - log.exiting(this.getClass().getName(), "setup"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "setup"); //$NON-NLS-1$ } private void start(String[] args) throws Exception { - log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$ if (args == null || args.length == 0) throw new OptionException(""); //$NON-NLS-1$ @@ -213,6 +224,8 @@ public class Main cmd = new KeyPasswdCmd(); else if (_DELETE.equals(opt)) cmd = new DeleteCmd(); + else if (_CACERT.equals(opt)) + cmd = new CACertCmd(); else if (_HELP.equals(opt)) throw new OptionException(""); //$NON-NLS-1$ else @@ -224,14 +237,14 @@ public class Main args = cmd.processArgs(cmdArgs); cmd.doCommand(); } - - log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$ } private Parser getParser() { - log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$ Parser result = new ClasspathToolParser(KEYTOOL_TOOL, true); result.setHeader(Messages.getString("Main.19")); //$NON-NLS-1$ result.setFooter(Messages.getString("Main.20")); //$NON-NLS-1$ @@ -260,16 +273,18 @@ public class Main Messages.getString("Main.32"))); //$NON-NLS-1$ cmdGroup.add(new NoParseOption(DELETE_CMD, Messages.getString("Main.33"))); //$NON-NLS-1$ + cmdGroup.add(new NoParseOption(CACERT_CMD, + Messages.getString("Main.5"))); //$NON-NLS-1$ result.add(cmdGroup); - - log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$ return result; } - private void teardown() + void teardown() { - log.entering(this.getClass().getName(), "teardown"); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "teardown"); //$NON-NLS-1$ // if we added our own providers remove them if (gnuCryptoProviderNdx > 0) ProviderUtil.removeProvider(Registry.GNU_CRYPTO); @@ -277,7 +292,8 @@ public class Main if (gnuCallbacksNdx > 0) ProviderUtil.removeProvider("GNU-CALLBACKS"); //$NON-NLS-1$ - log.exiting(this.getClass().getName(), "teardown"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "teardown"); //$NON-NLS-1$ } private void printHelp() @@ -309,4 +325,13 @@ public class Main // do nothing } } + + private class ShutdownHook + extends Thread + { + public void run() + { + teardown(); + } + } } diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/Messages.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/Messages.java index 7ecaa1c37ab..ea2825f105d 100644 --- a/libjava/classpath/tools/gnu/classpath/tools/keytool/Messages.java +++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/Messages.java @@ -38,6 +38,8 @@ package gnu.classpath.tools.keytool; +import gnu.classpath.Configuration; + import java.text.MessageFormat; import java.util.HashMap; import java.util.Map; @@ -99,8 +101,9 @@ class Messages } catch (IllegalArgumentException x) { - log.fine("Exception while rendering a message format keyed by [" - + key + "]: " + mf.toPattern()); + if (Configuration.DEBUG) + log.fine("Exception while rendering a message format keyed by [" + + key + "]: " + mf.toPattern()); return constructMessage(mf.toPattern(), args); } } diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/PrintCertCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/PrintCertCmd.java index d259258e723..2c5461b3619 100644 --- a/libjava/classpath/tools/gnu/classpath/tools/keytool/PrintCertCmd.java +++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/PrintCertCmd.java @@ -38,6 +38,7 @@ exception statement from your version. */ package gnu.classpath.tools.keytool; +import gnu.classpath.Configuration; import gnu.classpath.tools.getopt.ClasspathToolParser; import gnu.classpath.tools.getopt.Option; import gnu.classpath.tools.getopt.OptionException; @@ -86,31 +87,33 @@ class PrintCertCmd extends Command void setup() throws Exception { setInputStreamParam(_certFileName); - - log.finer("-printcert handler will use the following options:"); //$NON-NLS-1$ - log.finer(" -file=" + _certFileName); //$NON-NLS-1$ - log.finer(" -v=" + verbose); //$NON-NLS-1$ + if (Configuration.DEBUG) + { + log.fine("-printcert handler will use the following options:"); //$NON-NLS-1$ + log.fine(" -file=" + _certFileName); //$NON-NLS-1$ + log.fine(" -v=" + verbose); //$NON-NLS-1$ + } } void start() throws CertificateException { - log.entering(getClass().getName(), "start"); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(getClass().getName(), "start"); //$NON-NLS-1$ CertificateFactory x509Factory = CertificateFactory.getInstance(Main.X_509); Certificate certificate = x509Factory.generateCertificate(inStream); PrintWriter writer = new PrintWriter(System.out, true); writer.println(); printVerbose(certificate, writer); - - log.exiting(getClass().getName(), "start"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(getClass().getName(), "start"); //$NON-NLS-1$ } // own methods -------------------------------------------------------------- Parser getParser() { - log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$ Parser result = new ClasspathToolParser(Main.PRINTCERT_CMD, true); result.setHeader(Messages.getString("PrintCertCmd.5")); //$NON-NLS-1$ result.setFooter(Messages.getString("PrintCertCmd.6")); //$NON-NLS-1$ @@ -133,8 +136,8 @@ class PrintCertCmd extends Command } }); result.add(options); - - log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$ return result; } } diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/SelfCertCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/SelfCertCmd.java index db700a164e0..75f1e8299ed 100644 --- a/libjava/classpath/tools/gnu/classpath/tools/keytool/SelfCertCmd.java +++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/SelfCertCmd.java @@ -38,6 +38,7 @@ exception statement from your version. */ package gnu.classpath.tools.keytool; +import gnu.classpath.Configuration; import gnu.classpath.tools.getopt.ClasspathToolParser; import gnu.classpath.tools.getopt.Option; import gnu.classpath.tools.getopt.OptionException; @@ -264,24 +265,26 @@ class SelfCertCmd extends Command setAliasParam(_alias); setKeyPasswordNoPrompt(_password); setValidityParam(_validityStr); - - log.finer("-selfcert handler will use the following options:"); //$NON-NLS-1$ - log.finer(" -alias=" + alias); //$NON-NLS-1$ - log.finer(" -sigalg=" + _sigAlgorithm); //$NON-NLS-1$ - log.finer(" -dname=" + _dName); //$NON-NLS-1$ - log.finer(" -validity=" + validityInDays); //$NON-NLS-1$ - log.finer(" -storetype=" + storeType); //$NON-NLS-1$ - log.finer(" -keystore=" + storeURL); //$NON-NLS-1$ - log.finer(" -provider=" + provider); //$NON-NLS-1$ - log.finer(" -v=" + verbose); //$NON-NLS-1$ + if (Configuration.DEBUG) + { + log.fine("-selfcert handler will use the following options:"); //$NON-NLS-1$ + log.fine(" -alias=" + alias); //$NON-NLS-1$ + log.fine(" -sigalg=" + _sigAlgorithm); //$NON-NLS-1$ + log.fine(" -dname=" + _dName); //$NON-NLS-1$ + log.fine(" -validity=" + validityInDays); //$NON-NLS-1$ + log.fine(" -storetype=" + storeType); //$NON-NLS-1$ + log.fine(" -keystore=" + storeURL); //$NON-NLS-1$ + log.fine(" -provider=" + provider); //$NON-NLS-1$ + log.fine(" -v=" + verbose); //$NON-NLS-1$ + } } void start() throws KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException, IOException, UnsupportedCallbackException, InvalidKeyException, SignatureException, CertificateException { - log.entering(getClass().getName(), "start"); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(getClass().getName(), "start"); //$NON-NLS-1$ // 1. get the key entry and certificate chain associated to alias Key privateKey = getAliasPrivateKey(); Certificate[] chain = store.getCertificateChain(alias); @@ -310,16 +313,16 @@ class SelfCertCmd extends Command // 7. persist the key store saveKeyStore(); - - log.exiting(getClass().getName(), "start"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(getClass().getName(), "start"); //$NON-NLS-1$ } // own methods -------------------------------------------------------------- Parser getParser() { - log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$ Parser result = new ClasspathToolParser(Main.SELFCERT_CMD, true); result.setHeader(Messages.getString("SelfCertCmd.14")); //$NON-NLS-1$ result.setFooter(Messages.getString("SelfCertCmd.15")); //$NON-NLS-1$ @@ -414,8 +417,8 @@ class SelfCertCmd extends Command } }); result.add(options); - - log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$ return result; } diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/StorePasswdCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/StorePasswdCmd.java index 6c4dfddb92a..1313ec6abe7 100644 --- a/libjava/classpath/tools/gnu/classpath/tools/keytool/StorePasswdCmd.java +++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/StorePasswdCmd.java @@ -38,6 +38,7 @@ exception statement from your version. */ package gnu.classpath.tools.keytool; +import gnu.classpath.Configuration; import gnu.classpath.SystemProperties; import gnu.classpath.tools.getopt.ClasspathToolParser; import gnu.classpath.tools.getopt.Option; @@ -159,30 +160,32 @@ class StorePasswdCmd extends Command { setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL); setNewKeystorePassword(_newPassword); - - log.finer("-storepasswd handler will use the following options:"); //$NON-NLS-1$ - log.finer(" -storetype=" + storeType); //$NON-NLS-1$ - log.finer(" -keystore=" + storeURL); //$NON-NLS-1$ - log.finer(" -provider=" + provider); //$NON-NLS-1$ - log.finer(" -v=" + verbose); //$NON-NLS-1$ + if (Configuration.DEBUG) + { + log.fine("-storepasswd handler will use the following options:"); //$NON-NLS-1$ + log.fine(" -storetype=" + storeType); //$NON-NLS-1$ + log.fine(" -keystore=" + storeURL); //$NON-NLS-1$ + log.fine(" -provider=" + provider); //$NON-NLS-1$ + log.fine(" -v=" + verbose); //$NON-NLS-1$ + } } void start() throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException { - log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$ saveKeyStore(newStorePasswordChars); - - log.exiting(getClass().getName(), "start"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(getClass().getName(), "start"); //$NON-NLS-1$ } // own methods -------------------------------------------------------------- Parser getParser() { - log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$ - + if (Configuration.DEBUG) + log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$ Parser result = new ClasspathToolParser(Main.STOREPASSWD_CMD, true); result.setHeader(Messages.getString("StorePasswdCmd.18")); //$NON-NLS-1$ result.setFooter(Messages.getString("StorePasswdCmd.17")); //$NON-NLS-1$ @@ -241,8 +244,8 @@ class StorePasswdCmd extends Command } }); result.add(options); - - log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$ return result; } diff --git a/libjava/classpath/tools/gserialver.in b/libjava/classpath/tools/gserialver.in new file mode 100644 index 00000000000..15ed3f996c5 --- /dev/null +++ b/libjava/classpath/tools/gserialver.in @@ -0,0 +1,47 @@ +#!/bin/sh + +## Copyright (C) 2006 Free Software Foundation, Inc. +## +## This file is a part of GNU Classpath. +## +## GNU Classpath is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or (at +## your option) any later version. +## +## GNU Classpath 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 for more details. +## +## You should have received a copy of the GNU General Public License +## along with GNU Classpath; if not, write to the Free Software +## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 +## USA. +## +## Linking this library statically or dynamically with other modules is +## making a combined work based on this library. Thus, the terms and +## conditions of the GNU General Public License cover the whole +## combination. +## +## As a special exception, the copyright holders of this library give you +## permission to link this library with independent modules to produce an +## executable, regardless of the license terms of these independent +## modules, and to copy and distribute the resulting executable under +## terms of your choice, provided that you also meet, for each linked +## independent module, the terms and conditions of the license of that +## module. An independent module is a module which is not derived from +## or based on this library. If you modify this library, you may extend +## this exception to your version of the library, but you are not +## obligated to do so. If you do not wish to do so, delete this +## exception statement from your version. +## +## +## A simple shell script to launch the GNU Classpath serialver tool. +## + +prefix=@prefix@ +tools_dir=@datadir@/@PACKAGE@ +tools_cp=${tools_dir}/tools.zip + +exec @VM_BINARY@ -Xbootclasspath/p:"${tools_cp}" gnu.classpath.tools.serialver.Main "$@" |