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 的存留期 (Lifetime)。

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)

適用於