public void save() { lock.lock(); configurationFile.getParentFile().mkdirs(); Writer fw = null; try { // this is sort of dirty... String clearPass = null; // change the password to be encrypted if (configuration.getConnectionInfo() != null && StringUtils.isNotEmpty(configuration.getConnectionInfo().getSystemPassword())) { try { clearPass = configuration.getConnectionInfo().getSystemPassword(); configuration.getConnectionInfo().setSystemPassword(passwordHelper.encrypt(clearPass)); } catch (PlexusCipherException e) { getLogger().error("Failed to encrypt password while storing configuration file", e); } } fw = new OutputStreamWriter(new FileOutputStream(configurationFile)); LdapConfigurationXpp3Writer writer = new LdapConfigurationXpp3Writer(); writer.write(fw, configuration); // now reset the password if (configuration.getConnectionInfo() != null) { configuration.getConnectionInfo().setSystemPassword(clearPass); } } catch (IOException e) { getLogger().error("IOException while storing configuration file", e); } finally { if (fw != null) { try { fw.flush(); fw.close(); } catch (IOException e) { // just closing if open } } lock.unlock(); } // fire clear cache event this.applicationEventMulticaster.notifyEventListeners(new LdapClearCacheEvent(null)); }