@ -1,381 +1,381 @@
/* */ package com.archive.framework.config
package com.archive.framework.config
;
/* */
/* */ import at.pollux.thymeleaf.shiro.dialect.ShiroDialect ;
/* */ import com.archive.common.utils.StringUtils ;
/* */ import com.archive.common.utils.spring.SpringUtils ;
/* */ import com.archive.framework.shiro.realm.UserRealm ;
/* */ import com.archive.framework.shiro.session.OnlineSessionDAO ;
/* */ import com.archive.framework.shiro.session.OnlineSessionFactory ;
/* */ import com.archive.framework.shiro.web.filter.LogoutFilter ;
/* */ import com.archive.framework.shiro.web.filter.captcha.CaptchaValidateFilter ;
/* */ import com.archive.framework.shiro.web.filter.kickout.KickoutSessionFilter ;
/* */ import com.archive.framework.shiro.web.filter.online.OnlineSessionFilter ;
/* */ import com.archive.framework.shiro.web.filter.sync.SyncOnlineSessionFilter ;
/* */ import com.archive.framework.shiro.web.session.OnlineWebSessionManager ;
/* */ import com.archive.framework.shiro.web.session.SpringSessionValidationScheduler ;
/* */ import java.io.ByteArrayInputStream ;
/* */ import java.io.IOException ;
/* */ import java.io.InputStream ;
/* */ import java.util.LinkedHashMap ;
/* */ import java.util.Map ;
/* */ import javax.servlet.Filter ;
/* */ import net.sf.ehcache.CacheManager ;
/* */ import org.apache.commons.io.IOUtils ;
/* */
/* */ import org.apache.shiro.cache.ehcache.EhCacheManager ;
/* */ import org.apache.shiro.codec.Base64 ;
/* */ import org.apache.shiro.config.ConfigurationException ;
/* */ import org.apache.shiro.io.ResourceUtils ;
/* */ import org.apache.shiro.mgt.RememberMeManager ;
/* */ import org.apache.shiro.mgt.SecurityManager ;
/* */ import org.apache.shiro.realm.Realm ;
/* */ import org.apache.shiro.session.mgt.SessionFactory ;
/* */ import org.apache.shiro.session.mgt.SessionManager ;
/* */ import org.apache.shiro.session.mgt.SessionValidationScheduler ;
/* */ import org.apache.shiro.session.mgt.eis.SessionDAO ;
/* */ import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor ;
/* */ import org.apache.shiro.spring.web.ShiroFilterFactoryBean ;
/* */ import org.apache.shiro.web.mgt.CookieRememberMeManager ;
/* */ import org.apache.shiro.web.mgt.DefaultWebSecurityManager ;
/* */ import org.apache.shiro.web.servlet.Cookie ;
/* */ import org.apache.shiro.web.servlet.SimpleCookie ;
/* */ import org.springframework.beans.factory.annotation.Qualifier ;
/* */ import org.springframework.beans.factory.annotation.Value ;
/* */ import org.springframework.context.annotation.Bean ;
/* */ import org.springframework.context.annotation.Configuration ;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ @Configuration
/* */ public class ShiroConfig
/* */ {
/* */ @Value ( "${shiro.session.expireTime}" )
/* */ private int expireTime ;
/* */ @Value ( "${shiro.session.validationInterval}" )
/* */ private int validationInterval ;
/* */ @Value ( "${shiro.session.maxSession}" )
/* */ private int maxSession ;
/* */ @Value ( "${shiro.session.kickoutAfter}" )
/* */ private boolean kickoutAfter ;
/* */ @Value ( "${shiro.user.captchaEnabled}" )
/* */ private boolean captchaEnabled ;
/* */ @Value ( "${shiro.user.captchaType}" )
/* */ private String captchaType ;
/* */ @Value ( "${shiro.cookie.domain}" )
/* */ private String domain ;
/* */ @Value ( "${shiro.cookie.path}" )
/* */ private String path ;
/* */ @Value ( "${shiro.cookie.httpOnly}" )
/* */ private boolean httpOnly ;
/* */ @Value ( "${shiro.cookie.maxAge}" )
/* */ private int maxAge ;
/* */ @Value ( "${shiro.cookie.cipherKey}" )
/* */ private String cipherKey ;
/* */ @Value ( "${shiro.user.loginUrl}" )
/* */ private String loginUrl ;
/* */ @Value ( "${shiro.user.unauthorizedUrl}" )
/* */ private String unauthorizedUrl ;
/* */
/* */ @Bean
/* */ public EhCacheManager getEhCacheManager ( ) {
/* 105 */ CacheManager cacheManager = CacheManager . getCacheManager ( "archive" ) ;
/* 106 */ EhCacheManager em = new EhCacheManager ( ) ;
/* 107 */ if ( StringUtils . isNull ( cacheManager ) ) {
/* */
/* 109 */ em . setCacheManager ( new CacheManager ( getCacheManagerConfigFileInputStream ( ) ) ) ;
/* 110 */ return em ;
/* */ }
/* */
/* */
/* 114 */ em . setCacheManager ( cacheManager ) ;
/* 115 */ return em ;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */ protected InputStream getCacheManagerConfigFileInputStream ( ) {
/* 124 */ String configFile = "classpath:ehcache/ehcache-shiro.xml" ;
/* 125 */ InputStream inputStream = null ;
/* */
/* */ try {
/* 128 */ inputStream = ResourceUtils . getInputStreamForPath ( configFile ) ;
/* 129 */ byte [ ] b = IOUtils . toByteArray ( inputStream ) ;
/* 130 */ InputStream in = new ByteArrayInputStream ( b ) ;
/* 131 */ return in ;
/* */ }
/* 133 */ catch ( IOException e ) {
/* */
/* 135 */ throw new ConfigurationException ( "Unable to obtain input stream for cacheManagerConfigFile [" + configFile + "]" , e ) ;
/* */
/* */ }
/* */ finally {
/* */
/* 140 */ IOUtils . closeQuietly ( inputStream ) ;
/* */ }
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ @Bean
/* */ public UserRealm userRealm ( EhCacheManager cacheManager ) {
/* 150 */ UserRealm userRealm = new UserRealm ( ) ;
/* 151 */ userRealm . setAuthorizationCacheName ( "sys-authCache" ) ;
/* 152 */ userRealm . setCacheManager ( cacheManager ) ;
/* 153 */ return userRealm ;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ @Bean
/* */ public OnlineSessionDAO sessionDAO ( ) {
/* 162 */ OnlineSessionDAO sessionDAO = new OnlineSessionDAO ( ) ;
/* 163 */ return sessionDAO ;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ @Bean
/* */ public OnlineSessionFactory sessionFactory ( ) {
/* 172 */ OnlineSessionFactory sessionFactory = new OnlineSessionFactory ( ) ;
/* 173 */ return sessionFactory ;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ @Bean
/* */ public OnlineWebSessionManager sessionManager ( ) {
/* 182 */ OnlineWebSessionManager manager = new OnlineWebSessionManager ( ) ;
/* */
/* 184 */ manager . setCacheManager ( getEhCacheManager ( ) ) ;
/* */
/* 186 */ manager . setDeleteInvalidSessions ( true ) ;
/* */
/* 188 */ manager . setGlobalSessionTimeout ( ( this . expireTime * 60 * 1000 ) ) ;
/* */
/* 190 */ manager . setSessionIdUrlRewritingEnabled ( false ) ;
/* */
/* 192 */ manager . setSessionValidationScheduler ( ( SessionValidationScheduler ) SpringUtils . getBean ( SpringSessionValidationScheduler . class ) ) ;
/* */
/* 194 */ manager . setSessionValidationSchedulerEnabled ( true ) ;
/* */
/* 196 */ manager . setSessionDAO ( ( SessionDAO ) sessionDAO ( ) ) ;
/* */
/* 198 */ manager . setSessionFactory ( ( SessionFactory ) sessionFactory ( ) ) ;
/* 199 */ return manager ;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ @Bean
/* */ public SecurityManager securityManager ( UserRealm userRealm ) {
/* 208 */ DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager ( ) ;
/* */
/* 210 */ securityManager . setRealm ( ( Realm ) userRealm ) ;
/* */
/* 212 */ securityManager . setRememberMeManager ( ( RememberMeManager ) rememberMeManager ( ) ) ;
/* */
/* 214 */ securityManager . setCacheManager ( getEhCacheManager ( ) ) ;
/* */
/* 216 */ securityManager . setSessionManager ( ( SessionManager ) sessionManager ( ) ) ;
/* 217 */ return ( SecurityManager ) securityManager ;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public LogoutFilter logoutFilter ( ) {
/* 225 */ LogoutFilter logoutFilter = new LogoutFilter ( ) ;
/* 226 */ logoutFilter . setLoginUrl ( this . loginUrl ) ;
/* 227 */ return logoutFilter ;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ @Bean
/* */ public ShiroFilterFactoryBean shiroFilterFactoryBean ( SecurityManager securityManager ) {
/* 236 */ ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean ( ) ;
/* */
/* 238 */ shiroFilterFactoryBean . setSecurityManager ( securityManager ) ;
/* */
/* 240 */ shiroFilterFactoryBean . setLoginUrl ( this . loginUrl ) ;
/* */
/* 242 */ shiroFilterFactoryBean . setUnauthorizedUrl ( this . unauthorizedUrl ) ;
/* */
/* 244 */ LinkedHashMap < String , String > filterChainDefinitionMap = new LinkedHashMap < > ( ) ;
/* */
/* 246 */ filterChainDefinitionMap . put ( "/favicon.ico**" , "anon" ) ;
/* 247 */ filterChainDefinitionMap . put ( "/archive.png**" , "anon" ) ;
/* 248 */ filterChainDefinitionMap . put ( "/css/**" , "anon" ) ;
/* 249 */ filterChainDefinitionMap . put ( "/docs/**" , "anon" ) ;
/* 250 */ filterChainDefinitionMap . put ( "/fonts/**" , "anon" ) ;
/* 251 */ filterChainDefinitionMap . put ( "/img/**" , "anon" ) ;
/* 252 */ filterChainDefinitionMap . put ( "/ajax/**" , "anon" ) ;
/* 253 */ filterChainDefinitionMap . put ( "/plugins/**" , "anon" ) ;
/* 254 */ filterChainDefinitionMap . put ( "/js/**" , "anon" ) ;
/* 255 */ filterChainDefinitionMap . put ( "/archive/**" , "anon" ) ;
/* 256 */ filterChainDefinitionMap . put ( "/captcha/captchaImage**" , "anon" ) ;
/* */
/* 258 */ filterChainDefinitionMap . put ( "/logout" , "logout" ) ;
/* */
/* 260 */ filterChainDefinitionMap . put ( "/login" , "anon,captchaValidate" ) ;
/* 261 */ filterChainDefinitionMap . put ( "/browse/browseDocument" , "anon,captchaValidate" ) ;
/* */
/* 263 */ filterChainDefinitionMap . put ( "/register" , "anon,captchaValidate" ) ;
/* */
/* */
/* */
/* 267 */ Map < String , Filter > filters = new LinkedHashMap < > ( ) ;
/* 268 */ filters . put ( "onlineSession" , onlineSessionFilter ( ) ) ;
/* 269 */ filters . put ( "syncOnlineSession" , syncOnlineSessionFilter ( ) ) ;
/* 270 */ filters . put ( "captchaValidate" , captchaValidateFilter ( ) ) ;
/* 271 */ filters . put ( "kickout" , kickoutSessionFilter ( ) ) ;
/* */
/* 273 */ filters . put ( "logout" , logoutFilter ( ) ) ;
/* 274 */ shiroFilterFactoryBean . setFilters ( filters ) ;
/* */
/* */
/* 277 */ filterChainDefinitionMap . put ( "/**" , "user,kickout,onlineSession,syncOnlineSession" ) ;
/* 278 */ shiroFilterFactoryBean . setFilterChainDefinitionMap ( filterChainDefinitionMap ) ;
/* */
/* 280 */ return shiroFilterFactoryBean ;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public OnlineSessionFilter onlineSessionFilter ( ) {
/* 288 */ OnlineSessionFilter onlineSessionFilter = new OnlineSessionFilter ( ) ;
/* 289 */ onlineSessionFilter . setLoginUrl ( this . loginUrl ) ;
/* 290 */ onlineSessionFilter . setOnlineSessionDAO ( sessionDAO ( ) ) ;
/* 291 */ return onlineSessionFilter ;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public SyncOnlineSessionFilter syncOnlineSessionFilter ( ) {
/* 299 */ SyncOnlineSessionFilter syncOnlineSessionFilter = new SyncOnlineSessionFilter ( ) ;
/* 300 */ syncOnlineSessionFilter . setOnlineSessionDAO ( sessionDAO ( ) ) ;
/* 301 */ return syncOnlineSessionFilter ;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public CaptchaValidateFilter captchaValidateFilter ( ) {
/* 309 */ CaptchaValidateFilter captchaValidateFilter = new CaptchaValidateFilter ( ) ;
/* 310 */ captchaValidateFilter . setCaptchaEnabled ( this . captchaEnabled ) ;
/* 311 */ captchaValidateFilter . setCaptchaType ( this . captchaType ) ;
/* 312 */ return captchaValidateFilter ;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public SimpleCookie rememberMeCookie ( ) {
/* 320 */ SimpleCookie cookie = new SimpleCookie ( "rememberMe" ) ;
/* 321 */ cookie . setDomain ( this . domain ) ;
/* 322 */ cookie . setPath ( this . path ) ;
/* 323 */ cookie . setHttpOnly ( this . httpOnly ) ;
/* 324 */ cookie . setMaxAge ( this . maxAge * 24 * 60 * 60 ) ;
/* 325 */ return cookie ;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public CookieRememberMeManager rememberMeManager ( ) {
/* 333 */ CookieRememberMeManager cookieRememberMeManager = new CookieRememberMeManager ( ) ;
/* 334 */ cookieRememberMeManager . setCookie ( ( Cookie ) rememberMeCookie ( ) ) ;
/* 335 */ cookieRememberMeManager . setCipherKey ( Base64 . decode ( this . cipherKey ) ) ;
/* 336 */ return cookieRememberMeManager ;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public KickoutSessionFilter kickoutSessionFilter ( ) {
/* 344 */ KickoutSessionFilter kickoutSessionFilter = new KickoutSessionFilter ( ) ;
/* 345 */ kickoutSessionFilter . setCacheManager ( getEhCacheManager ( ) ) ;
/* 346 */ kickoutSessionFilter . setSessionManager ( ( SessionManager ) sessionManager ( ) ) ;
/* */
/* 348 */ kickoutSessionFilter . setMaxSession ( this . maxSession ) ;
/* */
/* 350 */ kickoutSessionFilter . setKickoutAfter ( this . kickoutAfter ) ;
/* */
/* 352 */ kickoutSessionFilter . setKickoutUrl ( "/login?kickout=1" ) ;
/* 353 */ return kickoutSessionFilter ;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ @Bean
/* */ public ShiroDialect shiroDialect ( ) {
/* 362 */ return new ShiroDialect ( ) ;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */ @Bean
/* */ public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor ( @Qualifier ( "securityManager" ) SecurityManager securityManager ) {
/* 372 */ AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor = new AuthorizationAttributeSourceAdvisor ( ) ;
/* 373 */ authorizationAttributeSourceAdvisor . setSecurityManager ( securityManager ) ;
/* 374 */ return authorizationAttributeSourceAdvisor ;
/* */ }
/* */ }
import at.pollux.thymeleaf.shiro.dialect.ShiroDialect ;
import com.archive.common.utils.StringUtils ;
import com.archive.common.utils.spring.SpringUtils ;
import com.archive.framework.shiro.realm.UserRealm ;
import com.archive.framework.shiro.session.OnlineSessionDAO ;
import com.archive.framework.shiro.session.OnlineSessionFactory ;
import com.archive.framework.shiro.web.filter.LogoutFilter ;
import com.archive.framework.shiro.web.filter.captcha.CaptchaValidateFilter ;
import com.archive.framework.shiro.web.filter.kickout.KickoutSessionFilter ;
import com.archive.framework.shiro.web.filter.online.OnlineSessionFilter ;
import com.archive.framework.shiro.web.filter.sync.SyncOnlineSessionFilter ;
import com.archive.framework.shiro.web.session.OnlineWebSessionManager ;
import com.archive.framework.shiro.web.session.SpringSessionValidationScheduler ;
import java.io.ByteArrayInputStream ;
import java.io.IOException ;
import java.io.InputStream ;
import java.util.LinkedHashMap ;
import java.util.Map ;
import javax.servlet.Filter ;
import net.sf.ehcache.CacheManager ;
import org.apache.commons.io.IOUtils ;
import org.apache.shiro.cache.ehcache.EhCacheManager ;
import org.apache.shiro.codec.Base64 ;
import org.apache.shiro.config.ConfigurationException ;
import org.apache.shiro.io.ResourceUtils ;
import org.apache.shiro.mgt.RememberMeManager ;
import org.apache.shiro.mgt.SecurityManager ;
import org.apache.shiro.realm.Realm ;
import org.apache.shiro.session.mgt.SessionFactory ;
import org.apache.shiro.session.mgt.SessionManager ;
import org.apache.shiro.session.mgt.SessionValidationScheduler ;
import org.apache.shiro.session.mgt.eis.SessionDAO ;
import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor ;
import org.apache.shiro.spring.web.ShiroFilterFactoryBean ;
import org.apache.shiro.web.mgt.CookieRememberMeManager ;
import org.apache.shiro.web.mgt.DefaultWebSecurityManager ;
import org.apache.shiro.web.servlet.Cookie ;
import org.apache.shiro.web.servlet.SimpleCookie ;
import org.springframework.beans.factory.annotation.Qualifier ;
import org.springframework.beans.factory.annotation.Value ;
import org.springframework.context.annotation.Bean ;
import org.springframework.context.annotation.Configuration ;
@Configuration
public class ShiroConfig
{
@Value ( "${shiro.session.expireTime}" )
private int expireTime ;
@Value ( "${shiro.session.validationInterval}" )
private int validationInterval ;
@Value ( "${shiro.session.maxSession}" )
private int maxSession ;
@Value ( "${shiro.session.kickoutAfter}" )
private boolean kickoutAfter ;
@Value ( "${shiro.user.captchaEnabled}" )
private boolean captchaEnabled ;
@Value ( "${shiro.user.captchaType}" )
private String captchaType ;
@Value ( "${shiro.cookie.domain}" )
private String domain ;
@Value ( "${shiro.cookie.path}" )
private String path ;
@Value ( "${shiro.cookie.httpOnly}" )
private boolean httpOnly ;
@Value ( "${shiro.cookie.maxAge}" )
private int maxAge ;
@Value ( "${shiro.cookie.cipherKey}" )
private String cipherKey ;
@Value ( "${shiro.user.loginUrl}" )
private String loginUrl ;
@Value ( "${shiro.user.unauthorizedUrl}" )
private String unauthorizedUrl ;
@Bean
public EhCacheManager getEhCacheManager ( ) {
CacheManager cacheManager = CacheManager . getCacheManager ( "archive" ) ;
EhCacheManager em = new EhCacheManager ( ) ;
if ( StringUtils . isNull ( cacheManager ) ) {
em . setCacheManager ( new CacheManager ( getCacheManagerConfigFileInputStream ( ) ) ) ;
return em ;
}
em . setCacheManager ( cacheManager ) ;
return em ;
}
protected InputStream getCacheManagerConfigFileInputStream ( ) {
String configFile = "classpath:ehcache/ehcache-shiro.xml" ;
InputStream inputStream = null ;
try {
inputStream = ResourceUtils . getInputStreamForPath ( configFile ) ;
byte [ ] b = IOUtils . toByteArray ( inputStream ) ;
InputStream in = new ByteArrayInputStream ( b ) ;
return in ;
}
catch ( IOException e ) {
throw new ConfigurationException ( "Unable to obtain input stream for cacheManagerConfigFile [" + configFile + "]" , e ) ;
}
finally {
IOUtils . closeQuietly ( inputStream ) ;
}
}
@Bean
public UserRealm userRealm ( EhCacheManager cacheManager ) {
UserRealm userRealm = new UserRealm ( ) ;
userRealm . setAuthorizationCacheName ( "sys-authCache" ) ;
userRealm . setCacheManager ( cacheManager ) ;
return userRealm ;
}
@Bean
public OnlineSessionDAO sessionDAO ( ) {
OnlineSessionDAO sessionDAO = new OnlineSessionDAO ( ) ;
return sessionDAO ;
}
@Bean
public OnlineSessionFactory sessionFactory ( ) {
OnlineSessionFactory sessionFactory = new OnlineSessionFactory ( ) ;
return sessionFactory ;
}
@Bean
public OnlineWebSessionManager sessionManager ( ) {
OnlineWebSessionManager manager = new OnlineWebSessionManager ( ) ;
manager . setCacheManager ( getEhCacheManager ( ) ) ;
manager . setDeleteInvalidSessions ( true ) ;
manager . setGlobalSessionTimeout ( ( this . expireTime * 60 * 1000 ) ) ;
manager . setSessionIdUrlRewritingEnabled ( false ) ;
manager . setSessionValidationScheduler ( ( SessionValidationScheduler ) SpringUtils . getBean ( SpringSessionValidationScheduler . class ) ) ;
manager . setSessionValidationSchedulerEnabled ( true ) ;
manager . setSessionDAO ( ( SessionDAO ) sessionDAO ( ) ) ;
manager . setSessionFactory ( ( SessionFactory ) sessionFactory ( ) ) ;
return manager ;
}
@Bean
public SecurityManager securityManager ( UserRealm userRealm ) {
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager ( ) ;
securityManager . setRealm ( ( Realm ) userRealm ) ;
securityManager . setRememberMeManager ( ( RememberMeManager ) rememberMeManager ( ) ) ;
securityManager . setCacheManager ( getEhCacheManager ( ) ) ;
securityManager . setSessionManager ( ( SessionManager ) sessionManager ( ) ) ;
return ( SecurityManager ) securityManager ;
}
public LogoutFilter logoutFilter ( ) {
LogoutFilter logoutFilter = new LogoutFilter ( ) ;
logoutFilter . setLoginUrl ( this . loginUrl ) ;
return logoutFilter ;
}
@Bean
public ShiroFilterFactoryBean shiroFilterFactoryBean ( SecurityManager securityManager ) {
ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean ( ) ;
shiroFilterFactoryBean . setSecurityManager ( securityManager ) ;
shiroFilterFactoryBean . setLoginUrl ( this . loginUrl ) ;
shiroFilterFactoryBean . setUnauthorizedUrl ( this . unauthorizedUrl ) ;
LinkedHashMap < String , String > filterChainDefinitionMap = new LinkedHashMap < > ( ) ;
filterChainDefinitionMap . put ( "/favicon.ico**" , "anon" ) ;
filterChainDefinitionMap . put ( "/archive.png**" , "anon" ) ;
filterChainDefinitionMap . put ( "/css/**" , "anon" ) ;
filterChainDefinitionMap . put ( "/docs/**" , "anon" ) ;
filterChainDefinitionMap . put ( "/fonts/**" , "anon" ) ;
filterChainDefinitionMap . put ( "/img/**" , "anon" ) ;
filterChainDefinitionMap . put ( "/ajax/**" , "anon" ) ;
filterChainDefinitionMap . put ( "/plugins/**" , "anon" ) ;
filterChainDefinitionMap . put ( "/js/**" , "anon" ) ;
filterChainDefinitionMap . put ( "/archive/**" , "anon" ) ;
filterChainDefinitionMap . put ( "/captcha/captchaImage**" , "anon" ) ;
filterChainDefinitionMap . put ( "/logout" , "logout" ) ;
filterChainDefinitionMap . put ( "/login" , "anon,captchaValidate" ) ;
filterChainDefinitionMap . put ( "/browse/browseDocument" , "anon,captchaValidate" ) ;
filterChainDefinitionMap . put ( "/register" , "anon,captchaValidate" ) ;
Map < String , Filter > filters = new LinkedHashMap < > ( ) ;
filters . put ( "onlineSession" , onlineSessionFilter ( ) ) ;
filters . put ( "syncOnlineSession" , syncOnlineSessionFilter ( ) ) ;
filters . put ( "captchaValidate" , captchaValidateFilter ( ) ) ;
filters . put ( "kickout" , kickoutSessionFilter ( ) ) ;
filters . put ( "logout" , logoutFilter ( ) ) ;
shiroFilterFactoryBean . setFilters ( filters ) ;
filterChainDefinitionMap . put ( "/**" , "user,kickout,onlineSession,syncOnlineSession" ) ;
shiroFilterFactoryBean . setFilterChainDefinitionMap ( filterChainDefinitionMap ) ;
return shiroFilterFactoryBean ;
}
public OnlineSessionFilter onlineSessionFilter ( ) {
OnlineSessionFilter onlineSessionFilter = new OnlineSessionFilter ( ) ;
onlineSessionFilter . setLoginUrl ( this . loginUrl ) ;
onlineSessionFilter . setOnlineSessionDAO ( sessionDAO ( ) ) ;
return onlineSessionFilter ;
}
public SyncOnlineSessionFilter syncOnlineSessionFilter ( ) {
SyncOnlineSessionFilter syncOnlineSessionFilter = new SyncOnlineSessionFilter ( ) ;
syncOnlineSessionFilter . setOnlineSessionDAO ( sessionDAO ( ) ) ;
return syncOnlineSessionFilter ;
}
public CaptchaValidateFilter captchaValidateFilter ( ) {
CaptchaValidateFilter captchaValidateFilter = new CaptchaValidateFilter ( ) ;
captchaValidateFilter . setCaptchaEnabled ( this . captchaEnabled ) ;
captchaValidateFilter . setCaptchaType ( this . captchaType ) ;
return captchaValidateFilter ;
}
public SimpleCookie rememberMeCookie ( ) {
SimpleCookie cookie = new SimpleCookie ( "rememberMe" ) ;
cookie . setDomain ( this . domain ) ;
cookie . setPath ( this . path ) ;
cookie . setHttpOnly ( this . httpOnly ) ;
cookie . setMaxAge ( this . maxAge * 24 * 60 * 60 ) ;
return cookie ;
}
public CookieRememberMeManager rememberMeManager ( ) {
CookieRememberMeManager cookieRememberMeManager = new CookieRememberMeManager ( ) ;
cookieRememberMeManager . setCookie ( ( Cookie ) rememberMeCookie ( ) ) ;
cookieRememberMeManager . setCipherKey ( Base64 . decode ( this . cipherKey ) ) ;
return cookieRememberMeManager ;
}
public KickoutSessionFilter kickoutSessionFilter ( ) {
KickoutSessionFilter kickoutSessionFilter = new KickoutSessionFilter ( ) ;
kickoutSessionFilter . setCacheManager ( getEhCacheManager ( ) ) ;
kickoutSessionFilter . setSessionManager ( ( SessionManager ) sessionManager ( ) ) ;
kickoutSessionFilter . setMaxSession ( this . maxSession ) ;
kickoutSessionFilter . setKickoutAfter ( this . kickoutAfter ) ;
kickoutSessionFilter . setKickoutUrl ( "/login?kickout=1" ) ;
return kickoutSessionFilter ;
}
@Bean
public ShiroDialect shiroDialect ( ) {
return new ShiroDialect ( ) ;
}
@Bean
public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor ( @Qualifier ( "securityManager" ) SecurityManager securityManager ) {
AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor = new AuthorizationAttributeSourceAdvisor ( ) ;
authorizationAttributeSourceAdvisor . setSecurityManager ( securityManager ) ;
return authorizationAttributeSourceAdvisor ;
}
}
/ * Location : C : \ Users \ Administrator \ Desktop \ extracted . zip ! \ extracted \ BOOT - INF \ classes \ com \ archive \ framework \ config \ ShiroConfig . class