This sample demonstrates how to secure EJBs in your application. The application consists of a servlet protected by a role, servletRole, which invokes the method hello on an injected EJB, which is in turn protected by a role, ejbRole. The sample's server is configured so that all authenticated users can access the servlet. However, only user1 is allowed to access the EJB method ejbRole. The following steps describe the how to test the sample, and what the expected results are.
In this scenario, you will access the servlet with a user who is authorized to both the servlet and the EJB method.
In SecureEJBServlet, Hello Secure EJB World.
In this scenario, you will access the servlet with a user who is not authorized to the EJB, because they are not mapped to the ejbRole in the application-bnd stanza of the server.xml
javax.ejb.EJBAccessException: CWWKS9400A: Authorization failed for user user2 while invoking hello on SecureEJBSample. The user is not granted access to any of the required roles: [ejbRole].
This sample can be installed onto runtime versions 8.5.5.0 and later.
Start the SecureEJBSample server by running the command 'bin/server run SecureEJBSampleServer' from the root of the Liberty profile installation, and confirm the application started by looking for the following message in the log:
CWWKZ0001I: Application SecureEJBSample started in XX.XX seconds.
For further information and resources for developers using IBM WebSphere Application Server, please visit wasdev.net.