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/Permissions P


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Security/Permissions PublisherIdentityPermission.cs,NONE,1.1 PublisherIdentityPermissionAttribute.cs,NONE,1.1 RegistryPermission.cs,NONE,1.1 RegistryPermissionAccess.cs,NONE,1.1 RegistryPermissionAttribute.cs,NONE,1.1 StrongNameIdentityPermission.cs,NONE,1.1 StrongNameIdentityPermissionAttribute.cs,NONE,1.1 StrongNamePublicKeyBlob.cs,NONE,1.1 UIPermission.cs,NONE,1.1 UIPermissionAttribute.cs,NONE,1.1 UIPermissionClipboard.cs,NONE,1.1 UIPermissionWindow.cs,NONE,1.1 FileIOPermission.cs,1.1,1.2 PermissionSetAttribute.cs,1.1,1.2 PrincipalPermission.cs,1.1,1.2
Date: Mon, 31 Mar 2003 21:16:33 -0500

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

Modified Files:
        FileIOPermission.cs PermissionSetAttribute.cs 
        PrincipalPermission.cs 
Added Files:
        PublisherIdentityPermission.cs 
        PublisherIdentityPermissionAttribute.cs RegistryPermission.cs 
        RegistryPermissionAccess.cs RegistryPermissionAttribute.cs 
        StrongNameIdentityPermission.cs 
        StrongNameIdentityPermissionAttribute.cs 
        StrongNamePublicKeyBlob.cs UIPermission.cs 
        UIPermissionAttribute.cs UIPermissionClipboard.cs 
        UIPermissionWindow.cs 
Log Message:


Implement the remainder of the non-ECMA permission classes.


