@Test public void testVerifyPasswordStrength_OK_specialChars() throws AuthenticationException { for (char special : AuthenticatorHelper.CHAR_SPECIALS) { String password = "aB178cd" + special; boolean isOK = AuthenticatorHelper.verifyPasswordStrength("test2", password, "test2"); System.out.println("password: " + password + " is OK"); if (!isOK) { System.out.println("password: " + password + " is NOK"); } assertTrue(isOK); } }
public static boolean verifyPasswordStrength(String oldPassword, String newPassword, String principalName) { if (newPassword == null || newPassword.isEmpty()) { LOG.error("verifyPasswordStrength failed because newPassword or principalName is null or empty"); return false; } else if (newPassword != null && newPassword.trim().length() < 8) { LOG.error("verifyPasswordStrength failed because newPassword is too short, should be at least 8 chars long"); return false; } else if (newPassword != null && !verifyCharSets(newPassword)) { LOG.error("verifyPasswordStrength failed because newPassword doesn't have a char from each char set"); return false; } if (principalName == null) { principalName = ""; } try { FileBasedAuthenticator.getInstance().verifyPasswordStrength(oldPassword, newPassword, getESAPIUser(principalName)); } catch (AuthenticationException e) { LOG.error("verifyPasswordStrength failed because: " + e.getUserMessage() + " " + e.getLogMessage()); return false; } return true; }
AuthenticatorHelper { public static boolean verifyPasswordStrength(String oldPassword, String newPassword, String principalName) { if (newPassword == null || newPassword.isEmpty()) { LOG.error("verifyPasswordStrength failed because newPassword or principalName is null or empty"); return false; } else if (newPassword != null && newPassword.trim().length() < 8) { LOG.error("verifyPasswordStrength failed because newPassword is too short, should be at least 8 chars long"); return false; } else if (newPassword != null && !verifyCharSets(newPassword)) { LOG.error("verifyPasswordStrength failed because newPassword doesn't have a char from each char set"); return false; } if (principalName == null) { principalName = ""; } try { FileBasedAuthenticator.getInstance().verifyPasswordStrength(oldPassword, newPassword, getESAPIUser(principalName)); } catch (AuthenticationException e) { LOG.error("verifyPasswordStrength failed because: " + e.getUserMessage() + " " + e.getLogMessage()); return false; } return true; } }
AuthenticatorHelper { public static boolean verifyPasswordStrength(String oldPassword, String newPassword, String principalName) { if (newPassword == null || newPassword.isEmpty()) { LOG.error("verifyPasswordStrength failed because newPassword or principalName is null or empty"); return false; } else if (newPassword != null && newPassword.trim().length() < 8) { LOG.error("verifyPasswordStrength failed because newPassword is too short, should be at least 8 chars long"); return false; } else if (newPassword != null && !verifyCharSets(newPassword)) { LOG.error("verifyPasswordStrength failed because newPassword doesn't have a char from each char set"); return false; } if (principalName == null) { principalName = ""; } try { FileBasedAuthenticator.getInstance().verifyPasswordStrength(oldPassword, newPassword, getESAPIUser(principalName)); } catch (AuthenticationException e) { LOG.error("verifyPasswordStrength failed because: " + e.getUserMessage() + " " + e.getLogMessage()); return false; } return true; }  }
AuthenticatorHelper { public static boolean verifyPasswordStrength(String oldPassword, String newPassword, String principalName) { if (newPassword == null || newPassword.isEmpty()) { LOG.error("verifyPasswordStrength failed because newPassword or principalName is null or empty"); return false; } else if (newPassword != null && newPassword.trim().length() < 8) { LOG.error("verifyPasswordStrength failed because newPassword is too short, should be at least 8 chars long"); return false; } else if (newPassword != null && !verifyCharSets(newPassword)) { LOG.error("verifyPasswordStrength failed because newPassword doesn't have a char from each char set"); return false; } if (principalName == null) { principalName = ""; } try { FileBasedAuthenticator.getInstance().verifyPasswordStrength(oldPassword, newPassword, getESAPIUser(principalName)); } catch (AuthenticationException e) { LOG.error("verifyPasswordStrength failed because: " + e.getUserMessage() + " " + e.getLogMessage()); return false; } return true; }  static boolean verifyPasswordStrength(String oldPassword, String newPassword, String principalName); }
AuthenticatorHelper { public static boolean verifyPasswordStrength(String oldPassword, String newPassword, String principalName) { if (newPassword == null || newPassword.isEmpty()) { LOG.error("verifyPasswordStrength failed because newPassword or principalName is null or empty"); return false; } else if (newPassword != null && newPassword.trim().length() < 8) { LOG.error("verifyPasswordStrength failed because newPassword is too short, should be at least 8 chars long"); return false; } else if (newPassword != null && !verifyCharSets(newPassword)) { LOG.error("verifyPasswordStrength failed because newPassword doesn't have a char from each char set"); return false; } if (principalName == null) { principalName = ""; } try { FileBasedAuthenticator.getInstance().verifyPasswordStrength(oldPassword, newPassword, getESAPIUser(principalName)); } catch (AuthenticationException e) { LOG.error("verifyPasswordStrength failed because: " + e.getUserMessage() + " " + e.getLogMessage()); return false; } return true; }  static boolean verifyPasswordStrength(String oldPassword, String newPassword, String principalName);  }