#if NET_2_0
[ComVisible (true)]
#endif
+ [MonoTODO ("CAS support is experimental (and unsupported).")]
public class PermissionSet: ISecurityEncodable, ICollection, IEnumerable, IStackWalk, IDeserializationCallback {
private const string tagName = "PermissionSet";
private PermissionState state;
private ArrayList list;
- private int _hashcode;
private PolicyLevel _policyLevel;
private bool _declsec;
private bool _readOnly;
// methods
+#if NET_2_0
+ public IPermission AddPermission (IPermission perm)
+#else
public virtual IPermission AddPermission (IPermission perm)
+#endif
{
if ((perm == null) || _readOnly)
return perm;
return perm;
}
- [MonoTODO ("Imperative mode isn't supported")]
+ [MonoTODO ("CAS support is experimental (and unsupported). Imperative mode is not implemented.")]
[SecurityPermission (SecurityAction.Demand, Assertion = true)]
+#if NET_2_0
+ public void Assert ()
+#else
public virtual void Assert ()
+#endif
{
int count = this.Count;
}
}
+#if NET_2_0
+ public void Demand ()
+#else
public virtual void Demand ()
+#endif
{
// Note: SecurityEnabled only applies to CAS permissions
// so we're not checking for it (yet)
bool call_cas_only = this.IsUnrestricted ();
// non CAS permissions (e.g. PrincipalPermission) do not requires a stack walk
for (int i = 0; i < n; i++) {
- CodeAccessPermission p = (CodeAccessPermission) list [i];
+ IPermission p = (IPermission) list [i];
Type t = p.GetType ();
if (t.IsSubclassOf (typeof (CodeAccessPermission))) {
_ignored [i] = false;
}
}
- [MonoTODO ("Imperative mode isn't supported")]
+ [MonoTODO ("CAS support is experimental (and unsupported). Imperative mode is not implemented.")]
+#if NET_2_0
+ public void Deny ()
+#else
public virtual void Deny ()
+#endif
{
if (!SecurityManager.SecurityEnabled)
return;
}
}
+#if NET_2_0
+ public IEnumerator GetEnumerator ()
+#else
public virtual IEnumerator GetEnumerator ()
+#endif
{
return list.GetEnumerator ();
}
- public virtual bool IsSubsetOf (PermissionSet target)
- {
#if NET_2_0
+ public bool IsSubsetOf (PermissionSet target)
+ {
// if target is empty we must be empty too
if ((target == null) || (target.IsEmpty ()))
return this.IsEmpty ();
return true;
if (this.IsUnrestricted ())
return false;
+#else
+ public virtual bool IsSubsetOf (PermissionSet target)
+ {
#endif
if (this.IsUnrestricted () && ((target == null) || !target.IsUnrestricted ()))
return false;
return true;
}
- [MonoTODO ("Imperative mode isn't supported")]
+ [MonoTODO ("CAS support is experimental (and unsupported). Imperative mode is not implemented.")]
+#if NET_2_0
+ public void PermitOnly ()
+#else
public virtual void PermitOnly ()
+#endif
{
if (!SecurityManager.SecurityEnabled)
return;
return false;
}
- [MonoTODO ("little documentation in Fx 2.0 beta 1")]
+ // FIXME little documentation in Fx 2.0 beta 1
public static byte[] ConvertPermissionSet (string inFormat, byte[] inData, string outFormat)
{
if (inFormat == null)
throw new SerializationException (String.Format (Locale.GetText ("Unknown output format {0}."), outFormat));
}
- public virtual IPermission GetPermission (Type permClass)
+#if NET_2_0
+ public IPermission GetPermission (Type permClass)
+#else
+ public virtual IPermission GetPermission (Type permClass)
+#endif
{
if ((permClass == null) || (list.Count == 0))
return null;
return null;
}
- public virtual PermissionSet Intersect (PermissionSet other)
+#if NET_2_0
+ public PermissionSet Intersect (PermissionSet other)
+#else
+ public virtual PermissionSet Intersect (PermissionSet other)
+#endif
{
// no intersection possible
if ((other == null) || (other.IsEmpty ()) || (this.IsEmpty ()))
}
}
- public virtual bool IsEmpty ()
+#if NET_2_0
+ public bool IsEmpty ()
+#else
+ public virtual bool IsEmpty ()
+#endif
{
// note: Unrestricted isn't empty
if (state == PermissionState.Unrestricted)
return true;
}
- public virtual bool IsUnrestricted ()
+#if NET_2_0
+ public bool IsUnrestricted ()
+#else
+ public virtual bool IsUnrestricted ()
+#endif
{
return (state == PermissionState.Unrestricted);
}
- public virtual IPermission RemovePermission (Type permClass)
+#if NET_2_0
+ public IPermission RemovePermission (Type permClass)
+#else
+ public virtual IPermission RemovePermission (Type permClass)
+#endif
{
if ((permClass == null) || _readOnly)
return null;
return null;
}
- public virtual IPermission SetPermission (IPermission perm)
+#if NET_2_0
+ public IPermission SetPermission (IPermission perm)
+#else
+ public virtual IPermission SetPermission (IPermission perm)
+#endif
{
if ((perm == null) || _readOnly)
return perm;
return se;
}
+#if NET_2_0
+ public PermissionSet Union (PermissionSet other)
+#else
public virtual PermissionSet Union (PermissionSet other)
+#endif
{
if (other == null)
return this.Copy ();
return (list.Count == 0) ? (int) state : base.GetHashCode ();
}
- [MonoTODO ("(2.0) what's it doing here? There's probably a reason this was added here.")]
+ // FIXME what's it doing here? There's probably a reason this was added here.
static public void RevertAssert ()
{
CodeAccessPermission.RevertAssert ();
if (frame.Deny != null) {
// but have restrictions (some denied permissions)
CodeAccessPermission.ThrowSecurityException (this, "Deny", frame, SecurityAction.Demand, null);
- } else if (frame.PermitOnly != null) {
+ } else if ((frame.PermitOnly != null) && !frame.PermitOnly.IsUnrestricted ()) {
// but have restrictions (only some permitted permissions)
CodeAccessPermission.ThrowSecurityException (this, "PermitOnly", frame, SecurityAction.Demand, null);
}