后台单点登录没有用户时,不会返回登录界面
老师们,请教下,设置了后台单点登录,但是没有用户时,不会返回登录界面,这个要如何解决呢0ad2722b4483a4a22a849be43b1088e.png

FineReport HiPooh 发布于 2024-5-17 17:10
1min目标场景问卷 立即参与
回答问题
悬赏:3 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共2回答
最佳回答
0
用户k6280494Lv6资深互助
发布于2024-5-17 17:15
最佳回答
0
XushuaisLv6初级互助
发布于2024-5-17 17:21

可以看看你的单店登录代码,帮你看下

  • HiPooh HiPooh(提问者) 老师好,代码主要部分如下,上传附件这网页就崩了,只能直接复制出来了 @Path("/fr") public class FRLogin { private static final int FRAGMENT_LENGTH = 245; @GET @Path("/login") @Produces({MediaType.TEXT_PLAIN}) public String getCompanyCode(@Context HttpServletRequest request, @Context HttpServletResponse response) { String nwip = "http://192.168.1.248:18301/digiwin/kanban?ssoToken="; String wwip = "http://113.108.246.214:18301/digiwin/kanban?ssoToken="; String url=""; url = request.getRequestURL().toString(); if(url.indexOf("192.168.1.20")>=0){ url = nwip; }else{ url = wwip; } User u = (User)request.getSession().getAttribute("weaver_user@bean"); try { url += getToken(u.getLoginid()); response.sendRedirect(url); return url; } catch (Exception e) { e.printStackTrace(); } /* Enumeration s = request.getSession().getAttributeNames(); while(s.hasMoreElements()){ String sss = s.nextElement().toString(); ss+=sss+":"; ss+=request.getSession().getAttribute(sss).toString()+","; if("weaver_user@bean".equals(sss)){ User u = (User)request.getSession().getAttribute(sss); ss+=u.getUsername()+";"; ss+=u.getAccount()+";"; } }*/ return url; //return ss; // return "OK"; } public String getToken(String workcode)throws UnsupportedEncodingException{ String un = "{\n" + " \"username\": \"sysadmin\",\n" + " \"issueTime\":1640832102097\n" + "}"; String currentTimeMillis = String.valueOf(System.currentTimeMillis()+1000*10); un=un.replace("1640832102097",currentTimeMillis); un=un.replace("sysadmin",workcode); String text = System.getProperty("text"); String key = System.getProperty("publicKey"); String username = text == null ? un : text; /* String defaultKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAphdj55QhPruspjwkgTRbPB8/Gi0N3UYG\n" + "nGHSHJ6yo26HH2CwadAaXpLAA5N8wewQGE/q0ZBmD8eZA4RDIUkQkMX1gGE+ZlunYH74lhGwvv1z\n" + "3UKCVt7i3h6L+/rMFLALxo9ttTL4FDzvU0vJWYxZyJopl+9xymOcdtYTsbU5mbX+K5DtIw+tFVWl\n" + "zNbCGnU2ro0AN1ShZLbthgfMwnY4W9z4FMeFBrVJNBm6E+nSgy7o4lfnaFKxsuJKwa2usDwwVHPd\n" + "gAf/7pUCDgPYbMJ0bLHhxFimeAzQ1jk4L6BGYgPORlPw31v4B6VNvCpnMe/FMCLzGQoFd0u4AhYd\n" + "a+E2sQIDAQAB";*/ String defaultKey ="MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApah8X8e8BP5VZhu+g9KA57npFBn+nVNQ\n" + "8+T6hsLJoNg4IbfK5h4LKNP4bztFSue5DvCfuy5MLoAjMTpY62/yLawaZN1SvQm3vKG77Stgf4L9\n" + "DrNuKc2jXSfpn9fg0lOllVzzdEQvsaYr/60gboeZoIg3T/PQtRyJuM9epb/hs7NXQoKd/R82D+Oc\n" + "+dJPu8QyRLSb3xsGUlWyHHDZZAVNAts9+Y/gBY0DtHoAwJiRVU4wCqRAcgCZAUxYw+1HjHGGohPp\n" + "LoZFg/fY/UNUXZTTjCHd72i0TI0ITgccEez2+mlxZkSCtXhT7dyM/kjELHbCu+AwC2ig6seIGTKi\n" + "OamzhwIDAQAB"; //从插件配置页面获取 String publicKey = key == null ? defaultKey : key; System.out.println(" un: " + un); System.out.println("defaultKey : " + defaultKey); //加密后的ssoToken,可以在前台界面进行解密测试 String encrypt = encrypt(username, publicKey); System.out.println("encrypted username: " + encrypt); //encode后的token,可以直接放于url上进行单点 String encode = URLEncoder.encode(encrypt, "UTF-8"); System.out.println("ssoToken: " + encode); return encode; }
    2024-05-20 09:27 
  • Xushuais Xushuais 回复 HiPooh(提问者) response.sendRedirect(url); return url; 在重定向前,对user进行判断,异常直接重定向login页面
    2024-05-20 10:28 
  • 3关注人数
  • 348浏览人数
  • 最后回答于:2024-5-17 17:21
    请选择关闭问题的原因
    确定 取消
    返回顶部