{
InputStream is = new FileInputStream(inputFile);
try
{
java.util.zip.ZipInputStream zis = null;
CipherInputStream cis = null;
// Check whether we need to decrypt the file content:
if (passCode != null && passCode.length() > 0)
{
byte[] iv = new byte[IV_LENGTH];
is.read(iv);
Cipher cipher = null;
try
{
cipher = getCipher(Cipher.DECRYPT_MODE, passCode, iv);
}
catch (GeneralSecurityException gse)
{
throw new ManifoldCFException("Could not decrypt configuratiom file: " + gse.getMessage());
}
cis = new CipherInputStream(is, cipher);
zis = new java.util.zip.ZipInputStream(cis);
}
else
zis = new java.util.zip.ZipInputStream(is);
try
{
// Now, work within a transaction.
database.beginTransaction();
try
{
// Process the entries in the order in which they were recorded.
int entries = 0;
while (true)
{
java.util.zip.ZipEntry z = zis.getNextEntry();
// Stop if there are no more entries
if (z == null)
break;
entries++;
// Get the name of the entry
String name = z.getName();
if (name.equals("outputs"))
outputManager.importConfiguration(zis);
else if (name.equals("authorities"))
authManager.importConfiguration(zis);
else if (name.equals("connections"))
connManager.importConfiguration(zis);
else if (name.equals("jobs"))
jobManager.importConfiguration(zis);
else
throw new ManifoldCFException("Configuration file has an entry named '"+name+"' that I do not recognize");
zis.closeEntry();
}
if (entries == 0 && passCode != null && passCode.length() > 0)
throw new ManifoldCFException("Cannot read configuration file. Please check your passcode and/or SALT value.");
// All done!!
}
catch (ManifoldCFException e)
{
database.signalRollback();
throw e;
}
catch (Error e)
{
database.signalRollback();
throw e;
}
finally
{
database.endTransaction();
}
}
finally
{
zis.close();
if (cis != null) {
cis.close();
}
}
}
finally
{