1 package org
.asamk
.signal
.commands
;
3 import net
.sourceforge
.argparse4j
.inf
.Namespace
;
4 import net
.sourceforge
.argparse4j
.inf
.Subparser
;
6 import org
.asamk
.signal
.commands
.exceptions
.CommandException
;
7 import org
.asamk
.signal
.commands
.exceptions
.IOErrorException
;
8 import org
.asamk
.signal
.commands
.exceptions
.UnexpectedErrorException
;
9 import org
.asamk
.signal
.commands
.exceptions
.UserErrorException
;
10 import org
.asamk
.signal
.manager
.RegistrationManager
;
11 import org
.whispersystems
.signalservice
.api
.KeyBackupServicePinException
;
12 import org
.whispersystems
.signalservice
.api
.KeyBackupSystemNoDataException
;
13 import org
.whispersystems
.signalservice
.internal
.push
.LockedException
;
15 import java
.io
.IOException
;
17 public class VerifyCommand
implements RegistrationCommand
{
20 public void attachToSubparser(final Subparser subparser
) {
21 subparser
.addArgument("verificationCode").help("The verification code you received via sms or voice call.");
22 subparser
.addArgument("-p", "--pin").help("The registration lock PIN, that was set by the user (Optional)");
26 public void handleCommand(final Namespace ns
, final RegistrationManager m
) throws CommandException
{
27 var verificationCode
= ns
.getString("verificationCode");
28 var pin
= ns
.getString("pin");
31 m
.verifyAccount(verificationCode
, pin
);
32 } catch (LockedException e
) {
33 throw new UserErrorException(
34 "Verification failed! This number is locked with a pin. Hours remaining until reset: "
35 + (e
.getTimeRemaining() / 1000 / 60 / 60)
36 + "\nUse '--pin PIN_CODE' to specify the registration lock PIN");
37 } catch (KeyBackupServicePinException e
) {
38 throw new UserErrorException("Verification failed! Invalid pin, tries remaining: " + e
.getTriesRemaining());
39 } catch (KeyBackupSystemNoDataException e
) {
40 throw new UnexpectedErrorException("Verification failed! No KBS data.");
41 } catch (IOException e
) {
42 throw new IOErrorException("Verify error: " + e
.getMessage());