From 531dc115aa25336964cc34f99a267985c6cab69b Mon Sep 17 00:00:00 2001 From: David Blacka Date: Thu, 5 Feb 2009 05:05:32 +0000 Subject: [PATCH] Use ObjectBuilder statically (this was generating warnings for me) git-svn-id: https://svn.verisignlabs.com/jdnssec/tools/trunk@123 4cbd57fe-54e5-0310-bd9a-f30fe5ea5e6e --- src/com/verisignlabs/dnssec/cl/DSTool.java | 28 +++---- src/com/verisignlabs/dnssec/cl/KeyGen.java | 11 ++- .../verisignlabs/dnssec/cl/KeyInfoTool.java | 18 ++--- .../verisignlabs/dnssec/cl/VerifyZone.java | 80 +++++++++---------- .../verisignlabs/dnssec/cl/ZoneFormat.java | 28 ++++--- 5 files changed, 84 insertions(+), 81 deletions(-) diff --git a/src/com/verisignlabs/dnssec/cl/DSTool.java b/src/com/verisignlabs/dnssec/cl/DSTool.java index 83f195c..6750e9d 100644 --- a/src/com/verisignlabs/dnssec/cl/DSTool.java +++ b/src/com/verisignlabs/dnssec/cl/DSTool.java @@ -74,23 +74,23 @@ public class DSTool // boolean options opts.addOption("h", "help", false, "Print this message."); - opts.addOption(OptionBuilder.withLongOpt("dlv") - .withDescription("Generate a DLV record instead.") - .create()); + OptionBuilder.withLongOpt("dlv"); + OptionBuilder.withDescription("Generate a DLV record instead."); + opts.addOption(OptionBuilder.create()); + OptionBuilder.hasOptionalArg(); + 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."); // Argument options - opts.addOption(OptionBuilder.hasOptionalArg() - .withLongOpt("verbose") - .withArgName("level") - .withDescription("verbosity level -- 0 is silence, 5 is debug information, 6 is trace information.\n" - + "default is level 5.") - .create('v')); + opts.addOption(OptionBuilder.create('v')); - opts.addOption(OptionBuilder.hasArg() - .withLongOpt("digest") - .withArgName("id") - .withDescription("The Digest ID to use (numerically): either 1 for SHA1 or 2 for SHA256") - .create('d')); + OptionBuilder.hasArg(); + OptionBuilder.withLongOpt("digest"); + OptionBuilder.withArgName("id"); + OptionBuilder.withDescription("The Digest ID to use (numerically): either 1 for SHA1 or 2 for SHA256"); + opts.addOption(OptionBuilder.create('d')); } public void parseCommandLine(String[] args) diff --git a/src/com/verisignlabs/dnssec/cl/KeyGen.java b/src/com/verisignlabs/dnssec/cl/KeyGen.java index 953f7af..026eed1 100644 --- a/src/com/verisignlabs/dnssec/cl/KeyGen.java +++ b/src/com/verisignlabs/dnssec/cl/KeyGen.java @@ -93,22 +93,21 @@ 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" + + "5 is debug information, 6 is trace information.\n" + "default is level 5."); opts.addOption(OptionBuilder.create('v')); OptionBuilder.hasArg(); OptionBuilder.withArgName("algorithm"); - OptionBuilder.withDescription("RSA | RSASHA1 | RSAMD5 | DH | DSA | alias, " - + "RSASHA1 is default."); + OptionBuilder.withDescription("RSA | RSASHA1 | RSAMD5 | DH | DSA " + + "| RSA-NSEC3-SHA1 | DSA-NSEC3-SHA1 " + + "| RSASHA256 | RSASHA512 | alias, RSASHA1 is default."); opts.addOption(OptionBuilder.create('a')); OptionBuilder.hasArg(); OptionBuilder.withArgName("size"); OptionBuilder.withDescription("key size, in bits. (default = 1024)\n" - + "RSA|RSASHA1|RSAMD5: [512..4096]\n" - + "DSA: [512..1024]\n" - + "DH: [128..4096]"); + + "RSA: [512..4096]\n" + "DSA: [512..1024]\n" + "DH: [128..4096]"); opts.addOption(OptionBuilder.create('b')); OptionBuilder.hasArg(); diff --git a/src/com/verisignlabs/dnssec/cl/KeyInfoTool.java b/src/com/verisignlabs/dnssec/cl/KeyInfoTool.java index d51d496..0ccf9dd 100644 --- a/src/com/verisignlabs/dnssec/cl/KeyInfoTool.java +++ b/src/com/verisignlabs/dnssec/cl/KeyInfoTool.java @@ -32,7 +32,7 @@ import com.verisignlabs.dnssec.security.DnsKeyAlgorithm; import com.verisignlabs.dnssec.security.DnsKeyPair; /** - * This class forms the command line implementation of a DNSSEC DS/DLV generator + * This class forms the command line implementation of a key introspection tool. * * @author David Blacka (original) * @author $Author: davidb $ @@ -67,16 +67,14 @@ public class KeyInfoTool // boolean options opts.addOption("h", "help", false, "Print this message."); + OptionBuilder.hasOptionalArg(); + 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."); // Argument options - opts.addOption(OptionBuilder.hasOptionalArg() - .withLongOpt("verbose") - .withArgName("level") - .withDescription( - "verbosity level -- 0 is silence, " - + "5 is debug information, " - + "6 is trace information.\n" - + "default is level 5.") - .create('v')); + opts.addOption(OptionBuilder.create('v')); OptionBuilder.hasArg(); OptionBuilder.withLongOpt("alg-alias"); diff --git a/src/com/verisignlabs/dnssec/cl/VerifyZone.java b/src/com/verisignlabs/dnssec/cl/VerifyZone.java index b61ae87..ee9aa80 100644 --- a/src/com/verisignlabs/dnssec/cl/VerifyZone.java +++ b/src/com/verisignlabs/dnssec/cl/VerifyZone.java @@ -79,27 +79,25 @@ public class VerifyZone + "signatures could be cryptographically verified"); // Argument options - opts.addOption(OptionBuilder.hasArg() - .withLongOpt("keydir") - .withArgName("dir") - .withDescription("directory to find " + "trusted key files") - .create('d')); + OptionBuilder.hasArg(); + OptionBuilder.withLongOpt("keydir"); + OptionBuilder.withArgName("dir"); + OptionBuilder.withDescription("directory to find " + "trusted key files"); + opts.addOption(OptionBuilder.create('d')); - opts.addOption(OptionBuilder.hasOptionalArg() - .withLongOpt("verbose") - .withArgName("level") - .withDescription( - "verbosity level -- 0 is silence, " - + "5 is debug information, 6 is trace information.\n" - + "default is level 5.") - .create('v')); - - opts.addOption(OptionBuilder.hasArg() - .withArgName("alias:original:mnemonic") - .withLongOpt("alg-alias") - .withDescription("Define an alias for an algorithm") - .create('A')); + OptionBuilder.hasOptionalArg(); + 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."); + opts.addOption(OptionBuilder.create('v')); + OptionBuilder.hasArg(); + OptionBuilder.withArgName("alias:original:mnemonic"); + OptionBuilder.withLongOpt("alg-alias"); + OptionBuilder.withDescription("Define an alias for an algorithm"); + opts.addOption(OptionBuilder.create('A')); } public void parseCommandLine(String[] args) @@ -118,16 +116,16 @@ public class VerifyZone Logger rootLogger = Logger.getLogger(""); switch (value) { - case 0: - rootLogger.setLevel(Level.OFF); - break; - case 5: - default: - rootLogger.setLevel(Level.FINE); - break; - case 6: - rootLogger.setLevel(Level.ALL); - break; + case 0: + rootLogger.setLevel(Level.OFF); + break; + case 5: + default: + rootLogger.setLevel(Level.FINE); + break; + case 6: + rootLogger.setLevel(Level.ALL); + break; } } @@ -191,7 +189,7 @@ public class VerifyZone PrintWriter out = new PrintWriter(System.err); // print our own usage statement: - f.printHelp(out, 75, "verifyZone.sh [..options..] zonefile " + f.printHelp(out, 75, "jdnssec-verifyzone [..options..] zonefile " + "[keyfile [keyfile...]]", null, opts, HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, null); @@ -329,19 +327,19 @@ public class VerifyZone switch (result) { - case DNSSEC.Failed: - System.out.println("zone did not verify."); - System.exit(1); - break; - case DNSSEC.Insecure: - if (state.strict) - { + case DNSSEC.Failed: System.out.println("zone did not verify."); System.exit(1); - } - case DNSSEC.Secure: - System.out.println("zone verified."); - break; + break; + case DNSSEC.Insecure: + if (state.strict) + { + System.out.println("zone did not verify."); + System.exit(1); + } + case DNSSEC.Secure: + System.out.println("zone verified."); + break; } System.exit(0); } diff --git a/src/com/verisignlabs/dnssec/cl/ZoneFormat.java b/src/com/verisignlabs/dnssec/cl/ZoneFormat.java index 3643a02..735242e 100644 --- a/src/com/verisignlabs/dnssec/cl/ZoneFormat.java +++ b/src/com/verisignlabs/dnssec/cl/ZoneFormat.java @@ -45,6 +45,14 @@ import org.xbill.DNS.Section; import com.verisignlabs.dnssec.security.RecordComparator; +/** + * This class forms the command line implementation of a zone file normalizer. + * That is, a tool to rewrite zones in a consistent, comparable format. + * + * @author David Blacka (original) + * @author $Author: davidb $ + * @version $Revision: 2218 $ + */ public class ZoneFormat { // private static Logger log; @@ -79,16 +87,16 @@ public class ZoneFormat Logger rootLogger = Logger.getLogger(""); switch (value) { - case 0: - rootLogger.setLevel(Level.OFF); - break; - case 5: - default: - rootLogger.setLevel(Level.FINE); - break; - case 6: - rootLogger.setLevel(Level.ALL); - break; + case 0: + rootLogger.setLevel(Level.OFF); + break; + case 5: + default: + rootLogger.setLevel(Level.FINE); + break; + case 6: + rootLogger.setLevel(Level.ALL); + break; } }