NutzCN Logo
问答 shiro实现记住密码
发布于 2341天前 作者 wx_vjqsjg4om8803f2gnu54 1924 次浏览 复制 上一个帖子 下一个帖子
标签: nutzwk

想给nutzwk加一个记住密码的功能,shiro生成token时记住密码也生成了。登录的方法我该怎么改?怎么能在页面吧用户名密码现实上去?有什么思路吗?

@At("")
    @Ok("re")
    @Filters
    public String login(HttpServletRequest req, HttpSession session) {
        Subject subject = SecurityUtils.getSubject();
        if (subject.isAuthenticated()) {
            return "redirect:/platform/home";
        } else {
            try {
                HashMap<String, Object> map = RSAUtil.getKeys();
                //生成公钥和私钥
                RSAPublicKey publicKey = (RSAPublicKey) map.get("public");
                RSAPrivateKey privateKey = (RSAPrivateKey) map.get("private");
                //模
                String publicKeyModulus = publicKey.getModulus().toString(16);
                //公钥指数
                String publicKeyExponent = publicKey.getPublicExponent().toString(16);
                //私钥指数
                req.setAttribute("publicKeyExponent", publicKeyExponent);
                req.setAttribute("publicKeyModulus", publicKeyModulus);
                session.setAttribute("platformPrivateKey", privateKey);
            } catch (Exception e) {
                e.printStackTrace();
            }
            return "beetl:/platform/sys/login.html";

        }
    }
1 回复

nutzwk自带remmeberme功能吧,shiro都封装好了

添加回复
请先登陆
回到顶部