multi-account
This commit is contained in:
parent
7ed9398009
commit
f0affaa332
|
@ -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;
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
Loading…
Reference in New Issue