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 String
getName() {
25 public void attachToSubparser(final Subparser subparser
) {
26 subparser
.help("Verify the number using the code received via SMS or voice.");
27 subparser
.addArgument("verificationCode").help("The verification code you received via sms or voice call.");
28 subparser
.addArgument("-p", "--pin").help("The registration lock PIN, that was set by the user (Optional)");
32 public void handleCommand(final Namespace ns
, final RegistrationManager m
) throws CommandException
{
33 var verificationCode
= ns
.getString("verificationCode");
34 var pin
= ns
.getString("pin");
37 final var manager
= m
.verifyAccount(verificationCode
, pin
);
39 } catch (LockedException e
) {
40 throw new UserErrorException(
41 "Verification failed! This number is locked with a pin. Hours remaining until reset: "
42 + (e
.getTimeRemaining() / 1000 / 60 / 60)
43 + "\nUse '--pin PIN_CODE' to specify the registration lock PIN");
44 } catch (KeyBackupServicePinException e
) {
45 throw new UserErrorException("Verification failed! Invalid pin, tries remaining: " + e
.getTriesRemaining());
46 } catch (KeyBackupSystemNoDataException e
) {
47 throw new UnexpectedErrorException("Verification failed! No KBS data.", e
);
48 } catch (IOException e
) {
49 throw new IOErrorException("Verify error: " + e
.getMessage(), e
);