File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed
publish-service/src/main/java/com/ericsson/eiffel/remrem/publish/config Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change 10
10
import org .slf4j .LoggerFactory ;
11
11
import org .springframework .http .HttpStatus ;
12
12
import org .springframework .security .authentication .BadCredentialsException ;
13
+ import org .springframework .security .authentication .InsufficientAuthenticationException ;
13
14
import org .springframework .security .authentication .InternalAuthenticationServiceException ;
14
15
import org .springframework .security .core .AuthenticationException ;
15
16
import org .springframework .security .web .AuthenticationEntryPoint ;
@@ -24,8 +25,11 @@ public class CustomAuthenticationEntryPoint implements AuthenticationEntryPoint
24
25
@ Override
25
26
public void commence (HttpServletRequest request , HttpServletResponse response ,
26
27
AuthenticationException authException ) throws IOException , ServletException {
27
- if (authException instanceof BadCredentialsException ) {
28
+ if (authException instanceof BadCredentialsException ||
29
+ authException instanceof InsufficientAuthenticationException ) {
28
30
LOGGER .warn ("Bad Credentials {}" , HttpStatus .UNAUTHORIZED );
31
+ // Ensure pop-up window is opened when request comes from a web browser.
32
+ response .setHeader ("WWW-Authenticate" , "Basic" );
29
33
response .sendError (HttpServletResponse .SC_UNAUTHORIZED , "Invalid credentials" );
30
34
}
31
35
else if (authException instanceof InternalAuthenticationServiceException ) {
You can’t perform that action at this time.
0 commit comments