Example usage for org.springframework.security.web.authentication UsernamePasswordAuthenticationFilter SPRING_SECURITY_FORM_USERNAME_KEY

List of usage examples for org.springframework.security.web.authentication UsernamePasswordAuthenticationFilter SPRING_SECURITY_FORM_USERNAME_KEY

Introduction

In this page you can find the example usage for org.springframework.security.web.authentication UsernamePasswordAuthenticationFilter SPRING_SECURITY_FORM_USERNAME_KEY.

Prototype

String SPRING_SECURITY_FORM_USERNAME_KEY

To view the source code for org.springframework.security.web.authentication UsernamePasswordAuthenticationFilter SPRING_SECURITY_FORM_USERNAME_KEY.

Click Source Link

Usage

From source file:com.edgenius.wiki.security.acegi.AuthenticationRedirectStrategy.java

@Override
public void sendRedirect(HttpServletRequest request, HttpServletResponse response, String url)
        throws IOException {

    //This parameter allow customers enable an external login form, but not from system default Ajax style login form.
    if (StringUtils.isNotEmpty(request.getParameter(EXTERNAL_LOGIN_FORM))) {
        super.sendRedirect(request, response, url);
        return;/*w  w w.j  a  v a  2  s . c  o  m*/
    }

    String username = request
            .getParameter(UsernamePasswordAuthenticationFilter.SPRING_SECURITY_FORM_USERNAME_KEY);
    if (url.indexOf(defaultFailureUrl) == -1) {
        //login success
        captchaRequiredFilterService.clean(username);
        response.getWriter().write(url);
    } else {
        //login error, re-display user name
        boolean require = captchaRequiredFilterService.reqiredCaptche(username);
        response.getOutputStream()
                .write((SharedConstants.FORM_RET_HEADER + SharedConstants.FORM_RET_HEADER_ERROR_IN_USERPASS
                        + (require ? 1 : 0) + username).getBytes(Constants.UTF8));
    }
}