ClaimSet 類別

定義

表示與實體相關聯的宣告集合。Represents the collection of claims that are associated with an entity.

public ref class ClaimSet abstract : 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
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 類別之後,就不能變更。After the ClaimSet class has been created, it cannot be changed.

檢查 ClaimSet 內容以尋找特定類型的宣告,是在使用宣告架構授權時的常見工作。Examining the content of a ClaimSet for particular types of claims is a common task when using claim-based authorization. 若要檢查 ClaimSet 是否存在特定的宣告,請使用 FindClaims 方法。To examine a ClaimSet for the presence of particular claims, use the FindClaims method. 這個方法比直接在 ClaimSet 上逐一查看提供更高的效能。The method provides better performance than iterating directly over the ClaimSet.

建構函式

ClaimSet()

初始化 ClaimSet 類別的新執行個體。Initializes a new instance of the ClaimSet class.

屬性

Count

在衍生類別中覆寫時,取得此宣告集中的宣告數。When overridden in a derived class, gets the number of claims in this claim set.

Issuer

在衍生類別中覆寫時,取得發行此 ClaimSet 的實體。When overridden in a derived class, gets the entity that issued this ClaimSet.

Item[Int32]

在衍生類別中覆寫時,取得指定索引的 ClaimWhen overridden in a derived class, gets the Claim for the specified index.

System

取得 ClaimSet 物件,這個物件表示應用程式信任的發行者。Gets a ClaimSet object that represents an application trusted issuer.

Windows

取得包含 Windows 安全性識別項的宣告集。Gets a set of claims that contains Windows security identifiers.

方法

ContainsClaim(Claim)

判斷 ClaimSet 是否包含指定的 ClaimDetermines whether the ClaimSet contains the specified Claim.

ContainsClaim(Claim, IEqualityComparer<Claim>)

使用指定的 ClaimSet 物件,判斷 Claim 是否包含指定的 IEqualityComparer<T>Determines whether the ClaimSet contains the specified Claim, by using the specified IEqualityComparer<T> object.

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
FindClaims(String, String)

在衍生類別中覆寫時,搜尋符合 Claim 中指定之宣告類型和權限的 ClaimSet 物件。When overridden in a derived class, searches for a Claim object that matches the specified claim type and rights in the ClaimSet.

GetEnumerator()

在衍生類別中覆寫時,取得可用來列舉 IEnumerator<T> 中之 Claim 物件的 ClaimSetWhen overridden in a derived class, gets a IEnumerator<T> that can be used to enumerate the Claim object in the ClaimSet.

GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

明確介面實作

IEnumerable.GetEnumerator()

取得可用來列舉在 IEnumerator<T>Claim 物件的 ClaimSetGets an IEnumerator<T> that can be used to enumerate the Claim object in the ClaimSet.

擴充方法

CopyToDataTable<T>(IEnumerable<T>)

根據輸入 DataTable 物件 (其中泛型參數 TDataRow) 傳回包含 IEnumerable<T> 物件複本的 DataRowReturns a DataTable that contains copies of the DataRow objects, given an input IEnumerable<T> object where the generic parameter T is DataRow.

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption)

根據輸入 DataRow 物件 (其中泛型參數 TDataTable),將 IEnumerable<T> 物件複製到指定的 DataRowCopies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler)

根據輸入 DataRow 物件 (其中泛型參數 TDataTable),將 IEnumerable<T> 物件複製到指定的 DataRowCopies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

根據指定的型別來篩選 IEnumerable 的項目。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

啟用查詢的平行化作業。Enables parallelization of a query.

AsQueryable(IEnumerable)

IEnumerable 轉換成 IQueryableConverts an IEnumerable to an IQueryable.

Ancestors<T>(IEnumerable<T>)

傳回包含來源集合中每個節點祖系的項目集合。Returns a collection of elements that contains the ancestors of every node in the source collection.

Ancestors<T>(IEnumerable<T>, XName)

傳回包含來源集合中每個節點祖系的已篩選項目集合。Returns a filtered collection of elements that contains the ancestors of every node in the source collection. 集合中只會包含具有相符之 XName 的項目。Only elements that have a matching XName are included in the collection.

DescendantNodes<T>(IEnumerable<T>)

傳回來源集合中每個文件和項目之子代節點的集合。Returns a collection of the descendant nodes of every document and element in the source collection.

Descendants<T>(IEnumerable<T>)

傳回包含來源集合中每個項目和文件之子代項目的項目集合。Returns a collection of elements that contains the descendant elements of every element and document in the source collection.

Descendants<T>(IEnumerable<T>, XName)

傳回已篩選的項目集合,其中包含來源集合中每個項目和文件的子代項目。Returns a filtered collection of elements that contains the descendant elements of every element and document in the source collection. 集合中只會包含具有相符之 XName 的項目。Only elements that have a matching XName are included in the collection.

Elements<T>(IEnumerable<T>)

傳回來源集合中每個項目和文件的子項目集合。Returns a collection of the child elements of every element and document in the source collection.

Elements<T>(IEnumerable<T>, XName)

傳回來源集合中每個項目和文件的已篩選子項目集合。Returns a filtered collection of the child elements of every element and document in the source collection. 集合中只會包含具有相符之 XName 的項目。Only elements that have a matching XName are included in the collection.

InDocumentOrder<T>(IEnumerable<T>)

傳回包含來源集合中所有節點的節點集合,依據文件順序來排序。Returns a collection of nodes that contains all nodes in the source collection, sorted in document order.

Nodes<T>(IEnumerable<T>)

傳回來源集合中每個文件和項目的子節點集合。Returns a collection of the child nodes of every document and element in the source collection.

Remove<T>(IEnumerable<T>)

在來源集合中,從每一個節點的父節點移除這些節點。Removes every node in the source collection from its parent node.

適用於