BinarySecurityToken Class
Provides a base class for all implementations of binary security tokens, as defined in the WS-Security specification.
Namespace: Microsoft.Web.Services2.Security.Tokens
Assembly: Microsoft.Web.Services2 (in microsoft.web.services2.dll)
Usage
'Usage
Dim valueType As String
Dim binarySecurityToken1 As New BinarySecurityToken(valueType)
Syntax
'Declaration
MustInherit Public Class BinarySecurityToken
Inherits SecurityToken
public abstract class BinarySecurityToken : SecurityToken
public abstract ref class BinarySecurityToken : public SecurityToken
public abstract class BinarySecurityToken extends SecurityToken
public abstract class BinarySecurityToken extends SecurityToken
Example
The following code example digitally signs a SOAP message using a custom binary security token.
private void Sign_Click(object sender, System.EventArgs e)
{
string senderKeyContainer = System.Configuration.ConfigurationSettings.AppSettings["senderPrivateKeyContainer"];
// Create an instance of the custom binary token class.
Sample.BinaryToken customToken = new Sample.BinaryToken(senderKeyContainer);
// Create an instance of the proxy class for the XML Web service.
WidgetService svc = new WidgetService();
// Get the SOAP context associated with the SOAP request.
SoapContext requestContext = svc.RequestSoapContext;
// Set the time-to-live to one minute.
requestContext.Security.Timestamp.TtlInSeconds = 60;
// Add the custom binary security token to the WS-Security SOAP header.
requestContext.Security.Tokens.Add(customToken);
// Specify the security token to sign the message with.
Signature sig = new Signature(customToken);
requestContext.Security.Elements.Add(sig);
try
{
// Call the XML Web service.
Widget widget = svc.OrderWidget("Bag of Jelly Beans.");
}
catch (SoapException se)
{
MessageBox.Show(se.ToString());
}
}
Remarks
Although the WSE natively supports X.509 certificates, user name tokens, and kerberos tickets, the WSE is flexible enough to allow you to use your own custom binary security credentials to sign and encrypt SOAP messages. To do so, create a class that derives from BinarySecurityToken. For details about creating a custom binary security token, see How to: Create a Class Representing a Custom Binary Security Token.
Inheritance Hierarchy
System.Object
Microsoft.Web.Services2.Security.Tokens.SecurityToken
Microsoft.Web.Services2.Security.Tokens.BinarySecurityToken
Microsoft.Web.Services2.Security.Tokens.KerberosToken
Microsoft.Web.Services2.Security.Tokens.KerberosToken2
Microsoft.Web.Services2.Security.Tokens.X509SecurityToken
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.Tokens Namespace