Store passwords encrypted

This commit is contained in:
M66B
2019-03-11 14:01:27 +00:00
parent de57f2ede1
commit a3063c3da4
10 changed files with 1688 additions and 27 deletions

View File

@@ -95,6 +95,20 @@ public class EntityAccount implements Serializable {
return "imap" + (starttls ? "" : "s");
}
String getPassword() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
return this.password;
else
return Helper.decryptPassword(this.password);
}
void setPassword(String plain) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
this.password = plain;
else
this.password = Helper.encryptPassword(plain);
}
static String getNotificationChannelName(long account) {
return "notification" + (account == 0 ? "" : "." + account);
}
@@ -124,7 +138,7 @@ public class EntityAccount implements Serializable {
json.put("insecure", insecure);
json.put("port", port);
json.put("user", user);
json.put("password", password);
json.put("password", getPassword());
json.put("realm", realm);
json.put("name", name);
@@ -156,7 +170,7 @@ public class EntityAccount implements Serializable {
account.insecure = (json.has("insecure") && json.getBoolean("insecure"));
account.port = json.getInt("port");
account.user = json.getString("user");
account.password = json.getString("password");
account.setPassword(json.getString("password"));
if (json.has("realm"))
account.realm = json.getString("realm");
@@ -194,7 +208,7 @@ public class EntityAccount implements Serializable {
this.insecure == other.insecure &&
this.port.equals(other.port) &&
this.user.equals(other.user) &&
this.password.equals(other.password) &&
this.getPassword().equals(other.getPassword()) &&
Objects.equals(this.realm, other.realm) &&
Objects.equals(this.name, other.name) &&
Objects.equals(this.color, other.color) &&