创建定制领域

除了三个内建领域以外,您还可以创建以其他方式存储用户数据 (例如存储在关系数据库中) 的定制领域。定制领域的开发不在本文档的讨论范围之内。有关详细信息,请参阅 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, 2013, Oracle and/or its affiliates. All rights reserved. Legal Notices