本文整理汇总了C#中System.Security.CodeAccessPermission类的典型用法代码示例。如果您正苦于以下问题:C# CodeAccessPermission类的具体用法?C# CodeAccessPermission怎么用?C# CodeAccessPermission使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CodeAccessPermission类属于System.Security命名空间,在下文中一共展示了CodeAccessPermission类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckAssembly
internal static void CheckAssembly(RuntimeAssembly asm, CodeAccessPermission demand)
{
PermissionSet set;
PermissionSet set2;
asm.GetGrantSet(out set, out set2);
CheckHelper(set, set2, demand, PermissionToken.GetToken(demand), RuntimeMethodHandleInternal.EmptyHandle, asm, SecurityAction.Demand, true);
}
示例2: CheckDemand
internal bool CheckDemand (CodeAccessPermission target)
{
if (target == null)
return false;
if (target.GetType () != this.GetType ())
return false;
return IsSubsetOf (target);
}
示例3: CheckAssert
internal bool CheckAssert (CodeAccessPermission asserted)
{
if (asserted == null)
return false;
if (asserted.GetType () != this.GetType ())
return false;
return IsSubsetOf (asserted);
}
示例4: CheckDemand
internal bool CheckDemand(CodeAccessPermission demand, PermissionToken permToken, RuntimeMethodHandleInternal rmh)
{
if (!CheckAssert(this.AssertSet, demand, permToken))
{
return false;
}
CodeAccessSecurityEngine.CheckHelper(this.GrantSet, this.RefusedSet, demand, permToken, rmh, null, SecurityAction.Demand, true);
return true;
}
示例5: CheckDemand
internal bool CheckDemand(CodeAccessPermission demand, PermissionToken permToken, RuntimeMethodHandle rmh)
{
this.CompleteConstruction(null);
if (this.PLS != null)
{
this.PLS.CheckDemand(demand, permToken, rmh);
}
return false;
}
示例6: CheckDemandNoThrow
internal bool CheckDemandNoThrow(CodeAccessPermission demand)
{
PermissionToken permToken = null;
if (demand != null)
{
permToken = PermissionToken.GetToken(demand);
}
return this.m_firstPermSetTriple.CheckDemandNoThrow(demand, permToken);
}
示例7: CheckDemand
internal bool CheckDemand(CodeAccessPermission demand, PermissionToken permToken, RuntimeMethodHandleInternal rmh)
{
bool flag = this.CheckDemand2(demand, permToken, rmh, false);
if (flag)
{
flag = this.CheckDemand2(demand, permToken, rmh, true);
}
return flag;
}
示例8: CheckDeny
internal bool CheckDeny(CodeAccessPermission denied)
{
IPermission permission = this.Intersect(denied);
if (permission != null)
{
return permission.IsSubsetOf(null);
}
return true;
}
示例9: IsPermissionGranted
internal static bool IsPermissionGranted(CodeAccessPermission requestedPermission)
{
try
{
// Try and get this permission
requestedPermission.Demand();
return true;
}
catch
{
return false;
}
}
示例10: CheckUnrestricted
// Returns true if OK to return from check, or false if
// permission-specific information must be checked.
internal static bool CheckUnrestricted(IUnrestrictedPermission grant, CodeAccessPermission demand)
{
// We return true here because we're defining a demand of null to
// automatically pass.
if (demand == null)
return true;
if (demand.GetType() != grant.GetType())
return false;
if (grant.IsUnrestricted())
return true;
if (((IUnrestrictedPermission)demand).IsUnrestricted())
throw new SecurityException(String.Format(Environment.GetResourceString("Security_Generic"), demand.GetType().FullName), demand.GetType(), demand.ToXml().ToString());
return false;
}
示例11: CheckDeny
internal bool CheckDeny (CodeAccessPermission denied)
{
if (denied == null)
return true;
Type t = denied.GetType ();
if (t != this.GetType ())
return true;
IPermission inter = Intersect (denied);
if (inter == null)
return true;
// sadly that's not enough :( at this stage we must also check
// if an empty (PermissionState.None) is a subset of the denied
// (which is like a empty intersection looks like for flag based
// permissions, e.g. AspNetHostingPermission).
return denied.IsSubsetOf (PermissionBuilder.Create (t));
}
示例12: CheckDemand
internal bool CheckDemand(CodeAccessPermission demand, PermissionToken permToken, RuntimeMethodHandleInternal rmh)
{
bool flag = true;
if (this.m_permSetTriples != null)
{
for (int i = 0; (i < this.m_permSetTriples.Count) && flag; i++)
{
flag = ((PermissionSetTriple) this.m_permSetTriples[i]).CheckDemand(demand, permToken, rmh);
}
}
else if (this.m_firstPermSetTriple != null)
{
flag = this.m_firstPermSetTriple.CheckDemand(demand, permToken, rmh);
}
return false;
}
示例13: Assert
internal static void Assert(CodeAccessPermission cap, ref StackCrawlMark stackMark)
{
FrameSecurityDescriptor descriptor = CheckNReturnSO(AssertPermissionToken, AssertPermission, ref stackMark, 1);
if (descriptor == null)
{
Environment.FailFast(Environment.GetResourceString("ExecutionEngine_MissingSecurityDescriptor"));
}
else
{
if (descriptor.HasImperativeAsserts())
{
throw new SecurityException(Environment.GetResourceString("Security_MustRevertOverride"));
}
descriptor.SetAssert(cap);
}
}
示例14: CheckAssert
private static bool CheckAssert(PermissionSet pSet, CodeAccessPermission demand, PermissionToken permToken)
{
if (pSet != null)
{
pSet.CheckDecoded(demand, permToken);
CodeAccessPermission asserted = (CodeAccessPermission) pSet.GetPermission(demand);
try
{
if (pSet.IsUnrestricted() || demand.CheckAssert(asserted))
{
return false;
}
}
catch (ArgumentException)
{
}
}
return true;
}
示例15: CheckDemandNoThrow
[System.Security.SecurityCritical] // auto-generated
internal bool CheckDemandNoThrow(CodeAccessPermission demand)
{
// AppDomain permissions - no asserts. So there should only be one triple to work with
Contract.Assert(m_permSetTriples == null && m_firstPermSetTriple != null, "More than one PermissionSetTriple encountered in AD PermissionListSet");
PermissionToken permToken = null;
if (demand != null)
permToken = PermissionToken.GetToken(demand);
return m_firstPermSetTriple.CheckDemandNoThrow(demand, permToken);
}