@@ -32,30 +32,57 @@ import org.apache.tools.ant.util.JavaEnvUtils;
*/
public class GenerateKey extends Task {
/**
* A DistinguishedName parameter.
* This is a nested element in a dname nested element.
*/
public static class DnameParam {
private String name;
private String value;
/**
* Set the name attribute.
* @param name a <code>String</code> value
*/
public void setName(String name) {
this.name = name;
}
/**
* Get the name attribute.
* @return the name.
*/
public String getName() {
return name;
}
/**
* Set the value attribute.
* @param value a <code>String</code> value
*/
public void setValue(String value) {
this.value = value;
}
/**
* Get the value attribute.
* @return the value.
*/
public String getValue() {
return value;
}
}
/**
* A class corresponding to the dname nested element.
*/
public static class DistinguishedName {
private Vector params = new Vector();
/**
* Create a param nested element.
* @return a DnameParam object to be configured.
*/
public Object createParam() {
DnameParam param = new DnameParam();
params.addElement(param);
@@ -63,10 +90,21 @@ public class GenerateKey extends Task {
return param;
}
/**
* Get the nested parameters.
* @return an enumeration of the nested parameters.
*/
public Enumeration getParams() {
return params.elements();
}
/**
* Generate a string rep of this distinguished name.
* The format is each of the parameters (name = value)
* separated by ','.
* This is used on the command line.
* @return a string rep of this name
*/
public String toString() {
final int size = params.size();
final StringBuffer sb = new StringBuffer();
@@ -87,6 +125,13 @@ public class GenerateKey extends Task {
return sb.toString();
}
/**
* Encode a name or value.
* The encoded result is the same as the input string
* except that each ',' is replaced by a '\,'.
* @param string the value to be encoded
* @return the encoded value.
*/
public String encode(final String string) {
int end = string.indexOf(',');
@@ -264,6 +309,10 @@ public class GenerateKey extends Task {
this.verbose = verbose;
}
/**
* Execute the task.
* @throws BuildException on error
*/
public void execute() throws BuildException {
if (null == alias) {