* @see com.adito.security.UserDatabase#checkPassword(java.lang.String,
* java.lang.String, int)
*/
public boolean checkPassword(String username, String password) throws UserDatabaseException, InvalidLoginCredentialsException {
// Get the user account
UNIXUser user = null;
try {
user = (UNIXUser) getAccount(username);
} catch (Exception e) {
throw new UserDatabaseException("Could not get user account", e);
}
// Make sure the user exists
if (user == null) {
throw new InvalidLoginCredentialsException();
}
// Determine the password type
String pw = new String(user.getPassword());
try {
if (pw.startsWith("$1$")) {
// MD5
return pw.substring(12).equals(MD5Crypt.crypt(password, pw.substring(3, 11)).substring(12));
} else if (pw.startsWith("$2a$")) {