Example usage for org.springframework.security.web WebAttributes AUTHENTICATION_EXCEPTION

List of usage examples for org.springframework.security.web WebAttributes AUTHENTICATION_EXCEPTION

Introduction

In this page you can find the example usage for org.springframework.security.web WebAttributes AUTHENTICATION_EXCEPTION.

Prototype

String AUTHENTICATION_EXCEPTION

To view the source code for org.springframework.security.web WebAttributes AUTHENTICATION_EXCEPTION.

Click Source Link

Document

Used to cache an authentication-failure exception in the session.

Usage

From source file:com.micromap.util.LoginErrorPhaseListener.java

@Override
public void beforePhase(PhaseEvent arg0) {
    Exception dadosIncorretosException = (Exception) FacesUtil.getSessionMap()
            .get(WebAttributes.AUTHENTICATION_EXCEPTION);
    if (dadosIncorretosException instanceof BadCredentialsException) {
        FacesUtil.getSessionMap().put(WebAttributes.AUTHENTICATION_EXCEPTION, null);
        FacesUtil.exibirMensagemErro("Dados incorretos!");
    }// ww w  .j  a  v a 2  s  . c om
}

From source file:com.mycompany.CRMFly.Security.LoginErrorPhaseListener.java

@Override
public void beforePhase(final PhaseEvent arg0) {

    Exception e = (Exception) FacesContext.getCurrentInstance().getExternalContext().getSessionMap()
            .get(WebAttributes.AUTHENTICATION_EXCEPTION);
    //FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR,
    //                 e.toString(), null));

    if (e instanceof BadCredentialsException) {
        FacesContext.getCurrentInstance().getExternalContext().getSessionMap()
                .put(WebAttributes.AUTHENTICATION_EXCEPTION, null);
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR,
                "? ? ?  .    ",
                null));//from ww w. j a  v a2s . c  om
    }

}

From source file:com.cfs.util.LoginErrorPhaseListener.java

@Override
public void beforePhase(PhaseEvent arg0) {
    Exception dadosIncorretosException = (Exception) FacesUtil.getSessionMap()
            .get(WebAttributes.AUTHENTICATION_EXCEPTION);
    if (dadosIncorretosException instanceof BadCredentialsException) {
        FacesUtil.getSessionMap().put(WebAttributes.AUTHENTICATION_EXCEPTION, null);
        FacesUtil.exibirMensagemErro("Dados incorretos!");
    }/*from  www .j av  a  2  s  .c  om*/

    //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}

From source file:com.mothsoft.alexis.web.faces.LoginErrorPhaseListener.java

public void beforePhase(final PhaseEvent event) {
    final FacesContext context = FacesContext.getCurrentInstance();

    Exception e = (Exception) context.getExternalContext().getSessionMap()
            .get(WebAttributes.AUTHENTICATION_EXCEPTION);

    if (e instanceof BadCredentialsException) {
        context.getExternalContext().getSessionMap().remove(WebAttributes.AUTHENTICATION_EXCEPTION);

        final FacesMessage message = new FacesMessage("Username or password not valid.");
        message.setSeverity(FacesMessage.SEVERITY_WARN);
        context.addMessage(null, message);
    }//w w w  . j  a  va2 s. c o m
}

From source file:th.co.geniustree.osgi.prototype.authen.security.AuthenSuccessHandlerImpl.java

@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
        Authentication authentication) throws IOException, ServletException {
    HttpSession session = request.getSession();
    session.removeAttribute(WebAttributes.AUTHENTICATION_EXCEPTION);
    store.storeAuthentication(session, authentication);
    strategy.sendRedirect(request, response, getRedirectUrl(request));
}

From source file:de.blizzy.documentr.web.access.AccessController.java

@RequestMapping(value = "/login/error", method = RequestMethod.GET)
@PreAuthorize("permitAll")
public String loginError(HttpSession session, Model model) {
    AuthenticationException exception = (AuthenticationException) session
            .getAttribute(WebAttributes.AUTHENTICATION_EXCEPTION);
    String msg = getMessage(exception);
    if (StringUtils.isNotBlank(msg)) {
        model.addAttribute("errorMessage", msg); //$NON-NLS-1$
    }//  w  w w . j  a  va  2  s  . co m
    return "/login"; //$NON-NLS-1$
}

From source file:hu.unideb.studentSupportInterface.backing.LoginController.java

public void beforePhase(PhaseEvent event) {
    Exception e = (Exception) FacesContext.getCurrentInstance().getExternalContext().getSessionMap()
            .get(WebAttributes.AUTHENTICATION_EXCEPTION);

    if (e instanceof BadCredentialsException) {
        logger.debug("Found exception in session map: " + e);
        FacesContext.getCurrentInstance().getExternalContext().getSessionMap()
                .put(WebAttributes.AUTHENTICATION_EXCEPTION, null);
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR,
                "Username or password not valid.", "Username or password not valid"));
    }/*w  w w  .ja v a2s.com*/
}

From source file:com.yj.google.SimpleSignInAdapter.java

private void removeAutheticationAttributes(HttpSession session) { //??  
    if (session == null) {
        return;/* w w  w.  j  a v a2 s  . com*/
    }
    session.removeAttribute(WebAttributes.AUTHENTICATION_EXCEPTION);
}

From source file:com.excilys.ebi.bank.web.controller.LoginController.java

@RequestMapping("/public/loginFailure.html")
public String loginFailure(ModelMap model, HttpSession session, HttpServletResponse res,
        RedirectAttributes redirectAttributes) {

    Exception loginException = Exception.class
            .cast(session.getAttribute(WebAttributes.AUTHENTICATION_EXCEPTION));

    Message message = handleException(loginException);
    MessageHelper.addFlashMessage(redirectAttributes, message);

    return "redirect:/public/login.html";
}

From source file:com.greglturnquist.spring.social.ecobee.SimpleSignInAdapter.java

private void removeAuthenticationAttributes(HttpSession session) {

    if (session == null) {
        return;/*from w w w. j  av  a 2s  . c  o m*/
    }
    session.removeAttribute(WebAttributes.AUTHENTICATION_EXCEPTION);
}