User user = null;
try {
user = usersDAO.getUser4Login(login);
} catch (DBAccessException ex) {
logger.error("processLogin(String, String)", ex);
throw new ServiceException(ex);
}
if (user == null) {
throw new ServiceException("No user found for username",
"services.LoginServiceImpl.processLogin.no_user",
new Object[] {login}
);
}
String passSHA1 = null;
try {
passSHA1 = DigestUtils.digestSHA1(password);
} catch (NoSuchAlgorithmException e) {
logger.error("processLogin(String, String)", e);
throw new ServiceException("NoSuchAlgorithmException", e,
"services.LoginServiceImpl.processLogin.algoritm_problem",
new Object[] {e.getMessage()}
);
}
if (logger.isDebugEnabled()) {
logger.debug("processLogin(String, String) - passSHA1=" + passSHA1);
logger.debug("processLogin(String, String) - user.getPassword()=" + user.getPassword());
}
if (!passSHA1.equalsIgnoreCase(user.getPassword())) {
throw new ServiceException("Wrong password",
"services.LoginServiceImpl.processLogin.wrong_password",
null
);
}