summaryrefslogtreecommitdiff
path: root/src/mscorlib/src/System/Security/CodeAccessPermission.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/mscorlib/src/System/Security/CodeAccessPermission.cs')
-rw-r--r--src/mscorlib/src/System/Security/CodeAccessPermission.cs69
1 files changed, 7 insertions, 62 deletions
diff --git a/src/mscorlib/src/System/Security/CodeAccessPermission.cs b/src/mscorlib/src/System/Security/CodeAccessPermission.cs
index 61334c22bd..70504d902e 100644
--- a/src/mscorlib/src/System/Security/CodeAccessPermission.cs
+++ b/src/mscorlib/src/System/Security/CodeAccessPermission.cs
@@ -13,20 +13,16 @@ namespace System.Security
using System.Collections;
using System.Text;
using System;
- using System.Diagnostics;
+ using System.Diagnostics;
using System.Diagnostics.Contracts;
using IUnrestrictedPermission = System.Security.Permissions.IUnrestrictedPermission;
[Serializable]
-#if !FEATURE_CORECLR
- [SecurityPermissionAttribute( SecurityAction.InheritanceDemand, ControlEvidence = true, ControlPolicy = true )]
-#endif
[System.Runtime.InteropServices.ComVisible(true)]
abstract public class CodeAccessPermission
: IPermission, ISecurityEncodable, IStackWalk
{
// Static methods for manipulation of stack
- [System.Security.SecuritySafeCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
public static void RevertAssert()
{
@@ -34,7 +30,6 @@ namespace System.Security
SecurityRuntime.RevertAssert(ref stackMark);
}
- [System.Security.SecuritySafeCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
[Obsolete("Deny is obsolete and will be removed in a future release of the .NET Framework. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
public static void RevertDeny()
@@ -43,7 +38,6 @@ namespace System.Security
SecurityRuntime.RevertDeny(ref stackMark);
}
- [System.Security.SecuritySafeCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
public static void RevertPermitOnly()
{
@@ -51,7 +45,6 @@ namespace System.Security
SecurityRuntime.RevertPermitOnly(ref stackMark);
}
- [System.Security.SecuritySafeCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
public static void RevertAll()
{
@@ -66,7 +59,6 @@ namespace System.Security
// Mark this method as requiring a security object on the caller's frame
// so the caller won't be inlined (which would mess up stack crawling).
- [System.Security.SecuritySafeCritical] // auto-generated
[DynamicSecurityMethodAttribute()]
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
public void Demand()
@@ -78,7 +70,6 @@ namespace System.Security
}
}
- [System.Security.SecuritySafeCritical] // auto-generated
[DynamicSecurityMethodAttribute()]
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
internal static void Demand(PermissionType permissionType)
@@ -87,7 +78,7 @@ namespace System.Security
// without having to create objects.
// The security annotation fxcop rule that flags all methods with a Demand() has logic
// which checks for methods named Demand in types that implement IPermission or IStackWalk.
- Contract.Assert(new StackFrame().GetMethod().Name.Equals("Demand"), "This method needs to be named Demand");
+ Debug.Assert(new StackFrame().GetMethod().Name.Equals("Demand"), "This method needs to be named Demand");
StackCrawlMark stackMark = StackCrawlMark.LookForMyCallersCaller;
CodeAccessSecurityEngine.SpecialDemand(permissionType, ref stackMark);
@@ -96,7 +87,6 @@ namespace System.Security
// Metadata for this method should be flaged with REQ_SQ so that
// EE can allocate space on the stack frame for FrameSecurityDescriptor
- [System.Security.SecuritySafeCritical] // auto-generated
[DynamicSecurityMethodAttribute()]
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
public void Assert()
@@ -106,7 +96,6 @@ namespace System.Security
}
- [System.Security.SecuritySafeCritical] // auto-generated
[DynamicSecurityMethodAttribute()]
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
static internal void Assert(bool allPossible)
@@ -115,7 +104,7 @@ namespace System.Security
// without having to new a PermissionSet.
// The security annotation fxcop rule that flags all methods with an Assert() has logic
// which checks for methods named Assert in types that implement IPermission or IStackWalk.
- Contract.Assert(new StackFrame().GetMethod().Name.Equals("Assert"), "This method needs to be named Assert");
+ Debug.Assert(new StackFrame().GetMethod().Name.Equals("Assert"), "This method needs to be named Assert");
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
SecurityRuntime.AssertAllPossible(ref stackMark);
@@ -124,7 +113,6 @@ namespace System.Security
// Metadata for this method should be flaged with REQ_SQ so that
// EE can allocate space on the stack frame for FrameSecurityDescriptor
- [System.Security.SecuritySafeCritical] // auto-generated
[DynamicSecurityMethodAttribute()]
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
[Obsolete("Deny is obsolete and will be removed in a future release of the .NET Framework. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
@@ -137,7 +125,6 @@ namespace System.Security
// Metadata for this method should be flaged with REQ_SQ so that
// EE can allocate space on the stack frame for FrameSecurityDescriptor
- [System.Security.SecuritySafeCritical] // auto-generated
[DynamicSecurityMethodAttribute()]
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
public void PermitOnly()
@@ -160,48 +147,6 @@ namespace System.Security
// otherwise we don't support it.
throw new NotSupportedException(Environment.GetResourceString( "NotSupported_SecurityPermissionUnion" ));
}
-
-#if FEATURE_CAS_POLICY
- static internal SecurityElement CreatePermissionElement( IPermission perm, String permname )
- {
- SecurityElement root = new SecurityElement( "IPermission" );
- XMLUtil.AddClassAttribute( root, perm.GetType(), permname );
- // If you hit this assert then most likely you are trying to change the name of this class.
- // This is ok as long as you change the hard coded string above and change the assert below.
- Contract.Assert( perm.GetType().FullName.Equals( permname ), "Incorrect class name passed in! Was: " + permname + " Should be " + perm.GetType().FullName);
-
- root.AddAttribute( "version", "1" );
- return root;
- }
-
- static internal void ValidateElement( SecurityElement elem, IPermission perm )
- {
- if (elem == null)
- throw new ArgumentNullException( "elem" );
- Contract.EndContractBlock();
-
- if (!XMLUtil.IsPermissionElement( perm, elem ))
- throw new ArgumentException( Environment.GetResourceString( "Argument_NotAPermissionElement"));
-
- String version = elem.Attribute( "version" );
-
- if (version != null && !version.Equals( "1" ))
- throw new ArgumentException( Environment.GetResourceString( "Argument_InvalidXMLBadVersion") );
- }
-
- abstract public SecurityElement ToXml();
- abstract public void FromXml( SecurityElement elem );
-
- //
- // Unimplemented interface methods
- // (as a reminder only)
- //
-
- public override String ToString()
- {
- return ToXml().ToString();
- }
-#endif // FEATURE_CAS_POLICY
//
// HELPERS FOR IMPLEMENTING ABSTRACT METHODS
@@ -258,26 +203,26 @@ namespace System.Security
internal bool CheckDemand(CodeAccessPermission grant)
{
- Contract.Assert( grant == null || grant.GetType().Equals( this.GetType() ), "CheckDemand not defined for permissions of different type" );
+ Debug.Assert( grant == null || grant.GetType().Equals( this.GetType() ), "CheckDemand not defined for permissions of different type" );
return IsSubsetOf( grant );
}
internal bool CheckPermitOnly(CodeAccessPermission permitted)
{
- Contract.Assert( permitted == null || permitted.GetType().Equals( this.GetType() ), "CheckPermitOnly not defined for permissions of different type" );
+ Debug.Assert( permitted == null || permitted.GetType().Equals( this.GetType() ), "CheckPermitOnly not defined for permissions of different type" );
return IsSubsetOf( permitted );
}
internal bool CheckDeny(CodeAccessPermission denied)
{
- Contract.Assert( denied == null || denied.GetType().Equals( this.GetType() ), "CheckDeny not defined for permissions of different type" );
+ Debug.Assert( denied == null || denied.GetType().Equals( this.GetType() ), "CheckDeny not defined for permissions of different type" );
IPermission intersectPerm = Intersect(denied);
return (intersectPerm == null || intersectPerm.IsSubsetOf(null));
}
internal bool CheckAssert(CodeAccessPermission asserted)
{
- Contract.Assert( asserted == null || asserted.GetType().Equals( this.GetType() ), "CheckPermitOnly not defined for permissions of different type" );
+ Debug.Assert( asserted == null || asserted.GetType().Equals( this.GetType() ), "CheckPermitOnly not defined for permissions of different type" );
return IsSubsetOf( asserted );
}
}