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

The following examples show how to use org.whispersystems.signalservice.internal.configuration.SignalServiceConfiguration. 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: SignalServiceMessageSender.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
public SignalServiceMessageSender(SignalServiceConfiguration urls,
                                  CredentialsProvider credentialsProvider,
                                  SignalProtocolStore store,
                                  String signalAgent,
                                  boolean isMultiDevice,
                                  boolean attachmentsV3,
                                  Optional<SignalServiceMessagePipe> pipe,
                                  Optional<SignalServiceMessagePipe> unidentifiedPipe,
                                  Optional<EventListener> eventListener,
                                  ClientZkProfileOperations clientZkProfileOperations,
                                  ExecutorService executor)
{
  this.socket           = new PushServiceSocket(urls, credentialsProvider, signalAgent, clientZkProfileOperations);
  this.store            = store;
  this.localAddress     = new SignalServiceAddress(credentialsProvider.getUuid(), credentialsProvider.getE164());
  this.pipe             = new AtomicReference<>(pipe);
  this.unidentifiedPipe = new AtomicReference<>(unidentifiedPipe);
  this.isMultiDevice    = new AtomicBoolean(isMultiDevice);
  this.attachmentsV3    = new AtomicBoolean(attachmentsV3);
  this.eventListener    = eventListener;
  this.executor         = executor != null ? executor : Executors.newSingleThreadExecutor();
}
 
Example #3
Source File: SignalServiceMessageReceiver.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Construct a SignalServiceMessageReceiver.
 *
 * @param urls The URL of the Signal Service.
 * @param credentials The Signal Service user's credentials.
 */
public SignalServiceMessageReceiver(SignalServiceConfiguration urls,
                                    CredentialsProvider credentials,
                                    String signalAgent,
                                    ConnectivityListener listener,
                                    SleepTimer timer,
                                    ClientZkProfileOperations clientZkProfileOperations)
{
  this.urls                      = urls;
  this.credentialsProvider       = credentials;
  this.socket                    = new PushServiceSocket(urls, credentials, signalAgent, clientZkProfileOperations);
  this.signalAgent               = signalAgent;
  this.connectivityListener      = listener;
  this.sleepTimer                = timer;
  this.clientZkProfileOperations = clientZkProfileOperations;
}
 
Example #4
Source File: SignalServiceMessageSender.java    From libsignal-service-java with GNU General Public License v3.0 6 votes vote down vote up
public SignalServiceMessageSender(SignalServiceConfiguration urls,
                                  CredentialsProvider credentialsProvider,
                                  SignalProtocolStore store,
                                  String userAgent,
                                  boolean isMultiDevice,
                                  Optional<SignalServiceMessagePipe> pipe,
                                  Optional<SignalServiceMessagePipe> unidentifiedPipe,
                                  Optional<EventListener> eventListener)
{
  this.socket           = new PushServiceSocket(urls, credentialsProvider, userAgent);
  this.store            = store;
  this.localAddress     = new SignalServiceAddress(credentialsProvider.getUuid(), credentialsProvider.getE164());
  this.pipe             = new AtomicReference<>(pipe);
  this.unidentifiedPipe = new AtomicReference<>(unidentifiedPipe);
  this.isMultiDevice    = new AtomicBoolean(isMultiDevice);
  this.eventListener    = eventListener;
}
 
Example #5
Source File: SignalServiceAccountManager.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
public SignalServiceAccountManager(SignalServiceConfiguration configuration,
                                   CredentialsProvider credentialsProvider,
                                   String signalAgent,
                                   GroupsV2Operations groupsV2Operations)
{
  this.groupsV2Operations = groupsV2Operations;
  this.pushServiceSocket  = new PushServiceSocket(configuration, credentialsProvider, signalAgent, groupsV2Operations.getProfileOperations());
  this.credentials        = credentialsProvider;
  this.userAgent          = signalAgent;
}
 
Example #6
Source File: ProvisioningManager.java    From signal-cli with GNU General Public License v3.0 5 votes vote down vote up
public ProvisioningManager(String settingsPath, SignalServiceConfiguration serviceConfiguration, String userAgent) {
    this.pathConfig = PathConfig.createDefault(settingsPath);
    this.serviceConfiguration = serviceConfiguration;
    this.userAgent = userAgent;

    identityKey = KeyHelper.generateIdentityKeyPair();
    registrationId = KeyHelper.generateRegistrationId(false);
    password = KeyUtils.createPassword();
    final SleepTimer timer = new UptimeSleepTimer();
    accountManager = new SignalServiceAccountManager(serviceConfiguration, null, null, password, SignalServiceAddress.DEFAULT_DEVICE_ID, userAgent, timer);
}
 
Example #7
Source File: Manager.java    From signal-cli with GNU General Public License v3.0 5 votes vote down vote up
public Manager(SignalAccount account, PathConfig pathConfig, SignalServiceConfiguration serviceConfiguration, String userAgent) {
    this.account = account;
    this.pathConfig = pathConfig;
    this.serviceConfiguration = serviceConfiguration;
    this.userAgent = userAgent;
    this.accountManager = createSignalServiceAccountManager();

    this.account.setResolver(this::resolveSignalServiceAddress);
}
 
