Try both Unix crypt and Stefan's new MD5 encoding for authentication.

This commit is contained in:
hns 2002-03-26 12:09:32 +00:00
parent 7041bf08e7
commit c88ac35c17

View file

@ -31,9 +31,18 @@ public class CryptFile {
users.clear ();
String realpw = users.getProperty (username);
if (realpw != null) {
// check if password matches
String cryptpw = Crypt.crypt (realpw, pw);
return realpw.equals (cryptpw);
try {
// check if password matches
// first we try with unix crypt algorithm
String cryptpw = Crypt.crypt (realpw, pw);
if (realpw.equals (cryptpw))
return true;
// then try MD5
if (realpw.equals (MD5Encoder.encode (pw)))
return true;
} catch (Exception x) {
return false;
}
} else {
if (parentFile != null)
return parentFile.authenticate (username, pw);