return;
}
}
// Configure decryption (system properties as defaults, then ant properties)
CharacterStreamCipherDispatcher dispatcher = new CharacterStreamCipherDispatcher();
Properties props = new Properties(SysUtil.getConfigProperties());
props.putAll(getProject().getProperties());
dispatcher.init(props);
// Process file
try
{
if (m_keystoreFile != null)
{
boolean bHasKeyStore = false;
Param param = null;
if (m_paramList != null)
{
for (Iterator paramItr = m_paramList.iterator(); paramItr.hasNext();)
{
param = (Param)paramItr.next();
if (param.getName().equals("clusterKeyStore") && param.shouldUse())
{
bHasKeyStore = true;
break;
}
}
}
if (!bHasKeyStore)
{
param = new Param();
fis = new BufferedInputStream(new FileInputStream(m_keystoreFile));
ByteArrayOutputStream dataStream = new ByteArrayOutputStream();
IOUtil.copy(dataStream, fis);
param.setName("clusterKeyStore");
param.setExpression(Base64Util.encode(dataStream.toByteArray()));
addConfiguredParam(param);
IOUtil.close(fis);
}
}
fis = new BufferedInputStream(new FileInputStream(m_propFile));
encReader = new InputStreamReader(fis, "UTF-8");
Object cipher = dispatcher.create(encReader);
Reader decReader = null;
if (cipher instanceof CharacterStreamCipher)
{
decReader = ((CharacterStreamCipher)cipher).createDecryptedReader(encReader);
}
else
{
IOUtil.close(encReader);
IOUtil.close(fis);
fis = null;
encReader = new StringReader((String)cipher);
decReader = encReader;
cipher = dispatcher;
// The file was not encrypted at all
props.setProperty("cipher.scheme",
props.getProperty("cipher.scheme", CharacterStreamCipherDispatcher.SCHEME_TEXT));
dispatcher.init(props);
}
// Read from disk, applying XSLT transformation if necessary
Document doc;
if (m_styleFile != null)
{
TransformerFactory factory = (TransformerFactory)Class.forName(
"org.apache.xalan.processor.TransformerFactoryImpl").newInstance();
FileInputStream styleStream = new FileInputStream(m_styleFile);
Transformer transformer = factory.newTransformer(new StreamSource(styleStream));
// Read and set the transformation parameters
if (m_paramList != null)
{
for (int i = 0; i < m_paramList.size(); i++)
{
XSLTProcess.Param param = (XSLTProcess.Param)m_paramList.get(i);
if (param.shouldUse())
{
transformer.setParameter(param.getName(), param.getExpression());
}
}
}
Source source = new StreamSource(decReader);
DOMResult result = new DOMResult();
transformer.transform(source, result);
doc = (Document)result.getNode();
}
else
{
doc = XMLUtil.parse(decReader);
}
Element root = XMLUtil.findFirstElement(doc.getFirstChild());
String sRootName = root.getNodeName();
NamedNodeMap attributes = root.getAttributes();
if (m_outFile == null)
{
String sPrefix = (m_sPrefix != null) ? m_sPrefix : (sRootName + '.');
// Read properties
for (int i = 0; i < attributes.getLength(); i++)
{
Node attribute = attributes.item(i);
StringBuilder nameBuilder = new StringBuilder();
nameBuilder.append(sPrefix);
nameBuilder.append(attribute.getNodeName());
getProject().setProperty(nameBuilder.toString(), dispatcher.decrypt(attribute.getNodeValue()));
}
}
else
{
fos = new FileOutputStream(m_outFile);