Example #8
Source File: PushServiceSocket.java    From libsignal-service-java with GNU General Public License v3.0 5 votes vote down vote up
public PushServiceSocket(SignalServiceConfiguration signalServiceConfiguration, CredentialsProvider credentialsProvider, String userAgent) {
  this.credentialsProvider               = credentialsProvider;
  this.userAgent                         = userAgent;
  this.serviceClients                    = createServiceConnectionHolders(signalServiceConfiguration.getSignalServiceUrls());
  this.cdnClients                        = createConnectionHolders(signalServiceConfiguration.getSignalCdnUrls());
  this.contactDiscoveryClients           = createConnectionHolders(signalServiceConfiguration.getSignalContactDiscoveryUrls());
  this.attachmentClient                  = createAttachmentClient();
  this.random                            = new SecureRandom();
}
 
Example #9
Source File: SignalServiceMessageReceiver.java    From libsignal-service-java with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Construct a SignalServiceMessageReceiver.
 *
 * @param urls The URL of the Signal Service.
 * @param credentials The Signal Service user's credentials.
 */
public SignalServiceMessageReceiver(SignalServiceConfiguration urls,
                                    CredentialsProvider credentials,
                                    String userAgent,
                                    ConnectivityListener listener,
                                    SleepTimer timer)
{
  this.urls                 = urls;
  this.credentialsProvider  = credentials;
  this.socket               = new PushServiceSocket(urls, credentials, userAgent);
  this.userAgent            = userAgent;
  this.connectivityListener = listener;
  this.sleepTimer           = timer;
}
 
Example #10
Source File: SignalServiceMessageSender.java    From libsignal-service-java with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Construct a SignalServiceMessageSender.
 *
 * @param urls The URL of the Signal Service.
 * @param uuid The Signal Service UUID.
 * @param e164 The Signal Service phone number.
 * @param password The Signal Service user password.
 * @param store The SignalProtocolStore.
 * @param eventListener An optional event listener, which fires whenever sessions are
 *                      setup or torn down for a recipient.
 */
public SignalServiceMessageSender(SignalServiceConfiguration urls,
                                  UUID uuid, String e164, String password,
                                  SignalProtocolStore store,
                                  String userAgent,
                                  boolean isMultiDevice,
                                  Optional<SignalServiceMessagePipe> pipe,
                                  Optional<SignalServiceMessagePipe> unidentifiedPipe,
                                  Optional<EventListener> eventListener)
{
  this(urls, new StaticCredentialsProvider(uuid, e164, password, null), store, userAgent, isMultiDevice, pipe, unidentifiedPipe, eventListener);
}
 
Example #11
Source File: SignalServiceAccountManager.java    From libsignal-service-java with GNU General Public License v3.0 5 votes vote down vote up
public SignalServiceAccountManager(SignalServiceConfiguration configuration,
                                   CredentialsProvider credentialsProvider,
                                   String userAgent)
{
  this.pushServiceSocket = new PushServiceSocket(configuration, credentialsProvider, userAgent);
  this.userUuid          = credentialsProvider.getUuid();
  this.userE164          = credentialsProvider.getE164();
  this.userAgent         = userAgent;
}
 
Example #12
Source File: SignalServiceNetworkAccess.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
public SignalServiceConfiguration getConfiguration(@Nullable String localNumber) {
  if (localNumber == null) return this.uncensoredConfiguration;

  for (String censoredRegion : this.censoredCountries) {
    if (localNumber.startsWith(censoredRegion)) {
      return this.censorshipConfiguration.get(censoredRegion);
    }
  }

  return this.uncensoredConfiguration;
}
 
Example #13
Source File: PushServiceSocket.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
public PushServiceSocket(SignalServiceConfiguration configuration,
                         CredentialsProvider credentialsProvider,
                         String signalAgent,
                         ClientZkProfileOperations clientZkProfileOperations)
{
  this.credentialsProvider       = credentialsProvider;
  this.signalAgent               = signalAgent;
  this.serviceClients            = createServiceConnectionHolders(configuration.getSignalServiceUrls(), configuration.getNetworkInterceptors(), configuration.getDns());
  this.cdnClientsMap             = createCdnClientsMap(configuration.getSignalCdnUrlMap(), configuration.getNetworkInterceptors(), configuration.getDns());
  this.contactDiscoveryClients   = createConnectionHolders(configuration.getSignalContactDiscoveryUrls(), configuration.getNetworkInterceptors(), configuration.getDns());
  this.keyBackupServiceClients   = createConnectionHolders(configuration.getSignalKeyBackupServiceUrls(), configuration.getNetworkInterceptors(), configuration.getDns());
  this.storageClients            = createConnectionHolders(configuration.getSignalStorageUrls(), configuration.getNetworkInterceptors(), configuration.getDns());
  this.random                    = new SecureRandom();
  this.clientZkProfileOperations = clientZkProfileOperations;
}
 
