use of com.joliciel.jochre.security.Parameters in project jochre by urieli.
the class LoginController method doAfterCompose.
@Override
public void doAfterCompose(Window window) throws Exception {
super.doAfterCompose(window);
String pageTitle = Labels.getLabel("login.title");
winLogin.getPage().setTitle(pageTitle);
Session session = Sessions.getCurrent();
session.removeAttribute(SESSION_JOCHRE_USER);
HttpServletRequest request = (HttpServletRequest) Executions.getCurrent().getNativeRequest();
String failed = request.getParameter("failed");
if (failed == null)
lblError.setVisible(false);
else
lblError.setVisible(true);
SecurityDao securityDao = SecurityDao.getInstance(jochreSession);
Parameters parameters = securityDao.loadParameters();
Date lastFailedLoginAttempt = parameters.getLastFailedLoginAttempt();
Date now = new Date();
long diff = now.getTime() - lastFailedLoginAttempt.getTime();
LOG.debug("time since last failed login: " + diff);
}
use of com.joliciel.jochre.security.Parameters in project jochre by urieli.
the class LoginController method onClick$btnLogin.
@Listen("onClick = #btnLogin")
public void onClick$btnLogin(Event event) {
try {
LOG.debug("onClick$btnLogin");
Session session = Sessions.getCurrent();
SecurityDao securityDao = SecurityDao.getInstance(jochreSession);
User user = null;
try {
user = securityDao.findUser(txtUserName.getValue());
} catch (EntityNotFoundException enfe) {
LOG.debug("Unknown user: " + txtUserName.getValue());
lblError.setVisible(true);
}
if (user != null) {
boolean success = user.login(txtPassword.getValue());
if (!success) {
LOG.debug("Login failed");
lblError.setVisible(true);
Parameters parameters = securityDao.loadParameters();
Date lastFailedLoginAttempt = parameters.getLastFailedLoginAttempt();
Date now = new Date();
long diff = now.getTime() - lastFailedLoginAttempt.getTime();
LOG.debug("time since last failed login: " + diff);
} else {
LOG.debug("Login success");
session.setAttribute(SESSION_JOCHRE_USER, user);
Executions.sendRedirect("docs.zul");
}
}
} catch (Exception e) {
LOG.error("Failure in onClick$btnLogin", e);
throw new RuntimeException(e);
}
}
Aggregations