| | |
| | | package com.gkhy.assess.framework.shiro.realm; |
| | | |
| | | import com.gkhy.assess.common.enums.UserIdentityEnum; |
| | | import com.gkhy.assess.common.utils.RequestUtil; |
| | | import com.gkhy.assess.common.utils.SpringContextUtils; |
| | | import com.gkhy.assess.framework.shiro.JwtToken; |
| | |
| | | Set<String> roles=new HashSet<>(); |
| | | Set<String> menus=new HashSet<>(); |
| | | SimpleAuthorizationInfo info=new SimpleAuthorizationInfo(); |
| | | info.addRole("admin"); |
| | | info.addStringPermission("*:*:*"); |
| | | if(sysUser.getIdentity().equals(UserIdentityEnum.MONITOR.getCode())){ |
| | | info.addRole("monitor"); |
| | | info.addStringPermission("system:assess:monitor"); |
| | | }else if(sysUser.getIdentity().equals(UserIdentityEnum.AGENCY.getCode())){ |
| | | info.addRole("agency"); |
| | | info.addStringPermission("system:assess:agency"); |
| | | }else{ |
| | | info.addRole("expert"); |
| | | info.addStringPermission("system:assess:expert"); |
| | | } |
| | | |
| | | return info; |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException { |
| | | HttpServletRequest req = SpringContextUtils.getHttpServletRequest(); |
| | | SysUser sysUser=null; |
| | | if(authenticationToken instanceof JwtToken){ |
| | | String token= (String) authenticationToken.getCredentials(); |
| | | if(token==null){ |
| | | HttpServletRequest req = SpringContextUtils.getHttpServletRequest(); |
| | | |
| | | log.info("————————身份认证失败——————————IP地址: "+ RequestUtil.getRequestIp(req) +",URL:"+req.getRequestURI()); |
| | | throw new AuthenticationException("token为空!"); |
| | | } |