Example #14
Source File: SignalServiceMessageReceiver.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Construct a SignalServiceMessageReceiver.
 *
 * @param urls The URL of the Signal Service.
 * @param uuid The Signal Service UUID.
 * @param e164 The Signal Service phone number.
 * @param password The Signal Service user password.
 * @param signalingKey The 52 byte signaling key assigned to this user at registration.
 */
public SignalServiceMessageReceiver(SignalServiceConfiguration urls,
                                    UUID uuid, String e164, String password,
                                    String signalingKey, String signalAgent,
                                    ConnectivityListener listener,
                                    SleepTimer timer,
                                    ClientZkProfileOperations clientZkProfileOperations)
{
  this(urls, new StaticCredentialsProvider(uuid, e164, password, signalingKey), signalAgent, listener, timer, clientZkProfileOperations);
}
 
Example #15
Source File: SignalServiceMessageSender.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Construct a SignalServiceMessageSender.
 *
 * @param urls The URL of the Signal Service.
 * @param uuid The Signal Service UUID.
 * @param e164 The Signal Service phone number.
 * @param password The Signal Service user password.
 * @param store The SignalProtocolStore.
 * @param eventListener An optional event listener, which fires whenever sessions are
 *                      setup or torn down for a recipient.
 */
public SignalServiceMessageSender(SignalServiceConfiguration urls,
                                  UUID uuid, String e164, String password,
                                  SignalProtocolStore store,
                                  String signalAgent,
                                  boolean isMultiDevice,
                                  boolean attachmentsV3,
                                  Optional<SignalServiceMessagePipe> pipe,
                                  Optional<SignalServiceMessagePipe> unidentifiedPipe,
                                  Optional<EventListener> eventListener,
                                  ClientZkProfileOperations clientZkProfileOperations,
                                  ExecutorService executor)
{
  this(urls, new StaticCredentialsProvider(uuid, e164, password, null), store, signalAgent, isMultiDevice, attachmentsV3, pipe, unidentifiedPipe, eventListener, clientZkProfileOperations, executor);
}
 
Example #16
Source File: SignalServiceAccountManager.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Construct a SignalServiceAccountManager.
 *
 * @param configuration The URL for the Signal Service.
 * @param uuid The Signal Service UUID.
 * @param e164 The Signal Service phone number.
 * @param password A Signal Service password.
 * @param signalAgent A string which identifies the client software.
 */
public SignalServiceAccountManager(SignalServiceConfiguration configuration,
                                   UUID uuid, String e164, String password,
                                   String signalAgent)
{
  this(configuration,
       new StaticCredentialsProvider(uuid, e164, password, null),
       signalAgent,
       new GroupsV2Operations(ClientZkOperations.create(configuration)));
}
 
Example #17
Source File: SignalServiceNetworkAccess.java    From mollyim-android with GNU General Public License v3.0 4 votes vote down vote up
public SignalServiceConfiguration getConfiguration(Context context) {
  String localNumber = TextSecurePreferences.getLocalNumber(context);
  return getConfiguration(localNumber);
}
 
Example #18
Source File: ClientZkOperations.java    From mollyim-android with GNU General Public License v3.0 4 votes vote down vote up
public static ClientZkOperations create(SignalServiceConfiguration configuration) {
  return new ClientZkOperations(new ServerPublicParams(configuration.getZkGroupServerPublicParams()));
}
 
Example #19
Source File: SignalServiceAccountManager.java    From libsignal-service-java with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Construct a SignalServiceAccountManager.
 *
 * @param configuration The URL for the Signal Service.
 * @param uuid The Signal Service UUID.
 * @param e164 The Signal Service phone number.
 * @param password A Signal Service password.
 * @param userAgent A string which identifies the client software.
 */
public SignalServiceAccountManager(SignalServiceConfiguration configuration,
                                   UUID uuid, String e164, String password,
                                   String userAgent)
{
  this(configuration, new StaticCredentialsProvider(uuid, e164, password, null), userAgent);
}
 
Example #20
Source File: SignalServiceMessageReceiver.java    From libsignal-service-java with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Construct a SignalServiceMessageReceiver.
 *
 * @param urls The URL of the Signal Service.
 * @param uuid The Signal Service UUID.
 * @param e164 The Signal Service phone number.
 * @param password The Signal Service user password.
 * @param signalingKey The 52 byte signaling key assigned to this user at registration.
 */
public SignalServiceMessageReceiver(SignalServiceConfiguration urls,
                                    UUID uuid, String e164, String password,
                                    String signalingKey, String userAgent,
                                    ConnectivityListener listener,
                                    SleepTimer timer)
{
  this(urls, new StaticCredentialsProvider(uuid, e164, password, signalingKey), userAgent, listener, timer);
}