/FileExtraction/Java_unseen/asarkar_spring/daily-update-microservices/auth-service/src/main/java/name/abhijitsarkar/javaee/auth/web/SuccessHandlingBasicAuthenticationFilter.java
package name.abhijitsarkar.javaee.auth.web;

import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.www.BasicAuthenticationFilter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author Abhijit Sarkar
 */
public class SuccessHandlingBasicAuthenticationFilter extends BasicAuthenticationFilter {
    public SuccessHandlingBasicAuthenticationFilter(AuthenticationManager authenticationManager) {
        super(authenticationManager);
    }

    @Override
    protected void onSuccessfulAuthentication(HttpServletRequest request, HttpServletResponse response, Authentication authResult) throws IOException {
        super.onSuccessfulAuthentication(request, response, authResult);

        request.setAttribute("authenticated", true);
    }
}
