The following example application starts with the example provided in Chapter 3, WSIT Example Using a Web Container and NetBeans IDE and demonstrates adding security to both the web service and to the web service client.
For this example, the security mechanism of Username Authentication with Symmetric Keys is used to secure the application. To add security to the service part of the example, follow these steps.
If you haven’t already completed these steps, complete them now:
Create the CalculatorApplication example by following the steps described in the following sections of Chapter 3, WSIT Example Using a Web Container and NetBeans IDE.
Expand CalculatorApplication->Web Services, then right-click the node for the web service (CalculatorWS) and select Edit Web Service Attributes.
Deselect Reliable Messaging if it is selected.
In the CalculatorWSPortBinding section, select Secure Service.
From the drop-down list for Security Mechanism, select Username Authentication with Symmetric Keys.
Click the Keystore button to provide your keystore with the alias identifying the service certificate. To do this, click the Load Aliases button and select xws-security-server, then click OK to close the dialog.
Click OK to close the WSIT Configuration dialog.
A new file is added to the project. To view the WSIT configuration file, expand Web Pages->WEB-INF, then double-click the file wsit-org.me.calculator.CalculatorWS.xml. This file contains the sc:KeyStore element.
An example of this file can be viewed in the tutorial by clicking this link: Service-Side WSIT Configuration Files.
Right-click the CalculatorApplication node and select Run Project. A browser will open and display the WSDL file for the application.
Verify that the WSDL file contains the following elements: SymmetricBinding and UsernameToken.
Follow the steps to secure the client application as described in To Secure the Example Web Service Client Application (UA).