background image

Running Basic Authentication Servlet

<< Building Servlet Basic Authentication Example | Running the Application >>
<< Building Servlet Basic Authentication Example | Running the Application >>

Running Basic Authentication Servlet

ant
This command uses web.xml and sun-web.xml files, located in the
tut-install/javaeetutorial5/examples/web/hello2_basicauth/web/WEB-INF/ directory.
5. To deploy the example using Ant, enter the following command at the terminal window or
command prompt:
ant deploy
The deploy target in this case gives you an incorrect URL to run the application. To run the
application, please use the URL shown in
"Running the Basic Authentication Servlet" on
page 883
.
6. To run the web application, follow the steps in
"Running the Basic Authentication Servlet"
on page 883
.
Running the Basic Authentication Servlet
To run the web client, follow these steps:
1. Open a web browser.
2. Enter the following URL in your web browser:
http://localhost:8080/hello2_basicauth/greeting
If you set the transport guarantee to CONFIDENTIAL as discussed in
"Protecting
Passwords with SSL" on page 880
, you must load the application in a web browser using
https
for the protocol, the HTTPS port that you specified during installation for the port
(by default this port is 8181), and the context name for the application you wish to run. For
the basic authentication example, you could run the example using the following URL:
https://localhost:8181/hello2_basicauth/greeting
.
3. A default login form displays. Enter a user name and password combination that
corresponds to a user that has already been created in the file realm of the Application
Server and has been assigned to the group of user, as discussed in
"Adding Authorized Roles
and Users" on page 881
.
Basic authentication is case-sensitive for both the user name and password, so enter the user
name and password exactly as defined for the Application Server.
If you entered My_Name as the name and My_Pwd for the password, the server returns the
requested resource if all of the following conditions are met:
There is a user defined for the Application Server with the user name of My_Name.
The user with the user name of My_Name has a password of My_Pwd defined for the
Application Server.
The user My_Name with the password My_Pwd is assigned to the group of user on the
Application Server.
Examples: Securing Web Applications
Chapter 30 · Securing Web Applications
883