单点登陆的测试


今天做了个单点登陆 。

但是怎么测试呢?

下面请看详解:

源码中是这样的:

    /**
     * 单点登录改造
     * 
     * @param request
     * @param response
     * @return
     * @throws IOException
     * @throws HttpException
     * @throws IOException
     */
    @RequestMapping(value = "/rcbSingleLoginCheck.do")
    public Object singleLoginCheck(HttpServletRequest request,
            HttpServletResponse response) throws IOException {
        response.setCharacterEncoding("UTF-8");
        // 会话失效
        request.getSession().invalidate();// 使会话失效,解除资源占用
        PrintWriter writer = null;
        PbUser pbUser = null;
        // 用户编码
        String userCode = request.getParameter("user_code");
        
        //config
        String config = request.getParameter("config");
        log.info("单点登陆时获取的config-----"+config);

        try {
            if (StringUtils.isEmpty(userCode)) {
                throw new PbException("无法获取用户编码,请确认!");
            }
            if(StringUtils.isEmpty(config)){
                throw new PbException("无法获取外设配置信息config!");
            }
            //将config保存在session中
            Session sc = new Session();
            HashMap customParam = new HashMap();
            customParam.put("config", config);
            sc.setCustomParam(customParam);
            
            pbUser = pbUserService.loadPbUser(userCode);
            if (null == pbUser) {
                throw new PbException("登录失败,当前系统中不存在该用户:" + userCode);
            } else if (pbUser.getEnabled() != 1) {
                throw new PbException("登录失败, 用户:" + userCode + "已禁用");
            }
            request.getSession().setAttribute("userInfo", pbUser); 

            sc.setUserId(pbUser.getUser_id());
            sc.setUserCode(pbUser.getUser_code());
            sc.setUserName(pbUser.getUser_name());
            sc.setUserType(pbUser.getUser_type());
            sc.setEntry(pbUser.getEntry());
            //记录用户登陆的网点编码、转账时需要传递机构编码(即是用户登陆的网点编码)
            sc.setBelongOrgCode(pbUser.getBank_code());
            sc.setTop_org(1);
            Calendar cal = Calendar.getInstance();
            sc.setBusiYear( cal.get(Calendar.YEAR));
            sc.setBelongOrgId(pbUser.getBank_id());
            //add zhouqi  20131213 终端号
            sc.setTellerCode(pbUser.getTellercode());
            //ztl 2014年4月23日17:42:07  济南 建行核心使用
            sc.setBankcode(pbUser.getBank_code());
            sc.setBankname(pbUser.getBank_name());
            //wtb  20160224 用户客户端id
            sc.setIp(this.getIp(request));
            sc.setBankLevel(pbUser.getBank_level());
            sc.setManager_type(pbUser.getManager_type());
            request.getSession().setAttribute("session", sc);
            //记录登录日志
            logService.saveLoginLogInfo(sc,"用户登录,ip:" + this.getIp(request),pbUser.getCode());
    
            int loginModel = PbParameters
                    .getIntParameter(PbParaConstant.LOGINMODEL);
            request.getSession().setAttribute("loginModel", loginModel);
            request.getSession().setAttribute("session", sc);
            // 更改用户最后登陆日期
            pbUserService.editUserLastloginDate(pbUser);
            return new ModelAndView("/Index");

        } catch (Exception e) {
            log.error(e.getMessage(), e);
            writer = response.getWriter();
            writer.write(e.getMessage());
        }
        return null;
    }

url 写 : http://localhost:8080/realware/rcbSingleLoginCheck.do?config=1&user_code=000015 这样就可以测试了。 经测试:成功。

优质内容筛选与推荐>>
1、shmget共享内存
2、练习——循环2
3、人生如此
4、常见面试问题
5、.Net 平台下的版本控制 --- Subversion(SVN)1.6.x


长按二维码向我转账

受苹果公司新规定影响,微信 iOS 版的赞赏功能被关闭,可通过二维码转账支持公众号。

    阅读
    好看
    已推荐到看一看
    你的朋友可以在“发现”-“看一看”看到你认为好看的文章。
    已取消,“好看”想法已同步删除
    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号