Ver código fonte

update

Signed-off-by: anderx <312518615@qq.com>
anderx 5 anos atrás
pai
commit
4763f99c64

+ 3 - 3
src/main/java/com/goafanti/core/shiro/token/UserRealm.java

@@ -52,7 +52,7 @@ public class UserRealm extends AuthorizingRealm {
 	 */
 	protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authcToken)
 			throws AuthenticationException {
-
+		System.out.println("进入登陆授权");
 		ShiroToken token = (ShiroToken) authcToken;
 		if (null == token.getType()) {
 			Admin admin = adminService.selectByMobile(token.getUsername(),"超级管理员");
@@ -86,14 +86,14 @@ public class UserRealm extends AuthorizingRealm {
 	 */
 	@Override
 	protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
+		System.out.println("进入角色授权");
 		int type=TokenManager.getUserType();
+		System.out.println(type);
 		String userId = TokenManager.getAdminId();
 		SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
 		// 根据用户ID查询角色(role),放入到Authorization里。
-		System.out.println(type);
 		if (type==3) {
 			Set<String> roles = skjtUserMapper.findRoleByUserId(userId);
-			System.out.println(roles);
 			info.setRoles(roles);
 			// 根据用户ID查询权限(permission),放入到Authorization里。
 			Set<String> permissions = skjtUserMapper.findPermissionByUserId(userId);

+ 1 - 4
src/main/java/com/goafanti/demandCollection/controller/DemandCollectionApiController.java

@@ -2,14 +2,11 @@ package com.goafanti.demandCollection.controller;
 
 
 
-import java.util.UUID;
-
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.ui.Model;
+import org.apache.shiro.authz.annotation.RequiresRoles;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;

+ 2 - 0
src/main/java/com/goafanti/demandCollection/service/impl/DemandCollectionServiceImpl.java

@@ -8,6 +8,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import javax.security.auth.Subject;
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.commons.lang3.StringUtils;
@@ -19,6 +20,7 @@ import org.apache.poi.xssf.usermodel.XSSFCellStyle;
 import org.apache.poi.xssf.usermodel.XSSFRow;
 import org.apache.poi.xssf.usermodel.XSSFSheet;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.apache.shiro.SecurityUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;