This Java library provides an implementation of the client side of the eID STS protocol. This library targets the Apache CXF JAX-WS runtime.
You need at least Apache CXF version 2.7.12. Tested Apache CXF versions: 2.7.12, 2.7.13, 2.7.16, 2.7.18. This eID STS CXF client does not work with Apache CXF version 3.
The Java client library is available within the e-contract.be Maven repository. Configure this Maven repository within your pom.xml as follows:
<repositories>
<repository>
<id>e-contract.be</id>
<url>https://www.e-contract.be/maven2/</url>
</repository>
</repositories>Add the client library within your pom.xml dependencies element as follows:
<dependency>
<groupId>be.e_contract.sts</groupId>
<artifactId>sts-client-cxf</artifactId>
<version>0.5.0</version>
</dependency>The Apache CXF JAX-WS runtime needs the WS-Security modules. Hence add the following dependencies:
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-policy</artifactId>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-security</artifactId>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-mex</artifactId>
</dependency>After compiling the WSDL of a web service that has an STS WS-SecurityPolicy you can enable the security as follows:
import java.security.Security;
import be.fedict.commons.eid.jca.BeIDProvider;
import be.e_contract.sts.client.cxf.SecurityDecorator;
...
static {
Security.addProvider(new BeIDProvider());
}
...
ExampleService exampleService = ExampleServiceFactory.newInstance();
ExampleServicePortType port = exampleService.getExampleServicePort();
SecurityDecorator securityDecorator = new SecurityDecorator(
"example-office-key", "example-software-key");
securityDecorator.decorate((BindingProvider) port,
"https://www.e-contract.be/iam/example");
String result = port.echoWithClaims("hello world");