2 // Getdown - application installer, patcher and launcher
3 // Copyright (C) 2004-2018 Getdown authors
4 // https://github.com/threerings/getdown/blob/master/LICENSE
6 package com.threerings.getdown.tools;
9 import java.io.IOException;
11 import java.security.GeneralSecurityException;
13 import org.apache.tools.ant.BuildException;
14 import org.apache.tools.ant.Task;
16 import com.threerings.getdown.data.Digest;
19 * An ant task used to create a <code>digest.txt</code> for a Getdown
20 * application deployment.
22 public class DigesterTask extends Task
25 * Sets the application directory.
27 public void setAppdir (File appdir)
33 * Sets the digest signing keystore.
35 public void setKeystore (File path)
41 * Sets the keystore decryption key.
43 public void setStorepass (String password)
45 _storepass = password;
49 * Sets the private key alias.
51 public void setAlias (String alias)
57 * Performs the actual work of the task.
60 public void execute () throws BuildException
62 // make sure appdir is set
63 if (_appdir == null) {
64 throw new BuildException("Must specify the path to the application directory " +
65 "via the 'appdir' attribute.");
68 // make sure _storepass and _keyalias are set, if _storepath is set
69 if (_storepath != null && (_storepass == null || _storealias == null)) {
70 throw new BuildException(
71 "Must specify both a keystore password and a private key alias.");
75 Digester.createDigests(_appdir, _storepath, _storepass, _storealias);
76 } catch (IOException ioe) {
77 throw new BuildException("Error creating digest: " + ioe.getMessage(), ioe);
78 } catch (GeneralSecurityException gse) {
79 throw new BuildException("Error creating signature: " + gse.getMessage(), gse);
83 /** The application directory in which we're creating a digest file. */
84 protected File _appdir;
86 /** The path to the keystore we'll use to sign the digest file, if any. */
87 protected File _storepath;
89 /** The decryption key for the keystore. */
90 protected String _storepass;
92 /** The private key alias. */
93 protected String _storealias;