multi-account

This commit is contained in:
Thomas 2021-02-23 19:15:10 +01:00
parent 7ed9398009
commit f0affaa332
2 changed files with 6 additions and 6 deletions

View File

@ -157,24 +157,24 @@ public class ECDH {
return base64Encode(getPair(context, account).getPublic().getEncoded()); return base64Encode(getPair(context, account).getPublic().getEncoded());
} }
void saveServerKey(Context context, String strPeerPublic) { void saveServerKey(Context context, Account account, String strPeerPublic) {
SharedPreferences.Editor prefsEditor = PreferenceManager SharedPreferences.Editor prefsEditor = PreferenceManager
.getDefaultSharedPreferences(context).edit(); .getDefaultSharedPreferences(context).edit();
prefsEditor.putString(peer_public, strPeerPublic); prefsEditor.putString(peer_public + account.getId() + account.getInstance(), strPeerPublic);
prefsEditor.commit(); prefsEditor.commit();
} }
PublicKey getServerKey(Context context) throws Exception { PublicKey getServerKey(Context context, Account account) throws Exception {
return readPublicKey( return readPublicKey(
PreferenceManager.getDefaultSharedPreferences(context) PreferenceManager.getDefaultSharedPreferences(context)
.getString(peer_public, "") .getString(peer_public + account.getId() + account.getInstance(), "")
); );
} }
byte[] getSecret(Context context, Account account) { byte[] getSecret(Context context, Account account) {
try { try {
return generateSecret(getPair(context, account).getPrivate(), getServerKey(context)); return generateSecret(getPair(context, account).getPrivate(), getServerKey(context, account));
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return null; return null;

View File

@ -21,7 +21,7 @@ public class PushNotifications {
//register //register
ecdh.saveServerKey(context, server_key); ecdh.saveServerKey(context, account, server_key);
} }
public static void getDistributors(Context context) { public static void getDistributors(Context context) {