ClaimSet 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
表示與實體相關聯的宣告集合。
public ref class ClaimSet abstract : System::Collections::Generic::IEnumerable<System::IdentityModel::Claims::Claim ^>
public abstract class ClaimSet : System.Collections.Generic.IEnumerable<System.IdentityModel.Claims.Claim>
[System.Runtime.Serialization.DataContract(Namespace="http://schemas.xmlsoap.org/ws/2005/05/identity")]
public abstract class ClaimSet : System.Collections.Generic.IEnumerable<System.IdentityModel.Claims.Claim>
type ClaimSet = class
interface seq<Claim>
interface IEnumerable
[<System.Runtime.Serialization.DataContract(Namespace="http://schemas.xmlsoap.org/ws/2005/05/identity")>]
type ClaimSet = class
interface seq<Claim>
interface IEnumerable
Public MustInherit Class ClaimSet
Implements IEnumerable(Of Claim)
- 繼承
-
ClaimSet
- 衍生
- 屬性
- 實作
範例
public class MyServiceAuthorizationManager : ServiceAuthorizationManager
{
protected override bool CheckAccessCore(OperationContext operationContext)
{
// Extract the action URI from the OperationContext. Match this against the claims
// in the AuthorizationContext.
string action = operationContext.RequestContext.RequestMessage.Headers.Action;
Console.WriteLine("action: {0}", action);
// Iterate through the various claim sets in the AuthorizationContext.
foreach (ClaimSet cs in operationContext.ServiceSecurityContext.AuthorizationContext.ClaimSets)
{
// Examine only those claim sets issued by System.
if (cs.Issuer == ClaimSet.System)
{
// Iterate through claims of type "http://example.org/claims/allowedoperation".
foreach (Claim c in cs.FindClaims("http://example.org/claims/allowedoperation",
Rights.PossessProperty))
{
// Write the claim resource to the console.
Console.WriteLine("resource: {0}", c.Resource.ToString());
// If the claim resource matches the action URI then return true to allow access.
if (action == c.Resource.ToString())
return true;
}
}
}
// If this point is reached, return false to deny access.
return false;
}
}
Public Class MyServiceAuthorizationManager
Inherits ServiceAuthorizationManager
Protected Overrides Function CheckAccessCore(ByVal operationContext As OperationContext) As Boolean
' Extract the action URI from the OperationContext. Match this against the claims
' in the AuthorizationContext.
Dim action As String = operationContext.RequestContext.RequestMessage.Headers.Action
Console.WriteLine("action: {0}", action)
' Iterate through the various claim sets in the AuthorizationContext.
Dim cs As ClaimSet
For Each cs In operationContext.ServiceSecurityContext.AuthorizationContext.ClaimSets
' Examine only those claim sets issued by System.
If cs.Issuer Is ClaimSet.System Then
' Iterate through claims of type "http://example.org/claims/allowedoperation".
Dim c As Claim
For Each c In cs.FindClaims("http://example.org/claims/allowedoperation", Rights.PossessProperty)
' Write the claim resource to the console.
Console.WriteLine("resource: {0}", c.Resource.ToString())
' If the claim resource matches the action URI then return true to allow access
If action = c.Resource.ToString() Then
Return True
End If
Next c
End If
Next cs
'
' If this point is reached, return false to deny access.
Return False
End Function
備註
類別建立後 ClaimSet ,無法更改。
使用宣告型授權時,檢查 特定宣告類型的內容 ClaimSet 是常見的工作。 若要檢查 ClaimSet 是否有特定宣告的存在,請使用 FindClaims 方法。 此方法比直接迭 ClaimSet代 p 提供更好的效能。
建構函式
| 名稱 | Description |
|---|---|
| ClaimSet() |
初始化 ClaimSet 類別的新執行個體。 |
屬性
| 名稱 | Description |
|---|---|
| Count |
當在派生類別中被覆寫時,會得到該權利要求集合中的權利要求數量。 |
| Issuer |
當在派生類別中被覆寫時,會得到發出此命令 ClaimSet的實體。 |
| Item[Int32] |
當在派生類別中覆寫時,會得到指定索引的 。Claim |
| System |
取得 ClaimSet 一個代表應用程式受信任發行者的物件。 |
| Windows |
會收到一組包含 Windows 安全識別碼的聲明。 |
方法
| 名稱 | Description |
|---|---|
| ContainsClaim(Claim, IEqualityComparer<Claim>) |
透過使用指定ClaimSet物件判斷是否Claim包含指定的 IEqualityComparer<T>。 |
| ContainsClaim(Claim) | |
| Equals(Object) |
判斷指定的物件是否等於目前的物件。 (繼承來源 Object) |
| FindClaims(String, String) | |
| GetEnumerator() |
當在導出類別中覆寫時,會得到IEnumerator<T>一個,可用來枚Claim舉該物件。ClaimSet |
| GetHashCode() |
做為預設哈希函式。 (繼承來源 Object) |
| GetType() |
取得目前實例的 Type。 (繼承來源 Object) |
| MemberwiseClone() |
建立目前 Object的淺層複本。 (繼承來源 Object) |
| ToString() |
傳回表示目前 物件的字串。 (繼承來源 Object) |
明確介面實作
| 名稱 | Description |
|---|---|
| IEnumerable.GetEnumerator() |
得到一個IEnumerator<T>,可用來枚舉 中的Claim物件。ClaimSet |