background image

Running the Secure Cart Example

<< Building the Secure Cart Example | getCallerPrincipal Method >>
<< Building the Secure Cart Example | getCallerPrincipal Method >>

Running the Secure Cart Example

Java Result: 1
run-cart-secure-app-client:
Building, Deploying, and Running the Secure Cart Example Using Ant
To build, deploy, and run the secure EJB example using the Ant tool, follow these steps:
1. If you have not already done so, specify properties specific to your installation in the
tut-install/javaeetutorial5/examples/bp-project/build.properties file and the
tut-install/javaeetutorial5/examples/common/admin-password.txt file. See
"Building
the Examples" on page 70
for information on which properties need to be set in which files.
2. If you have not already done so, add a user to the file realm and specify user for the group
of this new user. Refer to the section
"Managing Users and Groups on the Application
Server" on page 781
for instructions on completing this step.
3. From a terminal window or command prompt, go to the
tut-install/javaeetutorial5/examples/ejb/cart-secure/ directory.
4. Build, package, and deploy the enterprise application, and build and run the client, by
entering the following at the terminal window or command prompt in the
ejb/cart-secure/
directory:
ant all
Note ­
This step assumes that you have the executable for ant in your path; if not, you will
need to provide the fully qualified path to the ant executable. This command runs the ant
target named all in the build.xml file.
5. A Login for User dialog displays. Enter a user name and password that correspond to a user
set up on the Application Server with a group of user. Click OK.
If the user name and password are authenticated, the client displays the following output:
run:
[echo] Running appclient for Cart.
appclient-command-common:
[exec] Infinite Jest
[exec] Bel Canto
[exec] Kafka on the Shore
[exec] Caught a BookException:
"Gravity's Rainbow" not in cart.
If the username and password are not authenticated, the client displays the following error:
run:
[echo] Running appclient for Cart.
Enterprise Bean Example Applications
Chapter 29 · Securing Java EE Applications
825