String storedPassword = rs.getString(ATTR_PASSWORD); if (getPasswordEncryptor().matches(password, storedPassword)) { return getUserByName(user); } else { throw new AuthenticationFailedException( try { if (doesExist("anonymous")) { return getUserByName("anonymous"); } else { throw new AuthenticationFailedException(