Commit e7e3fb4c by tangzy

优化ukey登录的条件

parent 40fe6771
...@@ -31,48 +31,47 @@ public class UkeyLoginController { ...@@ -31,48 +31,47 @@ public class UkeyLoginController {
private NoUiParam noUiParam; private NoUiParam noUiParam;
private static final Log log = LogFactory.getLog(UkeyLoginController.class); private static final Log log = LogFactory.getLog(UkeyLoginController.class);
@ResponseBody @ResponseBody
@RequestMapping(value = "/getUserByDn", method = RequestMethod.POST) @RequestMapping(value = "/getUserByDn", method = RequestMethod.POST)
public Object ukeyLogin(@RequestBody Map<String, Object> dataMap, HttpServletRequest request, HttpServletResponse reponse) throws Exception { public Object ukeyLogin(@RequestBody Map<String, Object> dataMap, HttpServletRequest request, HttpServletResponse reponse) throws Exception {
String certdn=request.getHeader("certdn"); String certdn = request.getHeader("certdn");
log.info("====getUserByDn====certdn"+certdn); log.info("====getUserByDn====certdn" + certdn);
NoUiRequest noUiRequest = new NoUiRequest(request, "", dataMap); NoUiRequest noUiRequest = new NoUiRequest(request, "", dataMap);
Map<String,Object> retDatamap=new HashMap<>(); Map<String, Object> retDatamap = new HashMap<>();
if(StringUtils.isNotBlank(certdn)) if (StringUtils.isNotBlank(certdn)) {
{ Map<String, Object> map = getLoginidByDN(certdn, noUiRequest);
Map<String,Object> map=getLoginidByDN(certdn,noUiRequest); if (map.containsKey("nam")) {
String loginid=map.get("nam").toString(); String loginid = map.get("nam").toString();
log.info("====getUserByDn====loginid"+loginid); log.info("====getUserByDn====loginid" + loginid);
if(StringUtils.isNotBlank(loginid)) if (StringUtils.isNotBlank(loginid)) {
{ retDatamap.put("msgCode", "0000");
retDatamap.put("msgCode", "0000"); retDatamap.put("loginid", loginid);
retDatamap.put("loginid", loginid); return ResultUtil.result(ErrorCodes.SUCCESS, ErrorCodes.SUCCESS_INFO, retDatamap, noUiParam.getVersion());
return ResultUtil.result(ErrorCodes.SUCCESS, ErrorCodes.SUCCESS_INFO, retDatamap,noUiParam.getVersion()); }
} }
} }
retDatamap.put("msgCode", "9999"); retDatamap.put("msgCode", "9999");
retDatamap.put("loginid", ""); retDatamap.put("loginid", "");
return ResultUtil.result(ErrorCodes.SUCCESS, ErrorCodes.SUCCESS_INFO, retDatamap,noUiParam.getVersion()); return ResultUtil.result(ErrorCodes.SUCCESS, ErrorCodes.SUCCESS_INFO, retDatamap, noUiParam.getVersion());
} }
private Map<String,Object> getLoginidByDN(String certdn,NoUiRequest noUiRequest) { private Map<String, Object> getLoginidByDN(String certdn, NoUiRequest noUiRequest) {
Map<String,Object> values=new HashMap<>(); Map<String, Object> values = new HashMap<>();
NoUiContext context = NoUiContextManager.createNoUiContext(noUiRequest); NoUiContext context = NoUiContextManager.createNoUiContext(noUiRequest);
String sql="SELECT inr,nam,ukey FROM usr WHERE ukey=?"; String sql = "SELECT inr,nam,ukey FROM usr WHERE ukey=?";
context.getSupport().execute(sql,new Object[]{certdn}); context.getSupport().execute(sql, new Object[]{certdn});
Argument<String> inr=new Argument<>("inr"); Argument<String> inr = new Argument<>("inr");
Argument<String> nam=new Argument<>("nam"); Argument<String> nam = new Argument<>("nam");
Argument<String> ukey=new Argument<>("ukey"); Argument<String> ukey = new Argument<>("ukey");
while (true) while (true) {
{ context.getSupport().fetch(new IResult[]{inr, nam, ukey});
context.getSupport().fetch(new IResult[]{inr,nam,ukey}); if (context.getError() != 0) {
if(context.getError()!=0)
{
context.getSupport().close(); context.getSupport().close();
return values; return values;
} }
values.put("nam",nam.getValue()); values.put("nam", nam.getValue());
values.put("ukey",ukey.getValue()); values.put("ukey", ukey.getValue());
} }
} }
} }
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