LocalServiceSecuritySettings 类

定义

提供可设置的本地服务安全属性。

public ref class LocalServiceSecuritySettings sealed
public sealed class LocalServiceSecuritySettings
type LocalServiceSecuritySettings = class
Public NotInheritable Class LocalServiceSecuritySettings
继承
LocalServiceSecuritySettings

示例

此示例演示如何使用 LocalServiceSecuritySettings 类更改 DetectReplays 设置。

    // Create an instance of the binding to use.
    WSHttpBinding b = new WSHttpBinding();

    // Get the binding element collection.
    BindingElementCollection bec = b.CreateBindingElements();

    // Find the SymmetricSecurityBindingElement in the colllection.
    // Important: Cast to the SymmetricSecurityBindingElement when using the Find
    // method.
    SymmetricSecurityBindingElement sbe = (SymmetricSecurityBindingElement)
bec.Find<SecurityBindingElement>();

    // Get the LocalServiceSettings from the binding element.
    LocalServiceSecuritySettings lss = sbe.LocalServiceSettings;

    // Print out values.
    Console.WriteLine("DetectReplays: {0} days", lss.DetectReplays);
    Console.WriteLine("ReplayWindow: {0} minutes", lss.ReplayWindow.Minutes);
    Console.WriteLine("MaxClockSkew: {0} minutes", lss.MaxClockSkew.Minutes);

    Console.ReadLine();
    Console.WriteLine("Press Enter to Continue");
    // Change the MaxClockSkew to 3 minutes.
    lss.MaxClockSkew = new TimeSpan(0, 0, 3, 0);

    // Print the new value.
    Console.WriteLine("New MaxClockSkew: {0} minutes", lss.MaxClockSkew.Minutes);
    Console.WriteLine("Press Enter to End");
    Console.ReadLine();

    // Create a URI for the service.
    Uri httpUri = new Uri("http://localhost/calculator");

    // Create a ServiceHost. The binding has the changed MaxClockSkew.
    ServiceHost sh = new ServiceHost(typeof(Calculator), httpUri);
    sh.AddServiceEndpoint(typeof(ICalculator), b, "");
    // sh.Open();
    // Console.WriteLine("Listening");
    // Console.ReadLine();
    // sh.Close();
' Create an instance of the binding to use.
Dim b As New WSHttpBinding()

' Get the binding element collection.
Dim bec As BindingElementCollection = b.CreateBindingElements()

' Find the SymmetricSecurityBindingElement in the colllection.
' Important: Cast to the SymmetricSecurityBindingElement when using the Find
' method.
Dim sbe As SymmetricSecurityBindingElement = CType(bec.Find(Of SecurityBindingElement)(), SymmetricSecurityBindingElement)

' Get the LocalServiceSettings from the binding element.
Dim lss As LocalServiceSecuritySettings = sbe.LocalServiceSettings

' Print out values.
Console.WriteLine("DetectReplays: {0} days", lss.DetectReplays)
Console.WriteLine("ReplayWindow: {0} minutes", lss.ReplayWindow.Minutes)
Console.WriteLine("MaxClockSkew: {0} minutes", lss.MaxClockSkew.Minutes)

Console.ReadLine()
Console.WriteLine("Press Enter to Continue")
' Change the MaxClockSkew to 3 minutes.
lss.MaxClockSkew = New TimeSpan(0, 0, 3, 0)

' Print the new value.
Console.WriteLine("New MaxClockSkew: {0} minutes", lss.MaxClockSkew.Minutes)
Console.WriteLine("Press Enter to End")
Console.ReadLine()

' Create a URI for the service.
Dim httpUri As New Uri("http://localhost/calculator")

' Create a ServiceHost. The binding has the changed MaxClockSkew.
Dim sh As New ServiceHost(GetType(Calculator), httpUri)
sh.AddServiceEndpoint(GetType(ICalculator), b, "")
' sh.Open();
' Console.WriteLine("Listening");
' Console.ReadLine();
' sh.Close();

注解

此类包含 SecurityBindingElement 用于生成安全通道的本地安全设置。 这些设置是服务的本地设置,不以服务的安全策略来表示。

构造函数

LocalServiceSecuritySettings()

初始化 LocalServiceSecuritySettings 类的新实例。

属性

DetectReplays

获取或设置一个值,该值指示是否在服务上启用重播检测。

InactivityTimeout

获取或设置通道因处于不活动状态而关闭前等待的时间。

IssuedCookieLifetime

获取或设置服务颁发给客户端的 SecurityContextSecurityToken 的生存期。

MaxCachedCookies

获取或设置服务允许一次缓存的 SecurityContextSecurityToken 的最大数量。

MaxClockSkew

获取或设置通信双方的系统时钟之间允许的最大时间差异。

MaxPendingSessions

获取或设置已与服务器建立的并发安全会话的最大数目,该服务器已经为这些会话颁发会话令牌但尚未为这些会话发送任何应用程序消息。

MaxStatefulNegotiations

获取或设置服务可参与的与客户端的最大并发安全协商数。

NegotiationTimeout

获取或设置客户端与服务之间的安全协商阶段的最长持续时间。

NonceCache

获取或设置本地安全客户端安全设置的缓存。

ReconnectTransportOnFailure

获取或设置一个值,该值指示在传输失败后安全会话是否尝试重新连接。

ReplayCacheSize

获取或设置用于重播检测的 Nonce 缓存大小。

ReplayWindow

获取或设置服务接受消息的最长时间。

SessionKeyRenewalInterval

获取或设置在安全会话中使用的密钥的生存期。 此时间间隔到期后,将自动续订密钥。

SessionKeyRolloverInterval

获取或设置密钥续订后的一个时间间隔,这段时间间隔内上一个会话密钥在密钥续订期间对传入的消息有效。

TimestampValidityDuration

获取或设置消息在由服务发送时的最长有效时间。 如果客户端在此期间后收到服务的消息,该客户端将丢弃该消息。

方法

Clone()

从当前实例创建此类的新实例。

Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
ToString()

返回表示当前对象的字符串。

(继承自 Object)

适用于