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

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

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

    常言笑的家

    Spring, Hibernate, Struts, Ajax, RoR

    使用Acegi時獲取用戶信息的幾個函數

     

     1 /**
     2    * 取得當前用戶名
     3    *  @return
     4     */

     5    public   static  String getUsername() {
     6     Context context = ContextHolder.getContext();
     7      if (context != null ) {
     8        if (context  instanceof  SecureContext) {
     9         SecureContext sc = (SecureContext)context;
    10         Authentication auth = sc.getAuthentication();
    11          if (auth != null ) {
    12           Object principal = auth.getPrincipal();
    13            if (principal  instanceof  UserDetails)  {
    14              return  ((UserDetails)principal).getUsername();
    15           }
    else {
    16              return  principal.toString();
    17           }

    18         }

    19       }

    20     }

    21      return   null ;
    22   }

    23    /**
    24    * 取得當前用戶密碼
    25    *  @return
    26     */

    27    public   static  String getPassword() {
    28     Context context = ContextHolder.getContext();
    29      if (context != null ) {
    30        if (context  instanceof  SecureContext) {
    31         SecureContext sc = (SecureContext)context;
    32         Authentication auth = sc.getAuthentication();
    33          if (auth != null ) {
    34           Object principal = auth.getPrincipal();
    35            if (principal  instanceof  UserDetails)  {
    36              return  ((UserDetails)principal).getPassword();
    37           }
    else {
    38              return   null ;
    39           }

    40         }

    41       }

    42     }

    43      return   null ;
    44   }

    45    /**   */ /**
    46    * 取得當前用戶session id
    47    *  @return  sessionid or null
    48     */

    49    public   static  String getSessionID() {
    50     Context context = ContextHolder.getContext();
    51      if (context != null ) {
    52        if (context  instanceof  SecureContext) {
    53         SecureContext sc = (SecureContext)context;
    54         Authentication auth = sc.getAuthentication();
    55          if (auth != null ) {
    56           Object details = auth.getDetails();
    57            if (details  instanceof  WebAuthenticationDetails)  {
    58              return  ((WebAuthenticationDetails)details).getSessionId();
    59           }
    else {
    60              return   null ;
    61           }

    62         }

    63       }

    64     }

    65      return   null ;
    66   }

    67

    posted on 2006-12-16 22:46 常言笑 閱讀(349) 評論(1)  編輯  收藏 所屬分類: JAVA/J2EE

    Feedback

    # re: 使用Acegi時獲取用戶信息的幾個函數 2006-12-18 09:41 一餐三碗[匿名]

    老大,引用的我文章好歹要說一聲吧?

    http://m.tkk7.com/youlq/archive/2006/03/03/33487.html  回復  更多評論   


    My Links

    Blog Stats

    常用鏈接

    留言簿(5)

    隨筆分類

    隨筆檔案

    搜索

    積分與排名

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 亚洲av永久无码精品天堂久久 | 亚洲精品成人网站在线播放| 一级人做人a爰免费视频| 国产免费卡一卡三卡乱码| 亚洲AV无码一区二区三区牲色| 999久久久免费精品国产| 亚洲乱码在线观看| 亚洲av综合色区| 三年片在线观看免费西瓜视频| 日本红怡院亚洲红怡院最新| 亚洲色精品VR一区区三区| 午夜时刻免费入口| 黄网站色视频免费看无下截| 亚洲国产精品毛片av不卡在线| 精品国产污污免费网站入口| 久久精品国产精品亚洲艾| 曰批视频免费40分钟试看天天| 亚洲伊人久久大香线蕉在观| 暖暖免费高清日本一区二区三区| 国产偷国产偷亚洲高清在线| 亚洲午夜精品一级在线播放放| 国产真人无码作爱视频免费 | 亚洲精品美女久久777777| 日韩视频在线观看免费| 亚洲毛片一级带毛片基地| 免费网站看v片在线香蕉| 国产美女视频免费观看的网站| 西西人体44rt高清亚洲| 噼里啪啦免费观看高清动漫4| 久久无码av亚洲精品色午夜| 国产亚洲AV手机在线观看| 16女性下面扒开无遮挡免费| 亚洲国产高清国产拍精品| 亚洲视频免费在线看| 亚洲成aⅴ人片久青草影院按摩| 久久久久亚洲av成人无码电影| 中文字幕免费视频| 在线亚洲精品视频| 亚洲男人都懂得羞羞网站| 日韩黄色免费观看| 久久A级毛片免费观看|