Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
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
434ce2ce
Commit
434ce2ce
authored
Oct 21, 2022
by
向怀芳
🎱
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1. 新增账号锁定功能
parent
f8249b11
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
3 deletions
+43
-3
bootstrap-dev.yml
cloud-auth/src/main/resources/bootstrap-dev.yml
+1
-3
GlobalExceptionHandlerResolver.java
...on/security/component/GlobalExceptionHandlerResolver.java
+24
-0
ReloadMessageConfig.java
...ict/cloud/common/security/config/ReloadMessageConfig.java
+18
-0
No files found.
cloud-auth/src/main/resources/bootstrap-dev.yml
View file @
434ce2ce
...
@@ -15,6 +15,4 @@ spring:
...
@@ -15,6 +15,4 @@ spring:
config
:
config
:
namespace
:
be9383c3-e535-4e9c-81ab-a8c6b7ecdc82
namespace
:
be9383c3-e535-4e9c-81ab-a8c6b7ecdc82
file-extension
:
yml
file-extension
:
yml
shared-dataids
:
application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
shared-dataids
:
application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
shared-configs
:
\ No newline at end of file
-
application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
cloud-common/cloud-common-security/src/main/java/cn/sh/stc/sict/cloud/common/security/component/GlobalExceptionHandlerResolver.java
View file @
434ce2ce
...
@@ -7,6 +7,7 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -7,6 +7,7 @@ import lombok.extern.slf4j.Slf4j;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.converter.HttpMessageNotReadableException
;
import
org.springframework.http.converter.HttpMessageNotReadableException
;
import
org.springframework.security.access.AccessDeniedException
;
import
org.springframework.security.access.AccessDeniedException
;
import
org.springframework.security.authentication.BadCredentialsException
;
import
org.springframework.security.core.SpringSecurityMessageSource
;
import
org.springframework.security.core.SpringSecurityMessageSource
;
import
org.springframework.validation.BindException
;
import
org.springframework.validation.BindException
;
import
org.springframework.validation.FieldError
;
import
org.springframework.validation.FieldError
;
...
@@ -18,6 +19,7 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
...
@@ -18,6 +19,7 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
import
org.springframework.web.bind.annotation.ResponseStatus
;
import
org.springframework.web.bind.annotation.ResponseStatus
;
import
org.springframework.web.bind.annotation.RestControllerAdvice
;
import
org.springframework.web.bind.annotation.RestControllerAdvice
;
import
javax.security.auth.login.AccountLockedException
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.validation.ConstraintViolationException
;
import
javax.validation.ConstraintViolationException
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -77,6 +79,28 @@ public class GlobalExceptionHandlerResolver {
...
@@ -77,6 +79,28 @@ public class GlobalExceptionHandlerResolver {
return
objectR
;
return
objectR
;
}
}
@ExceptionHandler
({
BadCredentialsException
.
class
})
@ResponseStatus
(
HttpStatus
.
OK
)
public
R
handleBadCredentialsException
(
BadCredentialsException
exception
)
{
R
<
Object
>
objectR
=
R
.
builder
()
.
code
(
Constant
.
BYTE_NO
)
.
msg
(
exception
.
getMessage
())
.
build
();
return
objectR
;
}
@ExceptionHandler
({
AccountLockedException
.
class
})
@ResponseStatus
(
HttpStatus
.
OK
)
public
R
handleBAccountLockedException
(
AccountLockedException
exception
)
{
R
<
Object
>
objectR
=
R
.
builder
()
.
code
(
Constant
.
BYTE_NO
)
.
msg
(
exception
.
getMessage
())
.
build
();
return
objectR
;
}
/**
/**
* AccessDeniedException
* AccessDeniedException
*
*
...
...
cloud-common/cloud-common-security/src/main/java/cn/sh/stc/sict/cloud/common/security/config/ReloadMessageConfig.java
0 → 100644
View file @
434ce2ce
package
cn
.
sh
.
stc
.
sict
.
cloud
.
common
.
security
.
config
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.support.ReloadableResourceBundleMessageSource
;
//security中文提示信息配置类
@Configuration
public
class
ReloadMessageConfig
{
@Bean
//加载中文认证提示信息
public
ReloadableResourceBundleMessageSource
messageSource
(){
ReloadableResourceBundleMessageSource
messageSource
=
new
ReloadableResourceBundleMessageSource
();
//加载org/springframework/security包下的中文提示信息 配置文件
messageSource
.
setBasename
(
"classpath:security/messages_zh_CN"
);
return
messageSource
;
}
}
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