當前位置: 首頁>>代碼示例>>C#>>正文


C# Claim.ToString方法代碼示例

本文整理匯總了C#中Claim.ToString方法的典型用法代碼示例。如果您正苦於以下問題:C# Claim.ToString方法的具體用法?C# Claim.ToString怎麽用?C# Claim.ToString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Claim的用法示例。


在下文中一共展示了Claim.ToString方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: IssueStaffKeyClaims

        /// <summary>
        /// Issues the staff key claims.
        /// </summary>
        /// <param name="claimsPrincipal">The claims principal.</param>
        /// <param name="staff">The staff.</param>
        public void IssueStaffKeyClaims( IClaimsPrincipal claimsPrincipal, Staff staff )
        {
            Check.IsNotNull ( claimsPrincipal, "ClaimsPrincipal is required." );
            Check.IsNotNull ( staff, "Staff is required." );

            var realm = _federationAuthenticationModule.Realm;

            var claim = new Claim ( ClaimTypes.StaffKeyClaimType, staff.Key + string.Empty, realm );

            var identity = ( IClaimsIdentity )claimsPrincipal.Identity;
            identity.Claims.Add ( claim );

            Logger.Debug ( "Principal ({0}) is issued the following claim ({1}).", staff.StaffProfile.StaffName.Complete, claim.ToString () );
        }
開發者ID:divyang4481,項目名稱:REM,代碼行數:19,代碼來源:PermissionClaimsManager.cs

示例2: IssueSystemPermissionClaimsForStaff

        private void IssueSystemPermissionClaimsForStaff(
            IPrincipal claimsPrincipal,
            IEnumerable<SystemPermission> grantedPermissions,
            Staff staff )
        {
            var identity = ( IClaimsIdentity )claimsPrincipal.Identity;
            var exsitingPermissions = FindExistingSystemPermissionWellKnownNames ( identity );

            var realm = _federationAuthenticationModule.Realm;

            foreach ( var grantedPermission in grantedPermissions )
            {
                if ( !exsitingPermissions.Any ( x => x == grantedPermission.WellKnownName ) )
                {
                    var claim = new Claim (
                        ClaimTypes.PermissionClaimType,
                        grantedPermission.WellKnownName,
                        realm );

                    identity.Claims.Add ( claim );

                    Logger.Debug ( "Staff ({0}) is issued the following claim ({1}).", staff.Key, claim.ToString () );
                }
                else
                {
                    Logger.Debug ( "Claim for permission ({0}) has already existed.", grantedPermission.WellKnownName );
                }
            }
        }
開發者ID:divyang4481,項目名稱:REM,代碼行數:29,代碼來源:PermissionClaimsManager.cs

示例3: IssueAccountKeyClaims

        /// <summary>
        /// Issues the account key claims.
        /// </summary>
        /// <param name="claimsPrincipal">The claims principal.</param>
        /// <param name="systemAccount">The system account.</param>
        public void IssueAccountKeyClaims( IClaimsPrincipal claimsPrincipal, SystemAccount systemAccount )
        {
            Check.IsNotNull ( claimsPrincipal, "ClaimsPrincipal is required." );
            Check.IsNotNull ( systemAccount, "SystemAccount is required." );

            var realm = _federationAuthenticationModule.Realm;

            var claim = new Claim (
                ClaimTypes.AccountKeyClaimType, systemAccount.Key + string.Empty, realm );

            var identity = ( IClaimsIdentity )claimsPrincipal.Identity;
            identity.Claims.Add ( claim );

            Logger.Debug ( "Principal ({0}) is issued the following claim ({1}).", systemAccount.Identifier, claim.ToString () );
        }
開發者ID:divyang4481,項目名稱:REM,代碼行數:20,代碼來源:PermissionClaimsManager.cs


注:本文中的Claim.ToString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。