]>
nmode's Git Repositories - signal-cli/blob - src/main/java/org/asamk/signal/commands/VerifyCommand.java
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
.UserErrorException
;
9 import org
.asamk
.signal
.manager
.RegistrationManager
;
10 import org
.asamk
.signal
.manager
.api
.IncorrectPinException
;
11 import org
.asamk
.signal
.manager
.api
.PinLockedException
;
13 import java
.io
.IOException
;
15 public class VerifyCommand
implements RegistrationCommand
{
18 public String
getName() {
23 public void attachToSubparser(final Subparser subparser
) {
24 subparser
.help("Verify the number using the code received via SMS or voice.");
25 subparser
.addArgument("verificationCode").help("The verification code you received via sms or voice call.");
26 subparser
.addArgument("-p", "--pin").help("The registration lock PIN, that was set by the user (Optional)");
30 public void handleCommand(final Namespace ns
, final RegistrationManager m
) throws CommandException
{
31 var verificationCode
= ns
.getString("verificationCode");
32 var pin
= ns
.getString("pin");
35 final var manager
= m
.verifyAccount(verificationCode
, pin
);
37 } catch (PinLockedException e
) {
38 throw new UserErrorException(
39 "Verification failed! This number is locked with a pin. Hours remaining until reset: "
40 + (e
.getTimeRemaining() / 1000 / 60 / 60)
41 + "\nUse '--pin PIN_CODE' to specify the registration lock PIN");
42 } catch (IncorrectPinException e
) {
43 throw new UserErrorException("Verification failed! Invalid pin, tries remaining: " + e
.getTriesRemaining());
44 } catch (IOException e
) {
45 throw new IOErrorException("Verify error: " + e
.getMessage(), e
);