1 package org
.asamk
.signal
.manager
.config
;
3 import org
.slf4j
.Logger
;
4 import org
.slf4j
.LoggerFactory
;
5 import org
.whispersystems
.signalservice
.api
.account
.AccountAttributes
;
6 import org
.whispersystems
.signalservice
.api
.push
.TrustStore
;
8 import java
.io
.IOException
;
9 import java
.security
.KeyStore
;
10 import java
.security
.KeyStoreException
;
11 import java
.security
.NoSuchAlgorithmException
;
12 import java
.security
.cert
.CertificateException
;
13 import java
.util
.List
;
15 import okhttp3
.Interceptor
;
17 public class ServiceConfig
{
19 private final static Logger logger
= LoggerFactory
.getLogger(ServiceConfig
.class);
21 public final static int PREKEY_MINIMUM_COUNT
= 20;
22 public final static int PREKEY_BATCH_SIZE
= 100;
23 public final static int MAX_ATTACHMENT_SIZE
= 150 * 1024 * 1024;
24 public final static long MAX_ENVELOPE_SIZE
= 0;
25 public final static long AVATAR_DOWNLOAD_FAILSAFE_MAX_SIZE
= 10 * 1024 * 1024;
26 public final static boolean AUTOMATIC_NETWORK_RETRY
= true;
27 public final static int GROUP_MAX_SIZE
= 1001;
29 private final static KeyStore iasKeyStore
;
31 public static final AccountAttributes
.Capabilities capabilities
;
34 capabilities
= new AccountAttributes
.Capabilities(false, true, false, true, true, true, true, false);
37 TrustStore contactTrustStore
= new IasTrustStore();
39 var keyStore
= KeyStore
.getInstance("BKS");
40 keyStore
.load(contactTrustStore
.getKeyStoreInputStream(),
41 contactTrustStore
.getKeyStorePassword().toCharArray());
43 iasKeyStore
= keyStore
;
44 } catch (KeyStoreException
| CertificateException
| IOException
| NoSuchAlgorithmException e
) {
45 throw new AssertionError(e
);
49 public static boolean isSignalClientAvailable() {
52 org
.signal
.libsignal
.internal
.Native
.UuidCiphertext_CheckValidContents(new byte[0]);
53 } catch (IllegalArgumentException ignored
) {
56 } catch (UnsatisfiedLinkError e
) {
57 logger
.warn("Failed to call libsignal-client: {}", e
.getMessage());
62 public static KeyStore
getIasKeyStore() {
66 public static ServiceEnvironmentConfig
getServiceEnvironmentConfig(
67 ServiceEnvironment serviceEnvironment
, String userAgent
69 final Interceptor userAgentInterceptor
= chain
-> chain
.proceed(chain
.request()
71 .header("User-Agent", userAgent
)
74 final var interceptors
= List
.of(userAgentInterceptor
);
76 return switch (serviceEnvironment
) {
77 case LIVE
-> new ServiceEnvironmentConfig(LiveConfig
.createDefaultServiceConfiguration(interceptors
),
78 LiveConfig
.getUnidentifiedSenderTrustRoot(),
79 LiveConfig
.createKeyBackupConfig(),
80 LiveConfig
.getCdsMrenclave());
81 case STAGING
-> new ServiceEnvironmentConfig(StagingConfig
.createDefaultServiceConfiguration(interceptors
),
82 StagingConfig
.getUnidentifiedSenderTrustRoot(),
83 StagingConfig
.createKeyBackupConfig(),
84 StagingConfig
.getCdsMrenclave());