dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Security AllowPartiall


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Security AllowPartiallyTrustedCallersAttribute.cs,NONE,1.1 IEvidenceFactory.cs,NONE,1.1 ISecurityEncodable.cs,NONE,1.1 ISecurityPolicyEncodable.cs,NONE,1.1 IStackWalk.cs,NONE,1.1 NamedPermissionSet.cs,NONE,1.1 PolicyLevelType.cs,NONE,1.1 SecurityManager.cs,NONE,1.1 SecurityZone.cs,NONE,1.1 XmlSyntaxException.cs,NONE,1.1 CodeAccessPermission.cs,1.2,1.3 IPermission.cs,1.1,1.2 PermissionSet.cs,1.2,1.3SecurityElement.cs,1.2,1.3 SuppressUnmanagedCodeSecurityAttribute.cs,1.1,1.2 UnverifiableCodeAttribute.cs,1.2,1.3
Date: Sun, 30 Mar 2003 06:58:47 -0500

Update of /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Security
In directory subversions:/tmp/cvs-serv19206/runtime/System/Security

Modified Files:
        CodeAccessPermission.cs IPermission.cs PermissionSet.cs 
        SecurityElement.cs SuppressUnmanagedCodeSecurityAttribute.cs 
        UnverifiableCodeAttribute.cs 
Added Files:
        AllowPartiallyTrustedCallersAttribute.cs IEvidenceFactory.cs 
        ISecurityEncodable.cs ISecurityPolicyEncodable.cs 
        IStackWalk.cs NamedPermissionSet.cs PolicyLevelType.cs 
        SecurityManager.cs SecurityZone.cs XmlSyntaxException.cs 
Log Message:


Add missing classes and definitions under "System.Security".


