Last active
August 29, 2015 14:25
-
-
Save ivanursul/1c475d8939f070e8cf93 to your computer and use it in GitHub Desktop.
CustomBasicAuthenticationEntryPoint.java for www.ivanursul.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package org.ivanursul.security; | |
| import java.io.IOException; | |
| import javax.servlet.ServletException; | |
| import javax.servlet.http.HttpServletRequest; | |
| import javax.servlet.http.HttpServletResponse; | |
| import org.springframework.security.core.AuthenticationException; | |
| import org.springframework.security.web.authentication.www.BasicAuthenticationEntryPoint; | |
| public class CustomBasicAuthenticationEntryPoint extends | |
| BasicAuthenticationEntryPoint { | |
| public CustomBasicAuthenticationEntryPoint(String realmName) { | |
| setRealmName(realmName); | |
| } | |
| @Override | |
| public void commence(final HttpServletRequest request, final HttpServletResponse response, final AuthenticationException authException) throws IOException, ServletException { | |
| response.sendError(HttpServletResponse.SC_UNAUTHORIZED, authException.getMessage()); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment