XML SOAP signature sample
The sample in the xml/soap folder generates an XML signature for a SOAP document according to WS-Security.
Compiling the SOAP signature sample
Run the following command line in the etjava/examples directory.
javac -sourcepath source -d classes -classpath ../lib/enttoolkit.jar;<xalan.jar>;<xercesImpl.jar>;<xml-apis.jar> \source/com/entrust/toolkit/examples/xml/soap/SoapSigner.java \source/com/entrust/toolkit/examples/xml/soap/SigningWorker.java \source/com/entrust/toolkit/examples/xml/utils/Utils.java|
Parameter |
Value |
|
<xalan.jar> |
The path of the xalan.jar third-party library. |
|
<xercesImpl.jar> |
The path of the xercesImpl.jar third-party library. |
|
<xml-apis.jar> |
The path of the xml-apis.jar third-party library. |
Running the SOAP signature sample
Run the following command line in the etjava/examples directory.
java -classpath ../lib/enttoolkit.jar;<xalan.jar>;<xercesImpl.jar>;<xml-apis.jar> com.entrust.toolkit.examples.xml.soap.SoapSigner <epf_file> <epf_pwd> <init.properties> <in_xml> <out_xml> [<xml_element>]|
Parameter |
Value |
|
<xalan.jar> |
The path of the xalan.jar third-party library. |
|
<xercesImpl.jar> |
The path of the xercesImpl.jar third-party library. |
|
<xml-apis.jar> |
The path of the xml-apis.jar third-party library. |
|
<epf_file> |
The path of an Entrust user profile in .epf file format. |
|
<epf_pwd> |
The path of an Entrust user profile in .epf file format. |
|
<init.properties> |
The URI of the init.properties initialization file for the IXSIL library. |
|
<in_xml> |
The URI of an XML resource to be signed, for example file:/c:/test/tobesigned.xml |
|
<out_xml> |
The path of the resulting XML signed file. |
|
<xml_element> |
The name of the XML element in the document being signed where the Signature is to be inserted, For example "s:Body". |
For example:
D:\java\etjava\examples>java -classpath classes;..\lib\enttoolkit.jar;..\lib\xalan.jar;..\lib\xercesImpl.jar;..\lib\xml-apis.jarcom.entrust.toolkit.examples.xml.soap.SoapSigner data\userdata\RSAUser1.epf ~Sample7~file:/d:/java/etjava/examples/data/xml/init/properties/init.propertiesfile:data/xml/soap/soapSignMe.xml data\xml\soap\soapSigned.xml signmeIdLogging in to: data\userdata\RSAUser1.epfInitializing IXSIL properties from "file:/d:/java/etjava/examples/data/xml/init/properties/init.properties"...IXSIL is initialized.WS Schema locations: " http://schemas.xmlsoap.org/ws/2002/07/utility file:/d:/java/etjava/examples/data/xml/init/schemas/schemas-xmlsoap-org-ws-2002-07-utility.xsd http://schemas.xmlsoap.org/ws/2002/12/secext file:/d:/java/etjava/examples/data/xml/init/schemas/schemas-xmlsoap-org-ws-2002-12-secext.xsd http://schemas.xmlsoap.org/soap/envelope/ file:/d:/java/etjava/examples/data/xml/init/schemas/schemas-xmlsoap-org-soap-envelope.xsd"Created a signature over content at Id "signmeId" in the SOAP document at "file:data/xml/soap/soapSignMe.xml"<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext" xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://schemas.xmlsoap.org/soap/envelope/ http://schemas.xmlsoap.org/soap/envelope/ http://schemas.xmlsoap.org/ws/2002/07/utility http://schemas.xmlsoap.org/ws/2002/07/utility/ http://schemas.xmlsoap.org/ws/2002/12/secext http://schemas.xmlsoap.org/ws/2002/12/secext/"><soap:Header><wsse:Security><wsse:BinarySecurityToken EncodingType="wsse:Base64Binary" ValueType="wsse:X509v3"wsu:Id="X509Token">MIIDiDCCAnCgAwIBAgIEP3l9djANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJDQTEdMBsGA1UEChMUSmF2YSBUb29sa2l0IFNhbXBsZXMxDTALBgNVBAsTBFBLSTcwHhcNMDMxMDAxMTQ1MjIwWhcNMDgxMDAxMTUyMjIwWjBPMQswCQYDVQQGEwJDQTEdMBsGA1UEChMUSmF2YSBUb29sa2l0IFNhbXBsZXMxDTALBgNVBAsTBFBLSTcxEjAQBgNVBAMTCVJTQSBVc2VyMTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA0RqETfqyWrn7vMmHbikcnDRg+BLF+4xNTngGM4kMAZnepbXzHLeE+eEYlHV6aDfHbqoe+bxRaqbqahUYyoqgeLPRjNBhczd/ystM6QISaGa+AgnQ/SZja3FSz2axnvMlUSghOQ8ih52P/IJv4AeqgZTC9lUeqeLQA9yNAKChn38CAwEAAaOCAQIwgf8wCwYDVR0PBAQDAgeAMCsGA1UdEAQkMCKADzIwMDMxMDAxMTQ1MjIwWoEPMjAwNzA0MDIxMjIyMjBaMF0GA1UdHwRWMFQwUqBQoE6kTDBKMQswCQYDVQQGEwJDQTEdMBsGA1UEChMUSmF2YSBUb29sa2l0IFNhbXBsZXMxDTALBgNVBAsTBFBLSTcxDTALBgNVBAMTBENSTDEwHwYDVR0jBBgwFoAUV3GOJrFdh093mk0NWO/1W4td18cwHQYDVR0OBBYEFDpNqeL94Ls85pwAizoedB7+rIUZMAkGA1UdEwQCMAAwGQYJKoZIhvZ9B0EABAwwChsEVjcuMAMCBLAwDQYJKoZIhvcNAQEFBQADggEBAHl1NBMt1EtCQzqInasKvUYtw/sjpOf6IeNBZ8Gs/0K29OT69EKSiZBA7rTJoF6XZrJqQWV5ZDCpfYXjEVFp4YfWjOKceI/kxZIZj4thn727RAfUbO0T9Q3zvwWzZzdkf+w8G/RWEEp8K4RM0DjQPw60WetJcj3Gt4TtOZbYDNwy6sKH5Ivh/C2tt2BIlRLT4iuvaeG+qHPPXWAR0lihNkFKQAQuIEb4qz/dv7D1e8KN8T+P8SryktJcWehNeMLhauc8mDLHBf8YV9Exrf3NXrnhFHCKFu0f8EXhpWwpp1X/0bqjEh0dmrAdejQ6r7MaxoSVuevBaSWhWvxxVGgLQ9o=</wsse:BinarySecurityToken><dsig:Signature Id="Signature001" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext"><dsig:SignedInfo><dsig:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/><dsig:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/><dsig:Reference URI="#signmeId"><dsig:Transforms><dsig:Transform Algorithm="http://www.w3.org/2001/04/decrypt#"/></dsig:Transforms><dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><dsig:DigestValue>FnwNksOoGNEYIMMrkmd9QAmPhLs=</dsig:DigestValue></dsig:Reference></dsig:SignedInfo><dsig:SignatureValue>dB+a6PW1pzJrhmKgjV/ez/uhedhlurigvHpzk41s2X1eeF3zJRhGOABscj/3Srns85okuf5hxfU8KrxM/ZmRkuFkkGDfzqxDB7oCW3rvE5VhZdrqcoOmV72SI+WV+RJLv6SkzELJ7nZGFHpRgAsxHGMMF9m5ZgjH/ezw6rz+ZE8=</dsig:SignatureValue><dsig:KeyInfo Id="KeyInfo001"><wsse:SecurityTokenReference><wsse:Reference URI="#X509Token"/></wsse:SecurityTokenReference></dsig:KeyInfo></dsig:Signature></wsse:Security></soap:Header> <soap:Body wsu:Id="signmeId"> <confirmOrder> <sendTo> <name>John Doe</name> <address>123 Circle Road</address> <zip>K1B 0R4</zip> <city>Ottawa</city> <country>Canada</country> <phone>555 456 7890</phone> </sendTo> <item> <name>Swing Set</name> <serialNumber>4151986942</serialNumber> <quantity>1</quantity> <price>200</price> </item> </confirmOrder> </soap:Body></soap:Envelope>Writing to file: data\xml\soap\soapSigned.xmlDoneVerifying a SOAP signature
Run the sample application described in Running Verify to validate the generated SOAP signature. For example:
D:\java\etjava\examples>java -classpath classes;..\lib\enttoolkit.jar;..\lib\xalan.jar;..\lib\xercesImpl.jar;..\lib\xml-apis.jarcom.entrust.toolkit.examples.xml.sign.Verify data\userdata\RSAUser1.epf ~Sample7~file:/d:/java/etjava/examples/data/xml/init/properties/init.propertiesfile:/d:/java/etjava/examples/data/xml/soap/soapSigned.xmlJava installation directory:C:\Program Files\Java\j2re1.4.2JRE version: 1.4.2Java class path:classes;..\lib\enttoolkit.jarOS:Windows XPOS architecture:x86OS version:5.1File separator: \Path separator: ;Line separator: 0x0D 0x0AUser's account name: [deleted]User's home directory: [deleted]User's current working directory:D:\java\etjava\examplesJava VM version:1.4.2-b28Java library path: [deleted]XML DOM parser:nullXML SAX parser:nullXML XSLT implementation:nullLogging in to: data\userdata\RSAUser1.epfInitializing IXSIL properties from "file:/d:/java/etjava/examples/data/xml/init/properties/init.properties"...IXSIL has been initialized.dsig schema location: "http://www.w3.org/2000/09/xmldsig# file:/d:/java/etjava/examples/data/xml/init/schemas/Signature.xsd"WS Schema locations: " http://schemas.xmlsoap.org/ws/2002/07/utility file:/d:/java/etjava/examples/data/xml/init/schemas/schemas-xmlsoap-org-ws-2002-07-utility.xsd http://schemas.xmlsoap.org/ws/2002/12/secext file:/d:/java/etjava/examples/data/xml/init/schemas/schemas-xmlsoap-org-ws-2002-12-secext.xsd http://schemas.xmlsoap.org/soap/envelope/ file:/d:/java/etjava/examples/data/xml/init/schemas/schemas-xmlsoap-org-soap-envelope.xsd"Schema locations: "http://www.w3.org/2000/09/xmldsig# file:/d:/java/etjava/examples/data/xml/init/schemas/Signature.xsd http://schemas.xmlsoap.org/ws/2002/07/utility file:/d:/java/etjava/examples/data/xml/init/schemas/schemas-xmlsoap-org-ws-2002-07-utility.xsd http://schemas.xmlsoap.org/ws/2002/12/secext file:/d:/java/etjava/examples/data/xml/init/schemas/schemas-xmlsoap-org-ws-2002-12-secext.xsd http://schemas.xmlsoap.org/soap/envelope/ file:/d:/java/etjava/examples/data/xml/init/schemas/schemas-xmlsoap-org-soap-envelope.xsd"JAXP implementation: "jar:file:/D:/java/lib/xercesImpl.jar!/org/apache/xerces/jaxp/DocumentBuilderFactoryImpl.class"--------- START OF file:/d:/java/etjava/examples/data/xml/soap/soapSigned.xml SERIALIZED DOCUMENT ---------[deleted, the content is shown in the SoapSigner output]--------- END OF file:/d:/java/etjava/examples/data/xml/soap/soapSigned.xml SERIALIZED DOCUMENT ---------Opening "file:/d:/java/etjava/examples/data/xml/soap/soapSigned.xml"Creating a Verifier...Verify sample is demonstrating Method 1JAXP DOM implementation system property setting: nullJAXP implementation: "jar:file:/D:/java/lib/xercesImpl.jar!/org/apache/xerces/jaxp/DocumentBuilderFactoryImpl.class"It's an Apache parser.Setting parser feature: namespace awarenessSetting parser feature: including ignorable whitespace in element contentSetting parser feature: not expanding entity referencesThis document validates correctly against the schema(s) provided.Verifying...Verified !The signature was verified using a valid certificate.URI of signed content: "#signmeId"Done