org.whispersystems.signalservice.internal.configuration.SignalCdnUrl Java Examples

The following examples show how to use org.whispersystems.signalservice.internal.configuration.SignalCdnUrl. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ServiceConfig.java    From signal-cli with GNU General Public License v3.0 6 votes vote down vote up
public static SignalServiceConfiguration createDefaultServiceConfiguration(String userAgent) {
    final Interceptor userAgentInterceptor = chain ->
            chain.proceed(chain.request().newBuilder()
                    .header("User-Agent", userAgent)
                    .build());

    final List<Interceptor> interceptors = Collections.singletonList(userAgentInterceptor);

    final byte[] zkGroupServerPublicParams;
    try {
        zkGroupServerPublicParams = Base64.decode(zkGroupServerPublicParamsHex);
    } catch (IOException e) {
        throw new AssertionError(e);
    }

    return new SignalServiceConfiguration(
            new SignalServiceUrl[]{new SignalServiceUrl(URL, TRUST_STORE)},
            makeSignalCdnUrlMapFor(new SignalCdnUrl[]{new SignalCdnUrl(CDN_URL, TRUST_STORE)}, new SignalCdnUrl[]{new SignalCdnUrl(CDN2_URL, TRUST_STORE)}),
            new SignalContactDiscoveryUrl[0],
            new SignalKeyBackupServiceUrl[]{new SignalKeyBackupServiceUrl(SIGNAL_KEY_BACKUP_URL, TRUST_STORE)},
            new SignalStorageUrl[]{new SignalStorageUrl(STORAGE_URL, TRUST_STORE)},
            interceptors,
            dns,
            zkGroupServerPublicParams
    );
}
 
Example #2
Source File: PushServiceSocket.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
private static Map<Integer, ConnectionHolder[]> createCdnClientsMap(final Map<Integer, SignalCdnUrl[]> signalCdnUrlMap,
                                                                    final List<Interceptor> interceptors,
                                                                    final Optional<Dns> dns) {
  validateConfiguration(signalCdnUrlMap);
  final Map<Integer, ConnectionHolder[]> result = new HashMap<>();
  for (Map.Entry<Integer, SignalCdnUrl[]> entry : signalCdnUrlMap.entrySet()) {
    result.put(entry.getKey(),
               createConnectionHolders(entry.getValue(), interceptors, dns));
  }
  return Collections.unmodifiableMap(result);
}
 
Example #3
Source File: PushServiceSocket.java    From mollyim-android with GNU General Public License v3.0 4 votes vote down vote up
private static void validateConfiguration(Map<Integer, SignalCdnUrl[]> signalCdnUrlMap) {
  if (!signalCdnUrlMap.containsKey(0) || !signalCdnUrlMap.containsKey(2)) {
    throw new AssertionError("Configuration used to create PushServiceSocket must support CDN 0 and CDN 2");
  }
}
 
Example #4
Source File: SignalServiceNetworkAccess.java    From mollyim-android with GNU General Public License v3.0 4 votes vote down vote up
private static Map<Integer, SignalCdnUrl[]> makeSignalCdnUrlMapFor(SignalCdnUrl[] cdn0Urls, SignalCdnUrl[] cdn2Urls) {
  Map<Integer, SignalCdnUrl[]> result = new HashMap<>();
  result.put(0, cdn0Urls);
  result.put(2, cdn2Urls);
  return Collections.unmodifiableMap(result);
}
 
Example #5
Source File: ServiceConfig.java    From signal-cli with GNU General Public License v3.0 4 votes vote down vote up
private static Map<Integer, SignalCdnUrl[]> makeSignalCdnUrlMapFor(SignalCdnUrl[] cdn0Urls, SignalCdnUrl[] cdn2Urls) {
    Map<Integer, SignalCdnUrl[]> result = new HashMap<>();
    result.put(0, cdn0Urls);
    result.put(2, cdn2Urls);
    return Collections.unmodifiableMap(result);
}