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.cfs.backingbean.AutenticacaoBacking.java

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

    if (e instanceof BadCredentialsException) {
        FacesContext.getCurrentInstance().getExternalContext().getSessionMap()
                .put(WebAttributes.AUTHENTICATION_EXCEPTION, null);
        FacesContext.getCurrentInstance().addMessage(null,
                new FacesMessage(FacesMessage.SEVERITY_ERROR, "Invalid username or password", null));
    }//w  ww  .  ja  v  a2s. c o m
}

From source file:com.vodafone.poms.ii.security.loginController.java

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

    if (e instanceof BadCredentialsException) {
        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"));
    }//  ww  w .ja va2s  .co  m
}

From source file:org.vaadin.spring.security.shared.VaadinUrlAuthenticationSuccessHandler.java

/**
 * Removes temporary authentication-related data which may have been stored in the session
 * during the authentication process.//from  w w  w .j av a2 s .c  o  m
 */
protected final void clearAuthenticationAttributes() {
    HttpSession session = http.getCurrentRequest().getSession(false);

    if (session == null) {
        return;
    }

    session.removeAttribute(WebAttributes.AUTHENTICATION_EXCEPTION);
}

From source file:br.com.suricattus.surispring.spring.security.controller.FormLoginController.java

@URLAction(phaseId = PhaseId.RENDER_RESPONSE)
public void addError() {
    Exception ex = (Exception) getSession().getAttribute(WebAttributes.AUTHENTICATION_EXCEPTION);
    if (ex instanceof AuthenticationException) {
        addMsgErro("javax.faces.loginFailed");
        getSession().setAttribute(WebAttributes.AUTHENTICATION_EXCEPTION, null);
    }// w w  w.j a v  a  2s  . co m
}

From source file:com.sharmila.hibernatespringsecurity.authentication.MyAuthenticationSuccessHandler.java

protected void clearAuthenticationAttribute(HttpServletRequest request) {
    HttpSession session = request.getSession();
    if (session == null) {
        return;//from   www  .j a  v a  2s .  c  om
    }
    session.removeAttribute(WebAttributes.AUTHENTICATION_EXCEPTION);
}

From source file:de.iew.web.controllers.IdentityController.java

@RequestMapping(value = "/loginerror.html")
public ModelAndView loginError(HttpServletRequest request) {
    LoginForm loginForm = createLoginForm();

    DataBinder binder = new DataBinder(loginForm);
    MutablePropertyValues mutablePropertyValues = new MutablePropertyValues(request.getParameterMap());
    binder.bind(mutablePropertyValues);/*from   w  w w  . j av a  2 s. c om*/

    ModelAndView mav = new ModelAndView(this.viewScript);
    mav.addObject(this.loginFormModelKey, loginForm);
    mav.addObject("error", true);
    mav.addObject("loginErrorMessage", "errors.login.denied.message");

    // Hole den Login Fehler und verffentliche die Fehlermeldungen
    Exception e = (Exception) request.getAttribute(WebAttributes.AUTHENTICATION_EXCEPTION);
    if (e instanceof ValidatingFormAuthenticationFilter.LoginFormValidationException) {
        ValidatingFormAuthenticationFilter.LoginFormValidationException ex = (ValidatingFormAuthenticationFilter.LoginFormValidationException) e;
        BindingResult res = ex.getErrors();
        /*
        Oh man :-D
                
        @see http://stackoverflow.com/questions/6704478/access-spring-mvc-bindingresult-from-within-a-view
         */
        mav.addObject(BindingResult.MODEL_KEY_PREFIX + this.loginFormModelKey, res);
    }

    return mav;
}

From source file:org.jutge.joc.porra.controller.desktop.DesktopAccountController.java

private void validateLoginParams(final HttpSession session, final HttpServletRequest request)
        throws LoginException {
    final AuthenticationException authenticationException = (AuthenticationException) session
            .getAttribute(WebAttributes.AUTHENTICATION_EXCEPTION);
    if (authenticationException != null) {
        final Throwable cause = authenticationException.getCause();
        if (cause instanceof LoginException) {
            final LoginException loginException = (LoginException) cause;
            throw loginException;
        }//from  ww  w .  j  ava  2  s.  com
    }
}

From source file:br.com.jreader.util.security.URLAuthenticationSuccessHandler.java

protected void clearAuthenticationAttributes(HttpServletRequest request) {
    HttpSession session = request.getSession(false);
    if (session == null) {
        return;/*w ww .j  av  a2  s. c  o  m*/
    }
    session.removeAttribute(WebAttributes.AUTHENTICATION_EXCEPTION);
}

From source file:org.businessmanager.web.jsf.listener.LoginListener.java

@Override
public void beforePhase(PhaseEvent event) {
    logger.debug("Entering phase: renderResponse");
    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, ResourceBundleAccessor.getString("login_failed"),
                        ResourceBundleAccessor.getString("login_failed")));
    }//from  w ww. j a v  a2s.  c  o  m
}

From source file:com.faujnet.signin.adapter.SimpleSignInAdapter.java

private void removeAutheticationAttributes(HttpSession session) {
    if (session == null) {
        return;/*www.j a v a  2  s  .c  om*/
    }
    session.removeAttribute(WebAttributes.AUTHENTICATION_EXCEPTION);
}