--- NEW FILE ---
/*
 * AllowPartiallyTrustedCallersAttribute.cs - Implementation of 
 *                      "System.Security.AllowPartiallyTrustedCallersAttribute" 
class.
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace System.Security
{

using System;

#if !ECMA_COMPAT

[AttributeUsage(AttributeTargets.Assembly,
                                AllowMultiple=false, Inherited=false)]
public sealed class AllowPartiallyTrustedCallersAttribute: Attribute
{

        // Constructor.
        public AllowPartiallyTrustedCallersAttribute()
                        {
                                // Nothing to do here.
                        }

}; // class AllowPartiallyTrustedCallersAttribute

#endif

}; // namespace System.Security

--- NEW FILE ---
/*
 * IEvidenceFactory.cs - Implementation of the
 *              "System.Security.IEvidenceFactory" interface.
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace System.Security
{

using System;
using System.Security.Policy;

#if ECMA_COMPAT
internal
#else
public
#endif
interface IEvidenceFactory
{

        // Get evidence information from this object.
        Evidence Evidence { get; }

}; // interface IEvidenceFactory

}; // namespace System.Security

--- NEW FILE ---
/*
 * ISecurityEncodable.cs - Implementation of the
 *              "System.Security.ISecurityEncodable" interface.
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace System.Security
{

using System;

#if ECMA_COMPAT
internal
#else
public
#endif
interface ISecurityEncodable
{

        void FromXml(SecurityElement et);
        SecurityElement ToXml();

}; // interface ISecurityEncodable

}; // namespace System.Security

--- NEW FILE ---
/*
 * ISecurityPolicyEncodable.cs - Implementation of the
 *              "System.Security.ISecurityPolicyEncodable" interface.
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace System.Security
{

#if !ECMA_COMPAT

using System;
using System.Security.Policy;

public interface ISecurityPolicyEncodable
{

        void FromXml(SecurityElement et, PolicyLevel level);
        SecurityElement ToXml(PolicyLevel level);

}; // interface ISecurityPolicyEncodable

#endif // !ECMA_COMPAT

}; // namespace System.Security

--- NEW FILE ---
/*
 * IStackWalk.cs - Implementation of the
 *              "System.Security.IStackWalk" interface.
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace System.Security
{

using System;

#if ECMA_COMPAT
internal
#else
public
#endif
interface IStackWalk
{

        // Assert permissions for the caller.
        void Assert();

        // Throw an exception if the caller does not have
        // the specified permissions.
        void Demand();

        // Deny permissions to the caller.
        void Deny();

        // Set the caller's permissions to only this object.
        void PermitOnly();

}; // interface IStackWalk

}; // namespace System.Security

--- NEW FILE ---
/*
 * NamedPermissionSet.cs - Implementation of the
 *              "System.Security.NamedPermissionSet" class.
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace System.Security
{

#if !ECMA_COMPAT

using System;
using System.Collections;
using System.Security.Permissions;

public sealed class NamedPermissionSet : PermissionSet
{

        // Internal state.
        private String name;
        private String description;

        // Constructors.
        public NamedPermissionSet(String name)
                        : base(PermissionState.Unrestricted)
                        {
                                if(name == null || name == String.Empty)
                                {
                                        throw new 
ArgumentException(_("Invalid_PermissionSetName"));
                                }
                                this.name = name;
                        }
        public NamedPermissionSet(String name, PermissionState state)
                        : base(state)
                        {
                                if(name == null || name == String.Empty)
                                {
                                        throw new 
ArgumentException(_("Invalid_PermissionSetName"));
                                }
                                this.name = name;
                        }
        public NamedPermissionSet(String name, PermissionSet permSet)
                        : base(permSet)
                        {
                                if(name == null || name == String.Empty)
                                {
                                        throw new 
ArgumentException(_("Invalid_PermissionSetName"));
                                }
                                this.name = name;
                        }
        public NamedPermissionSet(NamedPermissionSet permSet)
                        : base(permSet)
                        {
                                this.name = permSet.name;
                                this.description = permSet.description;
                        }

        // Get or set the name of this permission set.
        public String Name
                        {
                                get
                                {
                                        return name;
                                }
                                set
                                {
                                        if(value == null || value == 
String.Empty)
                                        {
                                                throw new ArgumentException
                                                        
(_("Invalid_PermissionSetName"));
                                        }
                                        name = value;
                                }
                        }

        // Get or set the description of this permission set.
        public String Description
                        {
                                get
                                {
                                        return description;
                                }
                                set
                                {
                                        description = value;
                                }
                        }

        // Return a copy of this permission set.
        public override PermissionSet Copy()
                        {
                                return new NamedPermissionSet(this);
                        }

        // Copy this permission set and give the copy a new name.
        public NamedPermissionSet Copy(String name)
                        {
                                NamedPermissionSet permSet = new 
NamedPermissionSet(this);
                                permSet.Name = name;
                                return permSet;
                        }

        // Convert this permission set into an XML security element.
        public override SecurityElement ToXml()
                        {
                                SecurityElement elem = base.ToXml();
                                if(name != null && name != String.Empty)
                                {
                                        elem.AddAttribute("Name", 
SecurityElement.Escape(name));
                                }
                                if(description != null && description != 
String.Empty)
                                {
                                        elem.AddAttribute
                                                ("Description", 
SecurityElement.Escape(description));
                                }
                                return elem;
                        }

        // Convert an XML security element into a permission set.
        public override void FromXml(SecurityElement et)
                        {
                                base.FromXml(et);
                                name = et.Attribute("Name");
                                description = et.Attribute("Description");
                                if(description == null)
                                {
                                        description = String.Empty;
                                }
                        }

}; // class NamedPermissionSet

#endif // !ECMA_COMPAT

}; // namespace System.Security

--- NEW FILE ---
/*
 * PolicyLevelType.cs - Implementation of the
 *              "System.Security.PolicyLevelType" class.
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace System.Security
{

#if !ECMA_COMPAT

public enum PolicyLevelType
{

        User       = 0,
        Machine    = 1,
        Enterprise = 2,
        AppDomain  = 3

}; // enum PolicyLevelType

#endif // !ECMA_COMPAT

}; // namespace System.Security

--- NEW FILE ---
/*
 * SecurityManager.cs - Implementation of the
 *              "System.Security.SecurityManager" class.
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace System.Security
{

#if !ECMA_COMPAT

using System.Collections;
using System.Security.Policy;

public class SecurityManager
{

        // Determine if a specific permission has been granted.
        [TODO]
        public static bool IsGranted(IPermission perm)
                        {
                                if(perm == null)
                                {
                                        return true;
                                }
                                // TODO
                                return false;
                        }

        // Load policy level information from a file.
        [TODO]
        public static PolicyLevel LoadPolicyLevelFromFile
                                (String path, PolicyLevelType type)
                        {
                                // TODO
                                return null;
                        }

        // Load policy level information from a string.
        [TODO]
        public static PolicyLevel LoadPolicyLevelFromString
                                (String str, PolicyLevelType type)
                        {
                                // TODO
                                return null;
                        }

        // Save a particular policy level.
        [TODO]
        public static void SavePolicyLevel(PolicyLevel level)
                        {
                                // TODO
                        }

        // Resolve policy information.
        [TODO]
        public static PermissionSet ResolvePolicy
                                (Evidence evidence, PermissionSet reqdPset,
                                 PermissionSet optPset, PermissionSet denyPset,
                                 out PermissionSet denied)
                        {
                                // TODO
                                return null;
                        }
        [TODO]
        public static PermissionSet ResolvePolicy(Evidence evidence)
                        {
                                // TODO
                                return null;
                        }

        // Resolve policy group information.
        [TODO]
        public static IEnumerator ResolvePolicyGroups(Evidence evidence)
                        {
                                // TODO
                                return null;
                        }

        // Get an enumerator for the policy hierarchy.
        [TODO]
        public static IEnumerator PolicyHeirarchy()
                        {
                                // TODO
                                return null;
                        }

        // Save policy information.
        [TODO]
        public static void SavePolicy()
                        {
                                // TODO
                        }

        // Get or set the execution rights flag.
        [TODO]
        public static bool CheckExecutionRights
                        {
                                get
                                {
                                        // TODO
                                        return true;
                                }
                                set
                                {
                                        // TODO
                                }
                        }

        // Determine if security features have been enabled.
        [TODO]
        public static bool SecurityEnabled
                        {
                                get
                                {
                                        // TODO
                                        return true;
                                }
                                set
                                {
                                        // TODO
                                }
                        }

        // Print information about the granted permissions for the
        // current application domain's assemblies.
        [TODO]
        public static void PrintGrantInfo()
                        {
                                // TODO
                        }

}; // class SecurityManager

#endif // !ECMA_COMPAT

}; // namespace System.Security

--- NEW FILE ---
/*
 * SecurityZone.cs - Implementation of the
 *              "System.Security.SecurityZone" class.
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace System.Security
{

#if !ECMA_COMPAT

public enum SecurityZone
{

        NoZone     = -1,
        MyComputer = 0,
        Intranet   = 1,
        Trusted    = 2,
        Internet   = 3,
        Untrusted  = 4

}; // enum SecurityZone

#endif // !ECMA_COMPAT

}; // namespace System.Security

--- NEW FILE ---
/*
 * XmlSyntaxException.cs - Implementation of the
 *              "System.Security.XmlSyntaxException" class.
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace System.Security
{

#if !ECMA_COMPAT

using System;

public sealed class XmlSyntaxException : SystemException
{
        // Constructors.
        public XmlSyntaxException()
                        : base(_("Exception_XmlSyntax")) {}
        public XmlSyntaxException(String msg)
                        : base(msg) {}
        public XmlSyntaxException(String msg, Exception inner)
                        : base(msg, inner) {}
        public XmlSyntaxException(int lineNumber)
                        : base(String.Format(_("Exception_XmlSyntaxLine"), 
lineNumber)) {}
        public XmlSyntaxException(int lineNumber, String message)
                        : base(String.Format(_("Exception_XmlSyntaxLineMsg"),
                                                                 lineNumber, 
message)) {}

}; // class XmlSyntaxException

#endif // !ECMA_COMPAT

}; // namespace System.Security

Index: CodeAccessPermission.cs
===================================================================
RCS file: 
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Security/CodeAccessPermission.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** CodeAccessPermission.cs     20 Dec 2001 10:11:39 -0000      1.2
--- CodeAccessPermission.cs     30 Mar 2003 11:58:44 -0000      1.3
***************
*** 26,30 ****
  using System.Runtime.CompilerServices;
  
! public abstract class CodeAccessPermission : IPermission
  {
  
--- 26,30 ----
  using System.Runtime.CompilerServices;
  
! public abstract class CodeAccessPermission : IPermission, IStackWalk
  {
  
***************
*** 72,80 ****
        public abstract IPermission Intersect(IPermission target);
        public abstract bool IsSubsetOf(IPermission target);
!       [TODO]
!       public virtual IPermission Union(IPermission target)
                        {
!                               // TODO
!                               return null;
                        }
  
--- 72,86 ----
        public abstract IPermission Intersect(IPermission target);
        public abstract bool IsSubsetOf(IPermission target);
!       public virtual IPermission Union(IPermission other)
                        {
!                               if(other == null)
!                               {
!                                       return Copy();
!                               }
!                               else
!                               {
!                                       throw new NotSupportedException
!                                               (_("NotSupp_IPermissionUnion"));
!                               }
                        }
  
***************
*** 97,108 ****
        extern public static void RevertPermitOnly();
  
        // Set the caller's permissions to only this object.
        public void PermitOnly()
                        {
                                ClrSecurity.SetPermitOnlyBlock(1);
                                ClrSecurity.PermitOnly(this, 1);
                        }
- 
- #endif // !ECMA_COMPAT
  
  }; // class CodeAccessPermission
--- 103,118 ----
        extern public static void RevertPermitOnly();
  
+ #endif // !ECMA_COMPAT
+ 
        // Set the caller's permissions to only this object.
+ #if ECMA_COMPAT
+       void IStackWalk.PermitOnly()
+ #else
        public void PermitOnly()
+ #endif
                        {
                                ClrSecurity.SetPermitOnlyBlock(1);
                                ClrSecurity.PermitOnly(this, 1);
                        }
  
  }; // class CodeAccessPermission

Index: IPermission.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Security/IPermission.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** IPermission.cs      18 Dec 2001 10:27:04 -0000      1.1
--- IPermission.cs      30 Mar 2003 11:58:44 -0000      1.2
***************
*** 25,29 ****
  using System;
  
! public interface IPermission
  {
  
--- 25,29 ----
  using System;
  
! public interface IPermission : ISecurityEncodable
  {
  

Index: PermissionSet.cs
===================================================================
RCS file: 
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Security/PermissionSet.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** PermissionSet.cs    20 Dec 2001 10:11:39 -0000      1.2
--- PermissionSet.cs    30 Mar 2003 11:58:44 -0000      1.3
***************
*** 3,7 ****
   *            "System.Security.PermissionSet" class.
   *
!  * Copyright (C) 2001  Southern Storm Software, Pty Ltd.
   *
   * This program is free software; you can redistribute it and/or modify
--- 3,7 ----
   *            "System.Security.PermissionSet" class.
   *
!  * Copyright (C) 2001, 2003  Southern Storm Software, Pty Ltd.
   *
   * This program is free software; you can redistribute it and/or modify
***************
*** 27,31 ****
  using System.Security.Permissions;
  
! public class PermissionSet : ICollection, IEnumerable
  {
  
--- 27,32 ----
  using System.Security.Permissions;
  
! public class PermissionSet : ICollection, IEnumerable, ISecurityEncodable,
!                                                        IStackWalk
  {
  
***************
*** 108,112 ****
                                        if(perm != null)
                                        {
!                                               perm.Assert();
                                        }
                                }
--- 109,117 ----
                                        if(perm != null)
                                        {
!                                               if(!ClrSecurity.Assert(perm, 1))
!                                               {
!                                                       throw new 
SecurityException
!                                                               
(_("Exception_SecurityNotGranted"));
!                                               }
                                        }
                                }
***************
*** 160,175 ****
  
        // Convert an XML security element into a permission set.
-       [TODO]
        public virtual void FromXml(SecurityElement et)
                        {
!                               // TODO
                        }
  
        // Determine if this permission set is a subset of another.
-       [TODO]
        public virtual bool IsSubsetOf(PermissionSet target)
                        {
!                               // TODO
!                               return false;
                        }
  
--- 165,270 ----
  
        // Convert an XML security element into a permission set.
        public virtual void FromXml(SecurityElement et)
                        {
!                               // Validate the parameter.
!                               if(et == null)
!                               {
!                                       throw new ArgumentNullException("et");
!                               }
!                               if(et.Tag != "PermissionSet")
!                               {
!                                       throw new 
ArgumentException(_("Invalid_PermissionXml"));
!                               }
!                               if(et.Attribute("version") != "1")
!                               {
!                                       throw new 
ArgumentException(_("Arg_PermissionVersion"));
!                               }
! 
!                               // Initialize the permission set from the tag.
!                               if(et.Attribute("Unrestricted") == "true")
!                               {
!                                       state = PermissionState.Unrestricted;
!                               }
!                               else
!                               {
!                                       state = PermissionState.None;
!                               }
!                               permissions.Clear();
! 
!                               // Process the children.
!                               ArrayList children = et.Children;
!                               String className;
!                               Type type;
!                               Object[] args;
!                               IPermission perm;
!                               args = new Object [1];
!                               args[0] = PermissionState.None;
!                               if(children != null)
!                               {
!                                       foreach(SecurityElement child in 
children)
!                                       {
!                                               if(child.Tag != "IPermission" &&
!                                                  child.Tag != "Permission")
!                                               {
!                                                       // Skip tags that we 
don't understand.
!                                                       continue;
!                                               }
!                                               className = 
child.Attribute("class");
!                                               if(className == null)
!                                               {
!                                                       throw new 
ArgumentException
!                                                               
(_("Invalid_PermissionXml"));
!                                               }
!                                               type = Type.GetType(className);
!                                               if(type == null && 
className.IndexOf('.') == -1)
!                                               {
!                                                       // May not have been 
fully-qualified.
!                                                       type = Type.GetType
!                                                               
("System.Security.Permissions." + className);
!                                               }
!                                               
if(!typeof(IPermission).IsAssignableFrom(type))
!                                               {
!                                                       throw new 
ArgumentException
!                                                               
(_("Invalid_PermissionXml"));
!                                               }
!                                               perm = 
(Activator.CreateInstance(type, args)
!                                                                       as 
IPermission);
!                                               if(perm != null)
!                                               {
!                                                       perm.FromXml(child);
!                                                       AddPermission(perm);
!                                               }
!                                       }
!                               }
                        }
  
        // Determine if this permission set is a subset of another.
        public virtual bool IsSubsetOf(PermissionSet target)
                        {
!                               // Handle the simple cases first.
!                               if(target == null)
!                               {
!                                       return false;
!                               }
!                               else if(target.IsUnrestricted())
!                               {
!                                       return true;
!                               }
!                               else if(IsUnrestricted())
!                               {
!                                       return false;
!                               }
! 
!                               // Scan the source permission set and check 
subset conditions.
!                               IPermission other;
!                               foreach(IPermission perm in permissions)
!                               {
!                                       other = 
target.GetPermission(perm.GetType());
!                                       if(other == null || 
!perm.IsSubsetOf(other))
!                                       {
!                                               return false;
!                                       }
!                               }
!                               return true;
                        }
  
***************
*** 197,213 ****
  
        // Convert this permission set into an XML security element.
-       [TODO]
        public virtual SecurityElement ToXml()
                        {
!                               // TODO
!                               return null;
                        }
  
        // Form the union of this security set and another.
-       [TODO]
        public virtual PermissionSet Union(PermissionSet other)
                        {
!                               // TODO
!                               return null;
                        }
  
--- 292,361 ----
  
        // Convert this permission set into an XML security element.
        public virtual SecurityElement ToXml()
                        {
!                               SecurityElement elem = new 
SecurityElement("PermissionSet");
!                               elem.AddAttribute
!                                       ("class", 
typeof(PermissionSet).AssemblyQualifiedName);
!                               elem.AddAttribute("version", "1");
!                               if(IsUnrestricted())
!                               {
!                                       elem.AddAttribute("Unrestricted", 
"true");
!                               }
!                               foreach(IPermission perm in permissions)
!                               {
!                                       elem.AddChild(perm.ToXml());
!                               }
!                               return elem;
                        }
  
        // Form the union of this security set and another.
        public virtual PermissionSet Union(PermissionSet other)
                        {
!                               PermissionSet pset;
!                               if(other == null)
!                               {
!                                       pset = new PermissionSet(state);
!                               }
!                               else if(IsUnrestricted() || 
other.IsUnrestricted())
!                               {
!                                       pset = new 
PermissionSet(PermissionState.Unrestricted);
!                               }
!                               else
!                               {
!                                       pset = new 
PermissionSet(PermissionState.None);
!                               }
!                               foreach(IPermission perm in permissions)
!                               {
!                                       pset.AddPermission(perm);
!                               }
!                               if(other == null || other.IsEmpty())
!                               {
!                                       return pset;
!                               }
!                               IEnumerator e = other.GetEnumerator();
!                               IPermission permOther, permThis;
!                               int index;
!                               while(e.MoveNext())
!                               {
!                                       permOther = (e.Current as IPermission);
!                                       if(permOther != null)
!                                       {
!                                               index = 
pset.FindPermission(permOther.GetType());
!                                               if(index != -1)
!                                               {
!                                                       permThis = 
(IPermission)(permissions[index]);
!                                                       permThis = 
permThis.Union(permOther);
!                                                       if(permThis != null)
!                                                       {
!                                                               
pset.SetPermission(permThis);
!                                                       }
!                                               }
!                                               else
!                                               {
!                                                       
pset.AddPermission(permOther);
!                                               }
!                                       }
!                               }
!                               return pset;
                        }
  
***************
*** 245,248 ****
--- 393,464 ----
                        }
  
+       // Determine if this permission set is unrestricted.
+ #if ECMA_COMPAT
+       internal
+ #else
+       public
+ #endif
+       virtual bool IsUnrestricted()
+                       {
+                               return (state == PermissionState.Unrestricted);
+                       }
+ 
+       // Get a permission object of a specific type from this set.
+ #if ECMA_COMPAT
+       internal
+ #else
+       public
+ #endif
+       virtual IPermission GetPermission(Type permClass)
+                       {
+                               if(permClass != null)
+                               {
+                                       int index = FindPermission(permClass);
+                                       if(index != -1)
+                                       {
+                                               return 
(IPermission)(permissions[index]);
+                                       }
+                               }
+                               return null;
+                       }
+ 
+       // Determine if this permission set is empty.
+ #if ECMA_COMPAT
+       internal
+ #else
+       public
+ #endif
+       virtual bool IsEmpty()
+                       {
+                               return (permissions.Count == 0);
+                       }
+ 
+       // Set a permission into this permission set.
+ #if ECMA_COMPAT
+       internal
+ #else
+       public
+ #endif
+       virtual IPermission SetPermission(IPermission perm)
+                       {
+                               if(perm != null)
+                               {
+                                       int index = 
FindPermission(perm.GetType());
+                                       if(index != -1)
+                                       {
+                                               permissions[index] = perm;
+                                       }
+                                       else
+                                       {
+                                               permissions.Add(perm);
+                                       }
+                                       return perm;
+                               }
+                               else
+                               {
+                                       return null;
+                               }
+                       }
+ 
  #if !ECMA_COMPAT
  
***************
*** 261,268 ****
                        {
                                int posn;
-                               Type type = typeof(CodeAccessPermission);
                                for(posn = 0; posn < permissions.Count; ++posn)
                                {
!                                       
if(!type.IsAssignableFrom(permissions[posn].GetType()))
                                        {
                                                return true;
--- 477,483 ----
                        {
                                int posn;
                                for(posn = 0; posn < permissions.Count; ++posn)
                                {
!                                       if(!(permissions[posn] is 
CodeAccessPermission))
                                        {
                                                return true;
***************
*** 272,307 ****
                        }
  
!       // Get a permission object of a specific type from this set.
!       public virtual IPermission GetPermission(Type permClass)
                        {
!                               if(permClass != null)
                                {
!                                       int index = FindPermission(permClass);
!                                       if(index != -1)
                                        {
!                                               return 
(IPermission)(permissions[index]);
                                        }
                                }
!                               return null;
!                       }
! 
!       // Form the intersection of this permission set and another.
!       [TODO]
!       public virtual PermissionSet Intersect(PermissionSet other)
!                       {
!                               // TODO
!                               return null;
!                       }
! 
!       // Determine if this permission set is empty.
!       public virtual bool IsEmpty()
!                       {
!                               return (permissions.Count == 0);
!                       }
! 
!       // Determine if this permission set is unrestricted.
!       public virtual bool IsUnrestricted()
!                       {
!                               return (state == PermissionState.Unrestricted);
                        }
  
--- 487,531 ----
                        }
  
!       // Form the intersection of this permission set and another.
!       public virtual PermissionSet Intersect(PermissionSet other)
                        {
!                               PermissionSet pset;
!                               if(other == null)
                                {
!                                       pset = new 
PermissionSet(PermissionState.None);
!                               }
!                               else if(!IsUnrestricted() || 
!other.IsUnrestricted())
!                               {
!                                       pset = new 
PermissionSet(PermissionState.None);
!                               }
!                               else
!                               {
!                                       pset = new 
PermissionSet(PermissionState.Unrestricted);
!                               }
!                               if(other == null || other.IsEmpty() || 
IsEmpty())
!                               {
!                                       return pset;
!                               }
!                               IEnumerator e = other.GetEnumerator();
!                               IPermission permOther, permThis;
!                               int index;
!                               while(e.MoveNext())
!                               {
!                                       permOther = (e.Current as IPermission);
!                                       if(permOther != null)
                                        {
!                                               index = 
FindPermission(permOther.GetType());
!                                               if(index != -1)
!                                               {
!                                                       permThis = 
(IPermission)(permissions[index]);
!                                                       permThis = 
permThis.Intersect(permOther);
!                                                       if(permThis != null)
!                                                       {
!                                                               
pset.AddPermission(permThis);
!                                                       }
!                                               }
                                        }
                                }
!                               return pset;
                        }
  
***************
*** 320,345 ****
                                }
                                return null;
-                       }
- 
-       // Set a permission into this permission set.
-       public virtual IPermission SetPermission(IPermission perm)
-                       {
-                               if(perm != null)
-                               {
-                                       int index = 
FindPermission(perm.GetType());
-                                       if(index != -1)
-                                       {
-                                               permissions[index] = perm;
-                                       }
-                                       else
-                                       {
-                                               permissions.Add(perm);
-                                       }
-                                       return perm;
-                               }
-                               else
-                               {
-                                       return null;
-                               }
                        }
  
--- 544,547 ----

Index: SecurityElement.cs
===================================================================
RCS file: 
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Security/SecurityElement.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** SecurityElement.cs  11 Jul 2002 02:39:15 -0000      1.2
--- SecurityElement.cs  30 Mar 2003 11:58:44 -0000      1.3
***************
*** 571,574 ****
--- 571,575 ----
  
        // Parse an XML string into a tree of "SecurityElement" values.
+       [TODO]
        internal static SecurityElement Parse(String xmlString)
                        {

Index: SuppressUnmanagedCodeSecurityAttribute.cs
===================================================================
RCS file: 
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Security/SuppressUnmanagedCodeSecurityAttribute.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** SuppressUnmanagedCodeSecurityAttribute.cs   26 Jan 2003 20:23:12 -0000      
1.1
--- SuppressUnmanagedCodeSecurityAttribute.cs   30 Mar 2003 11:58:44 -0000      
1.2
***************
*** 3,9 ****
   *                    
"System.Security.SuppressUnmanagedCodeSecurityAttribute" class.
   *
!  * Copyright (C) 2002  Southern Storm Software, Pty Ltd.
   * 
!  * contributed by Gopal.V 
   *
   * This program is free software; you can redistribute it and/or modify
--- 3,9 ----
   *                    
"System.Security.SuppressUnmanagedCodeSecurityAttribute" class.
   *
!  * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
   * 
!  * contributions from Gopal.V 
   *
   * This program is free software; you can redistribute it and/or modify
***************
*** 22,37 ****
   */
  
