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

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

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

    隨筆 - 10, 文章 - 0, 評論 - 7, 引用 - 0
    數(shù)據(jù)加載中……

    使用Acegi時獲取用戶信息的幾個函數(shù)

    1 /**
     2    * 取得當(dāng)前用戶名
     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    * 取得當(dāng)前用戶密碼
    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    * 取得當(dāng)前用戶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 閱讀(366) 評論(0)  編輯  收藏 所屬分類: 身份認(rèn)證管理


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


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 亚洲精品中文字幕无码蜜桃| 亚洲人成www在线播放| 亚洲视频在线免费观看| 亚洲xxxxxx| 亚洲第一区在线观看| 免费毛片a线观看| ASS亚洲熟妇毛茸茸PICS| 亚洲精品黄色视频在线观看免费资源| 久久久久国色AV免费观看| 亚洲色av性色在线观无码| 免费国产人做人视频在线观看| 亚洲免费观看视频| 亚洲精品国产suv一区88| 国产亚洲av片在线观看播放 | 亚洲欧美精品午睡沙发| 亚洲日本va在线视频观看| 99久久综合国产精品免费| 国产精品成人啪精品视频免费| 亚洲人成电影在线观看网| 中文字幕亚洲日本岛国片| 毛片A级毛片免费播放| 日本视频在线观看永久免费| 麻豆亚洲AV成人无码久久精品| 久久久亚洲精品无码| 亚洲成A人片在线观看中文| 69xx免费观看视频| 在线视频网址免费播放| 亚洲乱码无人区卡1卡2卡3| 亚洲伦理一区二区| 久久亚洲欧洲国产综合| 国产色婷婷精品免费视频| 亚洲精品视频免费在线观看| 好猛好深好爽好硬免费视频| 久久精品国产亚洲AV未满十八| 99久久精品国产亚洲| 亚洲精品美女久久777777| 暖暖日本免费在线视频 | 久久WWW免费人成人片| 最近免费中文字幕大全高清大全1 最近免费中文字幕mv在线电影 | 91精品免费国产高清在线| 曰批全过程免费视频在线观看无码|