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)文章:
主站蜘蛛池模板: 日韩国产在线观看 | 国产一区二区三区视频 | 91综合网 | 久久久影院 | 亚洲久草 | 久久综合久久自在自线精品自 | 国产伦一区二区三区久久 | 国产资源在线播放 | 观看av | 韩国av网站在线观看 | 激情五月婷婷在线 | 久久久国产一区 | 成人av在线播放 | www.亚洲视频| 久久亚洲欧美日韩精品专区 | 欧美在线国产精品 | 亚洲成av人片在线观看无码 | 91在线电影 | 99热.com| 国产丝袜一区二区三区免费视频 | 99久久精品一区二区成人 | 日韩欧美一级精品久久 | 成人依人| 精品一二三区视频 | 国产视频在线观看一区二区三区 | 中文字幕在线视频免费观看 | 欧美视频免费在线观看 | 欧美综合一区二区三区 | 成人免费观看视频 | 久久国产精品偷 | 亚洲精品一区二区网址 | 狠狠操在线 | 欧美天堂 | 一区二区av| 亚洲精品国产精品国自产在线 | 盗摄精品av一区二区三区 | 色婷婷综合在线观看 | 日韩午夜在线观看 | 国产激情在线观看 | se婷婷| 一区二区激情 |