mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-25 03:18:20 +01:00
Renamed 'device key' to 'signed prekey'.
This commit is contained in:
@@ -130,8 +130,8 @@ public class FederationController {
|
||||
throws IOException
|
||||
{
|
||||
try {
|
||||
return keysControllerV2.getDeviceKey(new NonLimitedAccount("Unknown", -1, peer.getName()),
|
||||
number, device, Optional.<String>absent());
|
||||
return keysControllerV2.getDeviceKeys(new NonLimitedAccount("Unknown", -1, peer.getName()),
|
||||
number, device, Optional.<String>absent());
|
||||
} catch (RateLimitExceededException e) {
|
||||
logger.warn("Rate limiting on federated channel", e);
|
||||
throw new IOException(e);
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.whispersystems.textsecuregcm.controllers;
|
||||
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.google.common.base.Optional;
|
||||
import org.whispersystems.textsecuregcm.entities.DeviceKey;
|
||||
import org.whispersystems.textsecuregcm.entities.SignedPreKey;
|
||||
import org.whispersystems.textsecuregcm.entities.PreKeyResponseItemV2;
|
||||
import org.whispersystems.textsecuregcm.entities.PreKeyResponseV2;
|
||||
import org.whispersystems.textsecuregcm.entities.PreKeyStateV2;
|
||||
@@ -66,8 +66,8 @@ public class KeysControllerV2 extends KeysController {
|
||||
Device device = account.getAuthenticatedDevice().get();
|
||||
boolean updateAccount = false;
|
||||
|
||||
if (!preKeys.getDeviceKey().equals(device.getDeviceKey())) {
|
||||
device.setDeviceKey(preKeys.getDeviceKey());
|
||||
if (!preKeys.getSignedPreKey().equals(device.getSignedPreKey())) {
|
||||
device.setSignedPreKey(preKeys.getSignedPreKey());
|
||||
updateAccount = true;
|
||||
}
|
||||
|
||||
@@ -85,11 +85,11 @@ public class KeysControllerV2 extends KeysController {
|
||||
|
||||
@Timed
|
||||
@PUT
|
||||
@Path("/device")
|
||||
@Path("/signed")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public void setDeviceKey(@Auth Account account, @Valid DeviceKey deviceKey) {
|
||||
public void setSignedKey(@Auth Account account, @Valid SignedPreKey signedPreKey) {
|
||||
Device device = account.getAuthenticatedDevice().get();
|
||||
device.setDeviceKey(deviceKey);
|
||||
device.setSignedPreKey(signedPreKey);
|
||||
accounts.update(account);
|
||||
}
|
||||
|
||||
@@ -97,10 +97,10 @@ public class KeysControllerV2 extends KeysController {
|
||||
@GET
|
||||
@Path("/{number}/{device_id}")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Optional<PreKeyResponseV2> getDeviceKey(@Auth Account account,
|
||||
@PathParam("number") String number,
|
||||
@PathParam("device_id") String deviceId,
|
||||
@QueryParam("relay") Optional<String> relay)
|
||||
public Optional<PreKeyResponseV2> getDeviceKeys(@Auth Account account,
|
||||
@PathParam("number") String number,
|
||||
@PathParam("device_id") String deviceId,
|
||||
@QueryParam("relay") Optional<String> relay)
|
||||
throws RateLimitExceededException
|
||||
{
|
||||
try {
|
||||
@@ -118,8 +118,8 @@ public class KeysControllerV2 extends KeysController {
|
||||
|
||||
for (Device device : destination.getDevices()) {
|
||||
if (device.isActive() && (deviceId.equals("*") || device.getId() == Long.parseLong(deviceId))) {
|
||||
DeviceKey deviceKey = device.getDeviceKey();
|
||||
PreKeyV2 preKey = null;
|
||||
SignedPreKey signedPreKey = device.getSignedPreKey();
|
||||
PreKeyV2 preKey = null;
|
||||
|
||||
if (targetKeys.getKeys().isPresent()) {
|
||||
for (KeyRecord keyRecord : targetKeys.getKeys().get()) {
|
||||
@@ -129,8 +129,8 @@ public class KeysControllerV2 extends KeysController {
|
||||
}
|
||||
}
|
||||
|
||||
if (deviceKey != null || preKey != null) {
|
||||
devices.add(new PreKeyResponseItemV2(device.getId(), device.getRegistrationId(), deviceKey, preKey));
|
||||
if (signedPreKey != null || preKey != null) {
|
||||
devices.add(new PreKeyResponseItemV2(device.getId(), device.getRegistrationId(), signedPreKey, preKey));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,23 +28,23 @@ public class PreKeyResponseItemV2 {
|
||||
private int registrationId;
|
||||
|
||||
@JsonProperty
|
||||
private DeviceKey deviceKey;
|
||||
private SignedPreKey signedPreKey;
|
||||
|
||||
@JsonProperty
|
||||
private PreKeyV2 preKey;
|
||||
|
||||
public PreKeyResponseItemV2() {}
|
||||
|
||||
public PreKeyResponseItemV2(long deviceId, int registrationId, DeviceKey deviceKey, PreKeyV2 preKey) {
|
||||
public PreKeyResponseItemV2(long deviceId, int registrationId, SignedPreKey signedPreKey, PreKeyV2 preKey) {
|
||||
this.deviceId = deviceId;
|
||||
this.registrationId = registrationId;
|
||||
this.deviceKey = deviceKey;
|
||||
this.signedPreKey = signedPreKey;
|
||||
this.preKey = preKey;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public DeviceKey getDeviceKey() {
|
||||
return deviceKey;
|
||||
public SignedPreKey getSignedPreKey() {
|
||||
return signedPreKey;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
|
||||
@@ -35,7 +35,7 @@ public class PreKeyStateV2 {
|
||||
@JsonProperty
|
||||
@NotNull
|
||||
@Valid
|
||||
private DeviceKey deviceKey;
|
||||
private SignedPreKey signedPreKey;
|
||||
|
||||
@JsonProperty
|
||||
@NotNull
|
||||
@@ -49,9 +49,11 @@ public class PreKeyStateV2 {
|
||||
public PreKeyStateV2() {}
|
||||
|
||||
@VisibleForTesting
|
||||
public PreKeyStateV2(String identityKey, DeviceKey deviceKey, List<PreKeyV2> keys, PreKeyV2 lastResortKey) {
|
||||
public PreKeyStateV2(String identityKey, SignedPreKey signedPreKey,
|
||||
List<PreKeyV2> keys, PreKeyV2 lastResortKey)
|
||||
{
|
||||
this.identityKey = identityKey;
|
||||
this.deviceKey = deviceKey;
|
||||
this.signedPreKey = signedPreKey;
|
||||
this.preKeys = keys;
|
||||
this.lastResortKey = lastResortKey;
|
||||
}
|
||||
@@ -60,8 +62,8 @@ public class PreKeyStateV2 {
|
||||
return preKeys;
|
||||
}
|
||||
|
||||
public DeviceKey getDeviceKey() {
|
||||
return deviceKey;
|
||||
public SignedPreKey getSignedPreKey() {
|
||||
return signedPreKey;
|
||||
}
|
||||
|
||||
public String getIdentityKey() {
|
||||
|
||||
@@ -5,15 +5,15 @@ import org.hibernate.validator.constraints.NotEmpty;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class DeviceKey extends PreKeyV2 implements Serializable {
|
||||
public class SignedPreKey extends PreKeyV2 implements Serializable {
|
||||
|
||||
@JsonProperty
|
||||
@NotEmpty
|
||||
private String signature;
|
||||
|
||||
public DeviceKey() {}
|
||||
public SignedPreKey() {}
|
||||
|
||||
public DeviceKey(long keyId, String publicKey, String signature) {
|
||||
public SignedPreKey(long keyId, String publicKey, String signature) {
|
||||
super(keyId, publicKey);
|
||||
this.signature = signature;
|
||||
}
|
||||
@@ -24,8 +24,8 @@ public class DeviceKey extends PreKeyV2 implements Serializable {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (object == null || !(object instanceof DeviceKey)) return false;
|
||||
DeviceKey that = (DeviceKey) object;
|
||||
if (object == null || !(object instanceof SignedPreKey)) return false;
|
||||
SignedPreKey that = (SignedPreKey) object;
|
||||
|
||||
if (signature == null) {
|
||||
return super.equals(object) && that.signature == null;
|
||||
@@ -19,8 +19,7 @@ package org.whispersystems.textsecuregcm.storage;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.whispersystems.textsecuregcm.auth.AuthenticationCredentials;
|
||||
import org.whispersystems.textsecuregcm.entities.DeviceKey;
|
||||
import org.whispersystems.textsecuregcm.entities.PreKeyV2;
|
||||
import org.whispersystems.textsecuregcm.entities.SignedPreKey;
|
||||
import org.whispersystems.textsecuregcm.util.Util;
|
||||
|
||||
import java.io.Serializable;
|
||||
@@ -54,14 +53,14 @@ public class Device implements Serializable {
|
||||
private int registrationId;
|
||||
|
||||
@JsonProperty
|
||||
private DeviceKey deviceKey;
|
||||
private SignedPreKey signedPreKey;
|
||||
|
||||
public Device() {}
|
||||
|
||||
public Device(long id, String authToken, String salt,
|
||||
String signalingKey, String gcmId, String apnId,
|
||||
boolean fetchesMessages, int registrationId,
|
||||
DeviceKey deviceKey)
|
||||
SignedPreKey signedPreKey)
|
||||
{
|
||||
this.id = id;
|
||||
this.authToken = authToken;
|
||||
@@ -71,7 +70,7 @@ public class Device implements Serializable {
|
||||
this.apnId = apnId;
|
||||
this.fetchesMessages = fetchesMessages;
|
||||
this.registrationId = registrationId;
|
||||
this.deviceKey = deviceKey;
|
||||
this.signedPreKey = signedPreKey;
|
||||
}
|
||||
|
||||
public String getApnId() {
|
||||
@@ -139,11 +138,11 @@ public class Device implements Serializable {
|
||||
this.registrationId = registrationId;
|
||||
}
|
||||
|
||||
public DeviceKey getDeviceKey() {
|
||||
return deviceKey;
|
||||
public SignedPreKey getSignedPreKey() {
|
||||
return signedPreKey;
|
||||
}
|
||||
|
||||
public void setDeviceKey(DeviceKey deviceKey) {
|
||||
this.deviceKey = deviceKey;
|
||||
public void setSignedPreKey(SignedPreKey signedPreKey) {
|
||||
this.signedPreKey = signedPreKey;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user