mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 23:18:17 +01:00
Add check for length of pw
This commit is contained in:
parent
a828dc745b
commit
c0cc86badf
2 changed files with 10 additions and 4 deletions
|
@ -40,6 +40,7 @@ import org.bitcoinj.crypto.KeyCrypterScrypt;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static com.google.inject.internal.util.$Preconditions.checkArgument;
|
||||
import static io.bitsquare.gui.util.FormBuilder.*;
|
||||
|
||||
@FxmlView
|
||||
|
@ -93,6 +94,9 @@ public class PasswordView extends ActivatableView<GridPane, Void> {
|
|||
setText();
|
||||
|
||||
pwButton.setOnAction(e -> {
|
||||
String password = passwordField.getText();
|
||||
checkArgument(password.length() < 50, "Password must be less then 50 characters.");
|
||||
|
||||
pwButton.setDisable(true);
|
||||
deriveStatusLabel.setText("Derive key from password");
|
||||
progressIndicator.setProgress(-1);
|
||||
|
@ -105,7 +109,7 @@ public class PasswordView extends ActivatableView<GridPane, Void> {
|
|||
else
|
||||
keyCrypterScrypt = ScryptUtil.getKeyCrypterScrypt();
|
||||
|
||||
ScryptUtil.deriveKeyWithScrypt(keyCrypterScrypt, passwordField.getText(), aesKey -> {
|
||||
ScryptUtil.deriveKeyWithScrypt(keyCrypterScrypt, password, aesKey -> {
|
||||
deriveStatusLabel.setText("");
|
||||
progressIndicator.setVisible(false);
|
||||
|
||||
|
|
|
@ -40,10 +40,12 @@ public final class PasswordValidator extends InputValidator {
|
|||
}
|
||||
|
||||
private ValidationResult validateMinLength(String input) {
|
||||
if (input.length() > 7)
|
||||
return new ValidationResult(true);
|
||||
else
|
||||
if (input.length() < 8)
|
||||
return new ValidationResult(false, BSResources.get("validation.passwordTooShort"));
|
||||
else if (input.length() > 50)
|
||||
return new ValidationResult(false, BSResources.get("validation.passwordTooLong"));
|
||||
else
|
||||
return new ValidationResult(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue