av一区二区在线观看_亚洲男人的天堂网站_日韩亚洲视频_在线成人免费_欧美日韩精品免费观看视频_久草视

您的位置:首頁技術(shù)文章
文章詳情頁

java - shiro anon 不生效

瀏覽:95日期:2023-12-25 11:23:16

問題描述

在使用springboot整合shiro的過程中,希望靜態(tài)資源資源不受shiro過濾器‘a(chǎn)uthc’攔截,于是定義了“anon”,測試發(fā)現(xiàn)根本不生效,靜態(tài)資源路徑下的資源(如/js/**)依舊會被攔截并重定向到/login,以下是我的shiro javaconfig

ShiroConfig.java

@Configurationpublic class ShiroConfig { @Value('${shiro.credentialsMatcher.hashIterations}') private int hashIterations; @Value('${shiro.credentialsMatcher.storedCredentialsHexEncoded}') private boolean storedCredentialsHexEncoded; @Configuration protected static class Processor {@Beanpublic LifecycleBeanPostProcessor lifecycleBeanPostProcessor() { return new LifecycleBeanPostProcessor();}@Bean@DependsOn('lifecycleBeanPostProcessor')public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() { final DefaultAdvisorAutoProxyCreator proxyCreator = new DefaultAdvisorAutoProxyCreator(); proxyCreator.setProxyTargetClass(true); return proxyCreator;}@Beanpublic AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(DefaultWebSecurityManager securityManager) { AuthorizationAttributeSourceAdvisor advisor = new AuthorizationAttributeSourceAdvisor(); advisor.setSecurityManager(securityManager); return advisor;} } @Bean('credentialsMatcher') public HashedCredentialsMatcher getCredentialsMatcher() {HashedCredentialsMatcher credentialsMatcher = new HashedCredentialsMatcher();credentialsMatcher.setHashAlgorithmName('MD5');credentialsMatcher.setHashIterations(hashIterations);credentialsMatcher.setStoredCredentialsHexEncoded(storedCredentialsHexEncoded);return credentialsMatcher; } @Bean(name = 'shiroEhcacheManager') @DependsOn('lifecycleBeanPostProcessor') public EhCacheManager getEhCacheManager() {EhCacheManager em = new EhCacheManager();em.setCacheManagerConfigFile('classpath:conf/shiro-ehcache.xml');return em; } @Bean('userRealm') @DependsOn('lifecycleBeanPostProcessor') public UserRealm getUserRealm(HashedCredentialsMatcher credentialsMatcher) {UserRealm userRealm = new UserRealm();userRealm.setCachingEnabled(false);userRealm.setCredentialsMatcher(credentialsMatcher);return userRealm; } @Bean('securityManager') public DefaultWebSecurityManager getSecurityManager(UserRealm userRealm) {DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();securityManager.setCacheManager(getEhCacheManager());securityManager.setRealm(userRealm);return securityManager; } @Bean('shiroFilter') public ShiroFilterFactoryBean getShiroFilter(DefaultWebSecurityManager securityManager) {ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();shiroFilterFactoryBean.setSecurityManager(securityManager);Map<String, String> filterChainDefinitionMap = Maps.newHashMap();filterChainDefinitionMap.put('/css/**', 'anon');filterChainDefinitionMap.put('/img/**', 'anon');filterChainDefinitionMap.put('/js/**', 'anon');filterChainDefinitionMap.put('/plugins/**', 'anon');filterChainDefinitionMap.put('/error/**', 'anon');filterChainDefinitionMap.put('/login', 'authc');filterChainDefinitionMap.put('/logout', 'logout');filterChainDefinitionMap.put('/**', 'authc');shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);shiroFilterFactoryBean.setLoginUrl('/login');shiroFilterFactoryBean.setSuccessUrl('/');shiroFilterFactoryBean.setUnauthorizedUrl('/login');return shiroFilterFactoryBean; }}

請指正

問題解答

回答1:

解決了,filterChainDefinitionMap應(yīng)當(dāng)為LinkedHashMap

標(biāo)簽: java
相關(guān)文章:
主站蜘蛛池模板: 日韩精品一区二区三区视频播放 | 五月槐花香| 欧美一区二区三区在线观看视频 | 欧产日产国产精品v | 97视频久久 | 国产高潮好爽受不了了夜色 | 一级做a爰片性色毛片 | 欧美日韩国产欧美 | 国产成人免费视频网站高清观看视频 | 国产精品mv在线观看 | 久久久久久电影 | 久久99精品久久久 | 欧美一区二区三区在线看 | 亚洲欧美精品在线 | 日本精品一区 | 国产精品视频久久久 | 免费在线观看av的网站 | 午夜精| 欧美99久久精品乱码影视 | 久久精品综合 | 国产精品99久久久久久宅男 | 99热激情 | 亚洲精品视频免费 | 天天干天天操天天射 | 91久久精品国产91久久性色tv | 精品视频一区二区 | 91精品国产91久久久久久密臀 | 日本字幕在线观看 | 日本涩涩网 | 日本在线一区二区 | 99re在线 | 断背山在线观看 | 黄色一级电影在线观看 | 性网站免费 | 国产精品久久国产精品99 gif | 成人在线视频看看 | 久久久久久久一区 | 日韩欧美二区 | 国产精品毛片 | 日韩在线h | www.色.com|