From 645b8a1a60008c93acaaa2a98c835c97a7f2b24b Mon Sep 17 00:00:00 2001 From: David Blacka Date: Thu, 10 Feb 2011 00:25:10 +0000 Subject: [PATCH] fix my logger normalization -- it was still defaulting to INFO. git-svn-id: https://svn.verisignlabs.com/jdnssec/tools/trunk@244 4cbd57fe-54e5-0310-bd9a-f30fe5ea5e6e --- src/com/verisignlabs/dnssec/cl/DSTool.java | 57 +++++++-------- src/com/verisignlabs/dnssec/cl/KeyGen.java | 70 +++++++++---------- .../verisignlabs/dnssec/cl/KeyInfoTool.java | 70 +++++++++---------- .../verisignlabs/dnssec/cl/SignKeyset.java | 61 ++++++++-------- src/com/verisignlabs/dnssec/cl/SignRRset.java | 59 ++++++++-------- src/com/verisignlabs/dnssec/cl/SignZone.java | 51 +++++++------- .../verisignlabs/dnssec/cl/VerifyZone.java | 51 +++++++------- .../verisignlabs/dnssec/cl/ZoneFormat.java | 51 +++++++------- 8 files changed, 226 insertions(+), 244 deletions(-) diff --git a/src/com/verisignlabs/dnssec/cl/DSTool.java b/src/com/verisignlabs/dnssec/cl/DSTool.java index b07da9e..f9b3ee5 100644 --- a/src/com/verisignlabs/dnssec/cl/DSTool.java +++ b/src/com/verisignlabs/dnssec/cl/DSTool.java @@ -101,34 +101,33 @@ public class DSTool if (cli.hasOption('h')) usage(); Logger rootLogger = Logger.getLogger(""); - if (cli.hasOption('v')) + + int value = parseInt(cli.getOptionValue('v'), -1); + switch (value) { - int value = parseInt(cli.getOptionValue('v'), -1); - switch (value) - { - case 0: - rootLogger.setLevel(Level.OFF); - break; - case 1: - rootLogger.setLevel(Level.SEVERE); - break; - case 2: - default: - rootLogger.setLevel(Level.WARNING); - break; - case 3: - rootLogger.setLevel(Level.INFO); - break; - case 4: - rootLogger.setLevel(Level.CONFIG); - case 5: - rootLogger.setLevel(Level.FINE); - break; - case 6: - rootLogger.setLevel(Level.ALL); - break; - } + case 0: + rootLogger.setLevel(Level.OFF); + break; + case 1: + rootLogger.setLevel(Level.SEVERE); + break; + case 2: + default: + rootLogger.setLevel(Level.WARNING); + break; + case 3: + rootLogger.setLevel(Level.INFO); + break; + case 4: + rootLogger.setLevel(Level.CONFIG); + case 5: + rootLogger.setLevel(Level.FINE); + break; + case 6: + rootLogger.setLevel(Level.ALL); + break; } + // I hate java.util.logging, btw. for (Handler h : rootLogger.getHandlers()) { @@ -161,8 +160,7 @@ public class DSTool // print our own usage statement: f.printHelp(out, 75, "jdnssec-dstool [..options..] keyfile", null, opts, - HelpFormatter.DEFAULT_LEFT_PAD, - HelpFormatter.DEFAULT_DESC_PAD, null); + HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, null); out.flush(); System.exit(64); @@ -202,8 +200,7 @@ public class DSTool log.warning("DNSKEY is not an SEP-flagged key."); } - DSRecord ds = SignUtils.calculateDSRecord(dnskey, state.digest_id, - dnskey.getTTL()); + DSRecord ds = SignUtils.calculateDSRecord(dnskey, state.digest_id, dnskey.getTTL()); Record res = ds; if (state.createDLV) diff --git a/src/com/verisignlabs/dnssec/cl/KeyGen.java b/src/com/verisignlabs/dnssec/cl/KeyGen.java index e4751eb..d21c1ba 100644 --- a/src/com/verisignlabs/dnssec/cl/KeyGen.java +++ b/src/com/verisignlabs/dnssec/cl/KeyGen.java @@ -92,8 +92,7 @@ public class KeyGen OptionBuilder.withLongOpt("verbose"); OptionBuilder.withArgName("level"); OptionBuilder.withDescription("verbosity level -- 0 is silence, " - + "5 is debug information, 6 is trace information.\n" - + "default is level 5."); + + "5 is debug information, 6 is trace information.\n" + "default is level 5."); opts.addOption(OptionBuilder.create('v')); OptionBuilder.hasArg(); @@ -118,8 +117,7 @@ public class KeyGen OptionBuilder.hasArg(); OptionBuilder.withLongOpt("keydir"); OptionBuilder.withArgName("dir"); - OptionBuilder.withDescription("place generated key files in this " - + "directory"); + OptionBuilder.withDescription("place generated key files in this " + "directory"); opts.addOption(OptionBuilder.create('d')); OptionBuilder.hasArg(); @@ -140,34 +138,33 @@ public class KeyGen if (cli.hasOption('h')) usage(); Logger rootLogger = Logger.getLogger(""); - if (cli.hasOption('v')) + + int value = parseInt(cli.getOptionValue('v'), -1); + switch (value) { - int value = parseInt(cli.getOptionValue('v'), -1); - switch (value) - { - case 0: - rootLogger.setLevel(Level.OFF); - break; - case 1: - rootLogger.setLevel(Level.SEVERE); - break; - case 2: - default: - rootLogger.setLevel(Level.WARNING); - break; - case 3: - rootLogger.setLevel(Level.INFO); - break; - case 4: - rootLogger.setLevel(Level.CONFIG); - case 5: - rootLogger.setLevel(Level.FINE); - break; - case 6: - rootLogger.setLevel(Level.ALL); - break; - } + case 0: + rootLogger.setLevel(Level.OFF); + break; + case 1: + rootLogger.setLevel(Level.SEVERE); + break; + case 2: + default: + rootLogger.setLevel(Level.WARNING); + break; + case 3: + rootLogger.setLevel(Level.INFO); + break; + case 4: + rootLogger.setLevel(Level.CONFIG); + case 5: + rootLogger.setLevel(Level.FINE); + break; + case 6: + rootLogger.setLevel(Level.ALL); + break; } + // I hate java.util.logging, btw. for (Handler h : rootLogger.getHandlers()) { @@ -257,8 +254,7 @@ public class KeyGen // print our own usage statement: f.printHelp(out, 75, "jdnssec-keygen [..options..] name", null, opts, - HelpFormatter.DEFAULT_LEFT_PAD, - HelpFormatter.DEFAULT_DESC_PAD, null); + HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, null); out.flush(); System.exit(64); @@ -314,13 +310,13 @@ public class KeyGen if (state.zoneKey) flags |= DNSKEYRecord.Flags.ZONE_KEY; if (state.kskFlag) flags |= DNSKEYRecord.Flags.SEP_KEY; - log.fine("create key pair with (name = " + owner_name + ", ttl = " - + state.ttl + ", alg = " + state.algorithm + ", flags = " + flags - + ", length = " + state.keylength + ")"); + log.fine("create key pair with (name = " + owner_name + ", ttl = " + state.ttl + + ", alg = " + state.algorithm + ", flags = " + flags + ", length = " + + state.keylength + ")"); DnsKeyPair pair = signer.generateKey(owner_name, state.ttl, DClass.IN, - state.algorithm, flags, - state.keylength, state.useLargeE); + state.algorithm, flags, state.keylength, + state.useLargeE); if (state.outputfile != null) { diff --git a/src/com/verisignlabs/dnssec/cl/KeyInfoTool.java b/src/com/verisignlabs/dnssec/cl/KeyInfoTool.java index 9d3cac4..08b989e 100644 --- a/src/com/verisignlabs/dnssec/cl/KeyInfoTool.java +++ b/src/com/verisignlabs/dnssec/cl/KeyInfoTool.java @@ -71,8 +71,7 @@ public class KeyInfoTool OptionBuilder.withLongOpt("verbose"); OptionBuilder.withArgName("level"); OptionBuilder.withDescription("verbosity level -- 0 is silence, " - + "5 is debug information, 6 is trace information.\n" - + "default is level 5."); + + "5 is debug information, 6 is trace information.\n" + "default is level 5."); // Argument options opts.addOption(OptionBuilder.create('v')); @@ -92,34 +91,33 @@ public class KeyInfoTool if (cli.hasOption('h')) usage(); Logger rootLogger = Logger.getLogger(""); - if (cli.hasOption('v')) + + int value = parseInt(cli.getOptionValue('v'), -1); + switch (value) { - int value = parseInt(cli.getOptionValue('v'), -1); - switch (value) - { - case 0: - rootLogger.setLevel(Level.OFF); - break; - case 1: - rootLogger.setLevel(Level.SEVERE); - break; - case 2: - default: - rootLogger.setLevel(Level.WARNING); - break; - case 3: - rootLogger.setLevel(Level.INFO); - break; - case 4: - rootLogger.setLevel(Level.CONFIG); - case 5: - rootLogger.setLevel(Level.FINE); - break; - case 6: - rootLogger.setLevel(Level.ALL); - break; - } + case 0: + rootLogger.setLevel(Level.OFF); + break; + case 1: + rootLogger.setLevel(Level.SEVERE); + break; + case 2: + default: + rootLogger.setLevel(Level.WARNING); + break; + case 3: + rootLogger.setLevel(Level.INFO); + break; + case 4: + rootLogger.setLevel(Level.CONFIG); + case 5: + rootLogger.setLevel(Level.FINE); + break; + case 6: + rootLogger.setLevel(Level.ALL); + break; } + // I hate java.util.logging, btw. for (Handler h : rootLogger.getHandlers()) { @@ -153,8 +151,7 @@ public class KeyInfoTool // print our own usage statement: f.printHelp(out, 75, "jdnssec-keyinfo [..options..] keyfile", null, opts, - HelpFormatter.DEFAULT_LEFT_PAD, - HelpFormatter.DEFAULT_DESC_PAD, null); + HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, null); out.flush(); System.exit(64); @@ -218,23 +215,20 @@ public class KeyInfoTool System.out.println("Name: " + dnskey.getName()); System.out.println("SEP: " + isSEP); - System.out.println("Algorithm: " - + dnskeyalg.algToString(dnskey.getAlgorithm()) + " (" - + dnskey.getAlgorithm() + ")"); + System.out.println("Algorithm: " + dnskeyalg.algToString(dnskey.getAlgorithm()) + + " (" + dnskey.getAlgorithm() + ")"); System.out.println("ID: " + dnskey.getFootprint()); System.out.println("KeyFileBase: " + BINDKeyUtils.keyFileBase(key)); int basetype = dnskeyalg.baseType(dnskey.getAlgorithm()); switch (basetype) { - case DnsKeyAlgorithm.RSA: - { + case DnsKeyAlgorithm.RSA: { RSAPublicKey pub = (RSAPublicKey) key.getPublic(); System.out.println("RSA Public Exponent: " + pub.getPublicExponent()); System.out.println("RSA Modulus: " + pub.getModulus()); break; } - case DnsKeyAlgorithm.DSA: - { + case DnsKeyAlgorithm.DSA: { DSAPublicKey pub = (DSAPublicKey) key.getPublic(); System.out.println("DSA base (G): " + pub.getParams().getG()); System.out.println("DSA prime (P): " + pub.getParams().getP()); @@ -243,7 +237,7 @@ public class KeyInfoTool break; } } - if (state.keynames.length - i > 1) + if (state.keynames.length - i > 1) { System.out.println(); } diff --git a/src/com/verisignlabs/dnssec/cl/SignKeyset.java b/src/com/verisignlabs/dnssec/cl/SignKeyset.java index 04a3544..978a169 100644 --- a/src/com/verisignlabs/dnssec/cl/SignKeyset.java +++ b/src/com/verisignlabs/dnssec/cl/SignKeyset.java @@ -84,7 +84,7 @@ public class SignKeyset /** * Set up the command line options. - * + * * @return a set of command line options. */ private void setupCLI() @@ -136,34 +136,33 @@ public class SignKeyset if (cli.hasOption('h')) usage(); Logger rootLogger = Logger.getLogger(""); - if (cli.hasOption('v')) + + int value = parseInt(cli.getOptionValue('v'), -1); + switch (value) { - int value = parseInt(cli.getOptionValue('v'), -1); - switch (value) - { - case 0: - rootLogger.setLevel(Level.OFF); - break; - case 1: - rootLogger.setLevel(Level.SEVERE); - break; - case 2: - default: - rootLogger.setLevel(Level.WARNING); - break; - case 3: - rootLogger.setLevel(Level.INFO); - break; - case 4: - rootLogger.setLevel(Level.CONFIG); - case 5: - rootLogger.setLevel(Level.FINE); - break; - case 6: - rootLogger.setLevel(Level.ALL); - break; - } + case 0: + rootLogger.setLevel(Level.OFF); + break; + case 1: + rootLogger.setLevel(Level.SEVERE); + break; + case 2: + default: + rootLogger.setLevel(Level.WARNING); + break; + case 3: + rootLogger.setLevel(Level.INFO); + break; + case 4: + rootLogger.setLevel(Level.CONFIG); + case 5: + rootLogger.setLevel(Level.FINE); + break; + case 6: + rootLogger.setLevel(Level.ALL); + break; } + // I hate java.util.logging, btw. for (Handler h : rootLogger.getHandlers()) { @@ -241,7 +240,7 @@ public class SignKeyset /** * This is just a convenience method for parsing integers from strings. - * + * * @param s * the string to parse. * @param def @@ -263,7 +262,7 @@ public class SignKeyset /** * Verify the generated signatures. - * + * * @param zonename * the origin name of the zone. * @param records @@ -308,7 +307,7 @@ public class SignKeyset /** * Load the key pairs from the key files. - * + * * @param keyfiles * a string array containing the base names or paths of the keys * to be loaded. @@ -381,7 +380,7 @@ public class SignKeyset /** * Calculate a date/time from a command line time/offset duration string. - * + * * @param start * the start time to calculate offsets from. * @param duration diff --git a/src/com/verisignlabs/dnssec/cl/SignRRset.java b/src/com/verisignlabs/dnssec/cl/SignRRset.java index 304b6d7..a4fe6bc 100644 --- a/src/com/verisignlabs/dnssec/cl/SignRRset.java +++ b/src/com/verisignlabs/dnssec/cl/SignRRset.java @@ -85,7 +85,7 @@ public class SignRRset /** * Set up the command line options. - * + * * @return a set of command line options. */ private void setupCLI() @@ -138,34 +138,33 @@ public class SignRRset if (cli.hasOption('h')) usage(); Logger rootLogger = Logger.getLogger(""); - if (cli.hasOption('v')) + + int value = parseInt(cli.getOptionValue('v'), -1); + switch (value) { - int value = parseInt(cli.getOptionValue('v'), -1); - switch (value) - { - case 0: - rootLogger.setLevel(Level.OFF); - break; - case 1: - rootLogger.setLevel(Level.SEVERE); - break; - case 2: - default: - rootLogger.setLevel(Level.WARNING); - break; - case 3: - rootLogger.setLevel(Level.INFO); - break; - case 4: - rootLogger.setLevel(Level.CONFIG); - case 5: - rootLogger.setLevel(Level.FINE); - break; - case 6: - rootLogger.setLevel(Level.ALL); - break; - } + case 0: + rootLogger.setLevel(Level.OFF); + break; + case 1: + rootLogger.setLevel(Level.SEVERE); + break; + case 2: + default: + rootLogger.setLevel(Level.WARNING); + break; + case 3: + rootLogger.setLevel(Level.INFO); + break; + case 4: + rootLogger.setLevel(Level.CONFIG); + case 5: + rootLogger.setLevel(Level.FINE); + break; + case 6: + rootLogger.setLevel(Level.ALL); + break; } + // I hate java.util.logging, btw. for (Handler h : rootLogger.getHandlers()) { @@ -243,7 +242,7 @@ public class SignRRset /** * This is just a convenience method for parsing integers from strings. - * + * * @param s * the string to parse. * @param def @@ -310,7 +309,7 @@ public class SignRRset /** * Load the key pairs from the key files. - * + * * @param keyfiles * a string array containing the base names or paths of the keys * to be loaded. @@ -342,7 +341,7 @@ public class SignRRset /** * Calculate a date/time from a command line time/offset duration string. - * + * * @param start * the start time to calculate offsets from. * @param duration diff --git a/src/com/verisignlabs/dnssec/cl/SignZone.java b/src/com/verisignlabs/dnssec/cl/SignZone.java index 2428985..ae1cfc9 100644 --- a/src/com/verisignlabs/dnssec/cl/SignZone.java +++ b/src/com/verisignlabs/dnssec/cl/SignZone.java @@ -218,34 +218,33 @@ public class SignZone if (cli.hasOption('h')) usage(); Logger rootLogger = Logger.getLogger(""); - if (cli.hasOption('v')) + + int value = parseInt(cli.getOptionValue('v'), -1); + switch (value) { - int value = parseInt(cli.getOptionValue('v'), -1); - switch (value) - { - case 0: - rootLogger.setLevel(Level.OFF); - break; - case 1: - rootLogger.setLevel(Level.SEVERE); - break; - case 2: - default: - rootLogger.setLevel(Level.WARNING); - break; - case 3: - rootLogger.setLevel(Level.INFO); - break; - case 4: - rootLogger.setLevel(Level.CONFIG); - case 5: - rootLogger.setLevel(Level.FINE); - break; - case 6: - rootLogger.setLevel(Level.ALL); - break; - } + case 0: + rootLogger.setLevel(Level.OFF); + break; + case 1: + rootLogger.setLevel(Level.SEVERE); + break; + case 2: + default: + rootLogger.setLevel(Level.WARNING); + break; + case 3: + rootLogger.setLevel(Level.INFO); + break; + case 4: + rootLogger.setLevel(Level.CONFIG); + case 5: + rootLogger.setLevel(Level.FINE); + break; + case 6: + rootLogger.setLevel(Level.ALL); + break; } + // I hate java.util.logging, btw. for (Handler h : rootLogger.getHandlers()) { diff --git a/src/com/verisignlabs/dnssec/cl/VerifyZone.java b/src/com/verisignlabs/dnssec/cl/VerifyZone.java index 975362c..223643e 100644 --- a/src/com/verisignlabs/dnssec/cl/VerifyZone.java +++ b/src/com/verisignlabs/dnssec/cl/VerifyZone.java @@ -117,34 +117,33 @@ public class VerifyZone if (cli.hasOption('h')) usage(); Logger rootLogger = Logger.getLogger(""); - if (cli.hasOption('v')) + int value = parseInt(cli.getOptionValue('v'), -1); + + switch (value) { - int value = parseInt(cli.getOptionValue('v'), -1); - switch (value) - { - case 0: - rootLogger.setLevel(Level.OFF); - break; - case 1: - rootLogger.setLevel(Level.SEVERE); - break; - case 2: - default: - rootLogger.setLevel(Level.WARNING); - break; - case 3: - rootLogger.setLevel(Level.INFO); - break; - case 4: - rootLogger.setLevel(Level.CONFIG); - case 5: - rootLogger.setLevel(Level.FINE); - break; - case 6: - rootLogger.setLevel(Level.ALL); - break; - } + case 0: + rootLogger.setLevel(Level.OFF); + break; + case 1: + rootLogger.setLevel(Level.SEVERE); + break; + case 2: + default: + rootLogger.setLevel(Level.WARNING); + break; + case 3: + rootLogger.setLevel(Level.INFO); + break; + case 4: + rootLogger.setLevel(Level.CONFIG); + case 5: + rootLogger.setLevel(Level.FINE); + break; + case 6: + rootLogger.setLevel(Level.ALL); + break; } + // I hate java.util.logging, btw. for (Handler h : rootLogger.getHandlers()) { diff --git a/src/com/verisignlabs/dnssec/cl/ZoneFormat.java b/src/com/verisignlabs/dnssec/cl/ZoneFormat.java index 99d9de9..aea0040 100644 --- a/src/com/verisignlabs/dnssec/cl/ZoneFormat.java +++ b/src/com/verisignlabs/dnssec/cl/ZoneFormat.java @@ -85,34 +85,33 @@ public class ZoneFormat if (cli.hasOption('N')) assignNSEC3 = true; Logger rootLogger = Logger.getLogger(""); - if (cli.hasOption('v')) + + int value = parseInt(cli.getOptionValue('v'), -1); + switch (value) { - int value = parseInt(cli.getOptionValue('v'), -1); - switch (value) - { - case 0: - rootLogger.setLevel(Level.OFF); - break; - case 1: - rootLogger.setLevel(Level.SEVERE); - break; - case 2: - default: - rootLogger.setLevel(Level.WARNING); - break; - case 3: - rootLogger.setLevel(Level.INFO); - break; - case 4: - rootLogger.setLevel(Level.CONFIG); - case 5: - rootLogger.setLevel(Level.FINE); - break; - case 6: - rootLogger.setLevel(Level.ALL); - break; - } + case 0: + rootLogger.setLevel(Level.OFF); + break; + case 1: + rootLogger.setLevel(Level.SEVERE); + break; + case 2: + default: + rootLogger.setLevel(Level.WARNING); + break; + case 3: + rootLogger.setLevel(Level.INFO); + break; + case 4: + rootLogger.setLevel(Level.CONFIG); + case 5: + rootLogger.setLevel(Level.FINE); + break; + case 6: + rootLogger.setLevel(Level.ALL); + break; } + // I hate java.util.logging, btw. for (Handler h : rootLogger.getHandlers()) {