--- NEW FILE ---
/*
 * PublisherIdentityPermission.cs - Implementation of the
 *              "System.Security.Permissions.PublisherIdentityPermission" 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.Permissions
{

#if !ECMA_COMPAT

using System;
using System.Security;
using System.Security.Cryptography.X509Certificates;

public sealed class PublisherIdentityPermission : CodeAccessPermission
{
        // Internal state.
        private X509Certificate certificate;

        // Constructor.
        public PublisherIdentityPermission(PermissionState state)
                        {
                                if(state != PermissionState.None)
                                {
                                        throw new 
ArgumentException(_("Arg_PermissionState"));
                                }
                                certificate = null;
                        }
        public PublisherIdentityPermission(X509Certificate certificate)
                        {
                                if(certificate == null)
                                {
                                        throw new 
ArgumentNullException("certificate");
                                }
                                this.certificate = certificate;
                        }

        // Convert an XML value into a permissions value.
        public override void FromXml(SecurityElement esd)
                        {
                                if(esd == null)
                                {
                                        throw new ArgumentNullException("esd");
                                }
                                if(esd.Attribute("version") != "1")
                                {
                                        throw new 
ArgumentException(_("Arg_PermissionVersion"));
                                }
                                String value = 
esd.Attribute("X509v3Certificate");
                                if(value != null)
                                {
                                        certificate = new X509Certificate
                                                
(StrongNamePublicKeyBlob.FromHex(value));
                                }
                                else
                                {
                                        certificate = null;
                                }
                        }

        // Convert this permissions object into an XML value.
        public override SecurityElement ToXml()
                        {
                                SecurityElement element;
                                element = new SecurityElement("IPermission");
                                element.AddAttribute
                                        ("class",
                                         SecurityElement.Escape
                                                
(typeof(PublisherIdentityPermission).
                                                                
AssemblyQualifiedName));
                                element.AddAttribute("version", "1");
                                if(certificate != null)
                                {
                                        element.AddAttribute
                                                ("X509v3Certificate",
                                                 
certificate.GetRawCertDataString());
                                }
                                return element;
                        }

        // Implement the IPermission interface.
        public override IPermission Copy()
                        {
                                if(certificate == null)
                                {
                                        return new PublisherIdentityPermission
                                                (PermissionState.None);
                                }
                                else
                                {
                                        return new 
PublisherIdentityPermission(certificate);
                                }
                        }
        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;
                                }
                        }
        public override bool IsSubsetOf(IPermission target)
                        {
                                if(target == null)
                                {
                                        return (certificate == null);
                                }
                                else if(!(target is 
PublisherIdentityPermission))
                                {
                                        throw new 
ArgumentException(_("Arg_PermissionMismatch"));
                                }
                                else if(certificate != null &&
                                                !certificate.Equals
                                                        
(((PublisherIdentityPermission)target).certificate))
                                {
                                        return false;
                                }
                                else
                                {
                                        return true;
                                }
                        }
        public override IPermission Union(IPermission target)
                        {
                                if(target == null)
                                {
                                        return Copy();
                                }
                                else if(!(target is 
PublisherIdentityPermission))
                                {
                                        throw new 
ArgumentException(_("Arg_PermissionMismatch"));
                                }
                                else if(IsSubsetOf(target))
                                {
                                        return target.Copy();
                                }
                                else if(target.IsSubsetOf(this))
                                {
                                        return Copy();
                                }
                                else
                                {
                                        return null;
                                }
                        }

        // Get or set the certificate.
        public X509Certificate Certificate
                        {
                                get
                                {
                                        return certificate;
                                }
                                set
                                {
                                        if(value == null)
                                        {
                                                throw new 
ArgumentNullException("value");
                                        }
                                        certificate = value;
                                }
                        }

}; // class PublisherIdentityPermission

#endif // !ECMA_COMPAT

}; // namespace System.Security.Permissions

--- NEW FILE ---
/*
 * PublisherIdentityPermissionAttribute.cs - Implementation of the
 *  "System.Security.Permissions.PublisherIdentityPermissionAttribute" 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.Permissions
{

#if !ECMA_COMPAT

using System;
using System.Security;
using System.Security.Cryptography.X509Certificates;

[AttributeUsage(AttributeTargets.Assembly |
                                AttributeTargets.Class |
                                AttributeTargets.Struct |
                                AttributeTargets.Constructor |
                                AttributeTargets.Method,
                                AllowMultiple=true, Inherited=false)]
public sealed class PublisherIdentityPermissionAttribute
        : CodeAccessSecurityAttribute
{
        // Internal state.
        private String certFile;
        private String signedFile;
        private String cert;

        // Constructors.
        public PublisherIdentityPermissionAttribute(SecurityAction action)
                        : base(action)
                        {
                                // Nothing to do here.
                        }

        // Get or set the certificate file value.
        public String CertFile
                        {
                                get
                                {
                                        return certFile;
                                }
                                set
                                {
                                        certFile = value;
                                }
                        }

        // Get or set the signed certificate file value.
        public String SignedFile
                        {
                                get
                                {
                                        return signedFile;
                                }
                                set
                                {
                                        signedFile = value;
                                }
                        }

        // Get or set the X509 certificate value.
        public String X509Certificate
                        {
                                get
                                {
                                        return cert;
                                }
                                set
                                {
                                        cert = value;
                                }
                        }

        // Create a permission object that corresponds to this attribute.
        public override IPermission CreatePermission()
                        {
                                X509Certificate certificate;
                                if(Unrestricted)
                                {
                                        throw new 
ArgumentException(_("Arg_PermissionState"));
                                }
                                else if(certFile == null && signedFile == null 
&& cert == null)
                                {
                                        return new PublisherIdentityPermission
                                                (PermissionState.None);
                                }
                                else if(cert != null)
                                {
                                        certificate = new X509Certificate
                                                
(StrongNamePublicKeyBlob.FromHex(cert));
                                }
                                else if(certFile != null)
                                {
                                        certificate = 
X509Certificate.CreateFromCertFile(certFile);
                                }
                                else
                                {
                                        certificate = 
X509Certificate.CreateFromSignedFile
                                                (signedFile);
                                }
                                return new 
PublisherIdentityPermission(certificate);
                        }

}; // class PublisherIdentityPermissionAttribute

#endif // !ECMA_COMPAT

}; // namespace System.Security.Permissions

--- NEW FILE ---
/*
 * RegistryPermission.cs - Implementation of the
 *              "System.Security.Permissions.RegistryPermission" 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.Permissions
{

#if !ECMA_COMPAT

using System;
using System.IO;
using System.Collections;
using System.Security;

public sealed class RegistryPermission
        : CodeAccessPermission, IUnrestrictedPermission
{
        // Internal state.
        private PermissionState state;
        private String[] readList;
        private String[] writeList;
        private String[] createList;

        // Constructors.
        public RegistryPermission(PermissionState state)
                        {
                                if(state != PermissionState.Unrestricted &&
                                   state != PermissionState.None)
                                {
                                        throw new 
ArgumentException(_("Arg_PermissionState"));
                                }
                                this.state = state;
                        }
        public RegistryPermission(RegistryPermissionAccess flag, String 
pathList)
                        {
                                if(pathList == null)
                                {
                                        throw new 
ArgumentNullException("pathList");
                                }
                                if((flag & 
~(RegistryPermissionAccess.AllAccess)) != 0)
                                {
                                        throw new 
ArgumentException(_("Arg_RegistryAccess"));
                                }
                                this.state = PermissionState.None;
                                String[] split = 
EnvironmentPermission.SplitPath(pathList);
                                if((flag & RegistryPermissionAccess.Read) != 0)
                                {
                                        readList = split;
                                }
                                if((flag & RegistryPermissionAccess.Write) != 0)
                                {
                                        writeList = split;
                                }
                                if((flag & RegistryPermissionAccess.Create) != 
0)
                                {
                                        createList = split;
                                }
                        }
        internal RegistryPermission(PermissionState state, String[] readList,
                                                            String[] writeList, 
String[] createList)
                        {
                                this.state = state;
                                this.readList = readList;
                                this.writeList = writeList;
                                this.createList = createList;
                        }

        // Convert an XML value into a permissions value.
        public override void FromXml(SecurityElement esd)
                        {
                                String value;
                                if(esd == null)
                                {
                                        throw new ArgumentNullException("esd");
                                }
                                if(esd.Attribute("version") != "1")
                                {
                                        throw new 
ArgumentException(_("Arg_PermissionVersion"));
                                }
                                value = esd.Attribute("Unrestricted");
                                if(value != null && Boolean.Parse(value))
                                {
                                        state = PermissionState.Unrestricted;
                                }
                                else
                                {
                                        state = PermissionState.None;
                                }
                                if(state != PermissionState.Unrestricted)
                                {
                                        readList = 
EnvironmentPermission.SplitPath
                                                (esd.Attribute("Read"), ';');
                                        writeList = 
EnvironmentPermission.SplitPath
                                                (esd.Attribute("Write"), ';');
                                        createList = 
EnvironmentPermission.SplitPath
                                                (esd.Attribute("Create"), ';');
                                }
                        }

        // Convert this permissions object into an XML value.
        public override SecurityElement ToXml()
                        {
                                SecurityElement element;
                                element = new SecurityElement("IPermission");
                                element.AddAttribute
                                        ("class",
                                         
SecurityElement.Escape(typeof(RegistryPermission).
                                                                                
        AssemblyQualifiedName));
                                element.AddAttribute("version", "1");
                                if(state == PermissionState.Unrestricted)
                                {
                                        element.AddAttribute("Unrestricted", 
"true");
                                }
                                else
                                {
                                        // Always use ";" as the separator so 
that we can
                                        // guarantee a fixed external form, 
regardless of
                                        // whatever PathSeparator is set to.
                                        if(readList != null)
                                        {
                                                element.AddAttribute
                                                        ("Read", 
String.Join(";", readList));
                                        }
                                        if(writeList != null)
                                        {
                                                element.AddAttribute
                                                        ("Write", 
String.Join(";", writeList));
                                        }
                                        if(createList != null)
                                        {
                                                element.AddAttribute
                                                        ("Create", 
String.Join(";", createList));
                                        }
                                }
                                return element;
                        }

        // Implement the IPermission interface.
        public override IPermission Copy()
                        {
                                return new RegistryPermission
                                        (state, readList, writeList, 
createList);
                        }
        public override IPermission Intersect(IPermission target)
                        {
                                // Handle the easy cases first.
                                if(target == null)
                                {
                                        return target;
                                }
                                else if(!(target is RegistryPermission))
                                {
                                        throw new 
ArgumentException(_("Arg_PermissionMismatch"));
                                }
                                else 
if(((RegistryPermission)target).IsUnrestricted())
                                {
                                        return Copy();
                                }
                                else if(IsUnrestricted())
                                {
                                        return target.Copy();
                                }

                                // Create a new object and intersect the lists.
                                return new RegistryPermission
                                        (PermissionState.None,
                                         
EnvironmentPermission.Intersect(readList,
                                                           
((RegistryPermission)target).readList),
                                         
EnvironmentPermission.Intersect(writeList,
                                                           
((RegistryPermission)target).writeList),
                                         
EnvironmentPermission.Intersect(createList,
                                                           
((RegistryPermission)target).createList));
                        }
        public override bool IsSubsetOf(IPermission target)
                        {
                                if(target == null)
                                {
                                        return (state == PermissionState.None &&
                                                        readList == null && 
writeList == null &&
                                                        createList == null);
                                }
                                else if(!(target is RegistryPermission))
                                {
                                        throw new 
ArgumentException(_("Arg_PermissionMismatch"));
                                }
                                else 
if(((RegistryPermission)target).IsUnrestricted())
                                {
                                        return true;
                                }
                                else if(IsUnrestricted())
                                {
                                        return false;
                                }
                                else
                                {
                                        return EnvironmentPermission.IsSubsetOf
                                                (readList, 
((RegistryPermission)target).readList) &&
                                                        
EnvironmentPermission.IsSubsetOf
                                                (writeList, 
((RegistryPermission)target).writeList) &&
                                                        
EnvironmentPermission.IsSubsetOf
                                                (createList, 
((RegistryPermission)target).createList);
                                }
                        }
        public override IPermission Union(IPermission target)
                        {
                                if(target == null)
                                {
                                        return Copy();
                                }
                                else if(!(target is RegistryPermission))
                                {
                                        throw new 
ArgumentException(_("Arg_PermissionMismatch"));
                                }
                                else if(IsUnrestricted() ||
                                        
((RegistryPermission)target).IsUnrestricted())
                                {
                                        return new RegistryPermission
                                                (PermissionState.Unrestricted);
                                }
                                else
                                {
                                        return new RegistryPermission
                                                (PermissionState.None,
                                                 
EnvironmentPermission.Union(readList,
                                                           
((RegistryPermission)target).readList, false),
                                                 
EnvironmentPermission.Union(writeList,
                                                           
((RegistryPermission)target).writeList, false),
                                                 
EnvironmentPermission.Union(createList,
                                                           
((RegistryPermission)target).createList, false));
                                }
                        }

        // Determine if this object has unrestricted permissions.
        public bool IsUnrestricted()
                        {
                                return (state == PermissionState.Unrestricted);
                        }

        // Set the path list information.
        public void SetPathList(RegistryPermissionAccess flag, String pathList)
                        {
                                if(pathList == null)
                                {
                                        throw new 
ArgumentNullException("pathList");
                                }
                                if((flag & 
~(RegistryPermissionAccess.AllAccess)) != 0)
                                {
                                        throw new 
ArgumentException(_("Arg_RegistryAccess"));
                                }
                                if((flag & RegistryPermissionAccess.Read) != 0)
                                {
                                        readList = 
EnvironmentPermission.SplitPath
                                                (pathList, Path.PathSeparator);
                                }
                                if((flag & RegistryPermissionAccess.Write) != 0)
                                {
                                        writeList = 
EnvironmentPermission.SplitPath
                                                (pathList, Path.PathSeparator);
                                }
                                if((flag & RegistryPermissionAccess.Create) != 
0)
                                {
                                        createList = 
EnvironmentPermission.SplitPath
                                                (pathList, Path.PathSeparator);
                                }
                        }

        // Add to the path list information.
        public void AddPathList(RegistryPermissionAccess flag, String pathList)
                        {
                                if(pathList == null)
                                {
                                        throw new 
ArgumentNullException("pathList");
                                }
                                if((flag & 
~(RegistryPermissionAccess.AllAccess)) != 0)
                                {
                                        throw new 
ArgumentException(_("Arg_RegistryAccess"));
                                }
                                if((flag & RegistryPermissionAccess.Read) != 0)
                                {
                                        readList = 
EnvironmentPermission.Union(readList,
                                                EnvironmentPermission.SplitPath
                                                        (pathList, 
Path.PathSeparator), false);
                                }
                                if((flag & RegistryPermissionAccess.Write) != 0)
                                {
                                        writeList = 
EnvironmentPermission.Union(writeList,
                                                EnvironmentPermission.SplitPath
                                                        (pathList, 
Path.PathSeparator), false);
                                }
                                if((flag & RegistryPermissionAccess.Create) != 
0)
                                {
                                        createList = 
EnvironmentPermission.Union(createList,
                                                EnvironmentPermission.SplitPath
                                                        (pathList, 
Path.PathSeparator), false);
                                }
                        }

        // Get a specific path list.
        public String GetPathList(RegistryPermissionAccess flag)
                        {
                                switch(flag)
                                {
                                        case RegistryPermissionAccess.Read:
                                        {
                                                if(readList != null)
                                                {
                                                        return String.Join
                                                                
(Path.PathSeparator.ToString(), readList);
                                                }
                                                else
                                                {
                                                        return String.Empty;
                                                }
                                        }
                                        // Not reached.

                                        case RegistryPermissionAccess.Write:
                                        {
                                                if(writeList != null)
                                                {
                                                        return String.Join
                                                                
(Path.PathSeparator.ToString(), writeList);
                                                }
                                                else
                                                {
                                                        return String.Empty;
                                                }
                                        }
                                        // Not reached.

                                        case RegistryPermissionAccess.Create:
                                        {
                                                if(createList != null)
                                                {
                                                        return String.Join
                                                                
(Path.PathSeparator.ToString(), createList);
                                                }
                                                else
                                                {
                                                        return String.Empty;
                                                }
                                        }
                                        // Not reached.

                                        default:
                                        {
                                                throw new 
ArgumentException(_("Arg_RegistryAccess"));
                                        }
                                        // Not reached.
                                }
                        }

}; // class RegistryPermission

#endif // !ECMA_COMPAT

}; // namespace System.Security.Permissions

--- NEW FILE ---
/*
 * RegistryPermissionAccess.cs - Implementation of the
 *                      "System.Security.Permissions.RegistryPermissionAccess" 
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.Permissions
{

#if !ECMA_COMPAT

[Flags]
public enum RegistryPermissionAccess
{

        NoAccess  = 0x0000,
        Read      = 0x0001,
        Write     = 0x0002,
        Create    = 0x0004,
        AllAccess = 0x0007

}; // enum RegistryPermissionAccess

#endif // !ECMA_COMPAT

}; // namespace System.Security.Permissions

--- NEW FILE ---
/*
 * RegistryPermissionAttribute.cs - Implementation of the
 *                      
"System.Security.Permissions.RegistryPermissionAttribute" 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.Permissions
{

#if !ECMA_COMPAT

using System;
using System.Security;

[AttributeUsage(AttributeTargets.Assembly |
                                AttributeTargets.Class |
                                AttributeTargets.Struct |
                                AttributeTargets.Constructor |
                                AttributeTargets.Method,
                                AllowMultiple=true, Inherited=false)]
public sealed class RegistryPermissionAttribute : CodeAccessSecurityAttribute
{
        // Internal state.
        private String read;
        private String write;
        private String create;

        // Constructors.
        public RegistryPermissionAttribute(SecurityAction action)
                        : base(action)
                        {
                                // Nothing to do here.
                        }

        // Get or set the read permission value.
        public String Read
                        {
                                get
                                {
                                        return read;
                                }
                                set
                                {
                                        read = value;
                                }
                        }

        // Get or set the write permission value.
        public String Write
                        {
                                get
                                {
                                        return write;
                                }
                                set
                                {
                                        write = value;
                                }
                        }

        // Get or set the create permission value.
        public String Create
                        {
                                get
                                {
                                        return create;
                                }
                                set
                                {
                                        create = value;
                                }
                        }

        // Set the read, write, and create permission values.
        public String All
                        {
                                set
                                {
                                        read = value;
                                        write = value;
                                        create = value;
                                }
                        }

        // Create a permission object that corresponds to this attribute.
        public override IPermission CreatePermission()
                        {
                                if(Unrestricted)
                                {
                                        return new RegistryPermission
                                                (PermissionState.Unrestricted);
                                }
                                else
                                {
                                        return new RegistryPermission
                                                (PermissionState.None,
                                                
EnvironmentPermission.SplitPath(read),
                                                
EnvironmentPermission.SplitPath(write),
                                                
EnvironmentPermission.SplitPath(create));
                                }
                        }

}; // class RegistryPermissionAttribute

#endif // !ECMA_COMPAT

}; // namespace System.Security.Permissions

--- NEW FILE ---
/*
 * StrongNameIdentityPermission.cs - Implementation of the
 *              "System.Security.Permissions.StrongNameIdentityPermission" 
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.Permissions
{

#if !ECMA_COMPAT

using System;
using System.Security;

public sealed class StrongNameIdentityPermission : CodeAccessPermission
{
        // Internal state.
        private StrongNamePublicKeyBlob blob;
        private String name;
        private Version version;

        // Constructor.
        public StrongNameIdentityPermission(PermissionState state)
                        {
                                if(state != PermissionState.None)
                                {
                                        throw new 
ArgumentException(_("Arg_PermissionState"));
                                }
                                blob = null;
                                name = "";
                                version = new Version();
                        }
        public StrongNameIdentityPermission(StrongNamePublicKeyBlob blob,
                                                                                
String name, Version version)
                        {
                                if(blob == null)
                                {
                                        throw new ArgumentNullException("blob");
                                }
                                this.blob = blob;
                                this.name = name;
                                this.version = version;
                        }

        // Convert an XML value into a permissions value.
        public override void FromXml(SecurityElement esd)
                        {
                                if(esd == null)
                                {
                                        throw new ArgumentNullException("esd");
                                }
                                if(esd.Attribute("version") != "1")
                                {
                                        throw new 
ArgumentException(_("Arg_PermissionVersion"));
                                }
                                name = esd.Attribute("Name");
                                String value = esd.Attribute("Version");
                                if(value != null)
                                {
                                        version = new Version(value);
                                }
                                else
                                {
                                        version = null;
                                }
                                value = esd.Attribute("PublicKeyBlob");
                                if(value != null)
                                {
                                        blob = new 
StrongNamePublicKeyBlob(value);
                                }
                                else
                                {
                                        blob = null;
                                }
                        }

        // Convert this permissions object into an XML value.
        public override SecurityElement ToXml()
                        {
                                SecurityElement element;
                                element = new SecurityElement("IPermission");
                                element.AddAttribute
                                        ("class",
                                         SecurityElement.Escape
                                                
(typeof(StrongNameIdentityPermission).
                                                                
AssemblyQualifiedName));
                                element.AddAttribute("version", "1");
                                if(blob != null)
                                {
                                        element.AddAttribute("PublicKeyBlob", 
blob.ToString());
                                }
                                if(name != null)
                                {
                                        element.AddAttribute("Name", name);
                                }
                                if(version != null)
                                {
                                        element.AddAttribute("Version", 
version.ToString());
                                }
                                return element;
                        }

        // Implement the IPermission interface.
        public override IPermission Copy()
                        {
                                if(blob == null)
                                {
                                        return new StrongNameIdentityPermission
                                                (PermissionState.None);
                                }
                                else
                                {
                                        return new StrongNameIdentityPermission
                                                (blob, name, version);
                                }
                        }
        public override IPermission Intersect(IPermission target)
                        {
                                if(target == null)
                                {
                                        return target;
                                }
                                else if(!(target is 
StrongNameIdentityPermission))
                                {
                                        throw new 
ArgumentException(_("Arg_PermissionMismatch"));
                                }
                                else if(IsSubsetOf(target))
                                {
                                        return Copy();
                                }
                                else if(target.IsSubsetOf(this))
                                {
                                        return target.Copy();
                                }
                                else
                                {
                                        return null;
                                }
                        }
        public override bool IsSubsetOf(IPermission target)
                        {
                                // Handle the easy cases first.
                                if(target == null)
                                {
                                        return (blob == null);
                                }
                                else if(!(target is 
StrongNameIdentityPermission))
                                {
                                        throw new 
ArgumentException(_("Arg_PermissionMismatch"));
                                }

                                // Check blob subset conditions.
                                StrongNameIdentityPermission t;
                                t = ((StrongNameIdentityPermission)target);
                                if(blob != null && !blob.Equals(t.blob))
                                {
                                        return false;
                                }

                                // Check name subset conditions.
                                if(name != null && name != t.name)
                                {
                                        return false;
                                }

                                // Check version subset conditions.
                                if(version != null && version != t.version)
                                {
                                        return false;
                                }

                                // It is a subset.
                                return true;
                        }
        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;
                                }
                        }

        // Get or set the public key blob value.
        public StrongNamePublicKeyBlob PublicKey
                        {
                                get
                                {
                                        return blob;
                                }
                                set
                                {
                                        if(value == null)
                                        {
                                                throw new 
ArgumentNullException("value");
                                        }
                                        blob = value;
                                }
                        }

        // Get or set the name.
        public String Name
                        {
                                get
                                {
                                        return name;
                                }
                                set
                                {
                                        name = value;
                                }
                        }

        // Get or set the version.
        public Version Version
                        {
                                get
                                {
                                        return version;
                                }
                                set
                                {
                                        version = value;
                                }
                        }

}; // class StrongNameIdentityPermission

#endif // !ECMA_COMPAT

}; // namespace System.Security.Permissions

--- NEW FILE ---
/*
 * StrongNameIdentityPermissionAttribute.cs - Implementation of the
 *  "System.Security.Permissions.StrongNameIdentityPermissionAttribute" 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.Permissions
{

#if !ECMA_COMPAT

using System;
using System.Security;

[AttributeUsage(AttributeTargets.Assembly |
                                AttributeTargets.Class |
                                AttributeTargets.Struct |
                                AttributeTargets.Constructor |
                                AttributeTargets.Method,
                                AllowMultiple=true, Inherited=false)]
public sealed class StrongNameIdentityPermissionAttribute
        : CodeAccessSecurityAttribute
{
        // Internal state.
        private String blob;
        private String name;
        private String version;

        // Constructors.
        public StrongNameIdentityPermissionAttribute(SecurityAction action)
                        : base(action)
                        {
                                // Nothing to do here.
                        }

        // Get or set the blob value.
        public String PublicKey
                        {
                                get
                                {
                                        return blob;
                                }
                                set
                                {
                                        blob = value;
                                }
                        }

        // Get or set the name value.
        public String Name
                        {
                                get
                                {
                                        return name;
                                }
                                set
                                {
                                        name = value;
                                }
                        }

        // Get or set the version value.
        public String Version
                        {
                                get
                                {
                                        return version;
                                }
                                set
                                {
                                        version = value;
                                }
                        }

        // Create a permission object that corresponds to this attribute.
        public override IPermission CreatePermission()
                        {
                                if(Unrestricted)
                                {
                                        throw new 
ArgumentException(_("Arg_PermissionState"));
                                }
                                else if(blob == null && name == null && version 
== null)
                                {
                                        return new StrongNameIdentityPermission
                                                (PermissionState.None);
                                }
                                else if(blob == null)
                                {
                                        throw new 
ArgumentException(_("Arg_PublicKeyBlob"));
                                }
                                else
                                {
                                        StrongNamePublicKeyBlob key;
                                        Version vers;
                                        key = new StrongNamePublicKeyBlob(blob);
                                        if(version != null && version != 
String.Empty)
                                        {
                                                vers = new Version(version);
                                        }
                                        else
                                        {
                                                vers = null;
                                        }
                                        return new 
StrongNameIdentityPermission(key, name, vers);
                                }
                        }

}; // class StrongNameIdentityPermissionAttribute

#endif // !ECMA_COMPAT

}; // namespace System.Security.Permissions

--- NEW FILE ---
/*
 * StrongNamePublicKeyBlob.cs - Implementation of the
 *              "System.Security.Permissions.StrongNamePublicKeyBlob" 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.Permissions
{

#if !ECMA_COMPAT

using System;
using System.Text;
using System.Security;

public sealed class StrongNamePublicKeyBlob
{

        // Internal state.
        private byte[] blob;

        // Constructor.
        public StrongNamePublicKeyBlob(byte[] publicKey)
                        {
                                if(publicKey == null)
                                {
                                        throw new 
ArgumentNullException("publicKey");
                                }
                                else if(publicKey.Length == 0)
                                {
                                        throw new 
ArgumentException(_("Arg_PublicKeyBlob"));
                                }
                                else
                                {
                                        blob = (byte[])(publicKey.Clone());
                                }
                        }
        internal StrongNamePublicKeyBlob(String publicKey)
                        {
                                blob = FromHex(publicKey);
                        }

        // Convert a hex string into a byte buffer.
        internal static byte[] FromHex(String s)
                        {
                                byte[] blob;
                                if(s != null)
                                {
                                        blob = new byte [s.Length / 2];
                                        int posn;
                                        int value;
                                        char ch;
                                        for(posn = 0; posn < s.Length; posn += 
2)
                                        {
                                                ch = s[posn];
                                                if(ch >= '0' && ch <= '9')
                                                {
                                                        value = (ch - '0') << 4;
                                                }
                                                else if(ch >= 'A' && ch <= 'F')
                                                {
                                                        value = (ch - 'A' + 10) 
<< 4;
                                                }
                                                else if(ch >= 'a' && ch <= 'f')
                                                {
                                                        value = (ch - 'a' + 10) 
<< 4;
                                                }
                                                else
                                                {
                                                        throw new 
ArgumentException(_("Arg_PublicKeyBlob"));
                                                }
                                                ch = s[posn + 1];
                                                if(ch >= '0' && ch <= '9')
                                                {
                                                        value += (ch - '0');
                                                }
                                                else if(ch >= 'A' && ch <= 'F')
                                                {
                                                        value += (ch - 'A' + 
10);
                                                }
                                                else if(ch >= 'a' && ch <= 'f')
                                                {
                                                        value += (ch - 'a' + 
10);
                                                }
                                                else
                                                {
                                                        throw new 
ArgumentException(_("Arg_PublicKeyBlob"));
                                                }
                                                blob[posn / 2] = (byte)value;
                                        }
                                }
                                else
                                {
                                        blob = new byte [0];
                                }
                                return blob;
                        }

        // Determine if two objects are equal.
        public override bool Equals(Object obj)
                        {
                                StrongNamePublicKeyBlob key = (obj as 
StrongNamePublicKeyBlob);
                                if(key != null && blob.Length == 
key.blob.Length)
                                {
                                        int posn;
                                        for(posn = 0; posn < blob.Length; 
++posn)
                                        {
                                                if(blob[posn] != key.blob[posn])
                                                {
                                                        return false;
                                                }
                                        }
                                        return true;
                                }
                                else
                                {
                                        return false;
                                }
                        }

        // Get the hash code for this object.
        public override int GetHashCode()
                        {
                                int hash = 0;
                                int posn;
                                for(posn = 0; posn < blob.Length; ++posn)
                                {
                                        hash = (hash << 5) + hash + blob[posn];
                                }
                                return hash;
                        }

        // Convert this public key into a string.
        public override String ToString()
                        {
                                StringBuilder builder = new StringBuilder();
                                int posn;
                                for(posn = 0; posn < blob.Length; ++posn)
                                {
                                        BitConverter.AppendHex(builder, 
blob[posn]);
                                }
                                return builder.ToString();
                        }

}; // class StrongNamePublicKeyBlob

#endif // !ECMA_COMPAT

}; // namespace System.Security.Permissions

--- NEW FILE ---
/*
 * UIPermission.cs - Implementation of the
 *              "System.Security.Permissions.UIPermission" 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.Permissions
{

#if !ECMA_COMPAT

using System;
using System.Security;

public sealed class UIPermission
        : CodeAccessPermission, IUnrestrictedPermission
{
        // Internal state.
        private UIPermissionWindow window;
        private UIPermissionClipboard clipboard;

        // Constructors.
        public UIPermission(PermissionState state)
                        {
                                if(state == PermissionState.None)
                                {
                                        window = UIPermissionWindow.NoWindows;
                                        clipboard = 
UIPermissionClipboard.NoClipboard;
                                }
                                else if(state == PermissionState.Unrestricted)
                                {
                                        window = UIPermissionWindow.AllWindows;
                                        clipboard = 
UIPermissionClipboard.AllClipboard;
                                }
                                else
                                {
                                        throw new 
ArgumentException(_("Arg_PermissionState"));
                                }
                        }
        public UIPermission(UIPermissionWindow windowFlag)
                        {
                                if(windowFlag < UIPermissionWindow.NoWindows ||
                                   windowFlag > UIPermissionWindow.AllWindows)
                                {
                                        throw new 
ArgumentException(_("Arg_WindowFlag"));
                                }
                                window = windowFlag;
                                clipboard = UIPermissionClipboard.NoClipboard;
                        }
        public UIPermission(UIPermissionClipboard clipboardFlag)
                        {
                                if(clipboardFlag < 
UIPermissionClipboard.NoClipboard ||
                                   clipboardFlag > 
UIPermissionClipboard.AllClipboard)
                                {
                                        throw new 
ArgumentException(_("Arg_ClipboardFlag"));
                                }
                                window = UIPermissionWindow.NoWindows;
                                clipboard = clipboardFlag;
                        }
        public UIPermission(UIPermissionWindow windowFlag,
                                            UIPermissionClipboard clipboardFlag)
                        {
                                if(windowFlag < UIPermissionWindow.NoWindows ||
                                   windowFlag > UIPermissionWindow.AllWindows)
                                {
                                        throw new 
ArgumentException(_("Arg_WindowFlag"));
                                }
                                if(clipboardFlag < 
UIPermissionClipboard.NoClipboard ||
                                   clipboardFlag > 
UIPermissionClipboard.AllClipboard)
                                {
                                        throw new 
ArgumentException(_("Arg_ClipboardFlag"));
                                }
                                window = windowFlag;
                                clipboard = clipboardFlag;
                        }

        // Convert an XML value into a permissions value.
        public override void FromXml(SecurityElement esd)
                        {
                                String value;
                                if(esd == null)
                                {
                                        throw new ArgumentNullException("esd");
                                }
                                if(esd.Attribute("version") != "1")
                                {
                                        throw new 
ArgumentException(_("Arg_PermissionVersion"));
                                }
                                value = esd.Attribute("Unrestricted");
                                if(value != null && Boolean.Parse(value))
                                {
                                        window = UIPermissionWindow.NoWindows;
                                        clipboard = 
UIPermissionClipboard.NoClipboard;
                                }
                                else
                                {
                                        value = esd.Attribute("Window");
                                        if(value != null)
                                        {
                                                window = (UIPermissionWindow)
                                                        
Enum.Parse(typeof(UIPermissionWindow), value);
                                        }
                                        else
                                        {
                                                window = 
UIPermissionWindow.NoWindows;
                                        }
                                        value = esd.Attribute("Clipboard");
                                        if(value != null)
                                        {
                                                clipboard = 
(UIPermissionClipboard)
                                                        
Enum.Parse(typeof(UIPermissionClipboard), value);
                                        }
                                        else
                                        {
                                                clipboard = 
UIPermissionClipboard.NoClipboard;
                                        }
                                }
                        }

        // Convert this permissions object into an XML value.
        public override SecurityElement ToXml()
                        {
                                SecurityElement element;
                                element = new SecurityElement("IPermission");
                                element.AddAttribute
                                        ("class",
                                         
SecurityElement.Escape(typeof(UIPermission).
                                                                                
        AssemblyQualifiedName));
                                element.AddAttribute("version", "1");
                                if(IsUnrestricted())
                                {
                                        element.AddAttribute("Unrestricted", 
"true");
                                }
                                else
                                {
                                        element.AddAttribute("Window", 
window.ToString());
                                        element.AddAttribute("Clipboard", 
clipboard.ToString());
                                }
                                return element;
                        }

        // Implement the IPermission interface.
        public override IPermission Copy()
                        {
                                return new UIPermission(window, clipboard);
                        }
        public override IPermission Intersect(IPermission target)
                        {
                                // Handle the easy cases first.
                                if(target == null)
                                {
                                        return target;
                                }
                                else if(!(target is UIPermission))
                                {
                                        throw new 
ArgumentException(_("Arg_PermissionMismatch"));
                                }
                                else if(((UIPermission)target)
                                                        .IsUnrestricted())
                                {
                                        return Copy();
                                }
                                else if(IsUnrestricted())
                                {
                                        return target.Copy();
                                }

                                // Get the minimum flag values.
                                UIPermissionWindow w = 
((UIPermission)target).window;
                                if(((int)w) > ((int)window))
                                {
                                        w = window;
                                }
                                UIPermissionClipboard c = 
((UIPermission)target).clipboard;
                                if(((int)c) > ((int)clipboard))
                                {
                                        c = clipboard;
                                }

                                // Create a new object for the intersection.
                                if(w == UIPermissionWindow.NoWindows &&
                                   c == UIPermissionClipboard.NoClipboard)
                                {
                                        return null;
                                }
                                else
                                {
                                        return new UIPermission(w, c);
                                }
                        }
        public override bool IsSubsetOf(IPermission target)
                        {
                                if(target == null)
                                {
                                        return (window == 
UIPermissionWindow.NoWindows &&
                                                        clipboard == 
UIPermissionClipboard.NoClipboard);
                                }
                                else if(!(target is UIPermission))
                                {
                                        throw new 
ArgumentException(_("Arg_PermissionMismatch"));
                                }
                                else if(((UIPermission)target)
                                                        .IsUnrestricted())
                                {
                                        return true;
                                }
                                else if(IsUnrestricted())
                                {
                                        return false;
                                }
                                else if(((int)window) >
                                                        
((int)(((UIPermission)target).window)))
                                {
                                        return false;
                                }
                                else if(((int)clipboard) >
                                                        
((int)(((UIPermission)target).clipboard)))
                                {
                                        return false;
                                }
                                else
                                {
                                        return true;
                                }
                        }
        public override IPermission Union(IPermission target)
                        {
                                // Handle the easy cases first.
                                if(target == null)
                                {
                                        return Copy();
                                }
                                else if(!(target is UIPermission))
                                {
                                        throw new 
ArgumentException(_("Arg_PermissionMismatch"));
                                }
                                else if(IsUnrestricted() ||
                                        ((UIPermission)target).IsUnrestricted())
                                {
                                        return new 
UIPermission(PermissionState.Unrestricted);
                                }

                                // Get the maximum flag values.
                                UIPermissionWindow w = 
((UIPermission)target).window;
                                if(((int)w) < ((int)window))
                                {
                                        w = window;
                                }
                                UIPermissionClipboard c = 
((UIPermission)target).clipboard;
                                if(((int)c) < ((int)clipboard))
                                {
                                        c = clipboard;
                                }

                                // Create a new object for the union.
                                if(w == UIPermissionWindow.NoWindows &&
                                   c == UIPermissionClipboard.NoClipboard)
                                {
                                        return null;
                                }
                                else
                                {
                                        return new UIPermission(w, c);
                                }
                        }

        // Determine if this object has unrestricted permissions.
        public bool IsUnrestricted()
                        {
                                return (window == UIPermissionWindow.AllWindows 
&&
                                                clipboard == 
UIPermissionClipboard.AllClipboard);
                        }

        // Get or set the window flag.
        public UIPermissionWindow Window
                        {
                                get
                                {
                                        return window;
                                }
                                set
                                {
                                        if(value < UIPermissionWindow.NoWindows 
||
                                           value > 
UIPermissionWindow.AllWindows)
                                        {
                                                throw new 
ArgumentException(_("Arg_WindowFlag"));
                                        }
                                        window = value;
                                }
                        }

        // Get or set the clipboard flag.
        public UIPermissionClipboard Clipboard
                        {
                                get
                                {
                                        return clipboard;
                                }
                                set
                                {
                                        if(value < 
UIPermissionClipboard.NoClipboard ||
                                           value > 
UIPermissionClipboard.AllClipboard)
                                        {
                                                throw new 
ArgumentException(_("Arg_ClipboardFlag"));
                                        }
                                        clipboard = value;
                                }
                        }

}; // class UIPermission

#endif // !ECMA_COMPAT

}; // namespace System.Security.Permissions

--- NEW FILE ---
/*
 * UIPermissionAttribute.cs - Implementation of the
 *                      "System.Security.Permissions.UIPermissionAttribute" 
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.Permissions
{

#if !ECMA_COMPAT

using System;
using System.Security;

[AttributeUsage(AttributeTargets.Assembly |
                                AttributeTargets.Class |
                                AttributeTargets.Struct |
                                AttributeTargets.Constructor |
                                AttributeTargets.Method,
                                AllowMultiple=true, Inherited=false)]
public sealed class UIPermissionAttribute : CodeAccessSecurityAttribute
{
        // Internal state.
        private UIPermissionWindow window;
        private UIPermissionClipboard clipboard;

        // Constructors.
        public UIPermissionAttribute(SecurityAction action)
                        : base(action)
                        {
                                // Nothing to do here.
                        }

        // Get or set the window flag.
        public UIPermissionWindow Window
                        {
                                get
                                {
                                        return window;
                                }
                                set
                                {
                                        window = value;
                                }
                        }

        // Get or set the clipboard flag.
        public UIPermissionClipboard Clipboard
                        {
                                get
                                {
                                        return clipboard;
                                }
                                set
                                {
                                        clipboard = value;
                                }
                        }

        // Create a permission object that corresponds to this attribute.
        public override IPermission CreatePermission()
                        {
                                if(Unrestricted)
                                {
                                        return new UIPermission
                                                (PermissionState.Unrestricted);
                                }
                                else
                                {
                                        return new UIPermission(window, 
clipboard);
                                }
                        }

}; // class UIPermissionAttribute

#endif // !ECMA_COMPAT

}; // namespace System.Security.Permissions

--- NEW FILE ---
/*
 * UIPermissionClipboard.cs - Implementation of the
 *                      "System.Security.Permissions.UIPermissionClipboard" 
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.Permissions
{

#if !ECMA_COMPAT

public enum UIPermissionClipboard
{

        NoClipboard  = 0,
        OwnClipboard = 1,
        AllClipboard = 2,

}; // enum UIPermissionClipboard

#endif // !ECMA_COMPAT

}; // namespace System.Security.Permissions

--- NEW FILE ---
/*
 * UIPermissionWindow.cs - Implementation of the
 *                      "System.Security.Permissions.UIPermissionWindow" 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.Permissions
{

#if !ECMA_COMPAT

public enum UIPermissionWindow
{

        NoWindows           = 0,
        SafeSubWindows      = 1,
        SafeTopLevelWindows = 2,
        AllWindows          = 3

}; // enum UIPermissionWindow

#endif // !ECMA_COMPAT

}; // namespace System.Security.Permissions

Index: FileIOPermission.cs
===================================================================
RCS file: 
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Security/Permissions/FileIOPermission.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** FileIOPermission.cs 31 Mar 2003 01:00:38 -0000      1.1
--- FileIOPermission.cs 1 Apr 2003 02:16:31 -0000       1.2
***************
*** 229,233 ****
                                {
                                        return (state == PermissionState.None &&
!                                                       readList == null && 
writeList == null);
                                }
                                else if(!(target is FileIOPermission))
--- 229,234 ----
                                {
                                        return (state == PermissionState.None &&
!                                                       readList == null && 
writeList == null &&
!                                                       appendList == null && 
discoveryList == null);
                                }
                                else if(!(target is FileIOPermission))

Index: PermissionSetAttribute.cs
===================================================================
RCS file: 
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Security/Permissions/PermissionSetAttribute.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** PermissionSetAttribute.cs   31 Mar 2003 02:25:05 -0000      1.1
--- PermissionSetAttribute.cs   1 Apr 2003 02:16:31 -0000       1.2
***************
*** 26,29 ****
--- 26,30 ----
  
  using System;
+ using System.IO;
  using System.Security;
  
***************
*** 108,117 ****
                        }
  
        // Create a permission set object.
-       [TODO]
        public PermissionSet CreatePermissionSet()
                        {
!                               // TODO
!                               return null;
                        }
  
--- 109,217 ----
                        }
  
+       // Create a builtin permission set by name.
+       private static PermissionSet CreateBuiltinPermissionSet(String name)
+                       {
+                               NamedPermissionSet set = null;
+                               switch(name)
+                               {
+                                       case "Execution":
+                                       {
+                                               set = new NamedPermissionSet
+                                                       ("Execution", 
PermissionState.None);
+                                               set.Description = 
_("Arg_PermissionsExecution");
+                                               set.AddPermission(new 
SecurityPermission
+                                                               
(SecurityPermissionFlag.Execution));
+                                       }
+                                       break;
+ 
+                                       case "FullTrust":
+                                       {
+                                               set = new NamedPermissionSet
+                                                       ("FullTrust", 
PermissionState.Unrestricted);
+                                               set.Description = 
_("Arg_PermissionsFullTrust");
+                                       }
+                                       break;
+ 
+                                       case "Internet":
+                                       {
+                                               set = new NamedPermissionSet
+                                                       ("Internet", 
PermissionState.None);
+                                               set.Description = 
_("Arg_PermissionsInternet");
+                                       }
+                                       break;
+ 
+                                       case "LocalIntranet":
+                                       {
+                                               set = new NamedPermissionSet
+                                                       ("LocalIntranet", 
PermissionState.None);
+                                               set.Description = 
_("Arg_PermissionsLocalIntranet");
+                                       }
+                                       break;
+ 
+                                       case "Nothing":
+                                       {
+                                               set = new NamedPermissionSet
+                                                       ("Nothing", 
PermissionState.None);
+                                               set.Description = 
_("Arg_PermissionsNothing");
+                                       }
+                                       break;
+ 
+                                       case "SkipVerification":
+                                       {
+                                               set = new NamedPermissionSet
+                                                       ("SkipVerification", 
PermissionState.None);
+                                               set.Description = 
_("Arg_PermissionsSkipVerification");
+                                               set.AddPermission(new 
SecurityPermission
+                                                               
(SecurityPermissionFlag.SkipVerification));
+                                       }
+                                       break;
+                               }
+                               return set;
+                       }
+ 
        // Create a permission set object.
        public PermissionSet CreatePermissionSet()
                        {
!                               PermissionSet set;
!                               SecurityElement element;
!                               StreamReader reader;
!                               String buf;
! 
!                               if(Unrestricted)
!                               {
!                                       set = new 
PermissionSet(PermissionState.Unrestricted);
!                               }
!                               else if(name != null)
!                               {
!                                       set = CreateBuiltinPermissionSet(name);
!                               }
!                               else if(file != null)
!                               {
!                                       // Parse the contents of a file.
!                                       reader = new StreamReader(file);
!                                       buf = reader.ReadToEnd();
!                                       reader.Close();
!                                       set = new 
PermissionSet(PermissionState.None);
!                                       element = SecurityElement.Parse(buf);
!                                       if(element != null)
!                                       {
!                                               set.FromXml(element);
!                                       }
!                               }
!                               else if(xml != null)
!                               {
!                                       // Parse the contents of a string.
!                                       set = new 
PermissionSet(PermissionState.None);
!                                       element = SecurityElement.Parse(xml);
!                                       if(element != null)
!                                       {
!                                               set.FromXml(element);
!                                       }
!                               }
!                               else
!                               {
!                                       set = new 
PermissionSet(PermissionState.None);
!                               }
!                               return set;
                        }
  

Index: PrincipalPermission.cs
===================================================================
RCS file: 
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Security/Permissions/PrincipalPermission.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** PrincipalPermission.cs      31 Mar 2003 04:13:43 -0000      1.1
--- PrincipalPermission.cs      1 Apr 2003 02:16:31 -0000       1.2
***************
*** 195,202 ****
        // Throw an exception if the caller does not have
        // the specified permissions.
-       [TODO]
        public void Demand()
                        {
!                               // TODO
                        }
  
--- 195,201 ----
        // Throw an exception if the caller does not have
        // the specified permissions.
        public void Demand()
                        {
!                               // We don't use principals for security 
purposes here.
                        }
  





reply via email to

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