Like the good reverend said. Example below uses a file realm for authentication.
@Stateless
@WebService(name = "MyAppServices")
@RolesAllowed({"user"})
public class ItemEJB {
...
}
You will also need sun-ejb-jar.xml e.g.
<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>
Creation of a group in the file realm in glassfish is trivial (admin console). you can however create your own custom realm and login module
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…