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

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

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

    隨筆 - 10, 文章 - 0, 評論 - 7, 引用 - 0
    數據加載中……

    使用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   }

    posted on 2007-05-20 12:43 LiuTing 閱讀(371) 評論(0)  編輯  收藏 所屬分類: 身份認證管理


    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 亚洲大香人伊一本线| 在线观看91精品国产不卡免费| 四虎影在线永久免费四虎地址8848aa| 亚洲免费电影网站| 91免费国产视频| 久久久久国产精品免费看| 日本免费v片一二三区| 亚洲AV成人片色在线观看高潮| 美女被免费网站在线视频免费| 国拍在线精品视频免费观看| 亚洲AV无码乱码国产麻豆穿越| 日日躁狠狠躁狠狠爱免费视频 | 久久国产精品萌白酱免费| 日本人的色道www免费一区| 亚洲成av人片在线看片| 日本一区二区免费看| 女人张腿给男人桶视频免费版| 亚洲中文字幕不卡无码| 鲁啊鲁在线视频免费播放| 成人性生交视频免费观看| 国产亚洲精品va在线| 久久精品国产亚洲AV未满十八| 十八禁无码免费网站| 最新精品亚洲成a人在线观看| 校园亚洲春色另类小说合集| 一个人看的www在线观看免费| 久久久久亚洲Av无码专| 久久久久久久99精品免费观看| 国产日产成人免费视频在线观看| 亚洲不卡中文字幕| 2021免费日韩视频网| 亚洲精品高清久久| 国产vA免费精品高清在线观看| 亚洲国产成人精品久久久国产成人一区二区三区综 | 香港a毛片免费观看| 亚洲视频在线观看不卡| 大陆一级毛片免费视频观看i| 天天综合亚洲色在线精品| 亚洲精品无码mv在线观看网站| 日本免费xxxx| 国产偷国产偷亚洲高清人|