<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 常言笑 閱讀(350) 評論(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综合色区无码另类小说 | 日韩成全视频观看免费观看高清| 亚洲综合色区在线观看| 一级日本高清视频免费观看| 久久午夜夜伦鲁鲁片免费无码影视 | 久久精品亚洲中文字幕无码网站| 久久精品无码免费不卡| 成年女人免费视频播放77777| 亚洲视频一区二区| 精品国产呦系列在线观看免费| 国产成人精品久久亚洲高清不卡 | 国产99久久亚洲综合精品| 中文字幕免费高清视频| 国产亚洲av片在线观看18女人 | 100000免费啪啪18免进| 国产亚洲一区二区手机在线观看| 亚洲香蕉久久一区二区| 成**人免费一级毛片| 亚洲视频手机在线| 全黄大全大色全免费大片| www亚洲精品少妇裸乳一区二区| 亚洲精品乱码久久久久久下载| 99视频在线免费观看| 亚洲AV无码精品色午夜果冻不卡| 精品国产污污免费网站| 亚洲色大成网站WWW久久九九 | 久久亚洲一区二区| 国产在线播放线91免费| 亚洲国产精品激情在线观看| 亚洲成a人无码亚洲成av无码| 大胆亚洲人体视频| 久久成人免费大片| 久久精品国产亚洲| 色se01短视频永久免费| 亚洲伊人久久大香线蕉结合| 国产最新凸凹视频免费| 精品一区二区三区免费毛片| 亚洲精品美女久久久久99|