Fields Summary |
---|
protected File | jarThe name of the jar file. |
protected String | aliasThe alias of signer. |
protected String | keystoreThe url or path of keystore file. |
protected String | storepasspassword for the store |
protected String | storetypetype of store,-storetype param |
protected String | keypasspassword for the key in the store |
protected boolean | verboseverbose output |
protected String | maxMemoryThe maximum amount of memory to use for Jar signer |
protected Vector | filesetsthe filesets of the jars to sign |
protected static final String | JARSIGNER_COMMANDname of JDK program we are looking for |
private org.apache.tools.ant.types.RedirectorElement | redirectorredirector used to talk to the jarsigner program |
private org.apache.tools.ant.types.Environment | sysPropertiesJava declarations -J-Dname=value |
public static final String | ERROR_NO_SOURCEerror string for unit test verification: {@value} |
private org.apache.tools.ant.types.Path | pathPath holding all non-filesets of filesystem resources we want to sign. |
Methods Summary |
---|
public void | addFileset(org.apache.tools.ant.types.FileSet set)Adds a set of files to sign
filesets.addElement(set);
|
public void | addSysproperty(Environment.Variable sysp)Add a system property.
sysProperties.addVariable(sysp);
|
protected void | addValue(ExecTask cmd, java.lang.String value)add a value argument to a command
cmd.createArg().setValue(value);
|
protected void | beginExecution()init processing logic; this is retained through our execution(s)
redirector = createRedirector();
|
protected void | bindToKeystore(ExecTask cmd)bind to a keystore if the attributes are there
if (null != keystore) {
// is the keystore a file
addValue(cmd, "-keystore");
String loc;
File keystoreFile = getProject().resolveFile(keystore);
if (keystoreFile.exists()) {
loc = keystoreFile.getPath();
} else {
// must be a URL - just pass as is
loc = keystore;
}
addValue(cmd, loc);
}
if (null != storetype) {
addValue(cmd, "-storetype");
addValue(cmd, storetype);
}
|
protected ExecTask | createJarSigner()create the jarsigner executable task
final ExecTask cmd = new ExecTask(this);
cmd.setExecutable(JavaEnvUtils.getJdkExecutable(JARSIGNER_COMMAND));
cmd.setTaskType(JARSIGNER_COMMAND);
cmd.setFailonerror(true);
cmd.addConfiguredRedirector(redirector);
return cmd;
|
public org.apache.tools.ant.types.Path | createPath()Adds a path of files to sign.
if (path == null) {
path = new Path(getProject());
}
return path.createPath();
|
private org.apache.tools.ant.types.RedirectorElement | createRedirector()Create the redirector to use, if any.
RedirectorElement result = new RedirectorElement();
if (storepass != null) {
StringBuffer input = new StringBuffer(storepass).append('\n");
if (keypass != null) {
input.append(keypass).append('\n");
}
result.setInputString(input.toString());
result.setLogInputString(false);
}
return result;
|
protected org.apache.tools.ant.types.Path | createUnifiedSourcePath()clone our path and add all explicitly specified FileSets as
well, patch in the jar attribute as a new fileset if it is
defined.
Path p = path == null ? new Path(getProject()) : (Path) path.clone();
Vector s = createUnifiedSources();
Enumeration e = s.elements();
while (e.hasMoreElements()) {
p.add((FileSet) e.nextElement());
}
return p;
|
protected java.util.Vector | createUnifiedSources()clone our filesets vector, and patch in the jar attribute as a new
fileset, if is defined
Vector sources = (Vector) filesets.clone();
if (jar != null) {
//we create a fileset with the source file.
//this lets us combine our logic for handling output directories,
//mapping etc.
FileSet sourceJar = new FileSet();
sourceJar.setProject(getProject());
sourceJar.setFile(jar);
sourceJar.setDir(jar.getParentFile());
sources.add(sourceJar);
}
return sources;
|
protected void | declareSysProperty(ExecTask cmd, Environment.Variable property)
addValue(cmd, "-J-D" + property.getContent());
|
protected void | endExecution()any cleanup logic
redirector = null;
|
public org.apache.tools.ant.types.RedirectorElement | getRedirector()get the redirector. Non-null between invocations of
{@link #beginExecution()} and {@link #endExecution()}
return redirector;
|
protected boolean | hasResources()Has either a path or a fileset been specified?
return path != null || filesets.size() > 0;
|
public void | setAlias(java.lang.String alias)the alias to sign under; required
this.alias = alias;
|
protected void | setCommonOptions(ExecTask cmd)these are options common to signing and verifying
if (maxMemory != null) {
addValue(cmd, "-J-Xmx" + maxMemory);
}
if (verbose) {
addValue(cmd, "-verbose");
}
//now patch in all system properties
Vector props = sysProperties.getVariablesVector();
Enumeration e = props.elements();
while (e.hasMoreElements()) {
Environment.Variable variable = (Environment.Variable) e.nextElement();
declareSysProperty(cmd, variable);
}
|
public void | setJar(java.io.File jar)the jar file to sign; required
this.jar = jar;
|
public void | setKeypass(java.lang.String keypass)password for private key (if different); optional
this.keypass = keypass;
|
public void | setKeystore(java.lang.String keystore)keystore location; required
this.keystore = keystore;
|
public void | setMaxmemory(java.lang.String max)Set the maximum memory to be used by the jarsigner process
maxMemory = max;
|
public void | setStorepass(java.lang.String storepass)password for keystore integrity; required
this.storepass = storepass;
|
public void | setStoretype(java.lang.String storetype)keystore type; optional
this.storetype = storetype;
|
public void | setVerbose(boolean verbose)Enable verbose output when signing ; optional: default false
this.verbose = verbose;
|