Use the latest and in config, `@JsonCreator`

This commit is contained in:
Chris Eager 2021-11-04 18:19:53 -07:00 committed by Chris Eager
parent 0a4392f700
commit 31c0c3275f
3 changed files with 22 additions and 15 deletions

View File

@ -85,7 +85,7 @@ directory:
directoryV2: directoryV2:
client: # Configuration for interfacing with Contact Discovery Service v2 cluster client: # Configuration for interfacing with Contact Discovery Service v2 cluster
userAuthenticationTokenSharedSecret: # hex-encoded secret shared with CDS to generate auth tokens for Signal users userAuthenticationTokenSharedSecret: # base64-encoded secret shared with CDS to generate auth tokens for Signal users
messageCache: # Redis server configuration for message store cache messageCache: # Redis server configuration for message store cache
persistDelayMinutes: persistDelayMinutes:

View File

@ -4,19 +4,23 @@
*/ */
package org.whispersystems.textsecuregcm.configuration; package org.whispersystems.textsecuregcm.configuration;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import javax.validation.constraints.NotEmpty; import org.whispersystems.textsecuregcm.util.ExactlySize;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Hex;
public class DirectoryV2ClientConfiguration { public class DirectoryV2ClientConfiguration {
@NotEmpty private final byte[] userAuthenticationTokenSharedSecret;
@JsonProperty
private String userAuthenticationTokenSharedSecret;
public byte[] getUserAuthenticationTokenSharedSecret() throws DecoderException { @JsonCreator
return Hex.decodeHex(userAuthenticationTokenSharedSecret.toCharArray()); public DirectoryV2ClientConfiguration(
@JsonProperty("userAuthenticationTokenSharedSecret") final byte[] userAuthenticationTokenSharedSecret) {
this.userAuthenticationTokenSharedSecret = userAuthenticationTokenSharedSecret;
}
@ExactlySize({32})
public byte[] getUserAuthenticationTokenSharedSecret() {
return userAuthenticationTokenSharedSecret;
} }
} }

View File

@ -4,18 +4,21 @@
*/ */
package org.whispersystems.textsecuregcm.configuration; package org.whispersystems.textsecuregcm.configuration;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import javax.validation.Valid; import javax.validation.Valid;
import javax.validation.constraints.NotNull;
public class DirectoryV2Configuration { public class DirectoryV2Configuration {
@JsonProperty private final DirectoryV2ClientConfiguration clientConfiguration;
@NotNull
@Valid
private DirectoryV2ClientConfiguration client;
@JsonCreator
public DirectoryV2Configuration(@JsonProperty("client") DirectoryV2ClientConfiguration clientConfiguration) {
this.clientConfiguration = clientConfiguration;
}
@Valid
public DirectoryV2ClientConfiguration getDirectoryV2ClientConfiguration() { public DirectoryV2ClientConfiguration getDirectoryV2ClientConfiguration() {
return client; return clientConfiguration;
} }
} }