登录 注册

mobile与EOS单点

发布时间:Jun 12, 2019 10:29:34 AM 发布人:管理员


归属栏目: Mobile开发


外部链接: 


关键字: 


归属栏目: Mobile开发


文章来源: 


摘要: 

mobileEOS单点

本文介绍EOS应用如何与Mobile应用进行单点登录集成,方便实现PC应用与APP应用的用户登录事宜。在eos上做移动开发时,我们会涉及到前端调用eos后台逻辑流,如果eos不是门户模式那么则需要登录eos后才能调用,这时我们可以用增加拦截器的方式来预登录eos,步骤如下:

1.在eos项目中增加过滤器代码 新建一个类如:CopyOfLoginCAPortalCheckUserByMobile,实现Filter,这个类中主要代码是针对自定义格式访问的拦截如.mobile。

主要代码如下:

request.setCharacterEncoding("utf-8");

String url = request.getRequestURI();

String newurl=url.replace(".mobile", "");

String uid = request.getParameter("muserid");

HttpSession session = request.getSession();

userids=uid;

String requestIP = request.getRemoteAddr();

UserObject userObject = (UserObject)session.getAttribute(IUserObject.KEY_IN_CONTEXT);

if(uid!=null ){

  userObject = LogonUtil.initUserObject(uid);

   if(userObject.getUserName() == null){

response.sendRedirect("/default/coframe/auth/login/login.jsp");

       }else{

         userObject.setSessionId(userObject.getUniqueId());

         userObject.setUserId((String)userObject.getAttributes().get("EXTEND_USER_ID"));

userObject.setUserRemoteIP(request.getRemoteAddr());

         OnlineUserManager.login(userObject);

         session.setAttribute(IUserObject.KEY_IN_CONTEXT,userObject);

        }

    }

 if(userObject==null ||userObject.getUserName() == null ){

 response.sendRedirect("/default/coframe/auth/login/login.jsp");

 }else{

    response.sendRedirect(newurl);

  }

web.xml里配置监听:

<filter>

<filter-name>loginCAPortalCheckUserByMobile</filter-name>

<filter-class>com.gocom.components.coframe.loginUtil.CopyOfLoginCAPortalCheckUserByMobile</filter-class>

</filter>

<filter-mapping>

<filter-name>loginCAPortalCheckUserByMobile</filter-name>

<url-pattern>*.mobile</url-pattern>

<dispatcher>FORWARD</dispatcher>

<dispatcher>REQUEST</dispatcher>

<dispatcher>INCLUDE</dispatcher>

</filter-mapping>

2.前端调用

/** 

* 登录eos 

*/

function loginEOS(muserid){               

var loginurl="com.jinke.omp.warning.queryMsg.loguser.biz.ext.mobile?muserid="+muserid;

$.ajax({                                

 url: loginurl,                              

 type: "POST",                              

 contentType: "text/json",                                 

 success: function (text) {                                      

       }

});}

request.setCharacterEncoding("utf-8");

String url = request.getRequestURI(); String newurl=url.replace(".mobile", "");

String uid = request.getParameter("muserid");

HttpSession session = request.getSession();

userids=uid;

String requestIP = request.getRemoteAddr();

UserObject userObject = (UserObject)session.getAttribute(IUserObject.KEY_IN_CONTEXT);

if(uid!=null ){

userObject = LogonUtil.initUserObject(uid);

if(userObject.getUserName() == null) Unknown macro:

{

response.sendRedirect("/default/coframe/auth/login/login.jsp");

} else Unknown macro: {

userObject.setSessionId(userObject.getUniqueId());

userObject.setUserId((String)userObject.getAttributes().get("EXTEND_USER_ID"));

userObject.setUserRemoteIP(request.getRemoteAddr());

OnlineUserManager.login(userObject);

session.setAttribute(IUserObject.KEY_IN_CONTEXT,userObject);

}

}


相关文章

返回