Share via


KeyIdentifier Class

Specifies or references a security token uniquely.

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

Usage

'Usage
Dim identifier() As Byte
Dim keyIdentifier1 As New KeyIdentifier(identifier)

Syntax

'Declaration
Public Class KeyIdentifier
    Implements IXmlElement
public class KeyIdentifier : IXmlElement
public ref class KeyIdentifier : public IXmlElement
public class KeyIdentifier implements IXmlElement
public class KeyIdentifier implements IXmlElement

Example

The following code example creates a new instance of the KeyIdentifier class to associate additional information with a custom binary security token sent in a SOAP message. A receiver of the SOAP message can then use that additional information, which in this example is the name of the crypto key container for the key to decrypt the SOAP message. This code sample is part of a bigger custom binary security token sample. For more information about custom binary security tokens, see How to: Create a Class Representing a Custom Binary Security Token.

public override EncryptionKey EncryptionKey
{
   get
   {
      // Ensure the RSA key has already been retrieved.
      if (rsa == null)
         throw new InvalidOperationException("Encryption key is unavailable.");

      // Return the key that will be used to encrypt a SOAP message 
      // using this token.
      AsymmetricEncryptionKey key = new AsymmetricEncryptionKey(rsa);

      // Add a KeyInfo clause to the key specifying the key container name the receiver
      // will use to retrieve the decryption key.
      SecurityTokenReference  reference = new SecurityTokenReference();
      reference.KeyIdentifier           = new KeyIdentifier(System.Text.Encoding.UTF8.GetBytes(keyContainer),TokenValueType);
      key.KeyInfo.AddClause(reference);
      return key;
   }
   }

Remarks

A KeyIdentifier resides in a SecurityTokenReference so that a token can be referenced uniquely and constantly using an identifier.

For more information on the <KeyIdentifier> element, please refer to the Web Services Security Addendum in the MSDN Library (https://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnglobspec/html/ws-security-addendum.asp ).

Remarks

Inheritance Hierarchy

System.Object
  Microsoft.Web.Services2.Security.KeyIdentifier

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

KeyIdentifier Members