Spring security 带有EhCache 3的Spring安全ACL
我试图更新到EhCache 3,但注意到我的用于spring安全acl的AclConfig不再工作。原因是Spring security 带有EhCache 3的Spring安全ACL,spring-security,ehcache,ehcache-3,spring-security-acl,Spring Security,Ehcache,Ehcache 3,Spring Security Acl,我试图更新到EhCache 3,但注意到我的用于spring安全acl的AclConfig不再工作。原因是ehcachebasedaccache仍然使用import net.sf.ehcache.ehcache。从版本3开始,EhCache被移动到org.EhCache,因此不再工作。spring是否为EhCache 3提供了替换类,或者我是否需要实现自己的Acl缓存? 这是不再有效的代码: @Bean public EhCacheBasedAclCache aclCache() { r
ehcachebasedaccache
仍然使用import net.sf.ehcache.ehcache
。从版本3开始,EhCache被移动到org.EhCache
,因此不再工作。spring是否为EhCache 3提供了替换类,或者我是否需要实现自己的Acl缓存?
这是不再有效的代码:
@Bean
public EhCacheBasedAclCache aclCache() {
return new EhCacheBasedAclCache(aclEhCacheFactoryBean().getObject(),
permissionGrantingStrategy(), aclAuthorizationStrategy());
}
我在你的问题中添加了赏金,因为我也在寻找更权威的答案。
这里有一个可行的解决方案,但可能有更好的方法&缓存设置可以专门针对acl进行调整 1)
JdbcMutableAclService
接受任何AclCache
实现,而不仅仅是ehcachebasedaccache
。立即可用的实现是springcachebasedaccache
。您还可以实现自己的
2) 在项目中启用ehcache3,并将SpringCache作为抽象。在Spring Boot中,这与使用@EnableCache
注释一样简单。然后在bean配置类中添加@Autowired CacheManager CacheManager
3) 使用aclCache的条目更新您的ehcache3.xml注意-键是可序列化的,因为Spring acl会插入在Long和ObjectIdentity上都设置了键的缓存项:)
5) 在
JdbcMutableAclService
constructor中使用aclCache()
找到任何解决方案了吗?在这里看不到牵引力后,我放弃了更新。我可能会在今年晚些时候再试一次,如果我找到了解决办法,我会回答这个问题。
<cache alias="aclCache">
<key-type>java.io.Serializable</key-type>
<value-type>org.springframework.security.acls.model.MutableAcl</value-type>
<expiry>
<ttl unit="seconds">3600</ttl>
</expiry>
<resources>
<heap unit="entries">2000</heap>
<offheap unit="MB">10</offheap>
</resources>
</cache>
@Bean
public AclCache aclCache() {
return new SpringCacheBasedAclCache(
cacheManager.getCache("aclCache"),
permissionGrantingStrategy(),
aclAuthorizationStrategy());
}