<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    e代劍客——溫柔一刀

    生活就像海洋,只有意志堅強的人,才能到達彼岸

       :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
      76 隨筆 :: 7 文章 :: 215 評論 :: 0 Trackbacks

    使用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 溫柔一刀 閱讀(734) 評論(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,謝謝  回復  更多評論
      

    聯系偶 zhupanjava@gmail.com 溫柔一刀
    主站蜘蛛池模板: 亚洲精品无码av人在线观看| 亚洲白色白色永久观看| 国产午夜无码片免费| 亚洲91av视频| 国产网站免费观看| 羞羞视频免费网站在线看| 亚洲网站视频在线观看| 国产免费av一区二区三区| 人妻免费一区二区三区最新| 性xxxx黑人与亚洲| 国产成人亚洲精品影院| 精品成在人线AV无码免费看| 美女黄色免费网站| 亚洲综合色一区二区三区小说| 四虎影在线永久免费观看| 日本不卡免费新一区二区三区| 亚洲日产乱码一二三区别 | 亚洲人成电影网站国产精品| 99久久99热精品免费观看国产| 蜜芽亚洲av无码一区二区三区| 亚洲AV无码一区二区三区系列| 国产男女性潮高清免费网站 | 久久WWW免费人成人片| 国产中文字幕在线免费观看| 亚洲爆乳AAA无码专区| 亚洲v高清理论电影| 亚洲高清最新av网站| 国产情侣激情在线视频免费看| 中文字幕免费在线观看动作大片| 精品国产日韩久久亚洲| 亚洲精品国产成人99久久| 亚洲国产婷婷综合在线精品| 无码永久免费AV网站| 久久99热精品免费观看牛牛| 特级av毛片免费观看| 亚洲日韩精品国产3区| 亚洲国产福利精品一区二区| 国产亚洲综合网曝门系列| 亚洲精品成人片在线观看| 大陆一级毛片免费视频观看| 国产国产人免费视频成69堂|