Commit 57648e16 by WeiCong

增加coas角色映射

parent 3ba8a50b
......@@ -18,6 +18,7 @@ import org.sss.presentation.noui.util.DataSecurityUtil;
import org.sss.presentation.noui.util.HttpClientUtil;
import org.sss.presentation.noui.util.StringUtil;
import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;
......@@ -33,10 +34,18 @@ public class CoasHandleController {
private String coas_server;
@Value("${pushuser}")
private String pushuser;
@Value("${rol_mappings}")
private String rol_mappings;
private Map<String,String> codetable;
private Gson gson = new Gson();
@Autowired
private NoUiVersion noUiVersion;
@PostConstruct
public void init() {
codetable=gson.fromJson(rol_mappings, Map.class);
}
@RequestMapping(value = "/oauth2/callback", method = {RequestMethod.POST, RequestMethod.GET})
public ModelAndView callback(@RequestParam("type") String type, @RequestParam("value") String value, @RequestHeader(value = "certdn", required = false) String certdn, ModelAndView view) {
try {
......@@ -51,19 +60,14 @@ public class CoasHandleController {
url += "&user_certdn={user_certdn}";
}
log.info("准备请求:" + url + "请求参数:" + body);
// ResponseEntity<String> res = HttpClientUtil.post(coas_server + "get_token", body, String.class);
ResponseEntity<String> res = HttpClientUtil.post(url, null, String.class, body);
String res_str = res.getBody();
Map<String, Object> res_body = gson.fromJson(res_str, Map.class);
log.info("调用coas的get_token接口响应:" + res_body);
checkRes(res, (String) res_body.get("msgCode"), (String) res_body.get("message"), "get_token");
String access_token = (String) res_body.get("access_token");
String token_type = (String) res_body.get("token_type");
// log.info(String.format("准备调用coas的get_info接口.access_token=[%s],token_type=[%s]", access_token, token_type));
body = new HashMap<>();
body.put("access_token", access_token);
// res = HttpClientUtil.post(coas_server + "get_info", body, String.class);
url = coas_server + "oauth2/get_info?access_token={access_token}";
log.info("准备请求:" + url + "请求参数:" + body);
res = HttpClientUtil.post(url, null, String.class, body);
......@@ -99,7 +103,7 @@ public class CoasHandleController {
}
@ResponseBody
@RequestMapping(value = "/coas/pushuser", method = RequestMethod.POST)
@RequestMapping(value = "/coas/pushuser", method = {RequestMethod.POST, RequestMethod.GET})
public Object pushuser(@RequestBody Map<String, String> dataMap) {
//如果推送开关关闭,则不做推送动作
if("off".equalsIgnoreCase(pushuser)){
......@@ -118,7 +122,11 @@ public class CoasHandleController {
body.put("client_id", client_id);
body.put("client_secret", client_secret);
body.put("optype", "CR");
body.put("coasroleid", coasroleid);
if(!StringUtil.isEmpty(coasroleid) && codetable.containsKey(coasroleid)){
body.put("coasroleid", codetable.get(coasroleid));
}else{
body.put("coasroleid", "32");
}
body.put("coasdeptid", coasdeptid);
body.put("coascertdn", certdn);
body.put("loginid", loginid);
......
client_id=ESFE
client_secret=666666
coas_server=http://111.1.12.211:8088/coas/
pushuser=off
\ No newline at end of file
pushuser=off
rol_mappings={'pbcopr':'30','pbcrel':'31','bnkadm':'32','bnkbmg':'32','BUS-1':'32','REL-1':'32','MAG-1':'32','BUS-2':'32','REL-2':'32','MAG-2':'32','BUS-3':'32','REL-3':'32','MAG-3':'32','BUS-4':'32','REL-4':'32','MAG-4':'32'}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment