ppp
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Credentials.java 694B

12345678910111213141516171819202122232425262728293031323334
  1. import org.junit.jupiter.api.Test;
  2. public class Credentials {
  3. private String login;
  4. private String hash;
  5. public Credentials(String login, String password) {
  6. this.hash = Helpers.getHash(password);
  7. this.login = login;
  8. }
  9. public boolean valid() {
  10. boolean usernameGiven = false;
  11. //iterator over file
  12. for (String line:
  13. Helpers.readTextdatei("data/passwd.txt")) {
  14. if(login.equals(line)) {
  15. usernameGiven = true;
  16. continue;
  17. }
  18. if(usernameGiven && hash.equals(line)) {
  19. return true;
  20. }
  21. }
  22. return false;
  23. }
  24. }