Methods Summary |
---|
public org.apache.tools.ant.taskdefs.GenerateKey$DistinguishedName | createDname()Distinguished name list.
if (null != expandedDname) {
throw new BuildException("DName sub-element can only be "
+ "specified once.");
}
if (null != dname) {
throw new BuildException("It is not possible to specify dname "
+ " both as attribute and element.");
}
expandedDname = new DistinguishedName();
return expandedDname;
|
public void | execute()Execute the task.
if (null == alias) {
throw new BuildException("alias attribute must be set");
}
if (null == storepass) {
throw new BuildException("storepass attribute must be set");
}
if (null == dname && null == expandedDname) {
throw new BuildException("dname must be set");
}
final StringBuffer sb = new StringBuffer();
sb.append("-genkey ");
if (verbose) {
sb.append("-v ");
}
sb.append("-alias \"");
sb.append(alias);
sb.append("\" ");
if (null != dname) {
sb.append("-dname \"");
sb.append(dname);
sb.append("\" ");
}
if (null != expandedDname) {
sb.append("-dname \"");
sb.append(expandedDname);
sb.append("\" ");
}
if (null != keystore) {
sb.append("-keystore \"");
sb.append(keystore);
sb.append("\" ");
}
if (null != storepass) {
sb.append("-storepass \"");
sb.append(storepass);
sb.append("\" ");
}
if (null != storetype) {
sb.append("-storetype \"");
sb.append(storetype);
sb.append("\" ");
}
sb.append("-keypass \"");
if (null != keypass) {
sb.append(keypass);
} else {
sb.append(storepass);
}
sb.append("\" ");
if (null != sigalg) {
sb.append("-sigalg \"");
sb.append(sigalg);
sb.append("\" ");
}
if (null != keyalg) {
sb.append("-keyalg \"");
sb.append(keyalg);
sb.append("\" ");
}
if (0 < keysize) {
sb.append("-keysize \"");
sb.append(keysize);
sb.append("\" ");
}
if (0 < validity) {
sb.append("-validity \"");
sb.append(validity);
sb.append("\" ");
}
log("Generating Key for " + alias);
final ExecTask cmd = new ExecTask(this);
cmd.setExecutable(JavaEnvUtils.getJdkExecutable("keytool"));
Commandline.Argument arg = cmd.createArg();
arg.setLine(sb.toString());
cmd.setFailonerror(true);
cmd.setTaskName(getTaskName());
cmd.execute();
|
public void | setAlias(java.lang.String alias)The alias to add under.
this.alias = alias;
|
public void | setDname(java.lang.String dname)The distinguished name for entity.
if (null != expandedDname) {
throw new BuildException("It is not possible to specify dname "
+ " both as attribute and element.");
}
this.dname = dname;
|
public void | setKeyalg(java.lang.String keyalg)The method to use when generating name-value pair.
this.keyalg = keyalg;
|
public void | setKeypass(java.lang.String keypass)Password for private key (if different).
this.keypass = keypass;
|
public void | setKeysize(java.lang.String keysize)Indicates the size of key generated.
try {
this.keysize = Integer.parseInt(keysize);
} catch (final NumberFormatException nfe) {
throw new BuildException("KeySize attribute should be a integer");
}
|
public void | setKeystore(java.lang.String keystore)Keystore location.
this.keystore = keystore;
|
public void | setSigalg(java.lang.String sigalg)The algorithm to use in signing.
this.sigalg = sigalg;
|
public void | setStorepass(java.lang.String storepass)Password for keystore integrity.
Must be at least 6 characters long.
this.storepass = storepass;
|
public void | setStoretype(java.lang.String storetype)Keystore type.
this.storetype = storetype;
|
public void | setValidity(java.lang.String validity)Indicates how many days certificate is valid.
try {
this.validity = Integer.parseInt(validity);
} catch (final NumberFormatException nfe) {
throw new BuildException("Validity attribute should be a integer");
}
|
public void | setVerbose(boolean verbose)If true, verbose output when signing.
this.verbose = verbose;
|