Skip to content

Instantly share code, notes, and snippets.

@ivanursul
Last active August 29, 2015 14:25
Show Gist options
  • Select an option

  • Save ivanursul/1c475d8939f070e8cf93 to your computer and use it in GitHub Desktop.

Select an option

Save ivanursul/1c475d8939f070e8cf93 to your computer and use it in GitHub Desktop.
CustomBasicAuthenticationEntryPoint.java for www.ivanursul.com
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