25
25
import org .apache .shiro .cache .MemoryConstrainedCacheManager ;
26
26
import org .apache .shiro .mgt .DefaultSecurityManager ;
27
27
import org .apache .shiro .mgt .SecurityManager ;
28
+ import org .apache .shiro .realm .AuthorizingRealm ;
29
+ import org .apache .shiro .realm .Realm ;
28
30
import org .apache .shiro .session .mgt .DefaultSessionManager ;
29
31
import org .apache .shiro .spring .LifecycleBeanPostProcessor ;
30
32
import org .apache .shiro .spring .web .ShiroFilterFactoryBean ;
60
62
import org .springframework .web .bind .annotation .ResponseStatus ;
61
63
import org .springframework .web .bind .annotation .RestControllerAdvice ;
62
64
65
+ import java .util .ArrayList ;
63
66
import java .util .Collections ;
64
67
import java .util .List ;
65
68
@@ -78,6 +81,9 @@ public class ShiroAutoconfiguration {
78
81
@ Autowired
79
82
private ShiroProperties shiroProperties ;
80
83
84
+ @ Autowired (required = false )
85
+ private List <DataAccessHandler > dataAccessHandlers ;
86
+
81
87
@ Bean
82
88
public CacheManager shiroCacheManager () {
83
89
if (cacheManager == null ) {
@@ -101,36 +107,27 @@ public LifecycleBeanPostProcessor getLifecycleBeanPostProcessor() {
101
107
102
108
@ Bean (name = "securityManager" )
103
109
@ ConditionalOnWebApplication
104
- public DefaultWebSecurityManager defaultWebSecurityManager (ListenerAuthorizingRealm authorizingRealm ) {
110
+ public DefaultWebSecurityManager defaultWebSecurityManager (List <AuthorizingRealm > authorizingRealm ,
111
+ CacheManager cacheManager ) {
105
112
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager ();
106
- securityManager .setRealm ( authorizingRealm );
107
- securityManager .setCacheManager (authorizingRealm . getCacheManager () );
113
+ securityManager .setRealms ( new ArrayList <>( authorizingRealm ) );
114
+ securityManager .setCacheManager (cacheManager );
108
115
SecurityUtils .setSecurityManager (securityManager );
109
116
return securityManager ;
110
117
}
111
118
112
119
@ Bean (name = "securityManager" )
113
120
@ ConditionalOnNotWebApplication
114
- public DefaultSecurityManager defaultSecurityManager (ListenerAuthorizingRealm authorizingRealm ) {
121
+ public DefaultSecurityManager defaultSecurityManager (List <AuthorizingRealm > authorizingRealm ,
122
+ CacheManager cacheManager ) {
115
123
DefaultSecurityManager securityManager = new DefaultSecurityManager ();
116
- securityManager .setRealm ( authorizingRealm );
117
- securityManager .setCacheManager (authorizingRealm . getCacheManager () );
124
+ securityManager .setRealms ( new ArrayList <>( authorizingRealm ) );
125
+ securityManager .setCacheManager (cacheManager );
118
126
securityManager .setSessionManager (new DefaultSessionManager ());
119
127
SecurityUtils .setSecurityManager (securityManager );
120
128
return securityManager ;
121
129
}
122
130
123
- // @Bean
124
- // @ConditionalOnMissingBean
125
- // public DefaultAdvisorAutoProxyCreator getDefaultAdvisorAutoProxyCreator() {
126
- // DefaultAdvisorAutoProxyCreator advisorAutoProxyCreator = new DefaultAdvisorAutoProxyCreator();
127
- // advisorAutoProxyCreator.setProxyTargetClass(true);
128
- // return advisorAutoProxyCreator;
129
- // }
130
-
131
- @ Autowired (required = false )
132
- private List <DataAccessHandler > dataAccessHandlers ;
133
-
134
131
@ Bean
135
132
@ ConditionalOnMissingBean
136
133
public DefaultDataAccessController defaultDataAccessController () {
0 commit comments