当前位置: 首页>>代码示例>>C#>>正文


C# Evidence.RawSerialize方法代码示例

本文整理汇总了C#中System.Security.Policy.Evidence.RawSerialize方法的典型用法代码示例。如果您正苦于以下问题:C# Evidence.RawSerialize方法的具体用法?C# Evidence.RawSerialize怎么用?C# Evidence.RawSerialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Security.Policy.Evidence的用法示例。


在下文中一共展示了Evidence.RawSerialize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Resolve

        [System.Security.SecurityCritical]  // auto-generated
        internal PolicyStatement Resolve (Evidence evidence, int count, byte[] serializedEvidence) {
            if (evidence == null)
                throw new ArgumentNullException("evidence");
            Contract.EndContractBlock();

            PolicyStatement policy = null;
            if (serializedEvidence != null)
                policy = CheckCache(count, serializedEvidence);

            if (policy == null) {
                CheckLoaded();

                bool allConst;
                bool isFullTrust = m_fullTrustAssemblies != null && IsFullTrustAssembly(m_fullTrustAssemblies, evidence);
                if (isFullTrust) {
                    policy = new PolicyStatement(new PermissionSet(true), PolicyStatementAttribute.Nothing);
                    allConst = true;
                }
                else {
                    ArrayList list = GenericResolve(evidence, out allConst);
                    policy = new PolicyStatement();
                    // This will set the permission set to the empty set.
                    policy.PermissionSet = null;

                    IEnumerator enumerator = list.GetEnumerator();
                    while (enumerator.MoveNext()) {
                        PolicyStatement ps = ((CodeGroupStackFrame)enumerator.Current).policy;
                        if (ps != null) {
                            policy.GetPermissionSetNoCopy().InplaceUnion(ps.GetPermissionSetNoCopy());
                            policy.Attributes |= ps.Attributes;

                            // If we find a policy statement that's dependent upon unverified evidence, we
                            // need to mark that as used so that the VM can potentially force verification on
                            // the evidence.
                            if (ps.HasDependentEvidence) {
                                foreach (IDelayEvaluatedEvidence delayEvidence in ps.DependentEvidence) {
                                    delayEvidence.MarkUsed();
                                }
                            }
                        }
                    }
                }
                if (allConst) {
                    // We want to store in the cache the evidence that was touched during policy evaluation
                    // rather than the input serialized evidence, since that evidence is optimized for the
                    // standard policy and is not all-inclusive.  We need to make sure that any evidence
                    // used to determine the grant set is added to the cache key.
                    Cache(count, evidence.RawSerialize(), policy);
                }
            }

            return policy;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:54,代码来源:PolicyLevel.cs

示例2: CodeGroupResolve

        internal PermissionSet CodeGroupResolve (Evidence evidence, bool systemPolicy) {
            Contract.Assert(AppDomain.CurrentDomain.IsLegacyCasPolicyEnabled);

            PermissionSet grant = null;
            PolicyStatement policy;
            PolicyLevel currentLevel = null;

            IEnumerator levelEnumerator = PolicyLevels.GetEnumerator();

            // We're optimized for standard policy, where the only evidence that is generally evaluated are
            // Zone, StrongName and Url.  Since all of these are relatively inexpensive, we'll force them to
            // generate, then use that as a key into the cache.
            evidence.GetHostEvidence<Zone>();
            evidence.GetHostEvidence<StrongName>();
            evidence.GetHostEvidence<Url>();
            byte[] serializedEvidence = evidence.RawSerialize();
            int count = evidence.RawCount;

            bool legacyIgnoreSystemPolicy = (AppDomain.CurrentDomain.GetData("IgnoreSystemPolicy") != null);
            bool testApplicationLevels = false;
            while (levelEnumerator.MoveNext())
            {
                currentLevel = (PolicyLevel)levelEnumerator.Current;
                if (systemPolicy) {
                    if (currentLevel.Type == PolicyLevelType.AppDomain)
                        continue;
                } else if (legacyIgnoreSystemPolicy && currentLevel.Type != PolicyLevelType.AppDomain)
                    continue;

                policy = currentLevel.Resolve(evidence, count, serializedEvidence);

                // If the grant is "AllPossible", the intersection is just the other permission set.
                // Otherwise, do an inplace intersection (since we know we can alter the grant set since
                // it is a copy of the first policy statement's permission set).

                if (grant == null)
                    grant = policy.PermissionSet;
                else
                    grant.InplaceIntersect(policy.GetPermissionSetNoCopy());

                if (grant == null || grant.FastIsEmpty())
                {
                    break;
                }
                else if ((policy.Attributes & PolicyStatementAttribute.LevelFinal) == PolicyStatementAttribute.LevelFinal)
                {
                    if (currentLevel.Type != PolicyLevelType.AppDomain)
                    {
                        testApplicationLevels = true;
                    }
                    break;
                }
            }

            if (grant != null && testApplicationLevels)
            {
                PolicyLevel appDomainLevel = null;

                for (int i = PolicyLevels.Count - 1; i >= 0; --i)
                {
                    currentLevel = (PolicyLevel) PolicyLevels[i];
                    if (currentLevel.Type == PolicyLevelType.AppDomain)
                    {
                        appDomainLevel = currentLevel;
                        break;
                    }
                }

                if (appDomainLevel != null)
                {
                    policy = appDomainLevel.Resolve(evidence, count, serializedEvidence);
                    grant.InplaceIntersect(policy.GetPermissionSetNoCopy());
                }
            }

            if (grant == null)
                grant = new PermissionSet(PermissionState.None);

            // Each piece of evidence can possibly create an identity permission that we
            // need to add to our grant set.  Therefore, for all pieces of evidence that
            // implement the IIdentityPermissionFactory interface, ask it for its
            // adjoining identity permission and add it to the grant.

            if (!grant.IsUnrestricted())
            {
                IEnumerator enumerator = evidence.GetHostEnumerator();
                while (enumerator.MoveNext())
                {
                    Object obj = enumerator.Current;
                    IIdentityPermissionFactory factory = obj as IIdentityPermissionFactory;
                    if (factory != null)
                    {
                        IPermission perm = factory.CreateIdentityPermission( evidence );
                        if (perm != null)
                            grant.AddPermission( perm );
                    }
                }
            }

            grant.IgnoreTypeLoadFailures = true;
//.........这里部分代码省略.........
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:101,代码来源:policymanager.cs

示例3: Resolve

 internal PolicyStatement Resolve(Evidence evidence, int count, byte[] serializedEvidence)
 {
     if (evidence == null)
     {
         throw new ArgumentNullException("evidence");
     }
     PolicyStatement policy = null;
     if (serializedEvidence != null)
     {
         policy = this.CheckCache(count, serializedEvidence);
     }
     if (policy == null)
     {
         bool flag;
         this.CheckLoaded();
         if ((this.m_fullTrustAssemblies != null) && IsFullTrustAssembly(this.m_fullTrustAssemblies, evidence))
         {
             policy = new PolicyStatement(new PermissionSet(true), PolicyStatementAttribute.Nothing);
             flag = true;
         }
         else
         {
             ArrayList list = this.GenericResolve(evidence, out flag);
             policy = new PolicyStatement {
                 PermissionSet = null
             };
             IEnumerator enumerator = list.GetEnumerator();
             while (enumerator.MoveNext())
             {
                 PolicyStatement statement2 = ((CodeGroupStackFrame) enumerator.Current).policy;
                 if (statement2 != null)
                 {
                     policy.GetPermissionSetNoCopy().InplaceUnion(statement2.GetPermissionSetNoCopy());
                     policy.Attributes |= statement2.Attributes;
                     if (statement2.HasDependentEvidence)
                     {
                         foreach (IDelayEvaluatedEvidence evidence2 in statement2.DependentEvidence)
                         {
                             evidence2.MarkUsed();
                         }
                     }
                 }
             }
         }
         if (flag)
         {
             this.Cache(count, evidence.RawSerialize(), policy);
         }
     }
     return policy;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:51,代码来源:PolicyLevel.cs

示例4: CodeGroupResolve

 internal PermissionSet CodeGroupResolve(Evidence evidence, bool systemPolicy)
 {
     PermissionSet permissionSet = null;
     PolicyLevel current = null;
     IEnumerator enumerator = this.PolicyLevels.GetEnumerator();
     evidence.GetHostEvidence<Zone>();
     evidence.GetHostEvidence<StrongName>();
     evidence.GetHostEvidence<Url>();
     byte[] serializedEvidence = evidence.RawSerialize();
     int rawCount = evidence.RawCount;
     bool flag = AppDomain.CurrentDomain.GetData("IgnoreSystemPolicy") != null;
     bool flag2 = false;
     while (enumerator.MoveNext())
     {
         PolicyStatement statement;
         current = (PolicyLevel) enumerator.Current;
         if (systemPolicy)
         {
             if (current.Type != PolicyLevelType.AppDomain)
             {
                 goto Label_0078;
             }
             continue;
         }
         if (flag && (current.Type != PolicyLevelType.AppDomain))
         {
             continue;
         }
     Label_0078:
         statement = current.Resolve(evidence, rawCount, serializedEvidence);
         if (permissionSet == null)
         {
             permissionSet = statement.PermissionSet;
         }
         else
         {
             permissionSet.InplaceIntersect(statement.GetPermissionSetNoCopy());
         }
         if ((permissionSet == null) || permissionSet.FastIsEmpty())
         {
             break;
         }
         if ((statement.Attributes & PolicyStatementAttribute.LevelFinal) == PolicyStatementAttribute.LevelFinal)
         {
             if (current.Type != PolicyLevelType.AppDomain)
             {
                 flag2 = true;
             }
             break;
         }
     }
     if ((permissionSet != null) && flag2)
     {
         PolicyLevel level2 = null;
         for (int i = this.PolicyLevels.Count - 1; i >= 0; i--)
         {
             current = (PolicyLevel) this.PolicyLevels[i];
             if (current.Type == PolicyLevelType.AppDomain)
             {
                 level2 = current;
                 break;
             }
         }
         if (level2 != null)
         {
             permissionSet.InplaceIntersect(level2.Resolve(evidence, rawCount, serializedEvidence).GetPermissionSetNoCopy());
         }
     }
     if (permissionSet == null)
     {
         permissionSet = new PermissionSet(PermissionState.None);
     }
     if (!permissionSet.IsUnrestricted())
     {
         IEnumerator hostEnumerator = evidence.GetHostEnumerator();
         while (hostEnumerator.MoveNext())
         {
             object obj2 = hostEnumerator.Current;
             IIdentityPermissionFactory factory = obj2 as IIdentityPermissionFactory;
             if (factory != null)
             {
                 IPermission perm = factory.CreateIdentityPermission(evidence);
                 if (perm != null)
                 {
                     permissionSet.AddPermission(perm);
                 }
             }
         }
     }
     permissionSet.IgnoreTypeLoadFailures = true;
     return permissionSet;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:92,代码来源:PolicyManager.cs


注:本文中的System.Security.Policy.Evidence.RawSerialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。