|
@@ -6,6 +6,8 @@ import com.alibaba.fastjson.JSON;
|
|
import com.zhongzheng.common.core.domain.AjaxResult;
|
|
import com.zhongzheng.common.core.domain.AjaxResult;
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
import com.zhongzheng.common.utils.ServletUtils;
|
|
import com.zhongzheng.common.utils.ServletUtils;
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
import org.springframework.security.authentication.BadCredentialsException;
|
|
import org.springframework.security.authentication.BadCredentialsException;
|
|
import org.springframework.security.core.AuthenticationException;
|
|
import org.springframework.security.core.AuthenticationException;
|
|
import org.springframework.security.web.AuthenticationEntryPoint;
|
|
import org.springframework.security.web.AuthenticationEntryPoint;
|
|
@@ -28,11 +30,17 @@ public class AuthenticationEntryPointImpl implements AuthenticationEntryPoint, S
|
|
{
|
|
{
|
|
private static final long serialVersionUID = -8970718410437077606L;
|
|
private static final long serialVersionUID = -8970718410437077606L;
|
|
|
|
|
|
|
|
+ private static Logger log = LoggerFactory.getLogger(AuthenticationEntryPointImpl.class);
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException e)
|
|
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException e)
|
|
throws IOException
|
|
throws IOException
|
|
{
|
|
{
|
|
int code = HttpStatus.HTTP_UNAUTHORIZED;
|
|
int code = HttpStatus.HTTP_UNAUTHORIZED;
|
|
|
|
+ String tenantId = request.getHeader("TenantId");
|
|
|
|
+ String token = request.getHeader("AuthorizationToken");
|
|
|
|
+ log.error(String.format("token: %s",token));
|
|
|
|
+ log.error(String.format("tenantId: %s",tenantId));
|
|
String msg = StrUtil.format("请求访问:{},认证失败,无法访问系统资源", request.getRequestURI());
|
|
String msg = StrUtil.format("请求访问:{},认证失败,无法访问系统资源", request.getRequestURI());
|
|
ServletUtils.renderString(response, JSON.toJSONString(AjaxResult.error(code, msg)));
|
|
ServletUtils.renderString(response, JSON.toJSONString(AjaxResult.error(code, msg)));
|
|
}
|
|
}
|