+ "******************************************************************************";
getLogger().error(message);
throw new IOException("Could not create configuration file " + file.getAbsolutePath(), e);
}
final SecurityConfiguration configuration = getConfiguration();
checkNotNull(configuration, "Missing security configuration");
// store clear text password, as we have to encrypt the persisted password
final String clearPassword = configuration.getAnonymousPassword();
try {
configuration.setAnonymousPassword(passwordHelper.encrypt(clearPassword));
}
catch (Exception e) {
getLogger().warn(
"Failed to encrypt the anonymous users password, storing configuration with cleartext password!", e);
}
try {
// perform the "safe save"
getLogger().debug("Saving configuration: {}", file);
final FileReplacer fileReplacer = new FileReplacer(file);
fileReplacer.setDeleteBackupFile(true);
fileReplacer.replace(new ContentWriter()
{
@Override
public void write(final BufferedOutputStream output)
throws IOException
{
new SecurityConfigurationXpp3Writer().write(output, configuration);
}
});
}
finally {
// set back to clear text
configuration.setAnonymousPassword(clearPassword);
}
}