edu.vt.middleware.crypt.tasks.EncryptPropertyTask Maven / Gradle / Ivy
/*
$Id$
Copyright (C) 2007-2010 Virginia Tech.
All rights reserved.
SEE LICENSE FOR MORE INFORMATION
Author: Middleware Services
Email: [email protected]
Version: $Revision$
Updated: $Date$
*/
package edu.vt.middleware.crypt.tasks;
import edu.vt.middleware.crypt.symmetric.SymmetricAlgorithm;
import edu.vt.middleware.crypt.util.Base64Converter;
import edu.vt.middleware.crypt.util.Convert;
import org.apache.tools.ant.BuildException;
/**
* EncryptPropertyTask
will encrypt an ant property using a
* symmetric algorithm. Encrypted value will be BASE64 encoded.
*
* @author Middleware Services
* @version $Revision: 21 $
*/
public final class EncryptPropertyTask extends AbstractCryptTask
{
/** See @link{org.apache.tools.ant.Task}.
*/
public void execute()
{
try {
final SymmetricAlgorithm crypt = createAlgorithm();
crypt.initEncrypt();
final String propertyValue = this.getProject().getProperty(
this.propertyName);
final String encryptValue = crypt.encrypt(
Convert.toBytes(propertyValue),
new Base64Converter());
this.getProject().setProperty(this.propertyName, encryptValue);
} catch (Exception e) {
e.printStackTrace();
throw new BuildException(e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy