e代劍客——溫柔一刀
生活就像海洋,只有意志堅強的人,才能到達彼岸
::
首頁
::
新隨筆
::
聯系
::
聚合
::
管理
::
76 隨筆 :: 7 文章 :: 215 評論 :: 0 Trackbacks
隨筆分類
(78)
Agile(3)
(rss)
java相關(33)
(rss)
ROR(2)
(rss)
web相關(1)
(rss)
其他(11)
(rss)
開源框架(19)
(rss)
數據庫相關(8)
(rss)
生活點滴(1)
(rss)
隨筆檔案
(76)
2010年10月 (1)
2007年12月 (3)
2007年7月 (1)
2007年4月 (1)
2007年2月 (4)
2006年12月 (2)
2006年11月 (1)
2006年10月 (9)
2006年9月 (3)
2006年8月 (27)
2006年7月 (14)
2006年6月 (1)
2006年4月 (9)
java源碼
java examples
java學習源代碼檢索中心
java開源大全
spring源碼學習
友情連接
e代劍客—JavaEye
(rss)
開發文檔
hibernate中文文檔
Java2 API 規范
javascript參考手冊
MySQL中文參考手冊
Spring參考手冊
spring進階-IT實驗室
XPath 教程
搜索
最新評論
1.?re: Java應用iText動態生成PDF文件
e21e12eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
--eq23r
2.?re: Toad for oracle 教程[未登錄]
多謝!!!
--啊啊
3.?re: Toad for oracle 教程
謝了
--后來者
4.?re: Toad for oracle 教程
好人多
--hzlxm
5.?re: Toad for oracle 教程
謝謝!
--stophy
閱讀排行榜
1.?Toad for oracle 教程(11344)
2.?spring 生成Excel和PDF文件(7327)
3.?javascript獲取客戶端網卡MAC地址和IP地址和計算機名(7310)
4.?最簡單的iBatis入門例子(6623)
5.?JXL操作Excel(6491)
評論排行榜
1.?Toad for oracle 教程(109)
2.?spring、ibatis控制oracle分頁的問題 (23)
3.?最簡單的iBatis入門例子(16)
4.?德比軟件(DerbySoft)誠聘java工程師(上海)(10)
5.?spring 生成Excel和PDF文件(7)
使用Acegi 1.0獲取用戶信息
使用Acegi 1.0獲取用戶信息,
import
?org.acegisecurity.Authentication;
import
?org.acegisecurity.context.SecurityContext;
import
?org.acegisecurity.context.SecurityContextHolder;
import
?org.acegisecurity.ui.WebAuthenticationDetails;
import
?org.acegisecurity.userdetails.UserDetails;
public
?
class
?ThreadLocaTest?
{
?
?
/**?*/
/**
????*?取得當前用戶名
????*?
????
*/
???
public
?
static
?String?getUsername()
{
????SecurityContext?ctx?
=
?SecurityContextHolder.getContext();
?????
if
(ctx
!=
null
)
{
??????Authentication?auth?
=
?ctx.getAuthentication();???
?????????
if
(auth
!=
null
)
{
???????????Object?principal
=
auth.getPrincipal();
???????????
if
(principal?
instanceof
?UserDetails)?
{
?????????????
return
?((UserDetails)principal).getUsername();
???????????}
else
{
?????????????
return
?principal.toString();?????????
?????????}
???????}
?????}
?????
return
?
null
;
???}
???
/**?*/
/**
?
????*?取得當前用戶密碼
????*?
????
*/
???
public
?
static
?String?getPassword()
{
????SecurityContext?ctx?
=
?SecurityContextHolder.getContext();
?????
if
(ctx
!=
null
)
{???
?????????Authentication?auth
=
ctx.getAuthentication();
?????????
if
(auth
!=
null
)
{
???????????Object?principal
=
auth.getPrincipal();
???????????
if
(principal?
instanceof
?UserDetails)?
{
?????????????
return
?((UserDetails)principal).getPassword();
???????????}
else
{
?????????????
return
?
null
;
???????????}
?????????}
???????
?????}
?????
return
?
null
;
???}
???
/**?*/
/**
????*?取得當前用戶SessionId
????*?
????
*/
???
public
?
static
?String?getSessionID()
{
????SecurityContext?ctx?
=
?SecurityContextHolder.getContext();
?????
if
(ctx
!=
null
)
{
???????
if
(ctx?
instanceof
?SecurityContext)
{
????????SecurityContext?sc
=
(SecurityContext)ctx;
?????????Authentication?auth
=
sc.getAuthentication();
?????????
if
(auth
!=
null
)
{
???????????Object?details
=
auth.getDetails();
???????????
if
(details?
instanceof
?WebAuthenticationDetails)?
{
?????????????
return
?((WebAuthenticationDetails)details).getSessionId();
???????????}
else
{
?????????????
return
?
null
;
???????????}
?????????}
???????}
?????}
?????
return
?
null
;
???}
}
posted on 2006-09-29 15:17
溫柔一刀
閱讀(742)
評論(3)
編輯
收藏
所屬分類:
開源框架
評論
#
re: 使用Acegi 1.0獲取用戶信息[未登錄]
2008-04-22 16:49
rain
為什么我登入成功,Authentication auth = ctx.getAuthentication();
這個為空的呢..我是用struts2
回復
更多評論
#
re: 使用Acegi 1.0獲取用戶信息
2008-06-16 13:55
xx
我也是null
回復
更多評論
#
re: 使用Acegi 1.0獲取用戶信息
2008-08-06 15:57
jinshan
我的也是null,請指教!fujinshan_403@163.com,謝謝
回復
更多評論
新用戶注冊
刷新評論列表
只有注冊用戶
登錄
后才能發表評論。
網站導航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
相關文章:
使用OpenSessionInView模式時的一個異常問題解決方法
sping 、jxl 生成excel文件下載
spring 生成Excel和PDF文件
關于Acegi安全框架登陸后轉向的疑問
使用Acegi 1.0獲取用戶信息
Spring+Hibernate中OpenSessionInView模式運用
spring、ibatis控制oracle分頁的問題
ibatis 自帶分頁方法
Spring-Validator 說明文檔
spring對commons_fileupload和cos_fileuplaod的封裝
Powered by:
BlogJava
Copyright © 溫柔一刀
聯系偶
zhupanjava@gmail.com
溫柔一刀
主站蜘蛛池模板:
阜新
|
乌什县
|
天镇县
|
巨野县
|
兰溪市
|
鸡泽县
|
交城县
|
五指山市
|
盐山县
|
白城市
|
永嘉县
|
光泽县
|
芦溪县
|
太仓市
|
天长市
|
平乡县
|
永昌县
|
壤塘县
|
樟树市
|
靖宇县
|
南投县
|
绥江县
|
湖州市
|
城市
|
德昌县
|
乐安县
|
得荣县
|
大同县
|
新泰市
|
工布江达县
|
池州市
|
威远县
|
银川市
|
胶州市
|
南充市
|
中江县
|
崇信县
|
石柱
|
西贡区
|
昌江
|
东乡族自治县
|