Here is what our login methods look like (MongoDB realm):

public void login() {
        try {
            AuthenticationToken at = (new UsernamePasswordToken(username,
password, false));
            subject.login(at);

           
FacesContext.getCurrentInstance().getExternalContext().redirect(servlet.getContextPath()
+ "/welcome.xhtml");
        } catch (UnknownAccountException | IncorrectCredentialsException |
LockedAccountException ex) {
            FacesContext.getCurrentInstance().addMessage(null, new
FacesMessage(i18n.getString("template_login_failed"), ex.getMessage()));
        } catch (AuthenticationException ex) {
            FacesContext.getCurrentInstance().addMessage(null, new
FacesMessage(i18n.getString("template_login_failed"), ex.getMessage()));
        } catch (IOException | DuplicateEntityException ex) {
            LOG.log(Level.SEVERE, null, ex);
        }
    }

    /**
     * The redirect is needed to keep apache shiro from firing an
     * UnknownSessionException
     */
    public void logout() {      

        subject.logout();

        try {
           
FacesContext.getCurrentInstance().getExternalContext().redirect(servlet.getContextPath()
+ "/login.xhtml");
        } catch (IOException ex) {
            LOG.log(Level.SEVERE, null, ex);
        }
    }



--
View this message in context: 
http://shiro-user.582556.n2.nabble.com/login-button-and-custom-realm-tp7580819p7580824.html
Sent from the Shiro User mailing list archive at Nabble.com.

Reply via email to