Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
hphy
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
向怀芳
hphy
Commits
72342a61
Commit
72342a61
authored
Oct 21, 2022
by
向怀芳
🎱
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1. 处理账号登录锁定,返回状态码423
parent
4cf1983e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
12 deletions
+24
-12
SictWebResponseExceptionTranslator.java
...ecurity/component/SictWebResponseExceptionTranslator.java
+5
-0
UnauthorizedException.java
...loud/common/security/exception/UnauthorizedException.java
+19
-12
No files found.
cloud-common/cloud-common-security/src/main/java/cn/sh/stc/sict/cloud/common/security/component/SictWebResponseExceptionTranslator.java
View file @
72342a61
...
...
@@ -17,6 +17,8 @@ import org.springframework.security.oauth2.provider.error.WebResponseExceptionTr
import
org.springframework.security.web.util.ThrowableAnalyzer
;
import
org.springframework.web.HttpRequestMethodNotSupportedException
;
import
javax.security.auth.login.AccountLockedException
;
/**
* @Description
* @Author
...
...
@@ -37,6 +39,9 @@ public class SictWebResponseExceptionTranslator implements WebResponseExceptionT
Exception
ase
=
(
AuthenticationException
)
throwableAnalyzer
.
getFirstThrowableOfType
(
AuthenticationException
.
class
,
causeChain
);
if
(
ase
!=
null
)
{
if
(
ase
instanceof
AccountLockedException
){
return
handleOAuth2Exception
(
new
UnauthorizedException
(
e
.
getMessage
(),
e
,
HttpStatus
.
LOCKED
.
value
()));
}
return
handleOAuth2Exception
(
new
UnauthorizedException
(
e
.
getMessage
(),
e
));
}
...
...
cloud-common/cloud-common-security/src/main/java/cn/sh/stc/sict/cloud/common/security/exception/UnauthorizedException.java
View file @
72342a61
package
cn
.
sh
.
stc
.
sict
.
cloud
.
common
.
security
.
exception
;
import
cn.sh.stc.sict.cloud.common.core.util.NumberUtil
;
import
cn.sh.stc.sict.cloud.common.security.component.SictAuth2ExceptionSerializer
;
import
com.fasterxml.jackson.databind.annotation.JsonSerialize
;
import
org.springframework.http.HttpStatus
;
/**
* @author
lengleng
* @author
F_xh
* @date 2018/7/8
*/
@JsonSerialize
(
using
=
SictAuth2ExceptionSerializer
.
class
)
public
class
UnauthorizedException
extends
SictAuth2Exception
{
private
Integer
httpErrorCode
;
public
UnauthorizedException
(
String
msg
,
Throwable
t
)
{
super
(
msg
);
}
public
UnauthorizedException
(
String
msg
,
Throwable
t
)
{
super
(
msg
);
}
@Override
public
String
getOAuth2ErrorCode
()
{
return
"unauthorized"
;
}
public
UnauthorizedException
(
String
msg
,
Throwable
t
,
Integer
httpErrorCode
)
{
super
(
msg
);
this
.
httpErrorCode
=
httpErrorCode
;
}
@Override
public
int
getHttpErrorCode
()
{
return
HttpStatus
.
UNAUTHORIZED
.
value
();
}
@Override
public
String
getOAuth2ErrorCode
()
{
return
"unauthorized"
;
}
@Override
public
int
getHttpErrorCode
()
{
return
NumberUtil
.
isNullOrZero
(
this
.
httpErrorCode
)
?
HttpStatus
.
UNAUTHORIZED
.
value
()
:
this
.
httpErrorCode
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment