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


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


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 亚洲AV无码成人精品区天堂 | 亚洲宅男永久在线| 亚洲日本中文字幕天堂网| 亚洲人成网站18禁止一区| 亚洲精品岛国片在线观看| 中文亚洲AV片不卡在线观看 | 一区二区三区免费高清视频| 国产精品青草视频免费播放| 黄视频在线观看免费| 中文字幕免费在线看线人 | 亚洲aⅴ无码专区在线观看| 美女扒开尿口给男人爽免费视频 | 美女内射毛片在线看免费人动物 | 2022免费国产精品福利在线| 国产三级在线免费| 中文字幕影片免费在线观看| 国产免费人人看大香伊| 亚洲人成人无码网www电影首页| 亚洲国产精品福利片在线观看| 亚洲欧洲日本精品| 精品亚洲成a人在线观看| 热久久这里是精品6免费观看| 国产免费女女脚奴视频网| 国产免费观看视频| 亚洲AV永久纯肉无码精品动漫| 亚洲图片校园春色| 一级毛片免费毛片毛片| 免费99精品国产自在现线| 亚洲欧洲精品成人久久奇米网| 91亚洲性爱在线视频| 综合一区自拍亚洲综合图区 | 亚洲av成人无码久久精品| 亚洲AV无码成人网站在线观看| 在线观看肉片AV网站免费| 日本不卡视频免费| 666精品国产精品亚洲| 国产免费人成视频尤勿视频| 日韩成人免费在线| 亚洲丝袜中文字幕| 久久精品国产免费观看| 亚洲AV无码久久寂寞少妇|