diff options
author | Raif S. Naffah <raif@swiftdsl.com.au> | 2006-06-12 05:14:06 +0000 |
---|---|---|
committer | Raif S. Naffah <raif@swiftdsl.com.au> | 2006-06-12 05:14:06 +0000 |
commit | 2fc4e384dcea5a4ff5cefac633fe9a3c8607d6b3 (patch) | |
tree | fa151650323a9b08a5de427927ff331a3375e3a0 /tools | |
parent | b22d436fabc4b8bf25d2ea41ac4392cf949d6ba5 (diff) | |
download | classpath-2fc4e384dcea5a4ff5cefac633fe9a3c8607d6b3.tar.gz |
2006-06-12 Raif S. Naffah <raif@swiftdsl.com.au>
* tools/gnu/classpath/tools/keytool/StorePasswdCmd.java: Condition all
trace/debug code based on Configuration.DEBUG.
* tools/gnu/classpath/tools/keytool/SelfCertCmd.java: Likewise.
* tools/gnu/classpath/tools/keytool/PrintCertCmd.java: Likewise.
* tools/gnu/classpath/tools/keytool/Messages.java: Likewise.
* tools/gnu/classpath/tools/keytool/Main.java: Likewise.
* tools/gnu/classpath/tools/keytool/ListCmd.java: Likewise.
* tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java: Likewise.
* tools/gnu/classpath/tools/keytool/KeyCloneCmd.java: Likewise.
* tools/gnu/classpath/tools/keytool/ImportCmd.java: Likewise.
* tools/gnu/classpath/tools/keytool/IdentityDBCmd.java: Likewise.
* tools/gnu/classpath/tools/keytool/GenKeyCmd.java: Likewise.
* tools/gnu/classpath/tools/keytool/ExportCmd.java: Likewise.
* tools/gnu/classpath/tools/keytool/DeleteCmd.java: Likewise.
* tools/gnu/classpath/tools/keytool/Command.java: Likewise.
* tools/gnu/classpath/tools/keytool/CertReqCmd.java: Likewise.
* tools/gnu/classpath/tools/keytool/CACertCmd.java: Likewise.
* tools/gnu/classpath/tools/jarsigner/SFHelper.java: Likewise.
* tools/gnu/classpath/tools/jarsigner/Messages.java: Likewise.
* tools/gnu/classpath/tools/jarsigner/Main.java: Likewise.
* tools/gnu/classpath/tools/jarsigner/JarVerifier.java: Likewise.
* tools/gnu/classpath/tools/jarsigner/JarSigner.java: Likewise.
* tools/gnu/classpath/tools/jarsigner/HashUtils.java: Likewise.
Diffstat (limited to 'tools')
22 files changed, 538 insertions, 403 deletions
diff --git a/tools/gnu/classpath/tools/jarsigner/HashUtils.java b/tools/gnu/classpath/tools/jarsigner/HashUtils.java index 2286063f1..a085ca0c9 100644 --- a/tools/gnu/classpath/tools/jarsigner/HashUtils.java +++ b/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/tools/gnu/classpath/tools/jarsigner/JarSigner.java b/tools/gnu/classpath/tools/jarsigner/JarSigner.java index 8d3bc31af..87db8b952 100644 --- a/tools/gnu/classpath/tools/jarsigner/JarSigner.java +++ b/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/tools/gnu/classpath/tools/jarsigner/JarVerifier.java b/tools/gnu/classpath/tools/jarsigner/JarVerifier.java index f80147dfa..663f6906a 100644 --- a/tools/gnu/classpath/tools/jarsigner/JarVerifier.java +++ b/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/tools/gnu/classpath/tools/jarsigner/Main.java b/tools/gnu/classpath/tools/jarsigner/Main.java index 6928bce59..b6b50e741 100644 --- a/tools/gnu/classpath/tools/jarsigner/Main.java +++ b/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/tools/gnu/classpath/tools/jarsigner/Messages.java b/tools/gnu/classpath/tools/jarsigner/Messages.java index 35f461669..d5b8760ee 100644 --- a/tools/gnu/classpath/tools/jarsigner/Messages.java +++ b/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/tools/gnu/classpath/tools/jarsigner/SFHelper.java b/tools/gnu/classpath/tools/jarsigner/SFHelper.java index b4e5cc193..0d8c2eb44 100644 --- a/tools/gnu/classpath/tools/jarsigner/SFHelper.java +++ b/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; @@ -142,7 +143,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 +218,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 +244,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); @@ -322,7 +326,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 +349,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,7 +373,8 @@ 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; diff --git a/tools/gnu/classpath/tools/keytool/CACertCmd.java b/tools/gnu/classpath/tools/keytool/CACertCmd.java index 912744713..2bf832bee 100644 --- a/tools/gnu/classpath/tools/keytool/CACertCmd.java +++ b/tools/gnu/classpath/tools/keytool/CACertCmd.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; @@ -164,32 +165,38 @@ public class CACertCmd { setInputStreamParam(_certFileName); setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL); - log.finer("-cacert handler will use the following options:"); //$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(" -v=" + verbose); //$NON-NLS-1$ + 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 { - log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$ + 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); - log.finest("certificate = " + certificate); //$NON-NLS-1$ + 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 })); - log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$ } // own methods -------------------------------------------------------------- @@ -199,7 +206,8 @@ public class CACertCmd */ 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.CACERT_CMD, true); result.setHeader(Messages.getString("CACertCmd.2")); //$NON-NLS-1$ result.setFooter(Messages.getString("CACertCmd.3")); //$NON-NLS-1$ @@ -258,7 +266,8 @@ public class CACertCmd } }); 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; } @@ -276,7 +285,8 @@ public class CACertCmd */ private String getAliasFromFileName(String fileName) { - log.entering(this.getClass().getName(), "getAliasFromFileName", fileName); //$NON-NLS-1$ + 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 @@ -296,7 +306,8 @@ public class CACertCmd chars[i] = '_'; } String result = new String(chars); - log.exiting(this.getClass().getName(), "getAliasFromFileName", result); //$NON-NLS-1$ + if (Configuration.DEBUG) + log.exiting(this.getClass().getName(), "getAliasFromFileName", result); //$NON-NLS-1$ return result; } } diff --git a/tools/gnu/classpath/tools/keytool/CertReqCmd.java b/tools/gnu/classpath/tools/keytool/CertReqCmd.java index fc85e6abd..692b1f690 100644 --- a/tools/gnu/classpath/tools/keytool/CertReqCmd.java +++ b/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/tools/gnu/classpath/tools/keytool/Command.java b/tools/gnu/classpath/tools/keytool/Command.java index 0811074b8..da9293116 100644 --- a/tools/gnu/classpath/tools/keytool/Command.java +++ b/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 ----------------------------------- @@ -401,15 +404,18 @@ abstract class Command */ protected 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(); } } @@ -426,7 +432,8 @@ abstract class Command */ protected 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 @@ -525,7 +532,8 @@ abstract class Command 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$ @@ -551,7 +559,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 +573,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 }); @@ -596,8 +606,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 +829,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 +912,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 +1003,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 +1015,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/tools/gnu/classpath/tools/keytool/DeleteCmd.java b/tools/gnu/classpath/tools/keytool/DeleteCmd.java index 4c32ee1e6..8107055d0 100644 --- a/tools/gnu/classpath/tools/keytool/DeleteCmd.java +++ b/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/tools/gnu/classpath/tools/keytool/ExportCmd.java b/tools/gnu/classpath/tools/keytool/ExportCmd.java index 46f7acdf0..75f71801c 100644 --- a/tools/gnu/classpath/tools/keytool/ExportCmd.java +++ b/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/tools/gnu/classpath/tools/keytool/GenKeyCmd.java b/tools/gnu/classpath/tools/keytool/GenKeyCmd.java index 6da0f58b6..e9034eac2 100644 --- a/tools/gnu/classpath/tools/keytool/GenKeyCmd.java +++ b/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; @@ -309,61 +310,69 @@ class GenKeyCmd extends Command 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/tools/gnu/classpath/tools/keytool/IdentityDBCmd.java b/tools/gnu/classpath/tools/keytool/IdentityDBCmd.java index 46c5b9769..94234c5b9 100644 --- a/tools/gnu/classpath/tools/keytool/IdentityDBCmd.java +++ b/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; @@ -149,21 +150,23 @@ class IdentityDBCmd extends Command { 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$ + 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/tools/gnu/classpath/tools/keytool/ImportCmd.java b/tools/gnu/classpath/tools/keytool/ImportCmd.java index 2e01bc0e4..e733ad4c1 100644 --- a/tools/gnu/classpath/tools/keytool/ImportCmd.java +++ b/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; @@ -294,24 +295,26 @@ class ImportCmd extends Command setKeyStoreParams(_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/tools/gnu/classpath/tools/keytool/KeyCloneCmd.java b/tools/gnu/classpath/tools/keytool/KeyCloneCmd.java index 61a8eb880..81549864b 100644 --- a/tools/gnu/classpath/tools/keytool/KeyCloneCmd.java +++ b/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/tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java b/tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java index 83beb161b..89e6daa02 100644 --- a/tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java +++ b/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/tools/gnu/classpath/tools/keytool/ListCmd.java b/tools/gnu/classpath/tools/keytool/ListCmd.java index 99fcfa2cf..61cec01a4 100644 --- a/tools/gnu/classpath/tools/keytool/ListCmd.java +++ b/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/tools/gnu/classpath/tools/keytool/Main.java b/tools/gnu/classpath/tools/keytool/Main.java index 321934385..08d55556e 100644 --- a/tools/gnu/classpath/tools/keytool/Main.java +++ b/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; @@ -133,8 +134,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 @@ -151,13 +152,15 @@ 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 @@ -166,8 +169,8 @@ public class Main 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); } @@ -175,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$ @@ -234,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$ @@ -273,15 +276,15 @@ public class Main 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; } 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); @@ -289,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() diff --git a/tools/gnu/classpath/tools/keytool/Messages.java b/tools/gnu/classpath/tools/keytool/Messages.java index 7ecaa1c37..ea2825f10 100644 --- a/tools/gnu/classpath/tools/keytool/Messages.java +++ b/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/tools/gnu/classpath/tools/keytool/PrintCertCmd.java b/tools/gnu/classpath/tools/keytool/PrintCertCmd.java index d259258e7..2c5461b36 100644 --- a/tools/gnu/classpath/tools/keytool/PrintCertCmd.java +++ b/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/tools/gnu/classpath/tools/keytool/SelfCertCmd.java b/tools/gnu/classpath/tools/keytool/SelfCertCmd.java index db700a164..75f1e8299 100644 --- a/tools/gnu/classpath/tools/keytool/SelfCertCmd.java +++ b/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/tools/gnu/classpath/tools/keytool/StorePasswdCmd.java b/tools/gnu/classpath/tools/keytool/StorePasswdCmd.java index 6c4dfddb9..1313ec6ab 100644 --- a/tools/gnu/classpath/tools/keytool/StorePasswdCmd.java +++ b/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; } |