|
3 | 3 | import org.slf4j.Logger; |
4 | 4 | import org.slf4j.LoggerFactory; |
5 | 5 | import org.springframework.beans.factory.annotation.Autowired; |
| 6 | +import org.springframework.http.MediaType; |
| 7 | +import org.springframework.http.ResponseEntity; |
6 | 8 | import org.springframework.security.access.prepost.PreAuthorize; |
7 | 9 | import org.springframework.stereotype.Controller; |
8 | 10 | import org.springframework.ui.Model; |
9 | 11 | import org.springframework.web.bind.annotation.PathVariable; |
10 | 12 | import org.springframework.web.bind.annotation.RequestMapping; |
11 | 13 | import org.springframework.web.bind.annotation.RequestMethod; |
| 14 | +import org.springframework.web.bind.annotation.ResponseBody; |
12 | 15 |
|
13 | 16 | import com.glaum.login.configuration.Authorized; |
14 | 17 | import com.glaum.login.entity.permission; |
15 | 18 |
|
16 | 19 | import java.io.IOException; |
| 20 | +import java.lang.reflect.Field; |
| 21 | +import java.util.HashMap; |
17 | 22 | import java.util.List; |
18 | 23 | import java.util.Map; |
19 | 24 |
|
@@ -46,6 +51,25 @@ public String customerdel(HttpSession httpSession,HttpServletRequest request,Htt |
46 | 51 | return "admin_customer"; |
47 | 52 | } |
48 | 53 |
|
| 54 | + @RequestMapping(value={"/getuserpermission"}, method = RequestMethod.GET, produces=MediaType.APPLICATION_JSON_VALUE) |
| 55 | + @Authorized(keys = {"quote_delete","quote_read","quote_create"}) |
| 56 | + @ResponseBody |
| 57 | + public Map<String, Integer> fetchuserpermission(HttpSession httpSession,HttpServletRequest request,HttpServletResponse res) throws IOException { |
| 58 | + Map<String,Integer> mapofper= new HashMap<String, Integer>(); |
| 59 | + |
| 60 | + for (Field f : httpSession.getClass().getDeclaredFields()) { |
| 61 | + f.setAccessible(true); |
| 62 | + Object o; |
| 63 | + try { |
| 64 | + HttpSession s= (HttpSession) f.get(httpSession); |
| 65 | + mapofper= (Map<String, Integer>) s.getAttribute("userpermissiondetails"); |
| 66 | + } catch (Exception e) { |
| 67 | + o = e; |
| 68 | + } |
| 69 | + } |
| 70 | + return mapofper; |
| 71 | + } |
| 72 | + |
49 | 73 |
|
50 | 74 |
|
51 | 75 | } |
0 commit comments