Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Channels ▼
RSS

Web Development

Digitally Signing and Verifying Messages in Web Services


Signature Generation Using Oracle WSM

Oracle Web Services Manager can centrally manage the security policy, including digital signature generation. One of the greatest advantages in using Oracle WSM to digitally sign messages is that the policy information and the digital certificate information are centrally stored and managed.

An organization can have many web services and some of them might exchange certain business critical information and require that the messages be digitally signed. Oracle WSM will play a key role when different web services have different requirements to sign the message or when it is required to take certain actions before or after signing the message. Oracle WSM can be used to configure the signature at each web service level and that reduces the burden of deploying certifi cates across multiple systems. In this section, we will discuss more about how to digitally sign the response message of the web service using Oracle WSM.

Sign Message Policy Step

As a quick refresher, in Oracle WSM, each web service is registered within a gateway or an agent and a policy is attached to each web service. The policy steps are divided mainly into request pipeline template and response pipeline template, where different policies can be applied for request or response message processing. In this section, I describe how to confi gure the policy for a response pipeline template to digitally sign the response message. Note: It is assumed that the web service is registered within a gateway and a detailed example will be described later in this article.

In the response pipeline, we can add a policy step called Sign Message to digitally sign the message. To digitally sign a message, the key components that are required are:

  • Private key store
  • Private key password
  • The part of SOAP message that is being signed
  • The signature algorithm being used

The following screenshot describes the "Sign Message" policy step with certain values populated.

[Click image to view at full size]
Figure 1

The values that are populated are:

  • Keystore location -- The location where the private key fi le is located.
  • Keystore type -- Whether or not it is PKCS12 or JKS.
  • Keystore password -- The password to the keystore.
  • Signer's private-key alias -- The alias to gain access to the private key from the keystore.
  • Signer's private-key password -- the password to access the private key.
  • Signed Content -- Whether the BODY or envelope of the SOAP message should be signed.

The above information is a part of a policy that is attached to the time service which will sign the response message. As per the information that is shown in the screenshot, the BODY of the SOAP message response will be digitally signed using the SHA1 as the digest algorithm, and PKCS12 key store. Once the message is signed, the SOAP message will look like:

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope soap:encodingStyle="http://schemas.xmlsoap.org/
soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchemainstance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:
  soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:
    soapenc="http://schemas.xmlsoap.org/soap/encoding/">
    <soap:Header>
    <wsse:Security xmlns:wsse="http://docs.oasis-open.      org/wss/2004/01/oasis-200401-wss-wssecurity-secext-
      1.0.xsd" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
   soap:mustUnderstand="1">
   <wsse:BinarySecurityToken ValueType="http://docs.
     oasis-open.org/wss/2004/01/oasis-200401-wssx509-token-profile-1.0#X509v3"
     EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-messagesecurity-
       1.0#Base64Binary" wsu:Id="_VLL9yEsi09I9f5ihwae2lQ22" xmlns:wsu="http://docs.
        oasis-open.org/wss/2004/01/oasis-200401-wsswssecurity-
         utility-1.0.xsd">SecurityTOkenoKE2ZA==<
          /wsse:BinarySecurityToken>
    <dsig:Signature xmlns="http://www.w3.org/2000/09/
       xmldsig#" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#">
    <dsig:SignedInfo>
    <dsig:CanonicalizationMethodAlgorithm="http://www.w3.org/2001/10/
       xml-exc-c14n#"/>
         <dsig:SignatureMethodAlgorithm="http://www.w3.org/2000/09/
           xmldsig#rsa-sha1"/>
         <dsig:Reference URI="#ishUwYWW2AAthrxhlpv1CA22">
         <dsig:Transforms>
         <dsig:TransformAlgorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
         </dsig:Transforms>
         <dsig:DigestMethodAlgorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
         <dsig:DigestValue>ynuqANuYM3qzhdTnGOLT7SMxWHY=</dsig:DigestValue>
         </dsig:Reference>
         <dsig:Reference URI="#UljvWiL8yjedImz6zy0pHQ22">
         <dsig:Transforms>
         <dsig:TransformAlgorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
         </dsig:Transforms>
         <dsig:DigestMethodAlgorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
         <dsig:DigestValue>9ZebvrbVYLiPZ
           v1BaVLDaLJVhwo=</dsig:DigestValue>
         </dsig:Reference>
         </dsig:SignedInfo>
         <dsig:SignatureValue>QqmUUZDLNeLpAEFXndiBLk=</dsig:SignatureValue>
         <dsig:KeyInfo>
         <wsse:SecurityTokenReference
           xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wsswssecurity-
           secext-1.0.xsd" wsu:Id="_7vjdWs1ABULkiLeE7Y4lAg22"
            xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-
             wss-wssecurity-utility-1.0.xsd">
        <wsse:Reference URI="#_VLL9yEsi09I9f5ihwae2lQ22"/>
        </wsse:SecurityTokenReference>
        </dsig:KeyInfo>
        </dsig:Signature>
        <wsu:Timestamp xmlns:wsu="http://docs.oasis-open.
           org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
            xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wsswssecurity-
             utility-1.0.xsd" wsu:Id="UljvWiL8yjedImz6zy0pHQ22">
        <wsu:Created>2007-11-16T15:13:48Z</wsu:Created>
        </wsu:Timestamp>
        </wsse:Security>
        </soap:Header>
        <soap:Body wsu:Id="ishUwYWW2AAthrxhlpv1CA22" xmlns:wsu="http://
           docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurityutility-1.0.xsd">
        <n:getTimeResponse xmlns:n="urn:Test:GetTime">
      <Result xsi:type="xsd:string">10:13 AM</Result>
    </n:getTimeResponse>
  </soap:Body>
</soap:Envelope>


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.