ofbiz SSO 单点登录



1ofbiz单点登录介绍

 

ofbiz点单登录是集成了CAS SSOLDAP使用的。详细的CASLDAP怎么应用,在这里不做介绍。

 

2ofbiz点单登录文档

 

ofbiz 12版本号中,有英文的简单的ofbiz单点登录的问题。

路径在:apache-ofbiz-12.04.01frameworkdocumentsSingleSignOn.xml

 

3ofbiz单点登录文件夹

 

ofbiz  单点登录集成的文件夹在:apache-ofbiz-12.04.01specialpurposeldap

在使用单点登录时须要把这个文件夹的应用载入到component.xml中。

 

4ofbiz点单登录原始应用

 

ofbiz原始的单点登录建立在CASLDAP安装及配置好的前提下。

 

每个web应用程序,您须要使用LDAP(单点登录)功能,您须要更改事件的一些安全请求映射org.ofbiz.ldap.LdapLoginWorker类。

 

<request-mapuri="login">

       <securityhttps="false"auth="false"/>

       <eventtype="java"path="org.ofbiz.ldap.LdapLoginWorker"invoke="login"/>

       <responsename="success"type="view"value="main"/>

       <responsename="requirePasswordChange"type="view"value="requirePasswordChange"/>

       <responsename="error"type="view"value="login"/>

   </request-map>

 

 

<request-mapuri="logout">

       <securityhttps="false"auth="false"/>

       <eventtype="java"path="org.ofbiz.ldap.LdapLoginWorker " invoke="logout"/>

       <responsename="success"type="request-redirect"value="main"/>

       <responsename="error"type="view"value="main"/>

   </request-map>

 

5ofbiz ldap.xml 文件配置

 

进入这个文件。我相信搞过ofbiz的人都能开的明确。

在这我想说一下。安全配置的问题。

假设您不想用ssl https这样的模式情况下。https://localhost:8443/cas这样的方式改成http://localhost:8080/cas这样的连接就能够了。这样CAS就不再有签名的问题。当然您也须要配置CAS不使用证书验证的方式。

 

6ofbiz单点登录流程

 

 

 

7ofbiz SSO 改造应用

 

1CAS用户数据在ofbiz表中管理

 

新添加一个实体。名称为SsoUserLogin ,数据和UserLogin数据同步,password能够用先用明文或者通过CAS加密后的密文

 

2、去掉LDAP验证

 

为了更方便简单的单点登录的管理与应用。决定去掉LDAP

OFBizCasAuthenticationHandler.java中去掉:

//           SearchResult result = getLdapSearchResult(username,password, rootElement, false);

//           if (result != null) {

//               return login(request, response,username, password, rootElement, result);

//           }

 

 

这个事获取ldap验证及基于ldap的登录

 

改成:

 

LocalDispatcher dispatcher =(LocalDispatcher) request.getAttribute("dispatcher");

           Delegator delegator =dispatcher.getDelegator();

           GenericValue userTryToLogin= delegator.findOne("SsoUserLogin",false,"userLoginId", username);

           String currentPas =userTryToLogin.getString("currentPassword");

           HttpSessionsession = request.getSession();

           session.setAttribute("USERNAME",username);

           if(currentPas!=null && currentPas!=""){

              session.setAttribute("PASSWORD",currentPas);

           }else{

              session.setAttribute("PASSWORD",password);

          }

 

 

这样改动是为了使用ofbiz最原始的登录方式。

 

 

LdapLoginWorker.java改动:

//           boolean useOFBizLoginWhenFail =Boolean.getBoolean(UtilXml.childElementValue(rootElement,"UseOFBizLoginWhenLDAPFail", "false"));

           //boolean useOFBizLoginWhenFail =Boolean.getBoolean(UtilXml.childElementValue(rootElement,"UseOFBizLoginWhenLDAPFail", "true"));

//         if(useOFBizLoginWhenFail) {

           if (true) {

               return LoginWorker.login(request,response);

           }

 

 

使用ofbiz原始方式登录

 

 

 

登出是一样的节凑。

。。

。。


原文地址:https://www.cnblogs.com/wgwyanfs/p/6846850.html