#278 Forbid to create a vault with a very bad password
This commit is contained in:
parent
af051ccad0
commit
e5382b6d52
@ -51,6 +51,14 @@ class ChangePasswordDialog : BaseProgressErrorDialog<ChangePasswordDialog.Callba
|
|||||||
changePasswordButton?.let { button ->
|
changePasswordButton?.let { button ->
|
||||||
et_new_retype_password.nextFocusForwardId = button.id
|
et_new_retype_password.nextFocusForwardId = button.id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
registerOnEditorDoneActionAndPerformButtonClick(et_new_retype_password) { changePasswordButton }
|
||||||
|
|
||||||
|
PasswordStrengthUtil() //
|
||||||
|
.startUpdatingPasswordStrengthMeter(et_new_password, //
|
||||||
|
progressBarPwStrengthIndicator, //
|
||||||
|
textViewPwStrengthIndicator, //
|
||||||
|
changePasswordButton)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,11 +91,6 @@ class ChangePasswordDialog : BaseProgressErrorDialog<ChangePasswordDialog.Callba
|
|||||||
|
|
||||||
override fun setupView() {
|
override fun setupView() {
|
||||||
et_old_password.requestFocus()
|
et_old_password.requestFocus()
|
||||||
registerOnEditorDoneActionAndPerformButtonClick(et_new_retype_password) { changePasswordButton }
|
|
||||||
PasswordStrengthUtil() //
|
|
||||||
.startUpdatingPasswortStrengthMeter(et_new_password, //
|
|
||||||
progressBarPwStrengthIndicator, //
|
|
||||||
textViewPwStrengthIndicator)
|
|
||||||
dialog?.let { showKeyboard(it) }
|
dialog?.let { showKeyboard(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,9 +29,10 @@ class SetPasswordFragment : BaseFragment() {
|
|||||||
}
|
}
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
passwordStrengthUtil.startUpdatingPasswortStrengthMeter(passwordEditText, //
|
passwordStrengthUtil.startUpdatingPasswordStrengthMeter(passwordEditText, //
|
||||||
progressBarPwStrengthIndicator, //
|
progressBarPwStrengthIndicator, //
|
||||||
textViewPwStrengthIndicator)
|
textViewPwStrengthIndicator, //
|
||||||
|
createVaultButton)
|
||||||
|
|
||||||
passwordEditText.requestFocus()
|
passwordEditText.requestFocus()
|
||||||
}
|
}
|
||||||
|
@ -14,13 +14,21 @@ enum class PasswordStrength(val score: Int, val description: Int, val color: Int
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
|
private const val MIN_PASSWORD_LENGTH = 8
|
||||||
|
|
||||||
private val zxcvbn = Zxcvbn()
|
private val zxcvbn = Zxcvbn()
|
||||||
|
|
||||||
fun forPassword(password: String, sanitizedInputs: List<String>): PasswordStrength {
|
fun forPassword(password: String, sanitizedInputs: List<String>): PasswordStrength {
|
||||||
return if (password.isEmpty()) {
|
return when {
|
||||||
EMPTY
|
password.isEmpty() -> {
|
||||||
} else {
|
EMPTY
|
||||||
forScore(zxcvbn.measure(password, sanitizedInputs).score).orElse(EMPTY)
|
}
|
||||||
|
password.length < MIN_PASSWORD_LENGTH -> {
|
||||||
|
EXTREMELY_WEAK
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
forScore(zxcvbn.measure(password, sanitizedInputs).score).orElse(EMPTY)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package org.cryptomator.presentation.util;
|
package org.cryptomator.presentation.util;
|
||||||
|
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@ -40,9 +41,10 @@ public class PasswordStrengthUtil {
|
|||||||
public PasswordStrengthUtil() {
|
public PasswordStrengthUtil() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startUpdatingPasswortStrengthMeter(EditText passwordInput, //
|
public void startUpdatingPasswordStrengthMeter(EditText passwordInput, //
|
||||||
final ProgressBar strengthMeter, //
|
final ProgressBar strengthMeter, //
|
||||||
final TextView strengthLabel) {
|
final TextView strengthLabel, //
|
||||||
|
final Button button) {
|
||||||
RxTextView.textChanges(passwordInput) //
|
RxTextView.textChanges(passwordInput) //
|
||||||
.observeOn(Schedulers.computation()) //
|
.observeOn(Schedulers.computation()) //
|
||||||
.map(password -> PasswordStrength.Companion.forPassword(password.toString(), SANITIZED_INPUTS)) //
|
.map(password -> PasswordStrength.Companion.forPassword(password.toString(), SANITIZED_INPUTS)) //
|
||||||
@ -51,6 +53,7 @@ public class PasswordStrengthUtil {
|
|||||||
strengthMeter.getProgressDrawable().setColorFilter(ResourceHelper.Companion.getColor(strength.getColor()), PorterDuff.Mode.SRC_IN);
|
strengthMeter.getProgressDrawable().setColorFilter(ResourceHelper.Companion.getColor(strength.getColor()), PorterDuff.Mode.SRC_IN);
|
||||||
strengthLabel.setText(strength.getDescription());
|
strengthLabel.setText(strength.getDescription());
|
||||||
strengthMeter.setProgress(strength.getScore() + 1);
|
strengthMeter.setProgress(strength.getScore() + 1);
|
||||||
|
button.setEnabled(strength.getScore() > PasswordStrength.EXTREMELY_WEAK.getScore());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -187,7 +187,7 @@
|
|||||||
<string name="screen_set_password_password_label" translatable="false">@string/screen_webdav_settings_password_label</string>
|
<string name="screen_set_password_password_label" translatable="false">@string/screen_webdav_settings_password_label</string>
|
||||||
<string name="screen_set_password_retype_password_label">Retype password</string>
|
<string name="screen_set_password_retype_password_label">Retype password</string>
|
||||||
|
|
||||||
<string name="screen_set_password_strength_indicator_0">Very weak</string>
|
<string name="screen_set_password_strength_indicator_0">Too weak to create a vault</string>
|
||||||
<string name="screen_set_password_strength_indicator_1">Weak</string>
|
<string name="screen_set_password_strength_indicator_1">Weak</string>
|
||||||
<string name="screen_set_password_strength_indicator_2">Fair</string>
|
<string name="screen_set_password_strength_indicator_2">Fair</string>
|
||||||
<string name="screen_set_password_strength_indicator_3">Strong</string>
|
<string name="screen_set_password_strength_indicator_3">Strong</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user