Moving secret values out of the main configuration file

This commit is contained in:
Sergey Skrobotov
2023-05-17 11:14:04 -07:00
parent 8d1c26d07d
commit 287e2fa89a
57 changed files with 959 additions and 551 deletions

View File

@@ -12,7 +12,9 @@ import static org.mockito.Mockito.doThrow;
import java.time.Duration;
import java.util.Optional;
import org.apache.commons.lang3.RandomUtils;
import org.mockito.Mockito;
import org.whispersystems.textsecuregcm.configuration.secrets.SecretBytes;
import org.whispersystems.textsecuregcm.controllers.RateLimitExceededException;
import org.whispersystems.textsecuregcm.limits.RateLimiter;
import org.whispersystems.textsecuregcm.limits.RateLimiters;
@@ -70,4 +72,16 @@ public final class MockUtils {
throw new RuntimeException(e);
}
}
public static SecretBytes randomSecretBytes(final int size) {
return new SecretBytes(RandomUtils.nextBytes(size));
}
public static SecretBytes secretBytesOf(final int... byteVals) {
final byte[] bytes = new byte[byteVals.length];
for (int i = 0; i < byteVals.length; i++) {
bytes[i] = (byte) byteVals[i];
}
return new SecretBytes(bytes);
}
}