/*
- Copyright (C) 2015-2018 AsamK
+ Copyright (C) 2015-2020 AsamK and contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.freedesktop.dbus.DBusConnection;
import org.freedesktop.dbus.exceptions.DBusException;
+import org.whispersystems.signalservice.api.push.exceptions.AuthorizationFailedException;
import org.whispersystems.signalservice.api.util.PhoneNumberFormatter;
import java.io.File;
public class Main {
public static void main(String[] args) {
- // Register our own security provider
- Security.insertProviderAt(new SecurityProvider(), 1);
- Security.addProvider(new BouncyCastleProvider());
+ installSecurityProviderWorkaround();
Namespace ns = parseArgs(args);
if (ns == null) {
System.exit(res);
}
+ public static void installSecurityProviderWorkaround() {
+ // Register our own security provider
+ Security.insertProviderAt(new SecurityProvider(), 1);
+ Security.addProvider(new BouncyCastleProvider());
+ }
+
private static int handleCommands(Namespace ns) {
final String username = ns.getString("username");
Manager m;
ts = m;
try {
m.init();
+ } catch (AuthorizationFailedException e) {
+ if (!"register".equals(ns.getString("command"))) {
+ // Register command should still be possible, if current authorization fails
+ System.err.println("Authorization failed, was the number registered elsewhere?");
+ return 2;
+ }
} catch (Exception e) {
System.err.println("Error loading state file: " + e.getMessage());
return 2;