<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 閱讀(366) 評論(0)  編輯  收藏 所屬分類: 身份認證管理


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


    網站導航:
     
    主站蜘蛛池模板: 亚洲中文字幕无码久久2020| a在线观看免费视频| 免费无码VA一区二区三区| 国产大片91精品免费观看不卡| 久久经典免费视频| 亚洲美免无码中文字幕在线| 麻豆成人久久精品二区三区免费| 久久亚洲伊人中字综合精品| 99在线观看精品免费99| 亚洲精品在线播放| 黄色大片免费网站| 亚洲精品成人区在线观看| 一个人晚上在线观看的免费视频| 亚洲一区二区免费视频| 亚洲AV无码乱码麻豆精品国产| 一级毛片免费全部播放| 国产亚洲综合久久系列| 美女视频黄a视频全免费网站一区 美女视频黄a视频全免费网站色 | 国产精品美女久久久免费| 一二三四在线观看免费高清中文在线观看 | 日本亚洲欧洲免费天堂午夜看片女人员| 成人爽a毛片免费| 久久久久久亚洲精品| 91九色老熟女免费资源站| 亚洲一区中文字幕在线电影网 | 一级女人18毛片免费| 中文字幕无码精品亚洲资源网久久 | 日日操夜夜操免费视频 | 亚洲成在人线中文字幕| 女人被男人躁的女爽免费视频| 亚洲天堂久久精品| 亚洲人成电影网站免费| 一区二区视频在线免费观看| 亚洲国产精品自在在线观看| 免费可以在线看A∨网站| 香蕉国产在线观看免费| 四虎亚洲国产成人久久精品| 亚洲一卡2卡4卡5卡6卡残暴在线| 免费的一级黄色片| 久久香蕉国产线看免费| 99亚洲精品卡2卡三卡4卡2卡|