class FormBasedBasicAuthenticationEntryPoint extends BasicAuthenticationEntryPoint {
public FormBasedBasicAuthenticationEntryPoint() {
this("Realm");
}
public FormBasedBasicAuthenticationEntryPoint(String realmName) {
setRealmName(realmName);
}
@Override
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException {
response.addHeader("WWW-Authenticate", "FormBased");
response.sendError(HttpStatus.UNAUTHORIZED.value(), HttpStatus.UNAUTHORIZED.getReasonPhrase());
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter