|
@@ -10,6 +10,7 @@ import javax.servlet.http.HttpServletResponse;
|
|
import org.apache.commons.lang3.exception.ExceptionUtils;
|
|
import org.apache.commons.lang3.exception.ExceptionUtils;
|
|
import org.codehaus.jackson.map.ObjectMapper;
|
|
import org.codehaus.jackson.map.ObjectMapper;
|
|
import org.springframework.http.MediaType;
|
|
import org.springframework.http.MediaType;
|
|
|
|
+import org.springframework.security.authentication.InsufficientAuthenticationException;
|
|
import org.springframework.security.core.AuthenticationException;
|
|
import org.springframework.security.core.AuthenticationException;
|
|
import org.springframework.security.oauth2.common.exceptions.InvalidTokenException;
|
|
import org.springframework.security.oauth2.common.exceptions.InvalidTokenException;
|
|
import org.springframework.security.web.AuthenticationEntryPoint;
|
|
import org.springframework.security.web.AuthenticationEntryPoint;
|
|
@@ -27,14 +28,14 @@ public class BaseAuthenticationEntryPoint implements AuthenticationEntryPoint {
|
|
response.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
|
|
response.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
|
|
response.setStatus(HttpServletResponse.SC_OK);
|
|
response.setStatus(HttpServletResponse.SC_OK);
|
|
PrintWriter printWriter = response.getWriter();
|
|
PrintWriter printWriter = response.getWriter();
|
|
-
|
|
|
|
|
|
+
|
|
Throwable e = ExceptionUtils.getRootCause(authException);
|
|
Throwable e = ExceptionUtils.getRootCause(authException);
|
|
if (e == null) {
|
|
if (e == null) {
|
|
e = authException;
|
|
e = authException;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
int errorCode = 500;
|
|
int errorCode = 500;
|
|
- if(e instanceof InvalidTokenException){
|
|
|
|
|
|
+ if (e instanceof InvalidTokenException || e instanceof InsufficientAuthenticationException) {
|
|
errorCode = HttpServletResponse.SC_FORBIDDEN;
|
|
errorCode = HttpServletResponse.SC_FORBIDDEN;
|
|
}
|
|
}
|
|
|
|
|