[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Security/Permissions F
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Security/Permissions FileDialogPermission.cs,NONE,1.1FileDialogPermissionAccess.cs,NONE,1.1 FileDialogPermissionAttribute.cs,NONE,1.1 IsolatedStorageContainment.cs,NONE,1.1 IsolatedStorageFilePermission.cs,NONE,1.1 IsolatedStorageFilePermissionAttribute.cs,NONE,1.1 IsolatedStoragePermission.cs,NONE,1.1 IsolatedStoragePermissionAttribute.cs,NONE,1.1 PermissionSetAttribute.cs,NONE,1.1 EnvironmentPermissionAttribute.cs,1.2,1.3 FileIOPermissionAttribute.cs,1.2,1.3 ReflectionPermissionAttribute.cs,1.2,1.3 SecurityPermissionAttribute.cs,1.4,1.5 |
Date: |
Sun, 30 Mar 2003 21:25:08 -0500 |
Update of /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Security/Permissions
In directory subversions:/tmp/cvs-serv18581/runtime/System/Security/Permissions
Modified Files:
EnvironmentPermissionAttribute.cs FileIOPermissionAttribute.cs
ReflectionPermissionAttribute.cs
SecurityPermissionAttribute.cs
Added Files:
FileDialogPermission.cs FileDialogPermissionAccess.cs
FileDialogPermissionAttribute.cs IsolatedStorageContainment.cs
IsolatedStorageFilePermission.cs
IsolatedStorageFilePermissionAttribute.cs
IsolatedStoragePermission.cs
IsolatedStoragePermissionAttribute.cs
PermissionSetAttribute.cs
Log Message:
Add non-ECMA permission classes; handle "Unrestricted" on attributes
properly during "CreatePermission".
--- NEW FILE ---
/*
* FileDialogPermission.cs - Implementation of the
* "System.Security.Permissions.FileDialogPermission" 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 FileDialogPermission
: CodeAccessPermission, IUnrestrictedPermission
{
// Internal state.
private PermissionState state;
private FileDialogPermissionAccess flags;
// Constructor.
public FileDialogPermission(PermissionState state)
{
this.state = state;
this.flags =
FileDialogPermissionAccess.OpenSave;
}
public FileDialogPermission(FileDialogPermissionAccess flags)
{
this.flags = flags;
}
// 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;
}
value = esd.Attribute("Access");
if(value != null)
{
flags = (FileDialogPermissionAccess)
Enum.Parse(typeof(FileDialogPermissionAccess), value);
}
else
{
flags = FileDialogPermissionAccess.None;
}
}
// Convert this permissions object into an XML value.
public override SecurityElement ToXml()
{
SecurityElement element;
element = new SecurityElement("IPermission");
element.AddAttribute
("class",
SecurityElement.Escape(typeof(FileDialogPermission).
AssemblyQualifiedName));
element.AddAttribute("version", "1");
if(flags != FileDialogPermissionAccess.None)
{
element.AddAttribute("Access",
flags.ToString());
}
else if(state == PermissionState.Unrestricted)
{
element.AddAttribute("Unrestricted",
"true");
}
return element;
}
// Implement the IPermission interface.
public override IPermission Copy()
{
if(state != PermissionState.Unrestricted)
{
return new FileDialogPermission(flags);
}
else
{
return new FileDialogPermission(state);
}
}
public override IPermission Intersect(IPermission target)
{
FileDialogPermissionAccess newFlags;
if(target == null)
{
return target;
}
else if(!(target is FileDialogPermission))
{
throw new
ArgumentException(_("Arg_PermissionMismatch"));
}
else
if(((FileDialogPermission)target).IsUnrestricted())
{
if(IsUnrestricted())
{
return Copy();
}
else
{
newFlags = flags;
}
}
else if(IsUnrestricted())
{
newFlags =
((FileDialogPermission)target).flags;
}
else
{
newFlags =
((FileDialogPermission)target).flags & flags;
}
if(newFlags == 0)
{
return null;
}
else
{
return new
FileDialogPermission(newFlags);
}
}
public override bool IsSubsetOf(IPermission target)
{
if(target == null)
{
return (flags ==
FileDialogPermissionAccess.None);
}
else if(!(target is FileDialogPermission))
{
throw new
ArgumentException(_("Arg_PermissionMismatch"));
}
else
if(((FileDialogPermission)target).IsUnrestricted())
{
return true;
}
else if(IsUnrestricted())
{
return false;
}
else
{
return ((flags &
~(((FileDialogPermission)target).flags))
== 0);
}
}
public override IPermission Union(IPermission target)
{
if(target == null)
{
return Copy();
}
else if(!(target is FileDialogPermission))
{
throw new
ArgumentException(_("Arg_PermissionMismatch"));
}
else if(IsUnrestricted() ||
((FileDialogPermission)target).IsUnrestricted())
{
return new FileDialogPermission
(PermissionState.Unrestricted);
}
else
{
return new FileDialogPermission
(flags |
((FileDialogPermission)target).flags);
}
}
// Determine if this object has unrestricted permissions.
public bool IsUnrestricted()
{
return (state == PermissionState.Unrestricted);
}
// Get or set the flags on this permissions object.
public FileDialogPermissionAccess Access
{
get
{
return flags;
}
set
{
if((flags &
~(FileDialogPermissionAccess.OpenSave)) != 0)
{
throw new
ArgumentException(_("Arg_FileDialogAccess"));
}
}
}
}; // class FileDialogPermission
#endif // !ECMA_COMPAT
}; // namespace System.Security.Permissions
--- NEW FILE ---
/*
* FileDialogPermissionAccess.cs - Implementation of the
*
"System.Security.Permissions.FileDialogPermissionAccess" 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 FileDialogPermissionAccess
{
None = 0x0000,
Open = 0x0001,
Save = 0x0002,
OpenSave = 0x0003,
}; // enum FileDialogPermissionAccess
#endif // !ECMA_COMPAT
}; // namespace System.Security.Permissions
--- NEW FILE ---
/*
* FileDialogPermissionAttribute.cs - Implementation of the
*
"System.Security.Permissions.FileDialogPermissionAttribute" 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 FileDialogPermissionAttribute : CodeAccessSecurityAttribute
{
// Internal state.
private FileDialogPermissionAccess flags;
// Constructors.
public FileDialogPermissionAttribute(SecurityAction action)
: base(action)
{
// Nothing to do here.
}
// Get or set specific flags.
public bool Open
{
get
{
return ((flags &
FileDialogPermissionAccess.Open)
!= 0);
}
set
{
if(value)
{
flags |=
FileDialogPermissionAccess.Open;
}
else
{
flags &=
~FileDialogPermissionAccess.Open;
}
}
}
public bool Save
{
get
{
return ((flags &
FileDialogPermissionAccess.Save)
!= 0);
}
set
{
if(value)
{
flags |=
FileDialogPermissionAccess.Save;
}
else
{
flags &=
~FileDialogPermissionAccess.Save;
}
}
}
// Create a permission object that corresponds to this attribute.
public override IPermission CreatePermission()
{
if(Unrestricted)
{
return new FileDialogPermission
(PermissionState.Unrestricted);
}
else
{
return new FileDialogPermission(flags);
}
}
}; // class FileDialogPermissionAttribute
#endif // !ECMA_COMPAT
}; // namespace System.Security.Permissions
--- NEW FILE ---
/*
* IsolatedStorageContainment.cs - Implementation of the
*
"System.Security.Permissions.IsolatedStorageContainment" 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 IsolatedStorageContainment
{
None = 0x0000,
DomainIsolationByUser = 0x0010,
AssemblyIsolationByUser = 0x0020,
DomainIsolationByRoamingUser = 0x0050,
AssemblyIsolationByRomaingUser = 0x0060,
AdministerIsolatedStorageByUser = 0x0070,
UnrestrictedIsolatedStorage = 0x00F0
}; // enum IsolatedStorageContainment
#endif // !ECMA_COMPAT
}; // namespace System.Security.Permissions
--- NEW FILE ---
/*
* IsolatedStorageFilePermission.cs - Implementation of the
* "System.Security.Permissions.IsolatedStorageFilePermission"
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 IsolatedStorageFilePermission : IsolatedStoragePermission
{
// Constructors.
public IsolatedStorageFilePermission(PermissionState state)
: base(state)
{
// Nothing to do here.
}
internal IsolatedStorageFilePermission(IsolatedStoragePermission
copyFrom)
: base(copyFrom)
{
// Nothing to do here.
}
internal IsolatedStorageFilePermission
(IsolatedStoragePermissionAttribute
copyFrom)
: base(copyFrom)
{
// Nothing to do here.
}
// Implement the IPermission interface.
public override IPermission Copy()
{
return new IsolatedStorageFilePermission(this);
}
public override IPermission Intersect(IPermission target)
{
// Handle the easy cases first.
if(target == null)
{
return target;
}
else if(!(target is
IsolatedStorageFilePermission))
{
throw new
ArgumentException(_("Arg_PermissionMismatch"));
}
else if(((IsolatedStorageFilePermission)target)
.IsUnrestricted())
{
return Copy();
}
else if(IsUnrestricted())
{
return target.Copy();
}
// Get the minimum quota and containment values.
long quota =
((IsolatedStorageFilePermission)target).userQuota;
if(quota > userQuota)
{
quota = userQuota;
}
IsolatedStorageContainment allowed;
allowed =
((IsolatedStorageFilePermission)target).usageAllowed;
if(((int)allowed) > ((int)usageAllowed))
{
allowed = usageAllowed;
}
// Create a new object and intersect the lists.
IsolatedStorageFilePermission perm;
perm = new
IsolatedStorageFilePermission(PermissionState.None);
perm.userQuota = quota;
perm.usageAllowed = allowed;
return perm;
}
public override bool IsSubsetOf(IPermission target)
{
if(target == null)
{
return (state == PermissionState.None &&
userQuota == 0 &&
usageAllowed ==
IsolatedStorageContainment.None);
}
else if(!(target is
IsolatedStorageFilePermission))
{
throw new
ArgumentException(_("Arg_PermissionMismatch"));
}
else if(((IsolatedStorageFilePermission)target)
.IsUnrestricted())
{
return true;
}
else if(IsUnrestricted())
{
return false;
}
else if(userQuota >
((IsolatedStorageFilePermission)target)
.userQuota)
{
return false;
}
else if(((int)usageAllowed) >
((int)(((IsolatedStorageFilePermission)target)
.usageAllowed)))
{
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
IsolatedStorageFilePermission))
{
throw new
ArgumentException(_("Arg_PermissionMismatch"));
}
else if(IsUnrestricted() ||
((IsolatedStorageFilePermission)target)
.IsUnrestricted())
{
return new IsolatedStorageFilePermission
(PermissionState.Unrestricted);
}
// Get the maximum quota and containment values.
long quota =
((IsolatedStorageFilePermission)target).userQuota;
if(quota < userQuota)
{
quota = userQuota;
}
IsolatedStorageContainment allowed;
allowed =
((IsolatedStorageFilePermission)target).usageAllowed;
if(((int)allowed) < ((int)usageAllowed))
{
allowed = usageAllowed;
}
// Create a new object and intersect the lists.
IsolatedStorageFilePermission perm;
perm = new
IsolatedStorageFilePermission(PermissionState.None);
perm.userQuota = quota;
perm.usageAllowed = allowed;
return perm;
}
}; // class IsolatedStorageFilePermission
#endif // !ECMA_COMPAT
}; // namespace System.Security.Permissions
--- NEW FILE ---
/*
* IsolatedStorageFilePermissionAttribute.cs - Implementation of the
* "System.Security.Permissions.IsolatedStorageFilePermissionAttribute" 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 IsolatedStorageFilePermissionAttribute
: IsolatedStoragePermissionAttribute
{
// Constructors.
public IsolatedStorageFilePermissionAttribute(SecurityAction action)
: base(action)
{
// Nothing to do here.
}
// Create a permission object that corresponds to this attribute.
public override IPermission CreatePermission()
{
if(Unrestricted)
{
return new IsolatedStorageFilePermission
(PermissionState.Unrestricted);
}
else
{
return new
IsolatedStorageFilePermission(this);
}
}
}; // class IsolatedStorageFilePermissionAttribute
#endif // !ECMA_COMPAT
}; // namespace System.Security.Permissions
--- NEW FILE ---
/*
* IsolatedStoragePermission.cs - Implementation of the
* "System.Security.Permissions.IsolatedStoragePermission" 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 abstract class IsolatedStoragePermission
: CodeAccessPermission, IUnrestrictedPermission
{
// Internal state.
internal PermissionState state;
internal long userQuota;
internal IsolatedStorageContainment usageAllowed;
// Constructors.
public IsolatedStoragePermission(PermissionState state)
{
if(state != PermissionState.Unrestricted &&
state != PermissionState.None)
{
throw new
ArgumentException(_("Arg_PermissionState"));
}
this.state = state;
if(state == PermissionState.Unrestricted)
{
userQuota = Int64.MaxValue;
usageAllowed =
IsolatedStorageContainment.UnrestrictedIsolatedStorage;
}
else
{
userQuota = 0;
usageAllowed =
IsolatedStorageContainment.None;
}
}
internal IsolatedStoragePermission(IsolatedStoragePermission copyFrom)
{
this.state = copyFrom.state;
this.userQuota = copyFrom.userQuota;
this.usageAllowed = copyFrom.usageAllowed;
}
internal IsolatedStoragePermission
(IsolatedStoragePermissionAttribute
copyFrom)
{
this.state = PermissionState.None;
this.userQuota = copyFrom.userQuota;
this.usageAllowed = copyFrom.usageAllowed;
}
// 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)
{
value = esd.Attribute("Allowed");
if(value != null)
{
usageAllowed =
(IsolatedStorageContainment)
Enum.Parse(typeof(IsolatedStorageContainment),
value);
}
else
{
usageAllowed =
IsolatedStorageContainment.None;
}
}
else
{
usageAllowed =
IsolatedStorageContainment.UnrestrictedIsolatedStorage;
}
if(usageAllowed !=
IsolatedStorageContainment.UnrestrictedIsolatedStorage)
{
value = esd.Attribute("UserQuota");
if(value != null)
{
userQuota = Int64.Parse(value);
}
else
{
userQuota = 0;
}
}
else
{
userQuota = Int64.MaxValue;
}
}
// Convert this permissions object into an XML value.
public override SecurityElement ToXml()
{
SecurityElement element;
element = new SecurityElement("IPermission");
element.AddAttribute
("class",
SecurityElement.Escape(typeof(FileIOPermission).
AssemblyQualifiedName));
element.AddAttribute("version", "1");
if(state == PermissionState.Unrestricted)
{
element.AddAttribute("Unrestricted",
"true");
element.AddAttribute("Allowed",
usageAllowed.ToString());
}
else
{
element.AddAttribute("Allowed",
usageAllowed.ToString());
if(userQuota > 0)
{
element.AddAttribute("UserQuota", userQuota.ToString());
}
}
return element;
}
// Determine if this object has unrestricted permissions.
public bool IsUnrestricted()
{
return (state == PermissionState.Unrestricted);
}
// Get or set the user's quota value.
public long UserQuota
{
get
{
return userQuota;
}
set
{
userQuota = value;
}
}
// Get or set the user's isolated storage containment area.
public IsolatedStorageContainment UsageAllowed
{
get
{
return usageAllowed;
}
set
{
usageAllowed = value;
}
}
}; // class IsolatedStoragePermission
#endif // !ECMA_COMPAT
}; // namespace System.Security.Permissions
--- NEW FILE ---
/*
* IsolatedStoragePermissionAttribute.cs - Implementation of the
*
"System.Security.Permissions.IsolatedStoragePermissionAttribute" 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 abstract class IsolatedStoragePermissionAttribute
: CodeAccessSecurityAttribute
{
// Internal state.
internal long userQuota;
internal IsolatedStorageContainment usageAllowed;
// Constructors.
public IsolatedStoragePermissionAttribute(SecurityAction action)
: base(action)
{
// Nothing to do here.
}
// Get or set the user quota value.
public long UserQuota
{
get
{
return userQuota;
}
set
{
userQuota = value;
}
}
// Get or set the allowed containment usage value.
public IsolatedStorageContainment UsageAllowed
{
get
{
return usageAllowed;
}
set
{
usageAllowed = value;
}
}
}; // class IsolatedStoragePermissionAttribute
#endif // !ECMA_COMPAT
}; // namespace System.Security.Permissions
--- NEW FILE ---
/*
* PermissionSetAttribute.cs - Implementation of the
* "System.Security.Permissions.PermissionSetAttribute"
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 PermissionSetAttribute : CodeAccessSecurityAttribute
{
// Internal state.
private String file;
private String name;
private bool unicodeEncoded;
private String xml;
// Constructors.
public PermissionSetAttribute(SecurityAction action)
: base(action)
{
// Nothing to do here.
}
// Get or set the file for this permission set.
public String File
{
get
{
return file;
}
set
{
file = value;
}
}
// Get or set the name of this permission set.
public String Name
{
get
{
return name;
}
set
{
name = value;
}
}
// Get or set the "unicode encoded" flag for this permission set.
public bool UnicodeEncoded
{
get
{
return unicodeEncoded;
}
set
{
unicodeEncoded = value;
}
}
// Get or set the XML data for this permission set.
public String XML
{
get
{
return xml;
}
set
{
xml = value;
}
}
// Create a permission object that corresponds to this attribute.
public override IPermission CreatePermission()
{
// Use "CreatePermissionSet" instead.
return null;
}
// Create a permission set object.
[TODO]
public PermissionSet CreatePermissionSet()
{
// TODO
return null;
}
}; // class PermissionSetAttribute
#endif // !ECMA_COMPAT
}; // namespace System.Security.Permissions
Index: EnvironmentPermissionAttribute.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Security/Permissions/EnvironmentPermissionAttribute.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** EnvironmentPermissionAttribute.cs 31 Mar 2003 01:00:38 -0000 1.2
--- EnvironmentPermissionAttribute.cs 31 Mar 2003 02:25:05 -0000 1.3
***************
*** 85,92 ****
public override IPermission CreatePermission()
{
! return new EnvironmentPermission
! (PermissionState.None,
! EnvironmentPermission.SplitPath(read),
!
EnvironmentPermission.SplitPath(write));
}
--- 85,100 ----
public override IPermission CreatePermission()
{
! if(Unrestricted)
! {
! return new EnvironmentPermission
! (PermissionState.Unrestricted);
! }
! else
! {
! return new EnvironmentPermission
! (PermissionState.None,
!
EnvironmentPermission.SplitPath(read),
!
EnvironmentPermission.SplitPath(write));
! }
}
Index: FileIOPermissionAttribute.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Security/Permissions/FileIOPermissionAttribute.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** FileIOPermissionAttribute.cs 31 Mar 2003 01:00:38 -0000 1.2
--- FileIOPermissionAttribute.cs 31 Mar 2003 02:25:05 -0000 1.3
***************
*** 114,125 ****
public override IPermission CreatePermission()
{
! return new FileIOPermission
! (PermissionState.None,
! EnvironmentPermission.SplitPath(read),
! EnvironmentPermission.SplitPath(write),
!
EnvironmentPermission.SplitPath(append),
!
EnvironmentPermission.SplitPath(pathDiscovery),
! FileIOPermissionAccess.NoAccess,
! FileIOPermissionAccess.NoAccess);
}
--- 114,133 ----
public override IPermission CreatePermission()
{
! if(Unrestricted)
! {
! return new FileIOPermission
! (PermissionState.Unrestricted);
! }
! else
! {
! return new FileIOPermission
! (PermissionState.None,
!
EnvironmentPermission.SplitPath(read),
!
EnvironmentPermission.SplitPath(write),
!
EnvironmentPermission.SplitPath(append),
!
EnvironmentPermission.SplitPath(pathDiscovery),
! FileIOPermissionAccess.NoAccess,
!
FileIOPermissionAccess.NoAccess);
! }
}
Index: ReflectionPermissionAttribute.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Security/Permissions/ReflectionPermissionAttribute.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** ReflectionPermissionAttribute.cs 31 Mar 2003 01:00:38 -0000 1.2
--- ReflectionPermissionAttribute.cs 31 Mar 2003 02:25:05 -0000 1.3
***************
*** 123,127 ****
public override IPermission CreatePermission()
{
! return new ReflectionPermission(flags);
}
--- 123,135 ----
public override IPermission CreatePermission()
{
! if(Unrestricted)
! {
! return new ReflectionPermission
! (PermissionState.Unrestricted);
! }
! else
! {
! return new ReflectionPermission(flags);
! }
}
Index: SecurityPermissionAttribute.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Security/Permissions/SecurityPermissionAttribute.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** SecurityPermissionAttribute.cs 30 Mar 2003 11:58:44 -0000 1.4
--- SecurityPermissionAttribute.cs 31 Mar 2003 02:25:05 -0000 1.5
***************
*** 52,56 ****
public override IPermission CreatePermission()
{
! return new SecurityPermission(flags);
}
#endif
--- 52,64 ----
public override IPermission CreatePermission()
{
! if(Unrestricted)
! {
! return new SecurityPermission
! (PermissionState.Unrestricted);
! }
! else
! {
! return new SecurityPermission(flags);
! }
}
#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Security/Permissions FileDialogPermission.cs,NONE,1.1FileDialogPermissionAccess.cs,NONE,1.1 FileDialogPermissionAttribute.cs,NONE,1.1 IsolatedStorageContainment.cs,NONE,1.1 IsolatedStorageFilePermission.cs,NONE,1.1 IsolatedStorageFilePermissionAttribute.cs,NONE,1.1 IsolatedStoragePermission.cs,NONE,1.1 IsolatedStoragePermissionAttribute.cs,NONE,1.1 PermissionSetAttribute.cs,NONE,1.1 EnvironmentPermissionAttribute.cs,1.2,1.3 FileIOPermissionAttribute.cs,1.2,1.3 ReflectionPermissionAttribute.cs,1.2,1.3 SecurityPermissionAttribute.cs,1.4,1.5,
Rhys Weatherley <address@hidden> <=