This commit is contained in:
AsamK 2024-02-27 19:35:38 +01:00
parent aebe64571d
commit 5e17fe8414
11 changed files with 28 additions and 29 deletions

View file

@ -44,7 +44,7 @@ import org.asamk.signal.manager.api.UpdateGroup;
import org.asamk.signal.manager.api.UpdateProfile;
import org.asamk.signal.manager.api.UserStatus;
import org.asamk.signal.manager.api.UsernameLinkUrl;
import org.asamk.signal.manager.api.VerificationMethoNotAvailableException;
import org.asamk.signal.manager.api.VerificationMethodNotAvailableException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.whispersystems.signalservice.api.util.PhoneNumberFormatter;
@ -127,7 +127,7 @@ public interface Manager extends Closeable {
void startChangeNumber(
String newNumber, boolean voiceVerification, String captcha
) throws RateLimitException, IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, NotPrimaryDeviceException, VerificationMethoNotAvailableException;
) throws RateLimitException, IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, NotPrimaryDeviceException, VerificationMethodNotAvailableException;
void finishChangeNumber(
String newNumber, String verificationCode, String pin
@ -138,8 +138,7 @@ public interface Manager extends Closeable {
void deleteAccount() throws IOException;
void submitRateLimitRecaptchaChallenge(
String challenge,
String captcha
String challenge, String captcha
) throws IOException, CaptchaRejectedException;
List<Device> getLinkedDevices() throws IOException;

View file

@ -5,7 +5,7 @@ import org.asamk.signal.manager.api.IncorrectPinException;
import org.asamk.signal.manager.api.NonNormalizedPhoneNumberException;
import org.asamk.signal.manager.api.PinLockedException;
import org.asamk.signal.manager.api.RateLimitException;
import org.asamk.signal.manager.api.VerificationMethoNotAvailableException;
import org.asamk.signal.manager.api.VerificationMethodNotAvailableException;
import java.io.Closeable;
import java.io.IOException;
@ -14,7 +14,7 @@ public interface RegistrationManager extends Closeable {
void register(
boolean voiceVerification, String captcha, final boolean forceRegister
) throws IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, RateLimitException, VerificationMethoNotAvailableException;
) throws IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, RateLimitException, VerificationMethodNotAvailableException;
void verifyAccount(
String verificationCode, String pin

View file

@ -1,8 +0,0 @@
package org.asamk.signal.manager.api;
public class VerificationMethoNotAvailableException extends Exception {
public VerificationMethoNotAvailableException() {
super("Invalid verification method");
}
}

View file

@ -0,0 +1,8 @@
package org.asamk.signal.manager.api;
public class VerificationMethodNotAvailableException extends Exception {
public VerificationMethodNotAvailableException() {
super("Invalid verification method");
}
}

View file

@ -7,7 +7,7 @@ import org.asamk.signal.manager.api.InvalidDeviceLinkException;
import org.asamk.signal.manager.api.NonNormalizedPhoneNumberException;
import org.asamk.signal.manager.api.PinLockedException;
import org.asamk.signal.manager.api.RateLimitException;
import org.asamk.signal.manager.api.VerificationMethoNotAvailableException;
import org.asamk.signal.manager.api.VerificationMethodNotAvailableException;
import org.asamk.signal.manager.internal.SignalDependencies;
import org.asamk.signal.manager.jobs.SyncStorageJob;
import org.asamk.signal.manager.storage.SignalAccount;
@ -165,7 +165,7 @@ public class AccountHelper {
public void startChangeNumber(
String newNumber, boolean voiceVerification, String captcha
) throws IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, RateLimitException, VerificationMethoNotAvailableException {
) throws IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, RateLimitException, VerificationMethodNotAvailableException {
final var accountManager = dependencies.createUnauthenticatedAccountManager(newNumber, account.getPassword());
String sessionId = NumberVerificationUtils.handleVerificationSession(accountManager,
account.getSessionId(newNumber),

View file

@ -65,7 +65,7 @@ import org.asamk.signal.manager.api.UpdateGroup;
import org.asamk.signal.manager.api.UpdateProfile;
import org.asamk.signal.manager.api.UserStatus;
import org.asamk.signal.manager.api.UsernameLinkUrl;
import org.asamk.signal.manager.api.VerificationMethoNotAvailableException;
import org.asamk.signal.manager.api.VerificationMethodNotAvailableException;
import org.asamk.signal.manager.config.ServiceEnvironmentConfig;
import org.asamk.signal.manager.helper.AccountFileUpdater;
import org.asamk.signal.manager.helper.Context;
@ -380,7 +380,7 @@ public class ManagerImpl implements Manager {
@Override
public void startChangeNumber(
String newNumber, boolean voiceVerification, String captcha
) throws RateLimitException, IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, NotPrimaryDeviceException, VerificationMethoNotAvailableException {
) throws RateLimitException, IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, NotPrimaryDeviceException, VerificationMethodNotAvailableException {
if (!account.isPrimaryDevice()) {
throw new NotPrimaryDeviceException();
}

View file

@ -24,7 +24,7 @@ import org.asamk.signal.manager.api.NonNormalizedPhoneNumberException;
import org.asamk.signal.manager.api.PinLockedException;
import org.asamk.signal.manager.api.RateLimitException;
import org.asamk.signal.manager.api.UpdateProfile;
import org.asamk.signal.manager.api.VerificationMethoNotAvailableException;
import org.asamk.signal.manager.api.VerificationMethodNotAvailableException;
import org.asamk.signal.manager.config.ServiceConfig;
import org.asamk.signal.manager.config.ServiceEnvironmentConfig;
import org.asamk.signal.manager.helper.AccountFileUpdater;
@ -105,7 +105,7 @@ public class RegistrationManagerImpl implements RegistrationManager {
@Override
public void register(
boolean voiceVerification, String captcha, final boolean forceRegister
) throws IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, RateLimitException, VerificationMethoNotAvailableException {
) throws IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, RateLimitException, VerificationMethodNotAvailableException {
if (account.isRegistered()
&& account.getServiceEnvironment() != null
&& account.getServiceEnvironment() != serviceEnvironmentConfig.type()) {

View file

@ -6,7 +6,7 @@ import org.asamk.signal.manager.api.NonNormalizedPhoneNumberException;
import org.asamk.signal.manager.api.Pair;
import org.asamk.signal.manager.api.PinLockedException;
import org.asamk.signal.manager.api.RateLimitException;
import org.asamk.signal.manager.api.VerificationMethoNotAvailableException;
import org.asamk.signal.manager.api.VerificationMethodNotAvailableException;
import org.asamk.signal.manager.helper.PinHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -35,7 +35,7 @@ public class NumberVerificationUtils {
Consumer<String> sessionIdSaver,
boolean voiceVerification,
String captcha
) throws CaptchaRequiredException, IOException, RateLimitException, VerificationMethoNotAvailableException {
) throws CaptchaRequiredException, IOException, RateLimitException, VerificationMethodNotAvailableException {
RegistrationSessionMetadataResponse sessionResponse;
try {
sessionResponse = getValidSession(accountManager, sessionId);
@ -63,7 +63,7 @@ public class NumberVerificationUtils {
? sessionResponse.getBody().getNextCall()
: sessionResponse.getBody().getNextSms();
if (nextAttempt == null) {
throw new VerificationMethoNotAvailableException();
throw new VerificationMethodNotAvailableException();
} else if (nextAttempt > 0) {
final var timestamp = sessionResponse.getHeaders().getTimestamp() + nextAttempt * 1000;
throw new RateLimitException(timestamp);

View file

@ -15,7 +15,7 @@ import org.asamk.signal.manager.RegistrationManager;
import org.asamk.signal.manager.api.CaptchaRequiredException;
import org.asamk.signal.manager.api.NonNormalizedPhoneNumberException;
import org.asamk.signal.manager.api.RateLimitException;
import org.asamk.signal.manager.api.VerificationMethoNotAvailableException;
import org.asamk.signal.manager.api.VerificationMethodNotAvailableException;
import org.asamk.signal.output.JsonWriter;
import org.asamk.signal.util.CommandUtil;
@ -84,7 +84,7 @@ public class RegisterCommand implements RegistrationCommand, JsonRpcRegistration
} catch (IOException e) {
throw new IOErrorException("Failed to register: %s (%s)".formatted(e.getMessage(),
e.getClass().getSimpleName()), e);
} catch (VerificationMethoNotAvailableException e) {
} catch (VerificationMethodNotAvailableException e) {
throw new UserErrorException("Failed to register: " + e.getMessage() + (
voiceVerification
? ": Before requesting voice verification you need to request SMS verification and wait a minute."

View file

@ -13,7 +13,7 @@ import org.asamk.signal.manager.api.CaptchaRequiredException;
import org.asamk.signal.manager.api.NonNormalizedPhoneNumberException;
import org.asamk.signal.manager.api.NotPrimaryDeviceException;
import org.asamk.signal.manager.api.RateLimitException;
import org.asamk.signal.manager.api.VerificationMethoNotAvailableException;
import org.asamk.signal.manager.api.VerificationMethodNotAvailableException;
import org.asamk.signal.output.OutputWriter;
import org.asamk.signal.util.CommandUtil;
@ -60,7 +60,7 @@ public class StartChangeNumberCommand implements JsonRpcLocalCommand {
} catch (IOException e) {
throw new IOErrorException("Failed to change number: %s (%s)".formatted(e.getMessage(),
e.getClass().getSimpleName()), e);
} catch (VerificationMethoNotAvailableException e) {
} catch (VerificationMethodNotAvailableException e) {
throw new UserErrorException("Failed to register: " + e.getMessage() + (
voiceVerification
? ": Before requesting voice verification you need to request SMS verification and wait a minute."

View file

@ -13,7 +13,7 @@ import org.asamk.signal.manager.api.NonNormalizedPhoneNumberException;
import org.asamk.signal.manager.api.PinLockedException;
import org.asamk.signal.manager.api.RateLimitException;
import org.asamk.signal.manager.api.UserAlreadyExistsException;
import org.asamk.signal.manager.api.VerificationMethoNotAvailableException;
import org.asamk.signal.manager.api.VerificationMethodNotAvailableException;
import org.freedesktop.dbus.DBusPath;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -74,7 +74,7 @@ public class DbusSignalControlImpl implements org.asamk.SignalControl {
throw new Error.InvalidNumber(e.getMessage());
} catch (OverlappingFileLockException e) {
throw new SignalControl.Error.Failure("Account is already in use");
} catch (IOException | VerificationMethoNotAvailableException e) {
} catch (IOException | VerificationMethodNotAvailableException e) {
throw new SignalControl.Error.Failure(e.getClass().getSimpleName() + " " + e.getMessage());
}
}