Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
zlt2000
microservices-platform
提交
91d14784
microservices-platform
项目概览
zlt2000
/
microservices-platform
9 个月 前同步成功
通知
16
Star
4
Fork
3
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
microservices-platform
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
91d14784
编写于
12月 10, 2020
作者:
zlt2000
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
优化oauth2授权错误处理
上级
0f3145f3
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
9 addition
and
12 deletion
+9
-12
zlt-uaa/src/main/java/com/central/oauth/config/SecurityHandlerConfig.java
.../java/com/central/oauth/config/SecurityHandlerConfig.java
+9
-7
zlt-uaa/src/main/java/com/central/oauth/filter/OauthTokenAspect.java
.../main/java/com/central/oauth/filter/OauthTokenAspect.java
+0
-5
未找到文件。
zlt-uaa/src/main/java/com/central/oauth/config/SecurityHandlerConfig.java
浏览文件 @
91d14784
package
com.central.oauth.config
;
import
com.central.oauth.exception.ValidateCodeException
;
import
com.central.oauth.handler.OauthLogoutHandler
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.context.annotation.Bean
;
...
...
@@ -34,19 +35,20 @@ public class SecurityHandlerConfig {
@Bean
public
WebResponseExceptionTranslator
webResponseExceptionTranslator
()
{
return
new
DefaultWebResponseExceptionTranslator
()
{
public
static
final
String
BAD_MSG
=
"坏的凭证"
;
private
static
final
String
BAD_MSG
=
"坏的凭证"
;
private
static
final
String
BAD_MSG_EN
=
"Bad credentials"
;
@Override
public
ResponseEntity
<
OAuth2Exception
>
translate
(
Exception
e
)
throws
Exception
{
OAuth2Exception
oAuth2Exception
;
if
(
e
.
getMessage
()
!=
null
&&
e
.
getMessage
().
equals
(
BAD_MSG
))
{
if
(
e
.
getMessage
()
!=
null
&&
(
BAD_MSG
.
equals
(
e
.
getMessage
())
||
BAD_MSG_EN
.
equals
(
e
.
getMessage
())))
{
oAuth2Exception
=
new
InvalidGrantException
(
"用户名或密码错误"
,
e
);
}
else
if
(
e
instanceof
InternalAuthenticationServiceException
)
{
oAuth2Exception
=
new
InvalidGrantException
(
e
.
getMessage
(),
e
);
}
else
if
(
e
instanceof
RedirectMismatchException
)
{
oAuth2Exception
=
new
InvalidGrantException
(
e
.
getMessage
(),
e
);
}
else
if
(
e
instanceof
InvalidScopeException
)
{
}
else
if
(
e
instanceof
InternalAuthenticationServiceException
||
e
instanceof
ValidateCodeException
)
{
oAuth2Exception
=
new
InvalidGrantException
(
e
.
getMessage
(),
e
);
}
else
if
(
e
instanceof
OAuth2Exception
)
{
oAuth2Exception
=
(
OAuth2Exception
)
e
;
}
else
{
oAuth2Exception
=
new
UnsupportedResponseTypeException
(
"服务内部错误"
,
e
);
}
...
...
zlt-uaa/src/main/java/com/central/oauth/filter/OauthTokenAspect.java
浏览文件 @
91d14784
...
...
@@ -63,11 +63,6 @@ public class OauthTokenAspect {
.
status
(
HttpStatus
.
OK
)
.
body
(
Result
.
succeed
(
body
));
}
}
catch
(
Exception
e
)
{
log
.
error
(
"授权错误"
,
e
);
return
ResponseEntity
.
status
(
HttpStatus
.
BAD_REQUEST
)
.
body
(
Result
.
failed
(
e
.
getMessage
()));
}
finally
{
TenantContextHolder
.
clear
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录