All Downloads are FREE. Search and download functionalities are using the official Maven repository.

fr.zebasto.spring.identity.rest.security.RestAuthenticationFailureHandler Maven / Gradle / Ivy

There is a newer version: 1.0.0-BETA2
Show newest version
package fr.zebasto.spring.identity.rest.security;

import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler;

import javax.inject.Named;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Manage post successful authentication actions.
 *  Returns forbidden HTTP error code
 *
 * @author Houssem BELHADJ AHMED
 * @since 1.0.0
 */
@Named("restAuthenticationFailureHandler")
public class RestAuthenticationFailureHandler extends SimpleUrlAuthenticationFailureHandler {
    @Override
    public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException {
        response.sendError(HttpServletResponse.SC_FORBIDDEN, "Wrong username or password");
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy