本文整理汇总了C#中IPermission.IsSubsetOf方法的典型用法代码示例。如果您正苦于以下问题:C# IPermission.IsSubsetOf方法的具体用法?C# IPermission.IsSubsetOf怎么用?C# IPermission.IsSubsetOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPermission
的用法示例。
在下文中一共展示了IPermission.IsSubsetOf方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsGranted
// note: in 2.0 *all* permissions (including identity permissions) support unrestricted
internal static bool IsGranted (Assembly a, IPermission perm)
{
PermissionSet granted = a.GrantedPermissionSet;
if ((granted != null) && !granted.IsUnrestricted ()) {
CodeAccessPermission grant = (CodeAccessPermission) granted.GetPermission (perm.GetType ());
if (!perm.IsSubsetOf (grant)) {
return false;
}
}
PermissionSet denied = a.DeniedPermissionSet;
if ((denied != null) && !denied.IsEmpty ()) {
if (denied.IsUnrestricted ())
return false;
CodeAccessPermission refuse = (CodeAccessPermission) a.DeniedPermissionSet.GetPermission (perm.GetType ());
if ((refuse != null) && perm.IsSubsetOf (refuse))
return false;
}
return true;
}
示例2: Contains
// Returns true if perm is contained in this
internal bool Contains(IPermission perm)
{
if (perm == null)
return true;
if (m_Unrestricted)
return true;
if (FastIsEmpty())
return false;
PermissionToken token = PermissionToken.GetToken(perm);
Object thisObj = this.m_permSet.GetItem( token.m_index );
if (thisObj == null)
return perm.IsSubsetOf( null );
IPermission thisPerm = GetPermission(token.m_index);
if (thisPerm != null)
return perm.IsSubsetOf( thisPerm );
else
return perm.IsSubsetOf( null );
}
示例3: IsGranted
public static bool IsGranted(this IRole role, IPermission permission) {
var permissionSet = new PermissionSet(PermissionState.None);
role.Permissions.Each(perm => permissionSet.AddPermission(perm));
var getPermission = permissionSet.GetPermission(typeof(ObjectAccessPermission));
return getPermission != null && permission.IsSubsetOf(getPermission);
}
示例4: FrameDescHelper
private static bool FrameDescHelper(FrameSecurityDescriptor secDesc,
IPermission demand,
PermissionToken permToken)
{
PermissionSet permSet;
// If the demand is null, there is no need to continue
if (demand == null || demand.IsSubsetOf( null ))
return StackHalt;
// NOTE: See notes about exceptions and exception handling in FrameDescSetHelper
// Check Reduction
try
{
permSet = secDesc.GetPermitOnly();
if (permSet != null)
{
IPermission perm = permSet.GetPermission(demand);
#if _DEBUG
if (debug)
{
DEBUG_OUT("Checking PermitOnly");
DEBUG_OUT("permit only set =\n" + permSet.ToXml().ToString() );
DEBUG_OUT("demand =\n" + ((CodeAccessPermission)demand).ToXml().ToString() );
}
#endif
// If the permit only set does not contain the demanded permission, throw a security exception
if (perm == null)
{
if(!(demand is IUnrestrictedPermission && permSet.IsUnrestricted()))
throw new SecurityException(String.Format(Environment.GetResourceString("Security_Generic"), demand.GetType().AssemblyQualifiedName), demand.GetType(), demand.ToXml().ToString());
}
else
{
if (!demand.IsSubsetOf( perm ))
throw new SecurityException(String.Format(Environment.GetResourceString("Security_Generic"), demand.GetType().AssemblyQualifiedName), demand.GetType(), demand.ToXml().ToString());
}
}
}
catch (Exception)
{
throw new SecurityException(String.Format(Environment.GetResourceString("Security_Generic"), demand.GetType().AssemblyQualifiedName), demand.GetType(), demand.ToXml().ToString());
}
// Check Denials
try
{
permSet = secDesc.GetDenials();
if (permSet != null)
{
#if _DEBUG
if (debug)
{
DEBUG_OUT("Checking Denials");
DEBUG_OUT("denied set =\n" + permSet.ToXml().ToString() );
}
#endif
IPermission perm = permSet.GetPermission(demand);
// If the deny set does contain the demanded permission, throw a security exception
if ((perm != null && perm.Intersect( demand ) != null) || (demand is IUnrestrictedPermission && permSet.IsUnrestricted()))
throw new SecurityException(String.Format(Environment.GetResourceString("Security_Generic"), demand.GetType().AssemblyQualifiedName), demand.GetType(), demand.ToXml().ToString());
}
}
catch (Exception)
{
throw new SecurityException(String.Format(Environment.GetResourceString("Security_Generic"), demand.GetType().AssemblyQualifiedName), demand.GetType(), demand.ToXml().ToString());
}
if (secDesc.GetAssertAllPossible())
{
return StackHalt;
}
try
{
permSet = secDesc.GetAssertions();
// Check Assertions
if (permSet != null)
{
#if _DEBUG
if (debug)
DEBUG_OUT("Checking Assertions");
#endif
IPermission perm = permSet.GetPermission(demand);
// If the assert set does contain the demanded permission, halt the stackwalk
if ((perm != null && (demand.IsSubsetOf( perm )) || (demand is IUnrestrictedPermission && permSet.IsUnrestricted())))
{
#if _DEBUG
if (debug)
//.........这里部分代码省略.........
示例5: Contains
internal bool Contains(IPermission perm)
{
if (perm == null)
{
return true;
}
if (this.m_Unrestricted)
{
return true;
}
if (this.FastIsEmpty())
{
return false;
}
PermissionToken token = PermissionToken.GetToken(perm);
if (this.m_permSet.GetItem(token.m_index) != null)
{
IPermission target = this.GetPermission(token.m_index);
if (target != null)
{
return perm.IsSubsetOf(target);
}
}
return perm.IsSubsetOf(null);
}
示例6: Contains
// Returns true if perm is contained in this
internal virtual bool Contains(IPermission perm)
{
if (perm == null)
return true;
if (m_Unrestricted && perm is IUnrestrictedPermission)
{
return true;
}
PermissionToken token = PermissionToken.GetToken(perm);
IPermission p;
if (token.m_isUnrestricted)
{
if (m_unrestrictedPermSet == null)
return perm.IsSubsetOf( null );
p = (IPermission)m_unrestrictedPermSet.GetItem( token.m_index );
}
else
{
if (m_normalPermSet == null)
return perm.IsSubsetOf( null );
p = (IPermission)m_normalPermSet.GetItem( token.m_index );
}
return perm.IsSubsetOf(p);
}
示例7: Union
public override IPermission Union(IPermission target)
{
if(target == null)
{
return Copy();
}
else if(!(target is StrongNameIdentityPermission))
{
throw new ArgumentException(_("Arg_PermissionMismatch"));
}
else if(IsSubsetOf(target))
{
return target.Copy();
}
else if(target.IsSubsetOf(this))
{
return Copy();
}
else
{
return null;
}
}
示例8: Intersect
public override IPermission Intersect(IPermission target)
{
if(target == null)
{
return target;
}
else if(!(target is PublisherIdentityPermission))
{
throw new ArgumentException(_("Arg_PermissionMismatch"));
}
else if(IsSubsetOf(target))
{
return Copy();
}
else if(target.IsSubsetOf(this))
{
return target.Copy();
}
else
{
return null;
}
}