mirror of
https://github.com/M66B/FairEmail.git
synced 2025-12-29 00:51:44 +01:00
Store passwords encrypted
This commit is contained in:
@@ -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) &&
|
||||
|
||||
Reference in New Issue
Block a user