建立自訂範圍

除了三個內建的範圍之外,您還可以建立自訂範圍以其他方式儲存使用者資料,例如使用關聯式資料庫儲存。自訂範圍的開發不在本文件的討論之列。如需更多資訊,請參閱 Oracle GlassFish Server Application Development Guide 中第 5 章 Securing Applications

為進行管理,源自 Java 認證與授權服務 (JAAS) 套裝軟體的類別 (稱為 LoginModule) 會實作自訂範圍。

  1. 遵循建立範圍中的程序,鍵入自訂範圍的名稱以及 LoginModule 類別的名稱。

    針對自訂範圍使用不重複的名稱,例如 myCustomRealm

  2. 按一下 「確定」。

  3. 編輯網域的登入組態檔案 domain-dir/config/login.conf,並在檔案結尾加上 JAAS LoginModule 的完全合格類別名稱,如下所示:

    realmName {
        fully-qualified-LoginModule-classname required;
    };
    

    例如,

    myCustomRealm {
        com.foo.bar.security.customrealm.simpleCustomLoginModule required;
    };
    
  4. LoginModule 類別和所有附屬類別複製至目錄 domain-dir/lib/classes

  5. 如果管理主控台中顯示 「需要重新啟動」,請重新啟動伺服器。

  6. 請確認已正確載入範圍。

    檢查 domain-dir/logs/server.log 以確認伺服器已載入範圍。伺服器應該呼叫範圍的 init 方法。

另請參閱
Copyright © 2005, 2012, Oracle and/or its affiliates. All rights reserved. Legal Notices