/*    */ package com.picc.grab.common.shiro;
/*    */ 
/*    */ import com.picc.grab.common.shiro.service.IShiroService;
/*    */ import com.picc.grab.common.shiro.service.impl.ShiroServiceImpl;
/*    */ import com.picc.grab.config.PiccGrabConfig;
/*    */ import com.picc.grab.entity.ShiroUser;
/*    */ import com.picc.grab.util.MD5Util;
/*    */ import org.apache.shiro.authc.AuthenticationException;
/*    */ import org.apache.shiro.authc.AuthenticationInfo;
/*    */ import org.apache.shiro.authc.AuthenticationToken;
/*    */ import org.apache.shiro.authc.SimpleAuthenticationInfo;
/*    */ import org.apache.shiro.authc.UsernamePasswordToken;
/*    */ import org.apache.shiro.authz.AuthorizationInfo;
/*    */ import org.apache.shiro.authz.SimpleAuthorizationInfo;
/*    */ import org.apache.shiro.realm.AuthorizingRealm;
/*    */ import org.apache.shiro.subject.PrincipalCollection;
/*    */ import org.slf4j.Logger;
/*    */ import org.slf4j.LoggerFactory;
/*    */ import org.springframework.beans.factory.annotation.Autowired;
/*    */ 
/*    */ 
/*    */ public class ShiroRealm
/*    */   extends AuthorizingRealm
/*    */ {
/* 25 */   private Logger logger = LoggerFactory.getLogger(ShiroRealm.class);
/*    */ 
/*    */ 
/*    */ 
/*    */   
/*    */   @Autowired
/*    */   private PiccGrabConfig piccGrabConfig;
/*    */ 
/*    */ 
/*    */ 
/*    */   
/*    */   protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
/* 37 */     IShiroService shiroService = ShiroServiceImpl.me();
/*    */     
/* 39 */     if (token instanceof NoPwdToken) {
/*    */       
/* 41 */       NoPwdToken noPwdToken = (NoPwdToken)token;
/* 42 */       String str = noPwdToken.getUsername();
/*    */       
/* 44 */       ShiroUser shiroUser1 = shiroService.shiroUser(str);
/*    */       
/* 46 */       return (AuthenticationInfo)new SimpleAuthenticationInfo(shiroUser1, MD5Util.md5Hex32("123456"), getName());
/*    */     } 
/* 48 */     UsernamePasswordToken utoken = (UsernamePasswordToken)token;
/*    */     
/* 50 */     String userName = utoken.getUsername();
/*    */     
/* 52 */     ShiroUser shiroUser = new ShiroUser();
/* 53 */     shiroUser.setFgsId("");
/* 54 */     shiroUser.setUserName(this.piccGrabConfig.getLoginname());
/* 55 */     shiroUser.setUserPass("E10ADC3949BA59ABBE56E057F20F883E");
/* 56 */     if (shiroUser != null) {
/* 57 */       return (AuthenticationInfo)new SimpleAuthenticationInfo(shiroUser, shiroUser.getUserPass(), getName());
/*    */     }
/*    */     
/* 60 */     return null;
/*    */   }
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */   
/*    */   protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
/* 72 */     ShiroUser shiroUser = (ShiroUser)principals.getPrimaryPrincipal();
/*    */     
/* 74 */     SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
/* 75 */     info.addStringPermissions(shiroUser.getPermissionsList());
/* 76 */     return (AuthorizationInfo)info;
/*    */   }
/*    */ }


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