@Test public void testGetScore() { assertEquals(PasswordStrengthValidator.Strength.veryweak, new PasswordStrengthValidator().getScore("")); assertEquals(PasswordStrengthValidator.Strength.veryweak, new PasswordStrengthValidator().getScore("Cyberduck")); assertEquals(PasswordStrengthValidator.Strength.verystrong, new PasswordStrengthValidator().getScore("ahvae7faY3ae")); }
public Strength getScore(final String password) { if(StringUtils.isEmpty(password)) { return Strength.veryweak; } else { final int score = zxcvbn.measure(password, Collections.singletonList( PreferencesFactory.get().getProperty("application.name"))).getScore(); switch(score) { case 0: return Strength.veryweak; case 1: return Strength.weak; case 2: return Strength.fair; case 3: return Strength.strong; case 4: default: return Strength.verystrong; } } }
PasswordStrengthValidator { public Strength getScore(final String password) { if(StringUtils.isEmpty(password)) { return Strength.veryweak; } else { final int score = zxcvbn.measure(password, Collections.singletonList( PreferencesFactory.get().getProperty("application.name"))).getScore(); switch(score) { case 0: return Strength.veryweak; case 1: return Strength.weak; case 2: return Strength.fair; case 3: return Strength.strong; case 4: default: return Strength.verystrong; } } } }
PasswordStrengthValidator { public Strength getScore(final String password) { if(StringUtils.isEmpty(password)) { return Strength.veryweak; } else { final int score = zxcvbn.measure(password, Collections.singletonList( PreferencesFactory.get().getProperty("application.name"))).getScore(); switch(score) { case 0: return Strength.veryweak; case 1: return Strength.weak; case 2: return Strength.fair; case 3: return Strength.strong; case 4: default: return Strength.verystrong; } } }  }
PasswordStrengthValidator { public Strength getScore(final String password) { if(StringUtils.isEmpty(password)) { return Strength.veryweak; } else { final int score = zxcvbn.measure(password, Collections.singletonList( PreferencesFactory.get().getProperty("application.name"))).getScore(); switch(score) { case 0: return Strength.veryweak; case 1: return Strength.weak; case 2: return Strength.fair; case 3: return Strength.strong; case 4: default: return Strength.verystrong; } } }  Strength getScore(final String password); }
PasswordStrengthValidator { public Strength getScore(final String password) { if(StringUtils.isEmpty(password)) { return Strength.veryweak; } else { final int score = zxcvbn.measure(password, Collections.singletonList( PreferencesFactory.get().getProperty("application.name"))).getScore(); switch(score) { case 0: return Strength.veryweak; case 1: return Strength.weak; case 2: return Strength.fair; case 3: return Strength.strong; case 4: default: return Strength.verystrong; } } }  Strength getScore(final String password);  }