mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-26 19:56:02 +01:00
Add last resort key and signaling key.
This commit is contained in:
@@ -4,10 +4,12 @@ import java.util.List;
|
||||
|
||||
public class PreKeyList {
|
||||
|
||||
private PreKeyEntity lastResortKey;
|
||||
private List<PreKeyEntity> keys;
|
||||
|
||||
public PreKeyList(List<PreKeyEntity> keys) {
|
||||
this.keys = keys;
|
||||
public PreKeyList(PreKeyEntity lastResortKey, List<PreKeyEntity> keys) {
|
||||
this.keys = keys;
|
||||
this.lastResortKey = lastResortKey;
|
||||
}
|
||||
|
||||
public List<PreKeyEntity> getKeys() {
|
||||
@@ -17,4 +19,8 @@ public class PreKeyList {
|
||||
public static String toJson(PreKeyList entity) {
|
||||
return PreKeyEntity.getBuilder().create().toJson(entity);
|
||||
}
|
||||
|
||||
public PreKeyEntity getLastResortKey() {
|
||||
return lastResortKey;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,8 +65,9 @@ public class PushServiceSocket {
|
||||
makeRequest(String.format(path, localNumber), "POST", null);
|
||||
}
|
||||
|
||||
public void verifyAccount(String verificationCode) throws IOException {
|
||||
makeRequest(String.format(VERIFY_ACCOUNT_PATH, verificationCode), "PUT", null);
|
||||
public void verifyAccount(String verificationCode, String signalingKey) throws IOException {
|
||||
SignalingKey signalingKeyEntity = new SignalingKey(signalingKey);
|
||||
makeRequest(String.format(VERIFY_ACCOUNT_PATH, verificationCode), "PUT", new Gson().toJson(signalingKeyEntity));
|
||||
}
|
||||
|
||||
public void registerGcmId(String gcmRegistrationId) throws IOException {
|
||||
@@ -109,7 +110,9 @@ public class PushServiceSocket {
|
||||
throw new IOException("Got send failure: " + response.getFailure().get(0));
|
||||
}
|
||||
|
||||
public void registerPreKeys(IdentityKey identityKey, List<PreKeyRecord> records)
|
||||
public void registerPreKeys(IdentityKey identityKey,
|
||||
PreKeyRecord lastResortKey,
|
||||
List<PreKeyRecord> records)
|
||||
throws IOException
|
||||
{
|
||||
List<PreKeyEntity> entities = new LinkedList<PreKeyEntity>();
|
||||
@@ -121,7 +124,11 @@ public class PushServiceSocket {
|
||||
entities.add(entity);
|
||||
}
|
||||
|
||||
makeRequest(String.format(PREKEY_PATH, ""), "PUT", PreKeyList.toJson(new PreKeyList(entities)));
|
||||
PreKeyEntity lastResortEntity = new PreKeyEntity(lastResortKey.getId(),
|
||||
lastResortKey.getKeyPair().getPublicKey(),
|
||||
identityKey);
|
||||
|
||||
makeRequest(String.format(PREKEY_PATH, ""), "PUT", PreKeyList.toJson(new PreKeyList(lastResortEntity, entities)));
|
||||
}
|
||||
|
||||
public PreKeyEntity getPreKey(String number) throws IOException {
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.whispersystems.textsecure.push;
|
||||
|
||||
public class SignalingKey {
|
||||
|
||||
private String signalingKey;
|
||||
|
||||
public SignalingKey(String signalingKey) {
|
||||
this.signalingKey = signalingKey;
|
||||
}
|
||||
|
||||
public SignalingKey() {}
|
||||
|
||||
public String getSignalingKey() {
|
||||
return signalingKey;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user