<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://www.tkk7.com/youlq/archive/2006/03/03/33487.html  回復  更多評論   


    My Links

    Blog Stats

    常用鏈接

    留言簿(5)

    隨筆分類

    隨筆檔案

    搜索

    積分與排名

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 免费无码又爽又黄又刺激网站| 亚洲AV无码乱码麻豆精品国产| 337p日本欧洲亚洲大胆人人 | 岛国精品一区免费视频在线观看| 免费a级毛片网站| 免费大片av手机看片| 亚洲国产一区明星换脸| www成人免费观看网站| 中文字幕亚洲日本岛国片| 国产精品免费看久久久香蕉| 亚洲人成人无码网www电影首页 | 亚洲成人福利网站| 中文字幕av无码无卡免费| 亚洲精品无码人妻无码| 免费国产综合视频在线看| 国产日韩久久免费影院 | 在免费jizzjizz在线播| 2020久久精品亚洲热综合一本| 性xxxx视频播放免费| 杨幂最新免费特级毛片| 亚洲熟妇无码AV在线播放| 91青青国产在线观看免费| 亚洲成a人片毛片在线| 成人午夜免费福利| 美女黄色免费网站| 亚洲国产成人一区二区精品区| 99re6免费视频| 亚洲成AV人片在WWW| 久久99亚洲综合精品首页| 57pao一国产成视频永久免费| 亚洲色成人WWW永久在线观看| 亚洲伊人久久成综合人影院| 无码人妻精品中文字幕免费| 亚洲中文字幕无码av在线| 国产午夜免费福利红片| 久久久国产精品福利免费| 中文字幕精品三区无码亚洲| 久久久无码精品亚洲日韩软件| 永久黄色免费网站| 男女男精品网站免费观看| 亚洲女人影院想要爱|