mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-21 13:58:07 +01:00
Update shape of KeyTransparencyMonitorRequest
This commit is contained in:
@@ -8,58 +8,78 @@ package org.whispersystems.textsecuregcm.entities;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Positive;
|
||||
import org.whispersystems.textsecuregcm.identity.AciServiceIdentifier;
|
||||
import org.whispersystems.textsecuregcm.util.ByteArrayBase64UrlAdapter;
|
||||
import org.whispersystems.textsecuregcm.util.ServiceIdentifierAdapter;
|
||||
|
||||
import javax.validation.constraints.AssertTrue;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Positive;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public record KeyTransparencyMonitorRequest(
|
||||
|
||||
@Valid
|
||||
@NotNull
|
||||
@JsonSerialize(using = ServiceIdentifierAdapter.ServiceIdentifierSerializer.class)
|
||||
@JsonDeserialize(using = ServiceIdentifierAdapter.AciServiceIdentifierDeserializer.class)
|
||||
@Schema(description = "The aci identifier to monitor")
|
||||
AciServiceIdentifier aci,
|
||||
AciMonitor aci,
|
||||
|
||||
@NotEmpty
|
||||
@Schema(description = "A list of log tree positions maintained by the client for the aci search key.")
|
||||
List<@Positive Long> aciPositions,
|
||||
@Valid
|
||||
@NotNull
|
||||
Optional<@Valid E164Monitor> e164,
|
||||
|
||||
@Schema(description = "The e164-formatted phone number to monitor")
|
||||
Optional<String> e164,
|
||||
|
||||
@Schema(description = "A list of log tree positions maintained by the client for the e164 search key.")
|
||||
Optional<List<@Positive Long>> e164Positions,
|
||||
|
||||
@JsonSerialize(contentUsing = ByteArrayBase64UrlAdapter.Serializing.class)
|
||||
@JsonDeserialize(contentUsing = ByteArrayBase64UrlAdapter.Deserializing.class)
|
||||
@Schema(description = "The username hash to monitor, encoded in url-safe unpadded base64.")
|
||||
Optional<byte[]> usernameHash,
|
||||
|
||||
@Schema(description = "A list of log tree positions maintained by the client for the username hash search key.")
|
||||
Optional<List<@Positive Long>> usernameHashPositions,
|
||||
@Valid
|
||||
@NotNull
|
||||
Optional<@Valid UsernameHashMonitor> usernameHash,
|
||||
|
||||
@Schema(description = "The tree head size to prove consistency against.")
|
||||
@NotNull
|
||||
Optional<@Positive Long> lastNonDistinguishedTreeHeadSize,
|
||||
|
||||
@Schema(description = "The distinguished tree head size to prove consistency against.")
|
||||
@NotNull
|
||||
Optional<@Positive Long> lastDistinguishedTreeHeadSize
|
||||
) {
|
||||
|
||||
@AssertTrue
|
||||
public boolean isUsernameHashFieldsValid() {
|
||||
return (usernameHash.isEmpty() && usernameHashPositions.isEmpty()) ||
|
||||
(usernameHash.isPresent() && usernameHashPositions.isPresent() && !usernameHashPositions.get().isEmpty());
|
||||
}
|
||||
public record AciMonitor(
|
||||
@NotNull
|
||||
@JsonSerialize(using = ServiceIdentifierAdapter.ServiceIdentifierSerializer.class)
|
||||
@JsonDeserialize(using = ServiceIdentifierAdapter.AciServiceIdentifierDeserializer.class)
|
||||
@Schema(description = "The aci identifier to monitor")
|
||||
AciServiceIdentifier value,
|
||||
|
||||
@AssertTrue
|
||||
public boolean isE164VFieldsValid() {
|
||||
return (e164.isEmpty() && e164Positions.isEmpty()) ||
|
||||
(e164.isPresent() && e164Positions.isPresent() && !e164Positions.get().isEmpty());
|
||||
}
|
||||
@Schema(description = "A list of log tree positions maintained by the client for the aci search key.")
|
||||
@Valid
|
||||
@NotNull
|
||||
@NotEmpty
|
||||
List<@Positive Long> positions
|
||||
) {}
|
||||
|
||||
public record E164Monitor(
|
||||
@Schema(description = "The e164-formatted phone number to monitor")
|
||||
@NotBlank
|
||||
String value,
|
||||
|
||||
@Schema(description = "A list of log tree positions maintained by the client for the e164 search key.")
|
||||
@NotNull
|
||||
@NotEmpty
|
||||
@Valid
|
||||
List<@Positive Long> positions
|
||||
) {}
|
||||
|
||||
public record UsernameHashMonitor(
|
||||
|
||||
@Schema(description = "The username hash to monitor, encoded in url-safe unpadded base64.")
|
||||
@JsonSerialize(using = ByteArrayBase64UrlAdapter.Serializing.class)
|
||||
@JsonDeserialize(using = ByteArrayBase64UrlAdapter.Deserializing.class)
|
||||
@NotNull
|
||||
@NotEmpty
|
||||
byte[] value,
|
||||
|
||||
@Schema(description = "A list of log tree positions maintained by the client for the username hash search key.")
|
||||
@NotNull
|
||||
@NotEmpty
|
||||
@Valid List<@Positive Long> positions
|
||||
) {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user