Commit c8beaed0 authored by zeroleak's avatar zeroleak
Browse files

re-ask passphrase on auth failure

parent 12e052f8
package com.samourai.whirlpool.cli.exception;
import com.samourai.whirlpool.client.exception.NotifiableException;
public class AuthenticationException extends NotifiableException {
public AuthenticationException(String error) {
super(error);
}
}
......@@ -4,6 +4,7 @@ import com.samourai.whirlpool.cli.ApplicationArgs;
import com.samourai.whirlpool.cli.beans.CliProxy;
import com.samourai.whirlpool.cli.beans.CliResult;
import com.samourai.whirlpool.cli.config.CliConfig;
import com.samourai.whirlpool.cli.exception.AuthenticationException;
import com.samourai.whirlpool.cli.exception.NoSessionWalletException;
import com.samourai.whirlpool.cli.run.CliStatusOrchestrator;
import com.samourai.whirlpool.cli.run.RunCliCommand;
......@@ -167,14 +168,21 @@ public class CliService {
return CliResult.KEEP_RUNNING;
}
// authenticate to open wallet when passphrase providen through arguments
String seedPassphrase = authenticate();
// we may have authenticated from API in the meantime...
CliWallet cliWallet =
cliWalletService.hasSessionWallet()
? cliWalletService.getSessionWallet()
: cliWalletService.openWallet(seedPassphrase);
CliWallet cliWallet = null;
while (cliWallet == null) {
// authenticate to open wallet when passphrase providen through arguments
String seedPassphrase = authenticate();
try {
// we may have authenticated from API in the meantime...
cliWallet =
cliWalletService.hasSessionWallet()
? cliWalletService.getSessionWallet()
: cliWalletService.openWallet(seedPassphrase);
} catch (AuthenticationException e) {
log.error(e.getMessage());
// will retry
}
}
log.info(CliUtils.LOG_SEPARATOR);
log.info("⣿ AUTHENTICATION SUCCESS");
log.info("⣿ Whirlpool is starting...");
......
......@@ -18,6 +18,7 @@ import com.samourai.whirlpool.cli.beans.CliStatus;
import com.samourai.whirlpool.cli.beans.WhirlpoolPairingPayload;
import com.samourai.whirlpool.cli.config.CliConfig;
import com.samourai.whirlpool.cli.config.CliConfigFile;
import com.samourai.whirlpool.cli.exception.AuthenticationException;
import com.samourai.whirlpool.cli.exception.NoSessionWalletException;
import com.samourai.whirlpool.cli.utils.CliUtils;
import com.samourai.whirlpool.cli.wallet.CliWallet;
......@@ -87,13 +88,12 @@ public class CliWalletService extends WhirlpoolWalletService {
try {
seedWords = decryptSeedWords(cliConfig.getSeed(), passphrase);
} catch (Exception e) {
log.error("decryptSeedWords failed, invalid passphrase?");
if (log.isDebugEnabled()
&& !(e instanceof AEADBadTagException)
&& !(e instanceof InvalidCipherTextException)) {
log.debug("", e);
}
throw new NotifiableException("Decryption failed, invalid passphrase?");
throw new AuthenticationException("Authentication failed: invalid passphrase?");
}
String walletIdentifier;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment