h4. Generation and export/import of public keys
* Export/Import of public key 'sslclt':
{code}
keytool -export -keystore keystore-clt.jks -storetype JKS -storepass keystoreclt -alias sslclt -file sslclt.crt
keytool -import -keystore keystore-srv-ssl.jks -storetype JKS -storepass keystoresrv -alias sslclt -file sslclt.crt
{code}
* Export/Import of public key 'wsseclt-sign':
{code}
keytool -export -keystore keystore-clt.jks -storetype JKS -storepass keystoreclt -alias wsseclt-sign -file wsseclt-sign.crt
keytool -import -keystore keystore-srv.jks -storetype JKS -storepass keystoresrv -alias wsseclt-sign -file wsseclt-sign.crt
{code}
* Export/Import of public key 'wsseclt-crypt':
{code}
keytool -export -keystore keystore-srv.jks -storetype JKS -storepass keystoresrv -alias wsseclt-crypt -file wsseclt-crypt.crt
keytool -import -keystore keystore-clt.jks -storetype JKS -storepass keystoreclt -alias wsseclt-crypt -file wsseclt-crypt.crt
{code}
* Export/Import of public key 'sslsrv':
{code}
keytool -export -keystore keystore-srv-ssl.jks -storetype JKS -storepass keystoresrv -alias sslsrv -file sslsrv.crt
keytool -import -keystore keystore-clt.jks -storetype JKS -storepass keystoreclt -alias sslsrv -file sslsrv.crt
{code}
h3. Creation of the service unit
Using the Petals Studio, create a service unit to deploy on the BC SOAP and consume your service.
Next update its JBI descriptor to add the right configuration of the WS-Security:
{code}
<?xml version="1.0" encoding="UTF-8"?>
<jbi:jbi version="1.0"
xmlns:generatedNs="http://InformationDeProduction.cirtil.cer69.recouv/InformationDeProduction.wsdl"
xmlns:jbi="http://java.sun.com/xml/ns/jbi"
xmlns:petalsCDK="http://petals.ow2.org/components/extensions/version-5"
xmlns:soap="http://petals.ow2.org/components/soap/version-4"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<jbi:services binding-component="true">
<jbi:consumes
interface-name="generatedNs:InformationDeProductionPortType"
service-name="generatedNs:InformationDeProductionService"
endpoint-name="InformationDeProductionPort">
<!-- CDK specific elements -->
<petalsCDK:timeout>30000</petalsCDK:timeout>
<petalsCDK:mep xsi:nil="true" />
<!-- Component specific elements -->
<soap:service-name>InformationDeProductionServiceSSLandWSSE</soap:service-name>
<soap:mode>SOAP</soap:mode>
<soap:enable-http-transport>false</soap:enable-http-transport>
<soap:enable-https-transport>true</soap:enable-https-transport>
<soap:enable-jms-transport>false</soap:enable-jms-transport>
<soap:modules>rampart</soap:modules>
<soap:service-parameters>
<![CDATA[
<parameter name="InflowSecurity">
<action>
<items>Signature Encrypt Timestamp UsernameToken</items>
<user>wsseclt-id</user>
<passwordCallbackClass>org.ow2.petals.test.PWCBHandler</passwordCallbackClass>
<userCertAlias>wsseclt-sign</userCertAlias>
<signaturePropFile>service.properties</signaturePropFile>
<decryptionPropFile>service.properties</decryptionPropFile>
</action>
</parameter>
]]>
</soap:service-parameters>
</jbi:consumes>
</jbi:services>
</jbi:jbi>
{code}
Add the properties file 'service.properties' under the directory 'jbi' and containing:
{code}
org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.Merlin
org.apache.ws.security.crypto.merlin.keystore.type=jks
org.apache.ws.security.crypto.merlin.keystore.password=keystoresrv
org.apache.ws.security.crypto.merlin.file=../https/keystore-srv.jks
{code}
Add the class 'PWCBHandler' as password callback:
{code}
public class PWCBHandler implements CallbackHandler {
public void handle (Callback[] callbacks) throws IOException, UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i];
String id = pwcb.getIdentifer();
if (id.equals("wsseclt-id")) {
pwcb.setPassword("pwwsseid");
}
else if (id.equals("wsseclt-crypt")) {
pwcb.setPassword("keystoresrv");
}
}
}
}
{code}
h3. Running the use case
Launch a freshly installed Petals ESB.
Install the Petals BC SOAP enabling SSL through the component parameters:
* https-enabled = true
* https-port = 8083
* https-keystore-type = JKS
* https-keystore-file = ../https/keystore-srv-ssl.jks
* https-keystore-password = keystoresrv
* https-key-password = pwsslsrv
* https-client-authentication-enabled = true
Deploy your SU.
Use SoapUI to invoke your secured service !
h1. Complex Use Cases
These use cases involve several Petals components including the Petals-BC-SOAP component.
{contentbylabel:labels=uc-soap|showLabels=false|showSpace=false}