/** * changeMasterKey * * @param newMasterKey */ public synchronized void changeMasterKey(String newMasterKey) { String currMasterPasswd = getMasterKey(); // Change value in properties file first pl = new PropertiesLoader(propertiesFile); Properties prop = pl.getPropetiesFromFile(); prop.setProperty("meerkat.password.master", newMasterKey); pl.writePropertiesToFile(prop, propertiesFile); // Update the password for all applications BasicTextEncryptor oldTextEncrypt = new BasicTextEncryptor(); oldTextEncrypt.setPassword(currMasterPasswd); Iterator<WebApp> it = wac.getWebAppCollectionIterator(); WebApp curr; String passwd, currPasswd; while (it.hasNext()) { curr = it.next(); String type = curr.getType(); if (type.equals(WebApp.TYPE_SSH)) { // If SSH we need to update the encrypted password SecureShellSSH app = (SecureShellSSH) curr; passwd = app.getPassword(); currPasswd = oldTextEncrypt.decrypt(passwd); app.setPasswd(currPasswd); } else if (type.equals( WebApp.TYPE_DATABASE)) { // If SQL we need to update the encrypted password SQLService app = (SQLService) curr; passwd = app.getPassword(); currPasswd = oldTextEncrypt.decrypt(passwd); app.setPassword(currPasswd); } } wac.saveConfigXMLFile(); }
/** * getMasterKey * * @return */ public final String getMasterKey() { pl = new PropertiesLoader(propertiesFile); Properties prop = pl.getPropetiesFromFile(); return prop.getProperty("meerkat.password.master"); }