/** * Sets the password for barejid<br> * both will be encrypted * @param barejid * @param password * @throws Exception */ public void setPasswordForUser(String barejid, String password) throws Exception { String user = "password"+Encryptor.encrypt(barejid); String pw = Encryptor.encrypt(password); props.setProperty(user, pw); }
/** * Returns decrypted room's password. * * @return decrypted room's password. */ public String getGroupChatPassword(String roomName) { if(props.getProperty(roomName)!= null) return Encryptor.decrypt(props.getProperty(roomName)); return null; }
public void clearPasswordForUser(String barejid) throws Exception { String pw = "password"+Encryptor.encrypt(barejid); props.remove(pw); }
public void savePassword(String roomName, String password) { File sparkProperties = new File(Spark.getSparkUserHome().concat(File.separator).concat(SettingsManager.getSettingsFile().getName())); Properties props = new Properties(); try { props.load(new FileInputStream(sparkProperties)); } catch (Exception e) { Log.error("error with file"+ e.getCause()); } LocalPreferences preferences = new LocalPreferences(props); try { preferences.setGroupChatPassword(roomName,Encryptor.encrypt(password)); } catch (Exception ex) { Log.error(ex.getCause()); } FileOutputStream fileOut; try { fileOut = new FileOutputStream(sparkProperties); props.store(fileOut, "added room"); } catch (Exception ex) { Log.error(ex.getCause()); } }