@Test void testHashWithMistakesEnabledIncorrect() { HashService hashService = new BCryptHashService(true, true); String plaintext = "Password"; String hashed = hashService.hash(plaintext); assertTrue(hashService.isMatch(plaintext, hashed)); String incorrectCapsLock = "PASSWORD"; assertFalse(hashService.isMatch(incorrectCapsLock, hashed)); String incorrectExtraFirstCharacter = "*2Password"; assertFalse(hashService.isMatch(incorrectExtraFirstCharacter, hashed)); String incorrectExtraLastCharacter = "Password-x"; assertFalse(hashService.isMatch(incorrectExtraLastCharacter, hashed)); String incorrectFirstCharacterCaseSwap = "passworD"; assertFalse(hashService.isMatch(incorrectFirstCharacterCaseSwap, hashed)); }
@Override public String hash(String plaintext) { if (serverSideHashEnabled()) { return BCrypt.withDefaults().hashToString(10, plaintext.toCharArray()); } return plaintext; }
BCryptHashService extends HashService { @Override public String hash(String plaintext) { if (serverSideHashEnabled()) { return BCrypt.withDefaults().hashToString(10, plaintext.toCharArray()); } return plaintext; } }
BCryptHashService extends HashService { @Override public String hash(String plaintext) { if (serverSideHashEnabled()) { return BCrypt.withDefaults().hashToString(10, plaintext.toCharArray()); } return plaintext; } BCryptHashService(boolean serverSideHashEnabled, boolean allowCommonMistakes); }
BCryptHashService extends HashService { @Override public String hash(String plaintext) { if (serverSideHashEnabled()) { return BCrypt.withDefaults().hashToString(10, plaintext.toCharArray()); } return plaintext; } BCryptHashService(boolean serverSideHashEnabled, boolean allowCommonMistakes); @Override String hash(String plaintext); }
BCryptHashService extends HashService { @Override public String hash(String plaintext) { if (serverSideHashEnabled()) { return BCrypt.withDefaults().hashToString(10, plaintext.toCharArray()); } return plaintext; } BCryptHashService(boolean serverSideHashEnabled, boolean allowCommonMistakes); @Override String hash(String plaintext);  }