- using System;
- 
  namespace System.Security
  {
  #if !ECMA_COMPAT
!       public sealed class SuppressUnmanagedCodeSecurityAttribute: Attribute
!       {
!               public SuppressUnmanagedCodeSecurityAttribute()
!               {
!                       /* nothing to do here */
!               }
!       }
  #endif
! }//namespace
--- 22,48 ----
   */
  
  namespace System.Security
  {
+ 
+ using System;
+ 
  #if !ECMA_COMPAT
! 
! [AttributeUsage(AttributeTargets.Method |
!                               AttributeTargets.Class |
!                               AttributeTargets.Interface,
!                               AllowMultiple=true, Inherited=false)]
! public sealed class SuppressUnmanagedCodeSecurityAttribute: Attribute
! {
! 
!       // Constructor.
!       public SuppressUnmanagedCodeSecurityAttribute()
!                       {
!                               // Nothing to do here.
!                       }
! 
! }; // class SuppressUnmanagedCodeSecurityAttribute
! 
  #endif
! 
! }; // namespace System.Security

Index: UnverifiableCodeAttribute.cs
===================================================================
RCS file: 
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Security/UnverifiableCodeAttribute.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** UnverifiableCodeAttribute.cs        20 Dec 2001 10:11:39 -0000      1.2
--- UnverifiableCodeAttribute.cs        30 Mar 2003 11:58:44 -0000      1.3
***************
*** 3,7 ****
   *                    "System.Security.UnverifiableCodeAttribute" class.
   *
!  * Copyright (C) 2001  Southern Storm Software, Pty Ltd.
   *
   * This program is free software; you can redistribute it and/or modify
--- 3,7 ----
   *                    "System.Security.UnverifiableCodeAttribute" class.
   *
!  * Copyright (C) 2001, 2003  Southern Storm Software, Pty Ltd.
   *
   * This program is free software; you can redistribute it and/or modify
***************
*** 23,31 ****
  {
  
! [TODO]
! public class UnverifiableCodeAttribute
  {
! 
! // TODO
  
  }; // class UnverifiableCodeAttribute
--- 23,34 ----
  {
  
! [AttributeUsage(AttributeTargets.Module, AllowMultiple=true, Inherited=false)]
! public sealed class UnverifiableCodeAttribute : Attribute
  {
!       // Constructor.
!       public UnverifiableCodeAttribute()
!                       {
!                               // Nothing to do here.
!                       }
  
  }; // class UnverifiableCodeAttribute





reply via email to

[Prev in Thread] Current Thread [Next in Thread]