From 97100834a5bcb08f2fdf2eb6c580d3ceeb8b6b2f Mon Sep 17 00:00:00 2001 From: steckbrief Date: Sat, 16 Jul 2016 15:11:36 +0200 Subject: Implements FS#227: Store password encrypted in internal database --- .../java/de/thedevstack/conversationsplus/entities/Account.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/main/java/de/thedevstack/conversationsplus/entities/Account.java') diff --git a/src/main/java/de/thedevstack/conversationsplus/entities/Account.java b/src/main/java/de/thedevstack/conversationsplus/entities/Account.java index bc956364..2ee76504 100644 --- a/src/main/java/de/thedevstack/conversationsplus/entities/Account.java +++ b/src/main/java/de/thedevstack/conversationsplus/entities/Account.java @@ -28,6 +28,7 @@ import de.thedevstack.conversationsplus.crypto.axolotl.AxolotlService; import de.thedevstack.conversationsplus.crypto.axolotl.AxolotlServiceImpl; import de.thedevstack.conversationsplus.crypto.axolotl.AxolotlServiceStub; import de.thedevstack.conversationsplus.services.XmppConnectionService; +import de.thedevstack.conversationsplus.utils.SimpleCryptoUtil; import de.thedevstack.conversationsplus.xmpp.XmppConnection; import de.thedevstack.conversationsplus.xmpp.jid.InvalidJidException; import de.thedevstack.conversationsplus.xmpp.jid.Jid; @@ -172,6 +173,8 @@ public class Account extends AbstractEntity { private List bookmarks = new CopyOnWriteArrayList<>(); private final Collection blocklist = new CopyOnWriteArraySet<>(); + public static final String PW_SEED = "sadjgdiahsdkhashp3zt98edAFSFIOKZUIUOz23ejj12ezhez2398iehz"; + public Account() { this.uuid = "0"; } @@ -210,9 +213,10 @@ public class Account extends AbstractEntity { cursor.getString(cursor.getColumnIndex(SERVER)), "mobile"); } catch (final InvalidJidException ignored) { } + String password = SimpleCryptoUtil.decrypt(PW_SEED, cursor.getString(cursor.getColumnIndex(PASSWORD))); return new Account(cursor.getString(cursor.getColumnIndex(UUID)), jid, - cursor.getString(cursor.getColumnIndex(PASSWORD)), + password, cursor.getInt(cursor.getColumnIndex(OPTIONS)), cursor.getString(cursor.getColumnIndex(ROSTERVERSION)), cursor.getString(cursor.getColumnIndex(KEYS)), @@ -342,7 +346,7 @@ public class Account extends AbstractEntity { values.put(UUID, uuid); values.put(USERNAME, jid.getLocalpart()); values.put(SERVER, jid.getDomainpart()); - values.put(PASSWORD, password); + values.put(PASSWORD, SimpleCryptoUtil.encrypt(PW_SEED, password)); values.put(OPTIONS, options); values.put(KEYS, this.keys.toString()); values.put(ROSTERVERSION, rosterVersion); -- cgit v1.2.3