DefaultClaimSet.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / IdentityModel / System / IdentityModel / Claims / DefaultClaimSet.cs / 1 / DefaultClaimSet.cs

                            //------------------------------------------------------------ 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//-----------------------------------------------------------

namespace System.IdentityModel.Claims 
{
    using System.Collections; 
    using System.Collections.Generic; 
    using System.Runtime.Serialization;
 
    [DataContract(Namespace = XsiConstants.Namespace)]
    public class DefaultClaimSet : ClaimSet
    {
        [DataMember(Name = "Issuer")] 
        ClaimSet issuer;
        [DataMember(Name = "Claims")] 
        IList claims; 

        public DefaultClaimSet(params Claim[] claims) 
        {
            Initialize(this, claims);
        }
 
        public DefaultClaimSet(IList claims)
        { 
            Initialize(this, claims); 
        }
 
        public DefaultClaimSet(ClaimSet issuer, params Claim[] claims)
        {
            Initialize(issuer, claims);
        } 

        public DefaultClaimSet(ClaimSet issuer, IList claims) 
        { 
            Initialize(issuer, claims);
        } 

        public override Claim this[int index]
        {
            get { return this.claims[index]; } 
        }
 
        public override int Count 
        {
            get { return this.claims.Count; } 
        }

        public override ClaimSet Issuer
        { 
            get { return this.issuer; }
        } 
 
        public override bool ContainsClaim(Claim claim)
        { 
            if (claim == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("claim");

            for (int i = 0; i < this.claims.Count; ++i) 
            {
                if (claim.Equals(this.claims[i])) 
                { 
                    return true;
                } 
            }
            return false;
        }
 
        public override IEnumerable FindClaims(string claimType, string right)
        { 
            bool anyClaimType = (claimType == null); 
            bool anyRight = (right == null);
 
            for (int i = 0; i < this.claims.Count; ++i)
            {
                Claim claim = this.claims[i];
                if ((claim != null) && 
                    (anyClaimType || claimType == claim.ClaimType) &&
                    (anyRight || right == claim.Right)) 
                { 
                    yield return claim;
                } 
            }
        }

        public override IEnumerator GetEnumerator() 
        {
            return this.claims.GetEnumerator(); 
        } 

        protected void Initialize(ClaimSet issuer, IList claims) 
        {
            if (issuer == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("issuer");
            if (claims == null) 
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("claims");
 
            this.issuer = issuer; 
            this.claims = claims;
        } 

        public override string ToString()
        {
            return SecurityUtils.ClaimSetToString(this); 
        }
    } 
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK