10.12.2012 Views

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

3. Clean out files from the previous build, using the following command:<br />

ant clean<br />

4. Recompile, repackage, and redeploy the application, using the following commands:<br />

ant<br />

ant deploy<br />

5. Open your web browser and reload the following URL:<br />

http://localhost:8080/hello2_basicauth/greeting<br />

Example: Basic Authentication with JAX-WS<br />

Examples: SecuringWeb Applications<br />

This section discusses how to configure a JAX-WS-based web service for HTTP basic<br />

authentication. When a service that is constrained by HTTP basic authentication is requested,<br />

the server requests a user name and password from the client and verifies that the user name<br />

and password are valid by comparing them against a database of authorized users.<br />

If the topic of authentication is new to you, refer to the section titled “Specifying an<br />

Authentication Mechanism” on page 854. For an explanation of how basic authentication<br />

works, see Figure 30–2.<br />

For this tutorial, you will add the security elements to the JAX-WS service and client; build,<br />

package, and deploy the service; and then build and run the client application.<br />

This example service was developed by starting with an unsecured service, helloservice,<br />

which can be found in the directory<br />

tut-install/javaeetutorial5/examples/jaxws/helloservice and is discussed in “Creating a<br />

Simple Web Service and Client with JAX-WS” on page 478. You build on this simple<br />

application by adding the necessary elements to secure the application using basic<br />

authentication. <strong>The</strong> example client used in this application can be found at<br />

tut-install/javaeetutorial5/examples/jaxws/simpleclient-basicauth, which only varies<br />

from the original simpleclient application in that it uses the helloservice-basicauth<br />

endpoint instead of the helloservice endpoint. <strong>The</strong> completed version of the secured service<br />

can be found at tut-install/javaeetutorial5/examples/jaxws/helloservice-basicauth.<br />

Chapter 30 • SecuringWeb Applications 881

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!