欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
CAS如何跟普通的Web系統融合認證和授權

CAS的作用是負責單點(diǎn)登錄,登錄細節當然要自己寫(xiě),CAS3有一個(gè)這樣的AuthenticationHandler 接口,繼承關(guān)系如下
1,AbstractAuthenticationHandler implements AuthenticationHandler
2,AbstractUsernamePasswordAuthenticationHandler extends AbstractAuthenticationHandler

AbstractUsernamePasswordAuthenticationHandler 正是你認證管理的著(zhù)手點(diǎn),你寫(xiě)一個(gè)類(lèi),如WeblogicAuthenticanHandler去擴展它。

你先看看下面的接口:

public interface AuthenticationHandler {

    /**
     * Method to determine if the credentials supplied can be authenticated.
     *
     * @param credentials The credentials to authenticate
     * @return true if authenticated and false they are not
     * @throws AuthenticationException An AuthenticationException can contain details about why a particular authentication request failed.
     * AuthenticationExceptions contain code/desc.
     */
    boolean authenticate(Credentials credentials) throws AuthenticationException;
}


authenticate這個(gè)接口是每個(gè)Hander都必須實(shí)現,當然,AbstractHandler將它轉交給 authenticateInternal 方法去實(shí)現。

認證有兩種情況,成功或者失敗,true or false。
我使用Weblogic的LoginModule

loginContext = new LoginContext("WeblogicUsernamePasswordModule", new WeblogicCallbackHandler(username, password, url));

它拋出個(gè)各種不同的認證異常讓我輕松判斷認證過(guò)程中發(fā)生了什么事情,
     /**
      * Attempt authentication
      */
     try
     {
       // If we return without an exception, authentication succeeded
       loginContext.login();
     }
     catch(FailedLoginException fle)
     {
       System.out.println("Authentication Failed, " + fle.getMessage());
       loginsccess=false;
     }
     catch(AccountExpiredException aee)
     {
       System.out.println("Authentication Failed: Account Expired");
       loginsccess=false;
     }
     catch(CredentialExpiredException cee)
     {
       System.out.println("Authentication Failed: Credentials Expired");
       loginsccess=false;
     }
     catch(Exception e)
     {
       System.out.println("Authentication Failed: Unexpected Exception, " + e.getMessage());
       loginsccess=false;
     }

如果一切正常,授權開(kāi)始了。

     if(loginsccess==true)
     {
      /**
       * Retrieve authenticated subject, perform SampleAction as Subject
       */
      subject = loginContext.getSubject();
      System.out.println("User["+ username+"]["+ password+"] Login Success, Subject is"+subject.toString());
      return true;
     }
     else
     {
      System.out.println("User["+ username+"]["+ password+"] Login Fail, Check!!!!!");
      return false;
     }

OK,獲得了Subject,那你就可以獲得principal,編程式授權便有了依據。
同時(shí),你還可以用Weblogic的聲明式授權,直接在web.xml中定義資源的授權規則。

本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
使用 CAS 在 Tomcat 中實(shí)現單點(diǎn)登錄
單點(diǎn)登錄學(xué)習(1)CAS服務(wù)器端配置編程
Acegi簡(jiǎn)介
春季-身份驗證失敗重定向,請求參數不起作用
JAAS簡(jiǎn)介及實(shí)例
初識Shiro
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久