I\'m currently designing a login system for a make-believe company, right now all I have is the Main login, which needs a lot of cleaning up. Below is my login handler.
You will want to get to know the API well, to make it your best friend. The key to solving this is to see what JPasswordField#getPassword()
returns. Hint 1: it's not a String. Hint 2: you may want to solve this using the java.util.Arrays class methods.
The reason getPassword doesn't return a String is because of the way Java handles Strings -- it can store them in the String pool, allowing Strings to hang out in the program longer than you'd expect, and making the Strings potentially retrievable by malware -- something you don't want to have happen to a password. It's much safer to work with char arrays.
Incidentally, don't use JPasswords deprecated getText()
method or change a char array to a String using the new String(char[])
constructor since as these both return a String, they are not secure.