本文整理汇总了C#中System.Security.Policy.PolicyStatement.GetPermissionSetNoCopy方法的典型用法代码示例。如果您正苦于以下问题:C# PolicyStatement.GetPermissionSetNoCopy方法的具体用法?C# PolicyStatement.GetPermissionSetNoCopy怎么用?C# PolicyStatement.GetPermissionSetNoCopy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Security.Policy.PolicyStatement
的用法示例。
在下文中一共展示了PolicyStatement.GetPermissionSetNoCopy方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InplaceUnion
internal void InplaceUnion(PolicyStatement childPolicy)
{
if (((this.Attributes & childPolicy.Attributes) & PolicyStatementAttribute.Exclusive) == PolicyStatementAttribute.Exclusive)
{
throw new PolicyException(Environment.GetResourceString("Policy_MultipleExclusive"));
}
if (childPolicy.HasDependentEvidence)
{
bool flag = this.m_permSet.IsSubsetOf(childPolicy.GetPermissionSetNoCopy()) && !childPolicy.GetPermissionSetNoCopy().IsSubsetOf(this.m_permSet);
if (this.HasDependentEvidence || flag)
{
if (this.m_dependentEvidence == null)
{
this.m_dependentEvidence = new List<IDelayEvaluatedEvidence>();
}
this.m_dependentEvidence.AddRange(childPolicy.DependentEvidence);
}
}
if ((childPolicy.Attributes & PolicyStatementAttribute.Exclusive) == PolicyStatementAttribute.Exclusive)
{
this.m_permSet = childPolicy.GetPermissionSetNoCopy();
this.Attributes = childPolicy.Attributes;
}
else
{
this.m_permSet.InplaceUnion(childPolicy.GetPermissionSetNoCopy());
this.Attributes |= childPolicy.Attributes;
}
}
示例2: 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;
}
示例3: InplaceUnion
/// <summary>
/// Union a child policy statement into this policy statement
/// </summary>
internal void InplaceUnion(PolicyStatement childPolicy)
{
BCLDebug.Assert(childPolicy != null, "childPolicy != null");
if (((Attributes & childPolicy.Attributes) & PolicyStatementAttribute.Exclusive) == PolicyStatementAttribute.Exclusive)
{
throw new PolicyException(Environment.GetResourceString( "Policy_MultipleExclusive" ));
}
#if FEATURE_CAS_POLICY
// If our code group generated a grant set based upon unverified evidence, or it generated a grant
// set strictly less than that of a child group based upon unverified evidence, we need to keep
// track of any unverified evidence our child group has.
if (childPolicy.HasDependentEvidence)
{
bool childEvidenceNeedsVerification = m_permSet.IsSubsetOf(childPolicy.GetPermissionSetNoCopy()) &&
!childPolicy.GetPermissionSetNoCopy().IsSubsetOf(m_permSet);
if (HasDependentEvidence || childEvidenceNeedsVerification)
{
if (m_dependentEvidence == null)
{
m_dependentEvidence = new List<IDelayEvaluatedEvidence>();
}
m_dependentEvidence.AddRange(childPolicy.DependentEvidence);
}
}
#endif
// We need to merge together our grant set and attributes. The result of this merge is
// dependent upon if we're merging a child marked exclusive or not. If the child is not
// exclusive, we need to union in its grant set and or in its attributes. However, if the child
// is exclusive then it is the only code group which should have an effect on the resulting
// grant set and therefore our grant should be ignored.
if ((childPolicy.Attributes & PolicyStatementAttribute.Exclusive) == PolicyStatementAttribute.Exclusive)
{
m_permSet = childPolicy.GetPermissionSetNoCopy();
Attributes = childPolicy.Attributes;
}
else
{
m_permSet.InplaceUnion(childPolicy.GetPermissionSetNoCopy());
Attributes = Attributes | childPolicy.Attributes;
}
}
示例4: 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;
}
示例5: InplaceUnion
/// <summary>
/// Union a child policy statement into this policy statement
/// </summary>
internal void InplaceUnion(PolicyStatement childPolicy)
{
BCLDebug.Assert(childPolicy != null, "childPolicy != null");
if (((Attributes & childPolicy.Attributes) & PolicyStatementAttribute.Exclusive) == PolicyStatementAttribute.Exclusive)
{
throw new PolicyException(Environment.GetResourceString( "Policy_MultipleExclusive" ));
}
// We need to merge together our grant set and attributes. The result of this merge is
// dependent upon if we're merging a child marked exclusive or not. If the child is not
// exclusive, we need to union in its grant set and or in its attributes. However, if the child
// is exclusive then it is the only code group which should have an effect on the resulting
// grant set and therefore our grant should be ignored.
if ((childPolicy.Attributes & PolicyStatementAttribute.Exclusive) == PolicyStatementAttribute.Exclusive)
{
m_permSet = childPolicy.GetPermissionSetNoCopy();
Attributes = childPolicy.Attributes;
}
else
{
m_permSet.InplaceUnion(childPolicy.GetPermissionSetNoCopy());
Attributes = Attributes | childPolicy.Attributes;
}
}
示例6: Resolve
internal PolicyStatement Resolve (Evidence evidence, int count, char[] serializedEvidence) {
if (evidence == null)
throw new ArgumentNullException("evidence");
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 (allConst && serializedEvidence != null)
Cache(count, serializedEvidence, policy);
}
return policy;
}
示例7: CombinePolicy
private void CombinePolicy( PolicyStatement left, PolicyStatement right )
{
#if _DEBUG
if (debug)
{
DEBUG_OUT( "left = \n" + (left == null ? "<null>" : left.ToXml().ToString() ) );
DEBUG_OUT( "right = \n" + (right == null ? "<null>" : right.ToXml().ToString() ) );
}
#endif
if (right == null)
{
return;
}
else
{
// An exception somewhere in here means that a permission
// failed some operation. This simply means that it will be
// dropped from the grant set which is safe operation that
// can be ignored.
try
{
left.GetPermissionSetNoCopy().InplaceUnion( right.GetPermissionSetNoCopy() );
}
catch (Exception)
{
}
left.Attributes = left.Attributes | right.Attributes;
}
#if _DEBUG
if (debug)
DEBUG_OUT( "outcome =\n" + left.ToXml().ToString() );
#endif
}