}
public AuthenticationSession login(String user, Object credentials) throws AuthenticationException {
if (_status == STATUS_AUTHDB_UNKNOWN) {
throw new AuthenticationException("Authentication was unable to collect data for valid logins yet. Please ensure that source database '" + _dbkey + "' is enabled and can be connected.");
}
if (_status == STATUS_AUTHDB_PREPARED) {
try {
runAuthCollector().join();
}
catch (InterruptedException e) {
}
}
try {
String password = String.valueOf(credentials);
Login login = (Login) getLogin(user);
if (login != null) {
String hashedPassword = WGUtils.hashPassword(password);
if (login.getPassword() != null && login.getPassword().equals(hashedPassword)) {
return login;
}
else {
LOG.warn("Failed login for '" + user + "': Wrong password (" + getAuthenticationSource() + ")");
}
}
else {
LOG.warn("Failed login for '" + user + "': Unknown user (" + getAuthenticationSource() + ")");
}
return null;
}
catch (NoSuchAlgorithmException e) {
throw new AuthenticationException("Neccessary password hash algorithm not available: " + e.getMessage());
}
}