public void doLogin() throws IOException {
try {
SecurityUtils.getSubject().login(new UsernamePasswordToken(username, password, remember));
ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
SavedRequest savedRequest = WebUtils
.getAndClearSavedRequest((ServletRequest) externalContext
.getRequest());
externalContext
.redirect(savedRequest != null ? savedRequest.getRequestUrl() : getRootUrl(externalContext));
} catch (IncorrectCredentialsException e) {
messageContext.message().text("{octopus.invalid_password}").payload(MessageSeverity.ERROR).add();
} catch (UnknownAccountException e) {
messageContext.message().text("{octopus.unknown_username}").payload(MessageSeverity.ERROR).add();