Share via


SignatureReference Class

Specifies a digest algorithm and digest value, and optionally an identifier of the object being signed, the type of the object, and/or a list of transforms to be applied prior to digesting.

Namespace: Microsoft.Web.Services2.Security
Assembly: Microsoft.Web.Services2 (in microsoft.web.services2.dll)

Usage

'Usage
Dim signatureReference1 As New SignatureReference()

Syntax

'Declaration
Public Class SignatureReference
public class SignatureReference
public ref class SignatureReference
public class SignatureReference
public class SignatureReference

Example

The following code example shows how to identify a portion of a SOAP message, which is a SOAP header named OrderTimeHeader in the following example, and specify that portion of the SOAP message be signed.

private void button1_Click(object sender, System.EventArgs e)
{
   HeaderID.Service1Wse proxy = new Service1Wse();
   HeaderID.OrderTimeHeader header = new OrderTimeHeader();

   // Populate the contents of the SOAP header.
   header.Created = DateTime.Now;
   header.Expires = header.Created.AddMinutes(5);

   // Specify the unique identifier for reference.
   header.Id = "Id:05d2518d-d6db-481f-846d-2e8872b6e56d";

   // Assign the SOAP header to the member variable of the proxy class.
   proxy.TimeHeaderValue = header;

   // Get the X.509 certificate.
   X509SecurityToken token = GetSecurityToken(true);

   // Add the X.509 certificate to the WS-Security SOAP header.
   proxy.RequestSoapContext.Security.Tokens.Add(token);

   // Create a Signature.
   Signature sig = new Signature(token);

   // Note the addition of a # sign that prcecedes the value of the Id property
   // of the SOAP header.
   SignatureReference soapRef = new SignatureReference("#Id:05d2518d-d6db-481f-846d-2e8872b6e56d");

   // Add a transform.
   soapRef.AddTransform(new XmlDsigExcC14NTransform());

   // Add the reference to the signature.
   sig.AddReference(soapRef);

   // Add the digital signature to the SOAP message.
   proxy.RequestSoapContext.Security.Elements.Add(sig);

   // Call the XML Web service.
   Return.Text = proxy.EchoString(Send.Text);
   foreach (ISecurityElement secElm in proxy.ResponseSoapContext.Security.Elements)
   {
     if (secElm is EncryptedData)
     {
        EncryptedData enc = secElm as EncryptedData;
        String[] encryptionDetails = new String[]{enc.TargetElement.Name,enc.Type};
        ListViewItem lvItem = new ListViewItem(encryptionDetails);
        encryptedElements.Items.Add(lvItem);
     }
   }
   }

Remarks

Each SignatureReference includes the digest method and resulting digest value calculated over the identified data object. It also may include transformations that produced the input to the digest operation. A data object is signed by computing its digest value and a signature over that value.

Inheritance Hierarchy

System.Object
  Microsoft.Web.Services2.Security.SignatureReference
     Microsoft.Web.Services2.Security.Reference

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Platforms

Development Platforms

Windows XP Home Edition, Windows XP Professional, Windows Server 2003, Windows Longhorn, and Windows 2000

Target Platforms

Windows 2000, Windows 2000 Server, Windows 2000 Advanced Server, Windows XP Home Edition, Windows XP Professional, Windows Server 2003, Windows Longhorn, Pocket PC, Windows CE, Smart Phone

See Also

Reference

Microsoft.Web.Services2.Security Namespace

Other Resources

SignatureReference Members