除了三個內建的範圍之外,您還可以建立自訂範圍以其他方式儲存使用者資料,例如使用關聯式資料庫儲存。自訂範圍的開發不在本文件的討論之列。如需更多資訊,請參閱「Sun GlassFish Enterprise Server v3 Prelude Developer’s Guide」中的第 4 章「Securing Applications」。
為進行管理,源自 Java 認證與授權服務 (JAAS) 套裝軟體的類別 (稱為 LoginModule) 會實作自訂範圍。
針對自訂範圍使用不重複的名稱,例如 myCustomRealm。
realmName { fully-qualified-LoginModule-classname required; };
例如,
myCustomRealm { com.foo.bar.security.customrealm.simpleCustomLoginModule required; };
檢查 domain-dir/logs/server.log 以確認伺服器已載入範圍。伺服器應當呼叫範圍的 init 方法。