Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
K
kwell-mes
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
gavelinfo
kwell-mes
Commits
85014ca2
Commit
85014ca2
authored
Jun 14, 2022
by
周毅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改shiroconfig
parent
98c2aa36
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
23 deletions
+24
-23
ShiroConfig.java
gavel/src/main/java/com/gavel/kwell/config/ShiroConfig.java
+24
-23
No files found.
gavel/src/main/java/com/gavel/kwell/config/ShiroConfig.java
View file @
85014ca2
package
com
.
gavel
.
kwell
.
config
;
import
com.gavel.common.Constants
;
import
com.gavel.common.utils.StringUtils
;
import
com.gavel.framework.filter.GavelCommonLogoutFilter
;
import
com.gavel.framework.filter.ShiroAuthFilter
;
import
com.gavel.kzzx.auth.cas.GavelAuthenticationFilter
;
import
com.gavel.kzzx.auth.cas.GavelCasFilter
;
import
com.gavel.kzzx.auth.cas.GavelCasRealm
;
import
com.gavel.kzzx.auth.cas.GavelLogoutFilter
;
import
com.gavel.kzzx.auth.shiro.*
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
javax.servlet.Filter
;
import
org.apache.shiro.cache.CacheManager
;
import
org.apache.shiro.cache.MemoryConstrainedCacheManager
;
import
org.apache.shiro.cas.CasSubjectFactory
;
...
...
@@ -24,15 +20,24 @@ import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreato
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.boot.web.servlet.FilterRegistrationBean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.filter.DelegatingFilterProxy
;
import
javax.servlet.Filter
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
com.gavel.common.Constants
;
import
com.gavel.common.utils.StringUtils
;
import
com.gavel.framework.filter.GavelCommonLogoutFilter
;
import
com.gavel.framework.filter.ShiroAuthFilter
;
import
com.gavel.kzzx.auth.cas.GavelAuthenticationFilter
;
import
com.gavel.kzzx.auth.cas.GavelCasFilter
;
import
com.gavel.kzzx.auth.cas.GavelCasRealm
;
import
com.gavel.kzzx.auth.cas.GavelLogoutFilter
;
import
com.gavel.kzzx.auth.shiro.GavelAuthResource
;
import
com.gavel.kzzx.auth.shiro.GavelAuthorizationAttributeSourceAdvisor
;
import
com.gavel.kzzx.auth.shiro.GavelAuthorizingRealm
;
import
com.gavel.kzzx.auth.shiro.GavelHashedCredentialsMatcher
;
import
com.gavel.kzzx.auth.shiro.GavelSessionManager
;
@Configuration
...
...
@@ -169,13 +174,13 @@ public class ShiroConfig {
securityManager
.
setRealm
(
shiroRealm
());
}
// 注入缓存管理器;
if
(
StringUtils
.
equals
(
cacheType
,
"redis"
))
if
(
StringUtils
.
equals
(
cacheType
,
"redis"
))
{
securityManager
.
setCacheManager
(
redisCacheManager
());
securityManager
.
setSessionManager
(
sessionManager
());
}
else
securityManager
.
setCacheManager
(
cacheManager
());
securityManager
.
setSessionManager
(
sessionManager
());
return
securityManager
;
}
...
...
@@ -224,7 +229,6 @@ public class ShiroConfig {
* @return
*/
@Bean
(
"redisManager"
)
// @ConditionalOnProperty(value="shiro.cache", havingValue="redis", matchIfMissing=false)
public
RedisManager
redisManager
()
{
RedisManager
redisManager
=
new
RedisManager
();
redisManager
.
setHost
(
redisConfig
.
getHost
()+
":"
+
redisConfig
.
getPort
());
...
...
@@ -236,7 +240,6 @@ public class ShiroConfig {
*
* @return
*/
@ConditionalOnProperty
(
value
=
"shiro.cache"
,
havingValue
=
"redis"
,
matchIfMissing
=
false
)
@Bean
public
RedisCacheManager
redisCacheManager
()
{
RedisCacheManager
redisCacheManager
=
new
RedisCacheManager
();
...
...
@@ -247,25 +250,23 @@ public class ShiroConfig {
/**
* redisSessionDAO
*/
// @ConditionalOnProperty(value="shiro.cache", havingValue="redis", matchIfMissing=false)
@Bean
(
"redisSessionDAO"
)
public
RedisSessionDAO
redisSessionDAO
()
{
RedisSessionDAO
redisSessionDAO
=
new
RedisSessionDAO
();
redisSessionDAO
.
setRedisManager
(
redisManager
());
// redisSessionDAO.setSessionIdGenerator(new GavelSessionGenerator());
return
redisSessionDAO
;
}
/**
* sessionManager
*/
// @ConditionalOnProperty(value="shiro.cache", havingValue="redis", matchIfMissing=false)
@Bean
(
"sessionManager"
)
public
GavelSessionManager
sessionManager
()
{
// DefaultWebSessionManager sessionManager = new DefaultWebSessionManager();
GavelSessionManager
sessionManager
=
new
GavelSessionManager
();
sessionManager
.
setGlobalSessionTimeout
(
Constants
.
liveMills
);
if
(
StringUtils
.
equals
(
cacheType
,
"redis"
)){
sessionManager
.
setSessionDAO
(
redisSessionDAO
());
}
return
sessionManager
;
}
...
...
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