Allow for epoch start/expire times; add verboseSigning to jdnssec-signrrset

This commit is contained in:
David Blacka 2018-07-15 14:57:41 +00:00
parent b291bb430b
commit 55a139db82
2 changed files with 31 additions and 10 deletions

View File

@ -65,7 +65,7 @@ public abstract class CLBase
/**
* The base constructor. This will setup the command line options.
*
*
* @param usage
* The command line usage string (e.g.,
* "jdnssec-foo [..options..] zonefile")
@ -106,7 +106,7 @@ public abstract class CLBase
/**
* This is an overridable method for subclasses to add their own command
* line options.
*
*
* @param opts
* the options object to add (via OptionBuilder, typically) new
* options to.
@ -121,7 +121,7 @@ public abstract class CLBase
* Subclasses generally override processOptions() rather than this method.
* This method create the parsing objects and processes the standard
* options.
*
*
* @param args
* The command line arguments.
* @throws ParseException
@ -188,7 +188,7 @@ public abstract class CLBase
/**
* Process additional tool-specific options. Subclasses generally override
* this.
*
*
* @param cli
* The {@link CommandLine} object containing the parsed command
* line state.
@ -247,9 +247,22 @@ public abstract class CLBase
}
}
public static long parseLong(String s, long def)
{
try
{
long v = Long.parseLong(s);
return v;
}
catch (NumberFormatException e)
{
return def;
}
}
/**
* Calculate a date/time from a command line time/offset duration string.
*
*
* @param start
* the start time to calculate offsets from.
* @param duration
@ -272,6 +285,11 @@ public abstract class CLBase
long offset = (long) parseInt(duration.substring(1), 0) * 1000;
return new Date(start.getTime() + offset);
}
if (duration.length() <= 10)
{
long epoch = parseLong(duration, 0) * 1000;
return new Date(epoch);
}
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyyMMddHHmmss");
dateFormatter.setTimeZone(TimeZone.getTimeZone("GMT"));

View File

@ -42,7 +42,7 @@ import com.verisignlabs.dnssec.security.*;
* RRset. Note that it will sign any RRset with any private key without
* consideration of whether or not the RRset *should* be signed in the context
* of a zone.
*
*
* @author David Blacka
*/
public class SignRRset extends CLBase
@ -61,6 +61,7 @@ public class SignRRset extends CLBase
public String inputfile = null;
public String outputfile = null;
public boolean verifySigs = false;
public boolean verboseSigning = false;
public CLIState()
{
@ -74,6 +75,7 @@ public class SignRRset extends CLBase
{
// boolean options
opts.addOption("a", "verify", false, "verify generated signatures>");
opts.addOption("V", "verbose-signing", false, "Display verbose signing activity.");
OptionBuilder.hasArg();
OptionBuilder.withArgName("dir");
@ -104,6 +106,7 @@ public class SignRRset extends CLBase
String optstr = null;
if (cli.hasOption('a')) verifySigs = true;
if (cli.hasOption('V')) verboseSigning = true;
if ((optstr = cli.getOptionValue('D')) != null)
{
@ -155,7 +158,7 @@ public class SignRRset extends CLBase
/**
* Verify the generated signatures.
*
*
* @param zonename
* the origin name of the zone.
* @param records
@ -198,7 +201,7 @@ public class SignRRset extends CLBase
/**
* 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.
@ -310,7 +313,7 @@ public class SignRRset extends CLBase
state.outputfile = state.inputfile + ".signed";
}
JCEDnsSecSigner signer = new JCEDnsSecSigner();
JCEDnsSecSigner signer = new JCEDnsSecSigner(state.verboseSigning);
List<RRSIGRecord> sigs = signer.signRRset(rrset, keypairs, state.start, state.expire);
for (RRSIGRecord s : sigs)
@ -355,7 +358,7 @@ public class SignRRset extends CLBase
{
SignRRset tool = new SignRRset();
tool.state = new CLIState();
tool.run(tool.state, args);
}
}