<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 溫柔一刀 閱讀(735) 評論(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 溫柔一刀
    主站蜘蛛池模板: 免费一区二区三区四区五区| 啦啦啦完整版免费视频在线观看 | 国产成人啪精品视频免费网| 国产精品久久免费视频| 中文字幕亚洲综合久久综合 | www在线观看播放免费视频日本| 成全在线观看免费观看大全| 综合在线免费视频| 亚洲色图.com| 一级一级毛片免费播放| 亚洲国产精品成人AV无码久久综合影院 | 日本亚洲国产一区二区三区| 亚洲视频在线不卡| 热re99久久6国产精品免费| 亚洲男人的天堂在线播放| 96免费精品视频在线观看| 国产免费爽爽视频免费可以看| 亚洲国产精品久久久天堂 | 无码日韩精品一区二区免费暖暖| 色se01短视频永久免费| 亚洲校园春色小说| 成年女人免费碰碰视频| 亚洲AV无码一区二区三区鸳鸯影院| 成人爱做日本视频免费| 亚洲一本综合久久| 最近最新高清免费中文字幕| 亚洲天堂2017无码中文| 免费va人成视频网站全| 黄色视屏在线免费播放| 久久久久亚洲AV成人无码网站| 亚洲精品在线免费观看| 亚洲妇女无套内射精| 2048亚洲精品国产| 久久精品视频免费播放| 国产成人亚洲精品狼色在线| 午夜影院免费观看| 亚洲人成网站在线在线观看| 国产一卡2卡3卡4卡2021免费观看 国产一卡2卡3卡4卡无卡免费视频 | 国产精品免费久久久久久久久 | 亚洲综合网站色欲色欲| www视频免费看|