ClaimSet ClaimSet ClaimSet ClaimSet Class

定义

表示与某个实体关联的声明的集合。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)
继承
ClaimSetClaimSetClaimSetClaimSet
派生
属性
实现

示例

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() ClaimSet() ClaimSet()

初始化 ClaimSet 类的新实例。Initializes a new instance of the ClaimSet class.

属性

Count Count Count Count

在派生类中重写时,获取此声明集中的声明数。When overridden in a derived class, gets the number of claims in this claim set.

Issuer Issuer Issuer Issuer

在派生类中重写时,获取颁发此 ClaimSet 的实体。When overridden in a derived class, gets the entity that issued this ClaimSet.

Item[Int32] Item[Int32] Item[Int32] Item[Int32]

在派生类中重写时,获取指定索引的 ClaimWhen overridden in a derived class, gets the Claim for the specified index.

System System System System

获取表示应用程序可信颁发者的 ClaimSet 对象。Gets a ClaimSet object that represents an application trusted issuer.

Windows Windows Windows Windows

获取一组包含 Windows 安全标识符的声明。Gets a set of claims that contains Windows security identifiers.

方法

ContainsClaim(Claim) ContainsClaim(Claim) ContainsClaim(Claim) ContainsClaim(Claim)

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

ContainsClaim(Claim, IEqualityComparer<Claim>) ContainsClaim(Claim, IEqualityComparer<Claim>) ContainsClaim(Claim, IEqualityComparer<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) Equals(Object) Equals(Object) Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(Inherited from Object)
FindClaims(String, String) FindClaims(String, String) FindClaims(String, String) 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() GetEnumerator() GetEnumerator() GetEnumerator()

在派生类中重写时,获取一个 IEnumerator<T>,它可用于枚举 Claim 中的 ClaimSet 对象。When overridden in a derived class, gets a IEnumerator<T> that can be used to enumerate the Claim object in the ClaimSet.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)

显式界面实现

IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator()

获取一个 IEnumerator<T>,它可用于枚举 Claim 中的 ClaimSet 对象。Gets an IEnumerator<T> that can be used to enumerate the Claim object in the ClaimSet.

扩展方法

CopyToDataTable<T>(IEnumerable<T>) CopyToDataTable<T>(IEnumerable<T>) CopyToDataTable<T>(IEnumerable<T>) CopyToDataTable<T>(IEnumerable<T>)

在给定其泛型参数 TDataTable 的输入 DataRow 对象的情况下,返回包含 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) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption)

在给定其泛型参数 TDataRow 的输入 DataTable 对象的情况下,将 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) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler)

在给定其泛型参数 TDataRow 的输入 DataTable 对象的情况下,将 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) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable)

IEnumerable 的元素强制转换为指定的类型。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable)

根据指定类型筛选 IEnumerable 的元素。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable)

启用查询的并行化。Enables parallelization of a query.

AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable)

IEnumerable 转换为 IQueryableConverts an IEnumerable to an IQueryable.

Ancestors<T>(IEnumerable<T>) Ancestors<T>(IEnumerable<T>) Ancestors<T>(IEnumerable<T>) 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) Ancestors<T>(IEnumerable<T>, XName) Ancestors<T>(IEnumerable<T>, XName) 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>) DescendantNodes<T>(IEnumerable<T>) DescendantNodes<T>(IEnumerable<T>) DescendantNodes<T>(IEnumerable<T>)

返回源集合中每个文档和元素的子代节点的集合。Returns a collection of the descendant nodes of every document and element in the source collection.

Descendants<T>(IEnumerable<T>) Descendants<T>(IEnumerable<T>) Descendants<T>(IEnumerable<T>) 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) Descendants<T>(IEnumerable<T>, XName) Descendants<T>(IEnumerable<T>, XName) 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>) Elements<T>(IEnumerable<T>) Elements<T>(IEnumerable<T>) 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) Elements<T>(IEnumerable<T>, XName) Elements<T>(IEnumerable<T>, XName) 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>) InDocumentOrder<T>(IEnumerable<T>) InDocumentOrder<T>(IEnumerable<T>) 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>) Nodes<T>(IEnumerable<T>) Nodes<T>(IEnumerable<T>) Nodes<T>(IEnumerable<T>)

返回源集合中每个文档和元素的子节点集合。Returns a collection of the child nodes of every document and element in the source collection.

Remove<T>(IEnumerable<T>) Remove<T>(IEnumerable<T>) Remove<T>(IEnumerable<T>) Remove<T>(IEnumerable<T>)

将源集合中的每个节点从其父节点中移除。Removes every node in the source collection from its parent node.

适用于