Support for v2 registration lock

This commit is contained in:
Moxie Marlinspike
2019-06-07 15:19:11 -07:00
parent 4fdbe9b9ff
commit 11902dec3c
22 changed files with 538 additions and 127 deletions

View File

@@ -19,7 +19,6 @@ package org.whispersystems.textsecuregcm.entities;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.annotations.VisibleForTesting;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;
public class AccountAttributes {
@@ -36,15 +35,12 @@ public class AccountAttributes {
@Length(max = 204, message = "This field must be less than 50 characters")
private String name;
@JsonProperty
private boolean voice;
@JsonProperty
private boolean video;
@JsonProperty
private String pin;
@JsonProperty
private String registrationLock;
@JsonProperty
private byte[] unidentifiedAccessKey;
@@ -55,18 +51,17 @@ public class AccountAttributes {
@VisibleForTesting
public AccountAttributes(String signalingKey, boolean fetchesMessages, int registrationId, String pin) {
this(signalingKey, fetchesMessages, registrationId, null, false, false, pin);
this(signalingKey, fetchesMessages, registrationId, null, pin, null);
}
@VisibleForTesting
public AccountAttributes(String signalingKey, boolean fetchesMessages, int registrationId, String name, boolean voice, boolean video, String pin) {
this.signalingKey = signalingKey;
this.fetchesMessages = fetchesMessages;
this.registrationId = registrationId;
this.name = name;
this.voice = voice;
this.video = video;
this.pin = pin;
public AccountAttributes(String signalingKey, boolean fetchesMessages, int registrationId, String name, String pin, String registrationLock) {
this.signalingKey = signalingKey;
this.fetchesMessages = fetchesMessages;
this.registrationId = registrationId;
this.name = name;
this.pin = pin;
this.registrationLock = registrationLock;
}
public String getSignalingKey() {
@@ -85,18 +80,14 @@ public class AccountAttributes {
return name;
}
public boolean getVoice() {
return voice;
}
public boolean getVideo() {
return video;
}
public String getPin() {
return pin;
}
public String getRegistrationLock() {
return registrationLock;
}
public byte[] getUnidentifiedAccessKey() {
return unidentifiedAccessKey;
}

View File

@@ -0,0 +1,26 @@
package org.whispersystems.textsecuregcm.entities;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.annotations.VisibleForTesting;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;
public class DeprecatedPin {
@JsonProperty
@NotEmpty
@Length(min=4,max=20)
private String pin;
public DeprecatedPin() {}
@VisibleForTesting
public DeprecatedPin(String pin) {
this.pin = pin;
}
public String getPin() {
return pin;
}
}

View File

@@ -8,19 +8,19 @@ import org.hibernate.validator.constraints.NotEmpty;
public class RegistrationLock {
@JsonProperty
@Length(min=64,max=64)
@NotEmpty
@Length(min=4,max=20)
private String pin;
private String registrationLock;
public RegistrationLock() {}
@VisibleForTesting
public RegistrationLock(String pin) {
this.pin = pin;
public RegistrationLock(String registrationLock) {
this.registrationLock = registrationLock;
}
public String getPin() {
return pin;
public String getRegistrationLock() {
return registrationLock;
}
}

View File

@@ -2,20 +2,30 @@ package org.whispersystems.textsecuregcm.entities;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.whispersystems.textsecuregcm.auth.ExternalServiceCredentials;
public class RegistrationLockFailure {
@JsonProperty
private long timeRemaining;
@JsonProperty
private ExternalServiceCredentials storageCredentials;
public RegistrationLockFailure() {}
public RegistrationLockFailure(long timeRemaining) {
this.timeRemaining = timeRemaining;
public RegistrationLockFailure(long timeRemaining, ExternalServiceCredentials storageCredentials) {
this.timeRemaining = timeRemaining;
this.storageCredentials = storageCredentials;
}
@JsonIgnore
public long getTimeRemaining() {
return timeRemaining;
}
@JsonIgnore
public ExternalServiceCredentials getStorageCredentials() {
return storageCredentials;
}
}