Welcome to mirror list, hosted at ThFree Co, Russian Federation.

RoleClaimProvider.cs « Security « System.Web « referencesource « class « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ad8c9dc19e9f2c0e96927c8922a2af29438c14f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// ==++==
// 
//   Copyright (c) Microsoft Corporation.  All rights reserved.
// 
// ==--==
// <OWNER>[....]</OWNER>
// 
//
// RoleClaimProvider.cs
//

namespace System.Web.Security
{
    using System.Collections.Generic;
    using System.Security.Claims;

    /// <summary>
    /// This internal class is used to wrap role claims that are served up by the RolePrincipal.  They need to be kept distinct from other claims.
    /// ClaimsIdentity has a property the holds this type.
    /// made on parameters.
    /// </summary>    

    internal class RoleClaimProvider
    {
        RolePrincipal _rolePrincipal;
        ClaimsIdentity _subject;

        public RoleClaimProvider(RolePrincipal rolePrincipal, ClaimsIdentity subject)
        {
            _rolePrincipal  = rolePrincipal;
            _subject        = subject;
        }

        public IEnumerable<Claim> Claims
        {
            get
            {
                foreach (string role in _rolePrincipal.GetRoles())
                {
                    yield return new Claim(_subject.RoleClaimType, role, ClaimValueTypes.String, _rolePrincipal.ProviderName, _rolePrincipal.ProviderName, _subject);
                }
            }
        }
    }
}