關于JForum論壇的基本情況就不在此介紹了,官方網址:www.jforum.net.jforum論壇系統的安裝也很簡單,按照官方文檔,或者google一下,基本都可以搞定,在此就不在介紹了。大概描述一下我使用jforum的情況:
1.應用服務器:weblogic8.1
2.數據庫:oracle10g
3.已有一個電子商務網站,需要和jforum進行簡單的集成,提供sso(單點登錄的功能)。
4.說明:已有的電子商務網站域名:http://www.123.com jforum域名:www.123.com/forum,電子商務網站和jfroum在統一臺服務器和同一應用服務器下,如果分開可能會存在session或cookie訪問的問題。
5.JForum版本:2.1.8
下面簡要的介紹一下使用cookie進行jforum和電子商務網站的sso集成的過程:
(1)實現net.jforum.sso接口
public class CookieUserSSO implements SSO {
static final Logger logger = Logger.getLogger(CookieUserSSO.class.getName());
public String authenticateUser(RequestContext request) {
// login cookie set by my web LOGIN application
Cookie cookieNameUser = ControllerUtils.getCookie(SystemGlobals
.getValue(ConfigKeys.COOKIE_NAME_USER));
String username = null;
if (cookieNameUser != null) {
username = cookieNameUser.getValue();
}
logger.info("cookie username="+username);
System.out.println("cookie username="+username);
return username; // return username for jforum
// jforum will use this name to regist database or set in HttpSession
}
public boolean isSessionValid(UserSession userSession,
RequestContext request) {
Cookie cookieNameUser = ControllerUtils.getCookie(SystemGlobals
.getValue(ConfigKeys.COOKIE_NAME_USER)); // user cookie
String remoteUser = null;
if (cookieNameUser != null) {
remoteUser = cookieNameUser.getValue(); // jforum username
}
if (remoteUser == null
&& userSession.getUserId() != SystemGlobals
.getIntValue(ConfigKeys.ANONYMOUS_USER_ID)) {
// user has since logged out
return false;
} else if (remoteUser != null
&& userSession.getUserId() == SystemGlobals
.getIntValue(ConfigKeys.ANONYMOUS_USER_ID)) {
// anonymous user has logged in
return false;
} else if (remoteUser != null
&& !remoteUser.equals(userSession.getUsername())) {
// not the same user (cookie and session)
return false;
}
return true; // myapp user and forum user the same. valid user.
}
}
(2)修改SystemGlobals.properties中的配置:
修改SystemGlobals.properties文件中的一下屬性的內容:
authentication.type = sso
sso.implementation = net.jforum.sso.CookieUserSSO
sso.redirect = http://www.123.com/login.jsp //可根據實際的登錄頁面地址進行修改
cookie.name.user = 123UserInfo //電子商務網站中保存的cookie名稱,可根據實際情況修改
(3)修改web應用中的登錄和注銷部分的邏輯:
登錄部分加入以下代碼:
...
Cookie cookie = new Cookie("springTourUserInfo", sname);
cookie.setMaxAge(-1);
cookie.setPath("/");//cookie只在同一應用服務器有效
response.addCookie(cookie);
...
注銷部分加入以下代碼:
......
Cookie cookie = new Cookie("springTourUserInfo", "");
cookie.setMaxAge(0); // delete the cookie.
cookie.setPath("/");
response.addCookie(cookie);
......
(4)在電子商務網站增加論壇的鏈接:
<a href="/forum">論壇</a>
基本配置完整,測試通過,如有問題,歡迎交流!
感謝網友提供的資料:
http://www.lifevv.com/java/doc/20080305224358885.html?page=0
http://www.99inf.net/SoftwareDev/Java/54230.htm(作者:王保政)
FeedBack:
# re: JForum 的 SSO集成的問題解決
# re: JForum 的 SSO集成的問題解決
只有注冊用戶登錄后才能發表評論。 | ||
![]() |
||
網站導航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
|
||
相關文章:
|
||
| |||||||||
日 | 一 | 二 | 三 | 四 | 五 | 六 | |||
---|---|---|---|---|---|---|---|---|---|
25 | 26 | 27 | 28 | 29 | 30 | 31 | |||
1 | 2 | 3 | 4 | 5 | 6 | 7 | |||
8 | 9 | 10 | 11 | 12 | 13 | 14 | |||
15 | 16 | 17 | 18 | 19 | 20 | 21 | |||
22 | 23 | 24 | 25 | 26 | 27 | 28 | |||
29 | 30 | 1 | 2 | 3 | 4 | 5 |
常用鏈接
留言簿(17)
隨筆分類
- appfuse(1)
- CRM&ERP(1)
- Grails(3)
- java(11)
- ofbiz學習(1)
- seam2.0學習筆記(1)
- SPRING
- sso(3)
- STRUTS(1)
- Sync4j(1)
- SyncML(2)
- 大戰SOA & MULE
- 工作日志(2)
- 開發工具(3)
- 生活感悟(1)
- 系統維護(3)
隨筆檔案
- 2011年2月 (2)
- 2011年1月 (3)
- 2010年12月 (1)
- 2010年5月 (1)
- 2010年3月 (1)
- 2009年12月 (1)
- 2009年9月 (1)
- 2009年8月 (1)
- 2009年7月 (1)
- 2009年5月 (1)
- 2009年4月 (1)
- 2009年2月 (1)
- 2008年7月 (1)
- 2008年6月 (1)
- 2008年3月 (3)
- 2007年12月 (1)
- 2007年8月 (1)
- 2007年7月 (1)
- 2006年12月 (1)
- 2006年11月 (1)
- 2006年10月 (1)
- 2006年9月 (1)
- 2006年7月 (1)
- 2006年4月 (2)
- 2005年12月 (1)
- 2005年11月 (1)
- 2005年10月 (4)
- 2005年9月 (1)
文章檔案
blog
- eamoi之Coder日志
- ajax
- liferayPortal
- steeven
- sync4j
- sync4j1
- 大胃
- 月亮的太陽
- 鐵手劍譜
- 鐵手
搜索
最新評論

- 1.?re: cas配置全攻略
- 可以下載你的源碼么?尤其是person-directory-api-1.5.1.jar的源碼
- --xxr
- 2.?re: cas配置全攻略[未登錄]
- lz的代碼為什么沒有用排版插件,看的不清楚啊
- --Jason
- 3.?re: 找不到C.TLD的問題
- 33
- --ui
- 4.?re: cas server 3.4.5 部署在weblogic問題記錄[未登錄]
- 評論內容較長,點擊標題查看
- --大雄
- 5.?re: cas配置全攻略
- 同樣遇到 Map是空的,沒有附加屬性
- --fanfree