/*     */ package com.picc.grab.config;
/*     */ 
/*     */ import com.picc.grab.common.shiro.ShiroRealm;
/*     */ import java.util.LinkedHashMap;
/*     */ import java.util.Map;
/*     */ import org.apache.commons.lang3.StringUtils;
/*     */ import org.apache.commons.lang3.math.NumberUtils;
/*     */ import org.apache.shiro.authc.credential.CredentialsMatcher;
/*     */ import org.apache.shiro.authc.credential.HashedCredentialsMatcher;
/*     */ import org.apache.shiro.mgt.SecurityManager;
/*     */ import org.apache.shiro.realm.Realm;
/*     */ import org.apache.shiro.session.mgt.SessionManager;
/*     */ import org.apache.shiro.session.mgt.eis.SessionDAO;
/*     */ import org.apache.shiro.spring.LifecycleBeanPostProcessor;
/*     */ import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
/*     */ import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
/*     */ import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
/*     */ import org.apache.shiro.web.session.mgt.DefaultWebSessionManager;
/*     */ import org.crazycake.shiro.RedisCacheManager;
/*     */ import org.crazycake.shiro.RedisManager;
/*     */ import org.crazycake.shiro.RedisSessionDAO;
/*     */ import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;
/*     */ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
/*     */ import org.springframework.context.annotation.Bean;
/*     */ import org.springframework.context.annotation.Configuration;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ @Configuration
/*     */ public class ShiroConfig
/*     */ {
/*     */   private String host;
/*     */   private String port;
/*     */   private String password;
/*     */   
/*     */   @Bean
/*     */   public static LifecycleBeanPostProcessor getLifecycleBeanPostProcessor() {
/*  39 */     return new LifecycleBeanPostProcessor();
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   @Bean
/*     */   public HashedCredentialsMatcher hashedCredentialsMatcher() {
/*  51 */     HashedCredentialsMatcher hashedCredentialsMatcher = new HashedCredentialsMatcher();
/*     */     
/*  53 */     hashedCredentialsMatcher.setHashAlgorithmName("md5");
/*  54 */     hashedCredentialsMatcher.setHashIterations(1);
/*     */     
/*  56 */     return hashedCredentialsMatcher;
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   @Bean(name = {"shiroRealm"})
/*     */   public ShiroRealm shiroRealm() {
/*  66 */     ShiroRealm realm = new ShiroRealm();
/*  67 */     realm.setCredentialsMatcher((CredentialsMatcher)hashedCredentialsMatcher());
/*  68 */     return realm;
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public RedisCacheManager cacheManager() {
/*  77 */     RedisCacheManager redisCacheManager = new RedisCacheManager();
/*  78 */     redisCacheManager.setRedisManager(redisManager());
/*  79 */     return redisCacheManager;
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   @Bean
/*     */   public RedisSessionDAO redisSessionDAO() {
/*  87 */     RedisSessionDAO redisSessionDAO = new RedisSessionDAO();
/*  88 */     redisSessionDAO.setRedisManager(redisManager());
/*  89 */     return redisSessionDAO;
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   @Bean
/*     */   public DefaultWebSessionManager sessionManager() {
/*  97 */     DefaultWebSessionManager sessionManager = new DefaultWebSessionManager();
/*  98 */     sessionManager.setSessionDAO((SessionDAO)redisSessionDAO());
/*  99 */     return sessionManager;
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public RedisManager redisManager() {
/* 108 */     RedisManager redisManager = new RedisManager();
/* 109 */     redisManager.setHost(this.host);
/* 110 */     redisManager.setPort(NumberUtils.toInt(this.port, 0));
/* 111 */     redisManager.setExpire(1800);
/* 112 */     redisManager.setTimeout(1800);
/* 113 */     redisManager.setPassword(this.password);
/* 114 */     return redisManager;
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   @Bean(name = {"securityManager"})
/*     */   public DefaultWebSecurityManager securityManager() {
/* 124 */     DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
/* 125 */     securityManager.setRealm((Realm)shiroRealm());
/*     */ 
/*     */ 
/*     */     
/* 129 */     if (StringUtils.isNotBlank(this.host) && StringUtils.isNotBlank(this.port)) {
/* 130 */       securityManager.setSessionManager((SessionManager)sessionManager());
/*     */     }
/* 132 */     return securityManager;
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   @Bean(name = {"shiroFilter"})
/*     */   public ShiroFilterFactoryBean shiroFilterFactoryBean(DefaultWebSecurityManager securityManager) {
/* 148 */     System.out.println("ShiroConfiguration.shirFilter()");
/*     */     
/* 150 */     ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
/*     */     
/* 152 */     shiroFilterFactoryBean.setSecurityManager((SecurityManager)securityManager);
/*     */ 
/*     */     
/* 155 */     Map<String, String> filterChainDefinitionManager = new LinkedHashMap<>();
/*     */     
/* 157 */     filterChainDefinitionManager.put("/logout", "logout");
/*     */ 
/*     */ 
/*     */     
/* 161 */     filterChainDefinitionManager.put("/login", "authc");

///* 161 */     filterChainDefinitionManager.put("/syncInfo", "anon");
/*     */
/* 163 */     filterChainDefinitionManager.put("/favicon.ico", "anon");
/* 164 */     filterChainDefinitionManager.put("/install", "anon");
/* 165 */     filterChainDefinitionManager.put("/json/**", "anon");
/* 166 */     filterChainDefinitionManager.put("/", "anon");
/* 167 */     filterChainDefinitionManager.put("/login/**", "anon");
/* 168 */     filterChainDefinitionManager.put("/nopwdlogin", "anon");
/*     */ 
/*     */     
/* 171 */     filterChainDefinitionManager.put("/uminterface/**", "anon");
/*     */     
/* 173 */     filterChainDefinitionManager.put("/grabLogin/**", "anon");
/*     */     
/* 175 */     filterChainDefinitionManager.put("/findPwd", "anon");
/* 176 */     filterChainDefinitionManager.put("/findPwd/**", "anon");
/*     */     
/* 178 */     filterChainDefinitionManager.put("/verCode", "anon");
/* 179 */     filterChainDefinitionManager.put("/isVerCode", "anon");
/* 180 */     filterChainDefinitionManager.put("/verCodeImg", "anon");
/*     */     
/* 182 */     filterChainDefinitionManager.put("/**", "authc");
/*     */ 
/*     */     
/* 185 */     shiroFilterFactoryBean.setLoginUrl("/login");
/*     */     
/* 187 */     shiroFilterFactoryBean.setSuccessUrl("/login");
/*     */     
/* 189 */     shiroFilterFactoryBean.setUnauthorizedUrl("/nopermissions");
/*     */     
/* 191 */     shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionManager);
/* 192 */     return shiroFilterFactoryBean;
/*     */   }
/*     */   
/*     */   @Bean
/*     */   @ConditionalOnMissingBean
/*     */   public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() {
/* 198 */     DefaultAdvisorAutoProxyCreator daap = new DefaultAdvisorAutoProxyCreator();
/* 199 */     daap.setProxyTargetClass(true);
/* 200 */     return daap;
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   @Bean
/*     */   public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(DefaultWebSecurityManager securityManager) {
/* 212 */     AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor = new AuthorizationAttributeSourceAdvisor();
/* 213 */     authorizationAttributeSourceAdvisor.setSecurityManager((SecurityManager)securityManager);
/* 214 */     return authorizationAttributeSourceAdvisor;
/*     */   }
/*     */ }


/* Location:              C:\Users\Administrator\Desktop\ROOT\WEB-INF\classes\!\com\picc\grab\config\ShiroConfig.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */