Apache Rampart

##### Apache Rampart

- About
- Downloads
  - Releases
  - Source Code
- Documentation
  - Quick Start Guide
  - Rampart Configuration
  - Developer Guide
- Project Information
  - Mailing Lists
  - Issue Tracking
  - Dependencies

## Rampart Quick Start Guide

### Installing Rampart in Axis2

Steps to install

1. If you haven't installed Axis2, then download and extract the standard binary distribution. Make sure you have set the AXIS2_HOME environment variable
2. Run ant from the "samples" directory to copy the required libraries and modules to relevant directories in AXIS2_HOME.
3. Download xalan-2.7.0.jar from here and put under AXIS2_HOME\lib folder, if you use JDK 1.5.
4. Download log4j.jar from here and put under AXIS2_HOME\lib

### Running Samples

Now we'll look at how to run the first sample inside samples/policy folder.

1. Open a console and change the directory to sample/policy and give the following command. This will start the server at port 8080

    $ant service.01

2. Open a new console and change the directory to sample/policy and type the following command.

    $ant client.01

Congratulations! Now you have executed the first sample. Rest of the samples can be run by changing the sample number.

### Understanding the first sample

- Engaging Rampart

When securing a SOAP message, the sender must know the security actions to be performed on the message and the receiver must know enough details to process and validate the security of the message. Therefore when using Rampart with Axis2, it must be engaged at both ends.

Observe how module has been engaged in server side by opening samples/policy/sample01/services.xml. The following line has engaged the module.

<module ref="rampart"/>

Engaging Rampart at client side is done programatically as follows.

ServiceClient client = new ServiceClient(ctx, null);
client.engageModule("rampart");

- Understanding policy

WS-Security Policy can be used to indicate what security actions that needs be performed on SOAP messages and and what actions should be validated. The file 'samples/policy/sample01/policy.xml' configures Rampart to add Username Token with Timestamp to this message. The element <RampartConfig> in policy.xml defines Rampart specific configurations.

Policy at serverside is included in samples/policy/sample01/services.xml file. This configures Rampart module at serverside to validate the message for Username Token an Timestamp.

More details on RampartConfig can be found here.

- Viewing the Message on wire

It is interesting to view the secured SOAP message on the wire using TCP monitor. Change the "client.port" property in samples/policy/build.xml file to the listening port of TCP monitor. This will send all the messages through TCP monitor when you execute the ant script. Observe the header in the SOAP message.

### Setting up a Security Token Service

Security Token Service can be set up as per WS-Trust specification using Rampart. The default security token service shipped with the rampart distribution is contained in the rampart-trust.mar module. It can issue SCT tokens and SAML tokens. Sample05 contains a client that connects to the default STS and obtain a SAML token. The services.xml in the sample contains "saml-issuer-config" parameter that is used to configure the default SAML issuer.

STS with a custom issuer

First the default rampart.mar has to be removed from the modules. Then write you own issuer implementing the `"org.apache.rahas.TokenIssuer"` interface. Let's say that your issuer is `"org.custom.MyIssuer"`. Then create a Axis2 service archive with the following in the services.xml. Drop the archive into the repository and you have a STS with a CustomToken issuer.

<module ref="rampart" />
<operation name="IssueToken" mep="http://www.w3.org/2006/01/wsdl/in-out">
<messageReceiver class="org.apache.rahas.STSMessageReceiver"/>
<!-- Action mapping to accept SCT requests -->
<actionMapping>http://schemas.xmlsoap.org/ws/2005/02/trust/RST/SCT</actionMapping>
<actionMapping>http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue</actionMapping>
<actionMapping>http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Renew</actionMapping>
<actionMapping>http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Cancel</actionMapping>
<actionMapping>http://schemas.xmlsoap.org/ws/2005/02/trust/RST/SCT/Cancel</actionMapping>
<actionMapping>http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Validate</actionMapping>
<parameter name="token-dispatcher-configuration">
<token-dispatcher-configuration>
<!-- Issuers. You may have many issuers. -->
<issuer class="org.custom.MyIssuer" default="true">
<configuration type="parameter">saml-issuer-config</configuration>
<tokenType>http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1</tokenType>
</issuer>
</token-dispatcher-configuration>
</parameter>
</operation>