Support for verification tokens

// FREEBIE
This commit is contained in:
Moxie Marlinspike
2015-09-21 14:34:06 -07:00
parent cbb2038d46
commit a25ebefcbb
3 changed files with 23 additions and 0 deletions
@@ -235,6 +235,10 @@ public class TextSecureAccountManager {
return activeTokens;
}
public String getAccountVerificationToken() throws IOException {
return this.pushServiceSocket.getAccountVerificationToken();
}
public String getNewDeviceVerificationCode() throws IOException {
return this.pushServiceSocket.getNewDeviceVerificationCode();
}
@@ -0,0 +1,13 @@
package org.whispersystems.textsecure.internal.push;
import com.fasterxml.jackson.annotation.JsonProperty;
public class AuthorizationToken {
@JsonProperty
private String token;
public String getToken() {
return token;
}
}
@@ -82,6 +82,7 @@ public class PushServiceSocket {
private static final String VERIFY_ACCOUNT_CODE_PATH = "/v1/accounts/code/%s";
private static final String VERIFY_ACCOUNT_TOKEN_PATH = "/v1/accounts/token/%s";
private static final String REGISTER_GCM_PATH = "/v1/accounts/gcm/";
private static final String REQUEST_TOKEN_PATH = "/v1/accounts/token";
private static final String PREKEY_METADATA_PATH = "/v2/keys/";
private static final String PREKEY_PATH = "/v2/keys/%s";
@@ -135,6 +136,11 @@ public class PushServiceSocket {
"PUT", JsonUtil.toJson(signalingKeyEntity));
}
public String getAccountVerificationToken() throws IOException {
String responseText = makeRequest(REQUEST_TOKEN_PATH, "GET", null);
return JsonUtil.fromJson(responseText, AuthorizationToken.class).getToken();
}
public String getNewDeviceVerificationCode() throws IOException {
String responseText = makeRequest(PROVISIONING_CODE_PATH, "GET", null);
return JsonUtil.fromJson(responseText, DeviceCode.class).getVerificationCode();