2004-08-04 Sebastien Pouliot <sebastien@ximian.com>
authorSebastien Pouliot <sebastien@ximian.com>
Wed, 4 Aug 2004 22:19:23 +0000 (22:19 -0000)
committerSebastien Pouliot <sebastien@ximian.com>
Wed, 4 Aug 2004 22:19:23 +0000 (22:19 -0000)
* GacIdentityPermission.cs: New. for NET_2_0
* GacIdentityPermissionAttribute.cs: New. for NET_2_0

svn path=/trunk/mcs/; revision=31906

mcs/class/corlib/System.Security.Permissions/ChangeLog
mcs/class/corlib/System.Security.Permissions/GacIdentityPermission.cs [new file with mode: 0644]
mcs/class/corlib/System.Security.Permissions/GacIdentityPermissionAttribute.cs [new file with mode: 0644]

index e4acc1ddace8561ce14b83efb4fd1c5eaa80016f..4d5200b75a89b5d5d80378eff7d111dc3e37a47b 100644 (file)
@@ -1,5 +1,7 @@
 2004-08-04  Sebastien Pouliot  <sebastien@ximian.com>
 
+       * GacIdentityPermission.cs: New. for NET_2_0
+       * GacIdentityPermissionAttribute.cs: New. for NET_2_0
        * ZoneIdentityPermission.cs: NoZone is a subset of all SecurityZone.
 
 2004-08-03  Sebastien Pouliot  <sebastien@ximian.com>
diff --git a/mcs/class/corlib/System.Security.Permissions/GacIdentityPermission.cs b/mcs/class/corlib/System.Security.Permissions/GacIdentityPermission.cs
new file mode 100644 (file)
index 0000000..28ec16f
--- /dev/null
@@ -0,0 +1,131 @@
+//
+// System.Security.Permissions.GacIdentityPermission
+//
+// Author:
+//     Sebastien Pouliot  <sebastien@ximian.com>
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if NET_2_0
+
+using System;
+using System.Globalization;
+using System.Security;
+
+namespace System.Security.Permissions {
+
+       [Serializable]
+       public sealed class GacIdentityPermission : CodeAccessPermission, IBuiltInPermission {
+
+               public GacIdentityPermission ()
+               {
+               }
+
+               public GacIdentityPermission (PermissionState state)
+               {
+                       switch (state) {
+                               case PermissionState.None:
+                                       break;
+                               case PermissionState.Unrestricted:
+                                       throw new ArgumentException (Locale.GetText (
+                                               "unrestricted not allowed"));
+                               default:
+                                       throw new ArgumentException (Locale.GetText (
+                                               "invalid state"));
+                       }
+               }
+
+               public override IPermission Copy ()
+               {
+                       return (IPermission) new GacIdentityPermission ();
+               }
+
+               public override IPermission Intersect (IPermission target)
+               {
+                       if (target == null)
+                               return null;
+                       if (!(target is GacIdentityPermission)) {
+                               throw new ArgumentException (Locale.GetText (
+                                       "Invalid permission"));
+                       }
+                       return Copy ();
+               }
+
+               public override bool IsSubsetOf (IPermission target)
+               {
+                       if (target == null)
+                               return false;
+
+                       if (!(target is GacIdentityPermission)) {
+                               throw new ArgumentException (Locale.GetText (
+                                       "Invalid permission"));
+                       }
+
+                       return true;
+               }
+
+               public override IPermission Union (IPermission target)
+               {
+                       if (target == null)
+                               return Copy ();
+
+                       if (!(target is GacIdentityPermission)) {
+                               throw new ArgumentException (Locale.GetText (
+                                       "Invalid permission"));
+                       }
+
+                       return Copy ();
+               }
+
+               public override void FromXml (SecurityElement esd)
+               {
+                       if (esd == null)
+                               throw new ArgumentException ("esd");
+
+                       if (esd.Attribute ("version") != "1") {
+                               throw new ArgumentException (Locale.GetText (
+                                       "version attributte is wrong"));
+                       }
+
+                       // ??? check class name ???
+               }
+
+               public override SecurityElement ToXml ()
+               {
+                       SecurityElement se = new SecurityElement ("IPermission");
+                       Type t = GetType ();
+                       se.AddAttribute ("class", t.FullName + ", " + t.Module.Assembly.FullName);
+                       se.AddAttribute ("version", "1");
+                       return se;
+               }
+
+               // IBuildInPermission
+
+               int IBuiltInPermission.GetTokenIndex ()
+               {
+                       return -1; // TODO
+               }
+       }
+}
+
+#endif
diff --git a/mcs/class/corlib/System.Security.Permissions/GacIdentityPermissionAttribute.cs b/mcs/class/corlib/System.Security.Permissions/GacIdentityPermissionAttribute.cs
new file mode 100644 (file)
index 0000000..f2baabd
--- /dev/null
@@ -0,0 +1,51 @@
+//
+// System.Security.Permissions.GacIdentityPermissionAttribute
+//
+// Author:
+//     Sebastien Pouliot  <sebastien@ximian.com>
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if NET_2_0
+
+namespace System.Security.Permissions {
+
+       [Serializable]
+       [AttributeUsage (AttributeTargets.Assembly | AttributeTargets.Class |
+                        AttributeTargets.Struct | AttributeTargets.Constructor |
+                        AttributeTargets.Method, AllowMultiple=true, Inherited=false)]
+       public sealed class GacIdentityPermissionAttribute : CodeAccessSecurityAttribute {
+
+               public GacIdentityPermissionAttribute (SecurityAction action)
+                       : base (action)
+               {
+               }
+
+               public override IPermission CreatePermission ()
+               {
+                       return (IPermission) new GacIdentityPermission ();
+               }
+       }
+}
+
+#endif