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
.manager
.RegistrationManager
;
7 import org
.whispersystems
.signalservice
.api
.KeyBackupServicePinException
;
8 import org
.whispersystems
.signalservice
.api
.KeyBackupSystemNoDataException
;
9 import org
.whispersystems
.signalservice
.internal
.push
.LockedException
;
11 import java
.io
.IOException
;
13 public class VerifyCommand
implements RegistrationCommand
{
16 public void attachToSubparser(final Subparser subparser
) {
17 subparser
.addArgument("verificationCode").help("The verification code you received via sms or voice call.");
18 subparser
.addArgument("-p", "--pin").help("The registration lock PIN, that was set by the user (Optional)");
22 public int handleCommand(final Namespace ns
, final RegistrationManager m
) {
24 var verificationCode
= ns
.getString("verificationCode");
25 var pin
= ns
.getString("pin");
26 m
.verifyAccount(verificationCode
, pin
);
28 } catch (LockedException e
) {
29 System
.err
.println("Verification failed! This number is locked with a pin. Hours remaining until reset: "
30 + (e
.getTimeRemaining() / 1000 / 60 / 60));
31 System
.err
.println("Use '--pin PIN_CODE' to specify the registration lock PIN");
33 } catch (KeyBackupServicePinException e
) {
34 System
.err
.println("Verification failed! Invalid pin, tries remaining: " + e
.getTriesRemaining());
36 } catch (KeyBackupSystemNoDataException e
) {
37 System
.err
.println("Verification failed! No KBS data.");
39 } catch (IOException e
) {
40 System
.err
.println("Verify error: " + e
.getMessage());