就像好牧师说的那样。以下示例使用文件领域进行身份验证。
@Stateless@WebService(name = "MyAppServices")@RolesAllowed({"user"})public class ItemEJB { ...}您还将需要 sun-ejb-jar.xml 例如
<sun-ejb-jar><security-role-mapping> <!-- as defined in @RolesAllowed --> <role-name>user</role-name> <!-- glassfish group created in file realm --> <group-name>user</group-name></security-role-mapping><enterprise-beans> <ejb> <ejb-name>ItemEJB</ejb-name> <webservice-endpoint> <!-- equivalent to name attribute of @WebService --> <port-component-name>MyAppServices</port-component-name> <login-config> <auth-method>BASIC</auth-method> <realm>file</realm> </login-config> </webservice-endpoint> </ejb></enterprise-beans>
在glassfish的文件领域中创建组很简单(管理控制台)。但是,您可以创建自己的自定义领域和登录模块



