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
;
package
com
.
gavel
.
kwell
.
config
;
import
com.gavel.common.Constants
;
import
java.util.LinkedHashMap
;
import
com.gavel.common.utils.StringUtils
;
import
java.util.Map
;
import
com.gavel.framework.filter.GavelCommonLogoutFilter
;
import
com.gavel.framework.filter.ShiroAuthFilter
;
import
javax.servlet.Filter
;
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
org.apache.shiro.cache.CacheManager
;
import
org.apache.shiro.cache.CacheManager
;
import
org.apache.shiro.cache.MemoryConstrainedCacheManager
;
import
org.apache.shiro.cache.MemoryConstrainedCacheManager
;
import
org.apache.shiro.cas.CasSubjectFactory
;
import
org.apache.shiro.cas.CasSubjectFactory
;
...
@@ -24,15 +20,24 @@ import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreato
...
@@ -24,15 +20,24 @@ import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreato
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.boot.web.servlet.FilterRegistrationBean
;
import
org.springframework.boot.web.servlet.FilterRegistrationBean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.filter.DelegatingFilterProxy
;
import
org.springframework.web.filter.DelegatingFilterProxy
;
import
javax.servlet.Filter
;
import
com.gavel.common.Constants
;
import
java.util.LinkedHashMap
;
import
com.gavel.common.utils.StringUtils
;
import
java.util.Map
;
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
@Configuration
...
@@ -169,13 +174,13 @@ public class ShiroConfig {
...
@@ -169,13 +174,13 @@ public class ShiroConfig {
securityManager
.
setRealm
(
shiroRealm
());
securityManager
.
setRealm
(
shiroRealm
());
}
}
// 注入缓存管理器;
// 注入缓存管理器;
if
(
StringUtils
.
equals
(
cacheType
,
"redis"
))
if
(
StringUtils
.
equals
(
cacheType
,
"redis"
))
{
securityManager
.
setCacheManager
(
redisCacheManager
());
securityManager
.
setCacheManager
(
redisCacheManager
());
securityManager
.
setSessionManager
(
sessionManager
());
}
else
else
securityManager
.
setCacheManager
(
cacheManager
());
securityManager
.
setCacheManager
(
cacheManager
());
securityManager
.
setSessionManager
(
sessionManager
());
return
securityManager
;
return
securityManager
;
}
}
...
@@ -224,7 +229,6 @@ public class ShiroConfig {
...
@@ -224,7 +229,6 @@ public class ShiroConfig {
* @return
* @return
*/
*/
@Bean
(
"redisManager"
)
@Bean
(
"redisManager"
)
// @ConditionalOnProperty(value="shiro.cache", havingValue="redis", matchIfMissing=false)
public
RedisManager
redisManager
()
{
public
RedisManager
redisManager
()
{
RedisManager
redisManager
=
new
RedisManager
();
RedisManager
redisManager
=
new
RedisManager
();
redisManager
.
setHost
(
redisConfig
.
getHost
()+
":"
+
redisConfig
.
getPort
());
redisManager
.
setHost
(
redisConfig
.
getHost
()+
":"
+
redisConfig
.
getPort
());
...
@@ -236,7 +240,6 @@ public class ShiroConfig {
...
@@ -236,7 +240,6 @@ public class ShiroConfig {
*
*
* @return
* @return
*/
*/
@ConditionalOnProperty
(
value
=
"shiro.cache"
,
havingValue
=
"redis"
,
matchIfMissing
=
false
)
@Bean
@Bean
public
RedisCacheManager
redisCacheManager
()
{
public
RedisCacheManager
redisCacheManager
()
{
RedisCacheManager
redisCacheManager
=
new
RedisCacheManager
();
RedisCacheManager
redisCacheManager
=
new
RedisCacheManager
();
...
@@ -247,25 +250,23 @@ public class ShiroConfig {
...
@@ -247,25 +250,23 @@ public class ShiroConfig {
/**
/**
* redisSessionDAO
* redisSessionDAO
*/
*/
// @ConditionalOnProperty(value="shiro.cache", havingValue="redis", matchIfMissing=false)
@Bean
(
"redisSessionDAO"
)
@Bean
(
"redisSessionDAO"
)
public
RedisSessionDAO
redisSessionDAO
()
{
public
RedisSessionDAO
redisSessionDAO
()
{
RedisSessionDAO
redisSessionDAO
=
new
RedisSessionDAO
();
RedisSessionDAO
redisSessionDAO
=
new
RedisSessionDAO
();
redisSessionDAO
.
setRedisManager
(
redisManager
());
redisSessionDAO
.
setRedisManager
(
redisManager
());
// redisSessionDAO.setSessionIdGenerator(new GavelSessionGenerator());
return
redisSessionDAO
;
return
redisSessionDAO
;
}
}
/**
/**
* sessionManager
* sessionManager
*/
*/
// @ConditionalOnProperty(value="shiro.cache", havingValue="redis", matchIfMissing=false)
@Bean
(
"sessionManager"
)
@Bean
(
"sessionManager"
)
public
GavelSessionManager
sessionManager
()
{
public
GavelSessionManager
sessionManager
()
{
// DefaultWebSessionManager sessionManager = new DefaultWebSessionManager();
GavelSessionManager
sessionManager
=
new
GavelSessionManager
();
GavelSessionManager
sessionManager
=
new
GavelSessionManager
();
sessionManager
.
setGlobalSessionTimeout
(
Constants
.
liveMills
);
sessionManager
.
setGlobalSessionTimeout
(
Constants
.
liveMills
);
if
(
StringUtils
.
equals
(
cacheType
,
"redis"
)){
sessionManager
.
setSessionDAO
(
redisSessionDAO
());
sessionManager
.
setSessionDAO
(
redisSessionDAO
());
}
return
sessionManager
;
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