public void changePassword ( T user , String currentPassword , String newPassword , String newPassword2 ) throws AuthenticationException { verifyPassword ( user , currentPassword ) ; if ( ! newPassword . equals ( newPassword2 ) ) { throw new AuthenticationException ( user . getUsername ( ) + ": New password and re-type password must be same" ) ; } else if ( newPassword . equals ( currentPassword ) ) { throw new AuthenticationException ( user . getUsername ( ) + ": New password and old password must be different" ) ; } verifyPasswordStrength ( currentPassword , newPassword , user ) ; Optional < ? extends UserEntry > optional = userStore . changePassword ( user . getUsername ( ) , newPassword ) ; if ( ! optional . isPresent ( ) ) { throw new AuthenticationException ( user . getUsername ( ) + ": Can't update UserEntry Password" ) ; } }
Changes the password for the specified user . This requires the current password as well as the password to replace it with . The new password should be checked against old hashes to be sure the new password does not closely resemble or equal any recent passwords for that UserEntry . Password strength should also be verified . This new password must be repeated to ensure that the user has typed it in correctly .