Use multiline strings for `PreKeyState` documentation

This commit is contained in:
Jon Chambers 2023-11-28 21:53:06 -05:00 committed by Jon Chambers
parent 5f0726af8a
commit 9ecfe15ac4
1 changed files with 33 additions and 25 deletions

View File

@ -9,58 +9,65 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import java.util.ArrayList; import org.signal.libsignal.protocol.IdentityKey;
import java.util.List; import org.whispersystems.textsecuregcm.util.IdentityKeyAdapter;
import javax.validation.Valid; import javax.validation.Valid;
import javax.validation.constraints.AssertTrue; import javax.validation.constraints.AssertTrue;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import org.signal.libsignal.protocol.IdentityKey; import java.util.ArrayList;
import org.whispersystems.textsecuregcm.util.IdentityKeyAdapter; import java.util.List;
public class PreKeyState { public class PreKeyState {
@JsonProperty @JsonProperty
@Valid @Valid
@Schema(description="A list of unsigned elliptic-curve prekeys to use for this device. " + @Schema(description = """
"If present and not empty, replaces all stored unsigned EC prekeys for the device; " + A list of unsigned elliptic-curve prekeys to use for this device. If present and not empty, replaces all stored
"if absent or empty, any stored unsigned EC prekeys for the device are not deleted.") unsigned EC prekeys for the device; if absent or empty, any stored unsigned EC prekeys for the device are not
deleted.
""")
private List<@Valid ECPreKey> preKeys; private List<@Valid ECPreKey> preKeys;
@JsonProperty @JsonProperty
@Valid @Valid
@Schema(description="An optional signed elliptic-curve prekey to use for this device. " + @Schema(description = """
"If present, replaces the stored signed elliptic-curve prekey for the device; " + An optional signed elliptic-curve prekey to use for this device. If present, replaces the stored signed
"if absent, the stored signed prekey is not deleted. " + elliptic-curve prekey for the device; if absent, the stored signed prekey is not deleted. If present, must have a
"If present, must have a valid signature from the identity key in this request.") valid signature from the identity key in this request.
""")
private ECSignedPreKey signedPreKey; private ECSignedPreKey signedPreKey;
@JsonProperty @JsonProperty
@Valid @Valid
@Schema(description="A list of signed post-quantum one-time prekeys to use for this device. " + @Schema(description = """
"Each key must have a valid signature from the identity key in this request. " + A list of signed post-quantum one-time prekeys to use for this device. Each key must have a valid signature from
"If present and not empty, replaces all stored unsigned PQ prekeys for the device; " + the identity key in this request. If present and not empty, replaces all stored unsigned PQ prekeys for the
"if absent or empty, any stored unsigned PQ prekeys for the device are not deleted.") device; if absent or empty, any stored unsigned PQ prekeys for the device are not deleted.
""")
private List<@Valid KEMSignedPreKey> pqPreKeys; private List<@Valid KEMSignedPreKey> pqPreKeys;
@JsonProperty @JsonProperty
@Valid @Valid
@Schema(description="An optional signed last-resort post-quantum prekey to use for this device. " + @Schema(description = """
"If present, replaces the stored signed post-quantum last-resort prekey for the device; " + An optional signed last-resort post-quantum prekey to use for this device. If present, replaces the stored signed
"if absent, a stored last-resort prekey will *not* be deleted. " + post-quantum last-resort prekey for the device; if absent, a stored last-resort prekey will *not* be deleted. If
"If present, must have a valid signature from the identity key in this request.") present, must have a valid signature from the identity key in this request.
""")
private KEMSignedPreKey pqLastResortPreKey; private KEMSignedPreKey pqLastResortPreKey;
@JsonProperty @JsonProperty
@JsonSerialize(using = IdentityKeyAdapter.Serializer.class) @JsonSerialize(using = IdentityKeyAdapter.Serializer.class)
@JsonDeserialize(using = IdentityKeyAdapter.Deserializer.class) @JsonDeserialize(using = IdentityKeyAdapter.Deserializer.class)
@NotNull @NotNull
@Schema(description="Required. " + @Schema(description = """
"The public identity key for this identity (account or phone-number identity). " + Required. The public identity key for this identity (account or phone-number identity). If this device is not the
"If this device is not the primary device for the account, " + primary device for the account, must match the existing stored identity key for this identity.
"must match the existing stored identity key for this identity.") """)
private IdentityKey identityKey; private IdentityKey identityKey;
public PreKeyState() {} public PreKeyState() {
}
@VisibleForTesting @VisibleForTesting
public PreKeyState(IdentityKey identityKey, ECSignedPreKey signedPreKey, List<ECPreKey> keys) { public PreKeyState(IdentityKey identityKey, ECSignedPreKey signedPreKey, List<ECPreKey> keys) {
@ -68,7 +75,8 @@ public class PreKeyState {
} }
@VisibleForTesting @VisibleForTesting
public PreKeyState(IdentityKey identityKey, ECSignedPreKey signedPreKey, List<ECPreKey> keys, List<KEMSignedPreKey> pqKeys, KEMSignedPreKey pqLastResortKey) { public PreKeyState(IdentityKey identityKey, ECSignedPreKey signedPreKey, List<ECPreKey> keys,
List<KEMSignedPreKey> pqKeys, KEMSignedPreKey pqLastResortKey) {
this.identityKey = identityKey; this.identityKey = identityKey;
this.signedPreKey = signedPreKey; this.signedPreKey = signedPreKey;
this.preKeys = keys; this.preKeys = keys;