Skip to content

Commit 1d5da6c

Browse files
vijayanasokanglaumtech
authored andcommitted
Update CustomerController.java
test method for userpermission
1 parent 9797ad3 commit 1d5da6c

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

login/src/main/java/com/glaum/login/controller/CustomerController.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,22 @@
33
import org.slf4j.Logger;
44
import org.slf4j.LoggerFactory;
55
import org.springframework.beans.factory.annotation.Autowired;
6+
import org.springframework.http.MediaType;
7+
import org.springframework.http.ResponseEntity;
68
import org.springframework.security.access.prepost.PreAuthorize;
79
import org.springframework.stereotype.Controller;
810
import org.springframework.ui.Model;
911
import org.springframework.web.bind.annotation.PathVariable;
1012
import org.springframework.web.bind.annotation.RequestMapping;
1113
import org.springframework.web.bind.annotation.RequestMethod;
14+
import org.springframework.web.bind.annotation.ResponseBody;
1215

1316
import com.glaum.login.configuration.Authorized;
1417
import com.glaum.login.entity.permission;
1518

1619
import java.io.IOException;
20+
import java.lang.reflect.Field;
21+
import java.util.HashMap;
1722
import java.util.List;
1823
import java.util.Map;
1924

@@ -46,6 +51,25 @@ public String customerdel(HttpSession httpSession,HttpServletRequest request,Htt
4651
return "admin_customer";
4752
}
4853

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+
4973

5074

5175
}

0 commit comments

Comments
 (0)