@Override protected Map<String, String> getInfoMap(PtSessionBean ssoInfo) { Map<String, String> infoMap = new HashMap<String, String>(); infoMap.put(USERID, ssoInfo.getPk_user()); infoMap.put(GROUPNO, ssoInfo.getGroupNo()); return infoMap; }
public void afterLogin(LfwSessionBean sbean) { PtSessionBean ptBean = (PtSessionBean) sbean; IUserVO userVO = (IUserVO) ptBean.getUser(); try { /** License检查 */ // checkLicense(userVO.getPk_user(), userVO.getPassword()); /** 初始化用户信息 */ initUser(ptBean); UFBoolean loginResult = UFBoolean.TRUE; doLoginLog(sbean, loginResult); } catch (Exception e) { LfwLogger.error(e.getMessage(), e); throw new LfwRuntimeException(e.getMessage()); } }
@Override protected PtSessionBean restoreByInfoMap(Map<String, String> info) { try { String userid = info.get(USERID); String groupno = info.get(GROUPNO); CpUserVO userVO = CpbServiceFacility.getCpUserQry().getGlobalUserByCode(userid); if (userVO == null) return null; CpUser user = new CpUser(userVO); PtSessionBean ses = new PtSessionBean(); ses.setUser(user); ses.setGroupNo(groupno); return ses; } catch (CpbBusinessException e) { throw new PortalServerRuntimeException("恢复用户信息时出现错误"); } }
@Override public void addSsoSign(PtSessionBean sesbean, String sysid) { HttpServletRequest request = LfwRuntimeEnvironment.getWebContext().getRequest(); HttpSession session = request.getSession(); session.setAttribute(SessionConstant.LOGIN_SESSION_BEAN, sesbean); LfwRuntimeEnvironment.setLfwSessionBean(sesbean); LfwRuntimeEnvironment.setDatasource(sesbean.getDatasource()); String sesid = session.getId(); // 创建一个token LfwTokenVO token = new LfwTokenVO(); token.setDatasource(sesbean.getDatasource()); token.setPkcrop(sesbean.getPk_unit()); token.setUsername(sesbean.getUser_name()); token.setSessionid(sesid); token.setUserpk(sesbean.getPk_user()); token.setThemeid(sesbean.getThemeId()); token.setUsertype(String.valueOf(sesbean.getUserType())); token.setPasswd(sesbean.getUser().getPassword()); token.setUserid(sesbean.getUser_code()); token.setLoginip(request.getRemoteAddr()); token.setSessionid(sesid); token.setSystemid(sysid); token.setExt1(LfwRuntimeEnvironment.getRootPath()); // token.setAccountcode(sesbean.getAccount()); token.setLogindate(new UFDateTime(System.currentTimeMillis())); String uuid = UUID.randomUUID().toString(); token.setTokenid(uuid); ILfwSsoService ssoService = NCLocator.getInstance().lookup(ILfwSsoService.class); try { ssoService.createToken(token); // Token编号设置到session bean中 // 设置根Token编号 session.setAttribute(SessionConstant.ROOT_TOKEN_ID, LfwSsoUtil.getTokenID()); sesbean.setSsotoken(uuid); } catch (LfwBusinessException e) { LfwLogger.error("单点登陆信息注册失败", e); } }