Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,56 @@
//
// System.Security.Permissions.SecurityPermissionAttribute.cs
//
// Author: Nick Drochak, ndrochak@gol.com
// Created: 2002-01-06
//
// Copyright (C) 2001 Nick Drochak, All Rights Reserved
// Copyright (C) 2004-2006 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Runtime.InteropServices;
namespace System.Security.Permissions {
#if NET_2_1 && !MONOTOUCH
[Obsolete ("CAS support is not available with Silverlight applications.")]
#endif
[ComVisible (true)]
[AttributeUsage(
AttributeTargets.Assembly
| AttributeTargets.Class
| AttributeTargets.Struct
| AttributeTargets.Constructor
| AttributeTargets.Method,
AllowMultiple=true,
Inherited=false)
]
[Serializable]
public abstract class CodeAccessSecurityAttribute : SecurityAttribute {
protected CodeAccessSecurityAttribute (SecurityAction action)
: base (action)
{
}
}
}

View File

@@ -0,0 +1,364 @@
//
// System.Security.Permissions.EnvironmentPermission.cs
//
// Authors:
// Tim Coleman <tim@timcoleman.com>
// Sebastien Pouliot <sebastien@ximian.com>
//
// Copyright (C) 2002, Tim Coleman
// Portions Copyright (C) 2003 Motus Technologies (http://www.motus.com)
// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Collections;
using System.Runtime.InteropServices;
using System.Text;
namespace System.Security.Permissions {
[ComVisible (true)]
[Serializable]
public sealed class EnvironmentPermission : CodeAccessPermission, IUnrestrictedPermission, IBuiltInPermission {
#region Fields
private const int version = 1;
// EnvironmentPermissionAccess flags;
PermissionState _state;
ArrayList readList;
ArrayList writeList;
#endregion // Fields
#region Constructors
public EnvironmentPermission (PermissionState state) : base ()
{
_state = CheckPermissionState (state, true);
readList = new ArrayList ();
writeList = new ArrayList ();
}
public EnvironmentPermission (EnvironmentPermissionAccess flag, string pathList) : base ()
{
readList = new ArrayList ();
writeList = new ArrayList ();
SetPathList (flag, pathList);
}
#endregion // Constructors
#region Methods
public void AddPathList (EnvironmentPermissionAccess flag, string pathList)
{
if (pathList == null)
throw new ArgumentNullException ("pathList");
string[] paths;
switch (flag) {
case EnvironmentPermissionAccess.AllAccess:
paths = pathList.Split (';');
foreach (string path in paths) {
if (!readList.Contains (path))
readList.Add (path);
if (!writeList.Contains (path))
writeList.Add (path);
}
break;
case EnvironmentPermissionAccess.NoAccess:
// ??? unit tests doesn't show removal using NoAccess ???
break;
case EnvironmentPermissionAccess.Read:
paths = pathList.Split (';');
foreach (string path in paths) {
if (!readList.Contains (path))
readList.Add (path);
}
break;
case EnvironmentPermissionAccess.Write:
paths = pathList.Split (';');
foreach (string path in paths) {
if (!writeList.Contains (path))
writeList.Add (path);
}
break;
default:
ThrowInvalidFlag (flag, false);
break;
}
}
public override IPermission Copy ()
{
EnvironmentPermission ep = new EnvironmentPermission (_state);
string path = GetPathList (EnvironmentPermissionAccess.Read);
if (path != null)
ep.SetPathList (EnvironmentPermissionAccess.Read, path);
path = GetPathList (EnvironmentPermissionAccess.Write);
if (path != null)
ep.SetPathList (EnvironmentPermissionAccess.Write, path);
return ep;
}
public override void FromXml (SecurityElement esd)
{
// General validation in CodeAccessPermission
CheckSecurityElement (esd, "esd", version, version);
// Note: we do not (yet) care about the return value
// as we only accept version 1 (min/max values)
if (IsUnrestricted (esd))
_state = PermissionState.Unrestricted;
string read = esd.Attribute ("Read");
if ((read != null) && (read.Length > 0))
SetPathList (EnvironmentPermissionAccess.Read, read);
string write = esd.Attribute ("Write");
if ((write != null) && (write.Length > 0))
SetPathList (EnvironmentPermissionAccess.Write, write);
}
public string GetPathList (EnvironmentPermissionAccess flag)
{
switch (flag) {
case EnvironmentPermissionAccess.AllAccess:
case EnvironmentPermissionAccess.NoAccess:
ThrowInvalidFlag (flag, true);
break;
case EnvironmentPermissionAccess.Read:
return GetPathList (readList);
case EnvironmentPermissionAccess.Write:
return GetPathList (writeList);
default:
ThrowInvalidFlag (flag, false);
break;
}
return null; // never reached
}
public override IPermission Intersect (IPermission target)
{
EnvironmentPermission ep = Cast (target);
if (ep == null)
return null;
if (IsUnrestricted ())
return ep.Copy ();
if (ep.IsUnrestricted ())
return Copy ();
int n = 0;
EnvironmentPermission result = new EnvironmentPermission (PermissionState.None);
string readTarget = ep.GetPathList (EnvironmentPermissionAccess.Read);
if (readTarget != null) {
string[] targets = readTarget.Split (';');
foreach (string t in targets) {
if (readList.Contains (t)) {
result.AddPathList (EnvironmentPermissionAccess.Read, t);
n++;
}
}
}
string writeTarget = ep.GetPathList (EnvironmentPermissionAccess.Write);
if (writeTarget != null) {
string[] targets = writeTarget.Split (';');
foreach (string t in targets) {
if (writeList.Contains (t)) {
result.AddPathList (EnvironmentPermissionAccess.Write, t);
n++;
}
}
}
return ((n > 0) ? result : null);
}
public override bool IsSubsetOf (IPermission target)
{
EnvironmentPermission ep = Cast (target);
if (ep == null)
return false;
if (IsUnrestricted ())
return ep.IsUnrestricted ();
else if (ep.IsUnrestricted ())
return true;
foreach (string s in readList) {
if (!ep.readList.Contains (s))
return false;
}
foreach (string s in writeList) {
if (!ep.writeList.Contains (s))
return false;
}
return true;
}
public bool IsUnrestricted ()
{
return (_state == PermissionState.Unrestricted);
}
public void SetPathList (EnvironmentPermissionAccess flag, string pathList)
{
if (pathList == null)
throw new ArgumentNullException ("pathList");
string[] paths;
switch (flag) {
case EnvironmentPermissionAccess.AllAccess:
readList.Clear ();
writeList.Clear ();
paths = pathList.Split (';');
foreach (string path in paths) {
readList.Add (path);
writeList.Add (path);
}
break;
case EnvironmentPermissionAccess.NoAccess:
// ??? unit tests doesn't show removal using NoAccess ???
break;
case EnvironmentPermissionAccess.Read:
readList.Clear ();
paths = pathList.Split (';');
foreach (string path in paths) {
readList.Add (path);
}
break;
case EnvironmentPermissionAccess.Write:
writeList.Clear ();
paths = pathList.Split (';');
foreach (string path in paths) {
writeList.Add (path);
}
break;
default:
ThrowInvalidFlag (flag, false);
break;
}
}
public override SecurityElement ToXml ()
{
SecurityElement se = Element (version);
if (_state == PermissionState.Unrestricted) {
se.AddAttribute ("Unrestricted", "true");
}
else {
string path = GetPathList (EnvironmentPermissionAccess.Read);
if (path != null)
se.AddAttribute ("Read", path);
path = GetPathList (EnvironmentPermissionAccess.Write);
if (path != null)
se.AddAttribute ("Write", path);
}
return se;
}
public override IPermission Union (IPermission other)
{
EnvironmentPermission ep = Cast (other);
if (ep == null)
return Copy ();
if (IsUnrestricted () || ep.IsUnrestricted ())
return new EnvironmentPermission (PermissionState.Unrestricted);
if (IsEmpty () && ep.IsEmpty ())
return null;
EnvironmentPermission result = (EnvironmentPermission) Copy ();
string path = ep.GetPathList (EnvironmentPermissionAccess.Read);
if (path != null)
result.AddPathList (EnvironmentPermissionAccess.Read, path);
path = ep.GetPathList (EnvironmentPermissionAccess.Write);
if (path != null)
result.AddPathList (EnvironmentPermissionAccess.Write, path);
return result;
}
// IBuiltInPermission
int IBuiltInPermission.GetTokenIndex ()
{
return (int) BuiltInToken.Environment;
}
// helpers
private bool IsEmpty ()
{
return ((_state == PermissionState.None) && (readList.Count == 0) && (writeList.Count == 0));
}
private EnvironmentPermission Cast (IPermission target)
{
if (target == null)
return null;
EnvironmentPermission ep = (target as EnvironmentPermission);
if (ep == null) {
ThrowInvalidPermission (target, typeof (EnvironmentPermission));
}
return ep;
}
internal void ThrowInvalidFlag (EnvironmentPermissionAccess flag, bool context)
{
string msg = null;
if (context)
msg = Locale.GetText ("Unknown flag '{0}'.");
else
msg = Locale.GetText ("Invalid flag '{0}' in this context.");
throw new ArgumentException (String.Format (msg, flag), "flag");
}
private string GetPathList (ArrayList list)
{
if (IsUnrestricted ())
return String.Empty;
if (list.Count == 0)
return String.Empty;
StringBuilder sb = new StringBuilder ();
foreach (string path in list) {
sb.Append (path);
sb.Append (";");
}
string result = sb.ToString ();
// remove last ';'
int n = result.Length;
if (n > 0)
return result.Substring (0, n - 1);
return String.Empty;
}
#endregion // Methods
}
}

View File

@@ -0,0 +1,47 @@
// EnvironmentPermissionAccess.cs
//
// This code was automatically generated from
// ECMA CLI XML Library Specification.
// Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)]
// Created: Wed, 5 Sep 2001 06:29:59 UTC
// Source file: AllTypes.xml
// URL: http://msdn.microsoft.com/net/ecma/AllTypes.xml
//
// (C) 2001 Ximian, Inc. http://www.ximian.com
// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Runtime.InteropServices;
namespace System.Security.Permissions {
[ComVisible (true)]
[Serializable]
[Flags]
public enum EnvironmentPermissionAccess {
NoAccess = 0x00000000,
Read = 0x00000001,
Write = 0x00000002,
AllAccess = Read | Write,
}
}

View File

@@ -0,0 +1,91 @@
//
// System.Security.Permissions.EnvironmentPermissionAttribute.cs
//
// Authors
// Duncan Mak <duncan@ximian.com>
// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) 2002 Ximian, Inc. http://www.ximian.com
// Portions Copyright (C) 2003 Motus Technologies (http://www.motus.com)
// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Runtime.InteropServices;
namespace System.Security.Permissions {
[ComVisible (true)]
[AttributeUsage (AttributeTargets.Assembly | AttributeTargets.Class |
AttributeTargets.Struct | AttributeTargets.Constructor |
AttributeTargets.Method, AllowMultiple=true, Inherited=false)]
[Serializable]
public sealed class EnvironmentPermissionAttribute : CodeAccessSecurityAttribute {
// Fields
private string read;
private string write;
// Constructor
public EnvironmentPermissionAttribute (SecurityAction action) : base (action)
{
}
// Properties
public string All {
get { throw new NotSupportedException ("All"); }
set {
read = value;
write = value;
}
}
public string Read {
get { return read; }
set { read = value; }
}
public string Write {
get { return write; }
set { write = value; }
}
// Methods
public override IPermission CreatePermission ()
{
#if NET_2_1
return null;
#else
EnvironmentPermission perm = null;
if (this.Unrestricted)
perm = new EnvironmentPermission (PermissionState.Unrestricted);
else {
perm = new EnvironmentPermission (PermissionState.None);
if (read != null)
perm.AddPathList (EnvironmentPermissionAccess.Read, read);
if (write != null)
perm.AddPathList (EnvironmentPermissionAccess.Write, write);
}
return perm;
#endif
}
}
}

View File

@@ -0,0 +1,173 @@
//
// System.Security.Permissions.FileDialogPermission.cs
//
// Author
// Sebastien Pouliot <sebastien@ximian.com>
//
// Copyright (C) 2003 Motus Technologies. http://www.motus.com
// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Runtime.InteropServices;
namespace System.Security.Permissions {
[ComVisible (true)]
[Serializable]
public sealed class FileDialogPermission : CodeAccessPermission, IUnrestrictedPermission, IBuiltInPermission {
private const int version = 1;
private FileDialogPermissionAccess _access;
// Constructors
public FileDialogPermission (PermissionState state)
{
if (CheckPermissionState (state, true) == PermissionState.Unrestricted)
_access = FileDialogPermissionAccess.OpenSave;
else
_access = FileDialogPermissionAccess.None;
}
public FileDialogPermission (FileDialogPermissionAccess access)
{
// reuse validation by the Flags property
Access = access;
}
// Properties
public FileDialogPermissionAccess Access {
get { return _access; }
set {
if (!Enum.IsDefined (typeof (FileDialogPermissionAccess), value)) {
string msg = String.Format (Locale.GetText ("Invalid enum {0}"), value);
throw new ArgumentException (msg, "FileDialogPermissionAccess");
}
_access = value;
}
}
// Methods
public override IPermission Copy ()
{
return new FileDialogPermission (_access);
}
public override void FromXml (SecurityElement esd)
{
// General validation in CodeAccessPermission
CheckSecurityElement (esd, "esd", version, version);
// Note: we do not (yet) care about the return value
// as we only accept version 1 (min/max values)
if (IsUnrestricted (esd)) {
_access = FileDialogPermissionAccess.OpenSave;
}
else {
string a = esd.Attribute ("Access");
if (a == null)
_access = FileDialogPermissionAccess.None;
else {
_access = (FileDialogPermissionAccess) Enum.Parse (
typeof (FileDialogPermissionAccess), a);
}
}
}
public override IPermission Intersect (IPermission target)
{
FileDialogPermission fdp = Cast (target);
if (fdp == null)
return null;
FileDialogPermissionAccess a = (_access & fdp._access);
return ((a == FileDialogPermissionAccess.None) ? null : new FileDialogPermission (a));
}
public override bool IsSubsetOf (IPermission target)
{
FileDialogPermission fdp = Cast (target);
if (fdp == null)
return false;
return ((_access & fdp._access) == _access);
}
public bool IsUnrestricted ()
{
return (_access == FileDialogPermissionAccess.OpenSave);
}
public override SecurityElement ToXml ()
{
SecurityElement se = Element (1);
switch (_access) {
case FileDialogPermissionAccess.Open:
se.AddAttribute ("Access", "Open");
break;
case FileDialogPermissionAccess.Save:
se.AddAttribute ("Access", "Save");
break;
case FileDialogPermissionAccess.OpenSave:
se.AddAttribute ("Unrestricted", "true");
break;
}
return se;
}
public override IPermission Union (IPermission target)
{
FileDialogPermission fdp = Cast (target);
if (fdp == null)
return Copy ();
if (IsUnrestricted () || fdp.IsUnrestricted ())
return new FileDialogPermission (PermissionState.Unrestricted);
return new FileDialogPermission (_access | fdp._access);
}
// IBuiltInPermission
int IBuiltInPermission.GetTokenIndex ()
{
return (int) BuiltInToken.FileDialog;
}
// helpers
private FileDialogPermission Cast (IPermission target)
{
if (target == null)
return null;
FileDialogPermission fdp = (target as FileDialogPermission);
if (fdp == null) {
ThrowInvalidPermission (target, typeof (FileDialogPermission));
}
return fdp;
}
}
}

View File

@@ -0,0 +1,42 @@
//
// System.Security.Permissions.FileDialogPermissionAccess
//
// Author: Duncan Mak (duncan@ximian.com)
//
// (C) Ximian, Inc. http://www.ximian.com
// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Runtime.InteropServices;
namespace System.Security.Permissions {
[ComVisible (true)]
[Flags]
[Serializable]
public enum FileDialogPermissionAccess {
None = 0,
Open = 1,
Save = 2,
OpenSave = 3,
}
}

View File

@@ -0,0 +1,81 @@
//
// System.Security.Permissions.FileDialogPermissionAttribute.cs
//
// Authors
// Duncan Mak <duncan@ximian.com>
// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) 2002 Ximian, Inc. http://www.ximian.com
// Portions Copyright (C) 2003 Motus Technologies (http://www.motus.com)
// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Runtime.InteropServices;
namespace System.Security.Permissions {
[ComVisible (true)]
[AttributeUsage (AttributeTargets.Assembly | AttributeTargets.Class |
AttributeTargets.Struct | AttributeTargets.Constructor |
AttributeTargets.Method, AllowMultiple=true, Inherited=false)]
[Serializable]
public sealed class FileDialogPermissionAttribute : CodeAccessSecurityAttribute {
// Fields
private bool canOpen;
private bool canSave;
// Constructor
public FileDialogPermissionAttribute (SecurityAction action)
: base (action)
{
}
// Properties
public bool Open {
get { return canOpen; }
set { canOpen = value; }
}
public bool Save {
get { return canSave; }
set { canSave = value; }
}
// Methods
public override IPermission CreatePermission ()
{
FileDialogPermission perm = null;
if (this.Unrestricted)
perm = new FileDialogPermission (PermissionState.Unrestricted);
else {
FileDialogPermissionAccess access = FileDialogPermissionAccess.None;
if (canOpen)
access |= FileDialogPermissionAccess.Open;
if (canSave)
access |= FileDialogPermissionAccess.Save;
perm = new FileDialogPermission (access);
}
return perm;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,49 @@
// FileIOPermissionAccess.cs
//
// This code was automatically generated from
// ECMA CLI XML Library Specification.
// Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)]
// Created: Wed, 5 Sep 2001 06:30:11 UTC
// Source file: AllTypes.xml
// URL: http://msdn.microsoft.com/net/ecma/AllTypes.xml
//
// (C) 2001 Ximian, Inc. http://www.ximian.com
// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Runtime.InteropServices;
namespace System.Security.Permissions {
[ComVisible (true)]
[Serializable]
[Flags]
public enum FileIOPermissionAccess {
NoAccess = 0x00000000,
Read = 0x00000001,
Write = 0x00000002,
Append = 0x00000004,
PathDiscovery = 0x00000008,
AllAccess = Read | Write | Append | PathDiscovery,
}
}

View File

@@ -0,0 +1,144 @@
//
// System.Security.Permissions.FileIOPermissionAttribute.cs
//
// Authors
// Duncan Mak <duncan@ximian.com>
// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) 2002 Ximian, Inc. http://www.ximian.com
// Portions Copyright (C) 2003 Motus Technologies (http://www.motus.com)
// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Runtime.InteropServices;
namespace System.Security.Permissions {
[ComVisible (true)]
[AttributeUsage (AttributeTargets.Assembly | AttributeTargets.Class |
AttributeTargets.Struct | AttributeTargets.Constructor |
AttributeTargets.Method, AllowMultiple=true, Inherited=false)]
[Serializable]
public sealed class FileIOPermissionAttribute : CodeAccessSecurityAttribute {
// Fields
private string append;
private string path;
private string read;
private string write;
private FileIOPermissionAccess allFiles;
private FileIOPermissionAccess allLocalFiles;
private string changeAccessControl;
private string viewAccessControl;
//private string viewAndModify;
// Constructor
public FileIOPermissionAttribute (SecurityAction action) : base (action)
{
}
// Properties
[Obsolete ("use newer properties")]
public string All {
get { throw new NotSupportedException ("All"); }
set {
append = value;
path = value;
read = value;
write = value;
}
}
public string Append {
get { return append; }
set { append = value; }
}
public string PathDiscovery {
get { return path; }
set { path = value; }
}
public string Read {
get { return read; }
set { read = value; }
}
public string Write {
get { return write; }
set { write = value; }
}
public FileIOPermissionAccess AllFiles {
get { return allFiles; }
set { allFiles = value; }
}
public FileIOPermissionAccess AllLocalFiles {
get { return allLocalFiles; }
set { allLocalFiles = value; }
}
public string ChangeAccessControl {
get { return changeAccessControl; }
set { changeAccessControl = value; }
}
public string ViewAccessControl {
get { return viewAccessControl; }
set { viewAccessControl = value; }
}
public string ViewAndModify {
get { throw new NotSupportedException (); } // as documented
set {
append = value;
path = value;
read = value;
write = value;
}
}
// Methods
public override IPermission CreatePermission ()
{
#if NET_2_1
return null;
#else
FileIOPermission perm = null;
if (this.Unrestricted)
perm = new FileIOPermission (PermissionState.Unrestricted);
else {
perm = new FileIOPermission (PermissionState.None);
if (append != null)
perm.AddPathList (FileIOPermissionAccess.Append, append);
if (path != null)
perm.AddPathList (FileIOPermissionAccess.PathDiscovery, path);
if (read != null)
perm.AddPathList (FileIOPermissionAccess.Read, read);
if (write != null)
perm.AddPathList (FileIOPermissionAccess.Write, write);
}
return perm;
#endif
}
}
}

View File

@@ -0,0 +1,113 @@
//
// System.Security.Permissions.GacIdentityPermission.cs
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Globalization;
using System.Runtime.InteropServices;
namespace System.Security.Permissions {
[ComVisible (true)]
[Serializable]
public sealed class GacIdentityPermission : CodeAccessPermission, IBuiltInPermission {
private const int version = 1;
public GacIdentityPermission ()
{
}
public GacIdentityPermission (PermissionState state)
{
// false == do not allow Unrestricted for Identity Permissions
CheckPermissionState (state, false);
}
public override IPermission Copy ()
{
return (IPermission) new GacIdentityPermission ();
}
public override IPermission Intersect (IPermission target)
{
GacIdentityPermission gip = Cast (target);
if (gip == null)
return null;
return Copy ();
}
public override bool IsSubsetOf (IPermission target)
{
GacIdentityPermission gip = Cast (target);
return (gip != null);
}
public override IPermission Union (IPermission target)
{
Cast (target);
return Copy ();
}
public override void FromXml (SecurityElement securityElement)
{
// General validation in CodeAccessPermission
CheckSecurityElement (securityElement, "securityElement", version, version);
// Note: we do not (yet) care about the return value
// as we only accept version 1 (min/max values)
}
public override SecurityElement ToXml ()
{
SecurityElement se = Element (version);
return se;
}
// IBuildInPermission
int IBuiltInPermission.GetTokenIndex ()
{
return (int) BuiltInToken.GacIdentity;
}
// helpers
private GacIdentityPermission Cast (IPermission target)
{
if (target == null)
return null;
GacIdentityPermission uip = (target as GacIdentityPermission);
if (uip == null) {
ThrowInvalidPermission (target, typeof (GacIdentityPermission));
}
return uip;
}
}
}

View File

@@ -0,0 +1,51 @@
//
// System.Security.Permissions.GacIdentityPermissionAttribute
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Runtime.InteropServices;
namespace System.Security.Permissions {
[Serializable]
[ComVisible (true)]
[AttributeUsage (AttributeTargets.Assembly | AttributeTargets.Class |
AttributeTargets.Struct | AttributeTargets.Constructor |
AttributeTargets.Method, AllowMultiple=true, Inherited=false)]
public sealed class GacIdentityPermissionAttribute : CodeAccessSecurityAttribute {
public GacIdentityPermissionAttribute (SecurityAction action)
: base (action)
{
}
public override IPermission CreatePermission ()
{
return (IPermission) new GacIdentityPermission ();
}
}
}

View File

@@ -0,0 +1,183 @@
//
// System.Security.Permissions.HostProtectionAttribute class
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Runtime.InteropServices;
namespace System.Security.Permissions {
[AttributeUsage (AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Struct |
AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Delegate,
AllowMultiple = true, Inherited = false)]
[ComVisible (true)]
[Serializable]
public sealed class HostProtectionAttribute : CodeAccessSecurityAttribute {
private HostProtectionResource _resources;
public HostProtectionAttribute ()
: base (SecurityAction.LinkDemand)
{
}
public HostProtectionAttribute (SecurityAction action)
: base (action)
{
if (action != SecurityAction.LinkDemand) {
string msg = String.Format (Locale.GetText ("Only {0} is accepted."), SecurityAction.LinkDemand);
throw new ArgumentException (msg, "action");
}
}
public bool ExternalProcessMgmt {
get { return ((_resources & HostProtectionResource.ExternalProcessMgmt) != 0); }
set {
if (value) {
_resources |= HostProtectionResource.ExternalProcessMgmt;
}
else {
_resources &= ~HostProtectionResource.ExternalProcessMgmt;
}
}
}
public bool ExternalThreading {
get { return ((_resources & HostProtectionResource.ExternalThreading) != 0); }
set {
if (value) {
_resources |= HostProtectionResource.ExternalThreading;
}
else {
_resources &= ~HostProtectionResource.ExternalThreading;
}
}
}
public bool MayLeakOnAbort {
get { return ((_resources & HostProtectionResource.MayLeakOnAbort) != 0); }
set {
if (value) {
_resources |= HostProtectionResource.MayLeakOnAbort;
}
else {
_resources &= ~HostProtectionResource.MayLeakOnAbort;
}
}
}
[ComVisible (true)]
public bool SecurityInfrastructure {
get { return ((_resources & HostProtectionResource.SecurityInfrastructure) != 0); }
set {
if (value) {
_resources |= HostProtectionResource.SecurityInfrastructure;
}
else {
_resources &= ~HostProtectionResource.SecurityInfrastructure;
}
}
}
public bool SelfAffectingProcessMgmt {
get { return ((_resources & HostProtectionResource.SelfAffectingProcessMgmt) != 0); }
set {
if (value) {
_resources |= HostProtectionResource.SelfAffectingProcessMgmt;
}
else {
_resources &= ~HostProtectionResource.SelfAffectingProcessMgmt;
}
}
}
public bool SelfAffectingThreading {
get { return ((_resources & HostProtectionResource.SelfAffectingThreading) != 0); }
set {
if (value) {
_resources |= HostProtectionResource.SelfAffectingThreading;
}
else {
_resources &= ~HostProtectionResource.SelfAffectingThreading;
}
}
}
public bool SharedState {
get { return ((_resources & HostProtectionResource.SharedState) != 0); }
set {
if (value) {
_resources |= HostProtectionResource.SharedState;
}
else {
_resources &= ~HostProtectionResource.SharedState;
}
}
}
public bool Synchronization {
get { return ((_resources & HostProtectionResource.Synchronization) != 0); }
set {
if (value) {
_resources |= HostProtectionResource.Synchronization;
}
else {
_resources &= ~HostProtectionResource.Synchronization;
}
}
}
public bool UI {
get { return ((_resources & HostProtectionResource.UI) != 0); }
set {
if (value) {
_resources |= HostProtectionResource.UI;
}
else {
_resources &= ~HostProtectionResource.UI;
}
}
}
public HostProtectionResource Resources {
get { return _resources; }
set { _resources = value; }
}
public override IPermission CreatePermission ()
{
#if NET_2_1
return null;
#else
// looks like permission is internal
return new HostProtectionPermission (_resources);
#endif
}
}
}

View File

@@ -0,0 +1,159 @@
//
// System.Security.Permissions.HostProtectionPermission.cs
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Globalization;
namespace System.Security.Permissions {
[Serializable]
internal sealed class HostProtectionPermission : CodeAccessPermission, IUnrestrictedPermission, IBuiltInPermission {
private const int version = 1;
private HostProtectionResource _resources;
// constructors
public HostProtectionPermission (PermissionState state)
{
if (CheckPermissionState (state, true) == PermissionState.Unrestricted)
_resources = HostProtectionResource.All;
else
_resources = HostProtectionResource.None;
}
public HostProtectionPermission (HostProtectionResource resources)
{
// reuse validation by the Flags property
Resources = _resources;
}
public HostProtectionResource Resources {
get { return _resources; }
set {
if (!Enum.IsDefined (typeof (HostProtectionResource), value)) {
string msg = String.Format (Locale.GetText ("Invalid enum {0}"), value);
throw new ArgumentException (msg, "HostProtectionResource");
}
_resources = value;
}
}
public override IPermission Copy ()
{
return new HostProtectionPermission (_resources);
}
public override IPermission Intersect (IPermission target)
{
HostProtectionPermission hpp = Cast (target);
if (hpp == null)
return null;
if (this.IsUnrestricted () && hpp.IsUnrestricted ())
return new HostProtectionPermission (PermissionState.Unrestricted);
if (this.IsUnrestricted ())
return hpp.Copy ();
if (hpp.IsUnrestricted ())
return this.Copy ();
return new HostProtectionPermission (_resources & hpp._resources);
}
public override IPermission Union (IPermission target)
{
HostProtectionPermission hpp = Cast (target);
if (hpp == null)
return this.Copy ();
if (this.IsUnrestricted () || hpp.IsUnrestricted ())
return new HostProtectionPermission (PermissionState.Unrestricted);
return new HostProtectionPermission (_resources | hpp._resources);
}
public override bool IsSubsetOf (IPermission target)
{
HostProtectionPermission hpp = Cast (target);
if (hpp == null)
return (_resources == HostProtectionResource.None);
if (hpp.IsUnrestricted ())
return true;
if (this.IsUnrestricted ())
return false;
return ((_resources & ~hpp._resources) == 0);
}
public override void FromXml (SecurityElement e)
{
// General validation in CodeAccessPermission
CheckSecurityElement (e, "e", version, version);
// Note: we do not (yet) care about the return value
// as we only accept version 1 (min/max values)
_resources = (HostProtectionResource) Enum.Parse (
typeof (HostProtectionResource), e.Attribute ("Resources"));
}
public override SecurityElement ToXml ()
{
SecurityElement e = Element (version);
e.AddAttribute ("Resources", _resources.ToString ());
return e;
}
// IUnrestrictedPermission
public bool IsUnrestricted ()
{
return (_resources == HostProtectionResource.All);
}
// IBuiltInPermission
int IBuiltInPermission.GetTokenIndex ()
{
return (int) BuiltInToken.HostProtection;
}
// helpers
private HostProtectionPermission Cast (IPermission target)
{
if (target == null)
return null;
HostProtectionPermission hpp = (target as HostProtectionPermission);
if (hpp == null) {
ThrowInvalidPermission (target, typeof (HostProtectionPermission));
}
return hpp;
}
}
}

View File

@@ -0,0 +1,51 @@
//
// System.Security.Permissions.HostProtectionResource enumeration
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Runtime.InteropServices;
namespace System.Security.Permissions {
[Flags]
[Serializable]
[ComVisible (true)]
public enum HostProtectionResource {
None = 0,
Synchronization = 1,
SharedState = 2,
ExternalProcessMgmt = 4,
SelfAffectingProcessMgmt = 8,
ExternalThreading = 16,
SelfAffectingThreading = 32,
SecurityInfrastructure = 64,
UI = 128,
MayLeakOnAbort = 256,
All = ExternalProcessMgmt | ExternalThreading | MayLeakOnAbort | SecurityInfrastructure |
SelfAffectingProcessMgmt | SelfAffectingThreading | SharedState | Synchronization | UI
}
}

View File

@@ -0,0 +1,75 @@
//
// System.Security.Permissions.IBuiltInPermission.cs
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// Copyright (C) 2003 Motus Technologies (http://www.motus.com)
// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace System.Security.Permissions {
// LAMESPEC: Undocumented interface
internal interface IBuiltInPermission {
int GetTokenIndex ();
}
// 1_1 2_0 Name
// 0 0 EnvironmentPermission
// 1 1 FileDialogPermission
// 2 2 FileIOPermission
// 3 3 IsolatedStorageFilePermission
// 4 4 ReflectionPermission
// 5 5 RegistryPermission
// 6 6 SecurityPermission
// 7 7 UIPermission
// 8 8 PrincipalPermission
// N/A 9 HostProtectionPermission (internal)
// 9 10 PublisherIdentityPermission
// 10 11 SiteIdentityPermission
// 11 12 StrongNameIdentityPermission
// 12 13 UrlIdentityPermission
// 13 14 ZoneIdentityPermission
// N/A 15 GacIdentityPermission
// N/A 16 KeyContainerPermission
internal enum BuiltInToken {
Environment = 0,
FileDialog = 1,
FileIO = 2,
IsolatedStorageFile = 3,
Reflection = 4,
Registry = 5,
Security = 6,
UI = 7,
Principal = 8,
HostProtection = 9,
PublisherIdentity = 10,
SiteIdentity = 11,
StrongNameIdentity = 12,
UrlIdentity = 13,
ZoneIdentity = 14,
GacIdentity = 15,
KeyContainer = 16,
}
}

View File

@@ -0,0 +1,38 @@
//
// System.Security.Permissions.IUnrestrictedPermission.cs
//
// Author:
// Nick Drochak(ndrochak@gol.com)
//
// (C) Nick Drochak
// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Runtime.InteropServices;
namespace System.Security.Permissions {
[ComVisible (true)]
public interface IUnrestrictedPermission {
bool IsUnrestricted ();
}
}

View File

@@ -0,0 +1,55 @@
//
// IsolatedStorageContainment.cs
//
// This code was automatically generated from
// ECMA CLI XML Library Specification.
// Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)]
// Created: Wed, 5 Sep 2001 06:41:57 UTC
// Source file: all.xml
// URL: http://devresource.hp.com/devresource/Docs/TechPapers/CSharp/all.xml
//
// (C) 2001 Ximian, Inc. http://www.ximian.com
// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Runtime.InteropServices;
namespace System.Security.Permissions {
[Serializable]
[ComVisible (true)]
public enum IsolatedStorageContainment
{
None = 0x00,
DomainIsolationByUser = 0x10,
AssemblyIsolationByUser = 0x20,
DomainIsolationByRoamingUser = 0x50,
AssemblyIsolationByRoamingUser = 0x60,
AdministerIsolatedStorageByUser = 0x70,
UnrestrictedIsolatedStorage = 0xF0,
ApplicationIsolationByUser = 0x15,
DomainIsolationByMachine = 0x30,
AssemblyIsolationByMachine = 0x40,
ApplicationIsolationByMachine = 0x45,
ApplicationIsolationByRoamingUser = 0x65,
}
}

View File

@@ -0,0 +1,143 @@
//
// System.Security.Permissions.IsolatedStorageFilePermission.cs
//
// Author
// Sebastien Pouliot <sebastien@ximian.com>
//
// Copyright (C) 2003 Motus Technologies. http://www.motus.com
// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Runtime.InteropServices;
namespace System.Security.Permissions {
[Serializable]
[ComVisible (true)]
public sealed class IsolatedStorageFilePermission : IsolatedStoragePermission, IBuiltInPermission {
// Constructors
public IsolatedStorageFilePermission (PermissionState state)
: base (state)
{
}
// Properties
// Methods
public override IPermission Copy ()
{
IsolatedStorageFilePermission p = new IsolatedStorageFilePermission (PermissionState.None);
p.m_userQuota = m_userQuota;
p.m_machineQuota = m_machineQuota;
p.m_expirationDays = m_expirationDays;
p.m_permanentData = m_permanentData;
p.m_allowed = m_allowed;
return p;
}
public override IPermission Intersect (IPermission target)
{
IsolatedStorageFilePermission isfp = Cast (target);
if (isfp == null)
return null;
if (IsEmpty () && isfp.IsEmpty ())
return null;
IsolatedStorageFilePermission p = new IsolatedStorageFilePermission (PermissionState.None);
p.m_userQuota = (m_userQuota < isfp.m_userQuota) ? m_userQuota : isfp.m_userQuota;
p.m_machineQuota = (m_machineQuota < isfp.m_machineQuota) ? m_machineQuota : isfp.m_machineQuota;
p.m_expirationDays = (m_expirationDays < isfp.m_expirationDays) ? m_expirationDays : isfp.m_expirationDays;
p.m_permanentData = (m_permanentData && isfp.m_permanentData);
// UsageAllowed == Unrestricted is a special case handled by the property
p.UsageAllowed = (m_allowed < isfp.m_allowed) ? m_allowed : isfp.m_allowed;
return p;
}
public override bool IsSubsetOf (IPermission target)
{
IsolatedStorageFilePermission isfp = Cast (target);
if (isfp == null)
return IsEmpty ();
if (isfp.IsUnrestricted ())
return true;
if (m_userQuota > isfp.m_userQuota)
return false;
if (m_machineQuota > isfp.m_machineQuota)
return false;
if (m_expirationDays > isfp.m_expirationDays)
return false;
if (m_permanentData != isfp.m_permanentData)
return false;
if (m_allowed > isfp.m_allowed)
return false;
return true;
}
public override IPermission Union (IPermission target)
{
IsolatedStorageFilePermission isfp = Cast (target);
if (isfp == null)
return Copy ();
IsolatedStorageFilePermission p = new IsolatedStorageFilePermission (PermissionState.None);
p.m_userQuota = (m_userQuota > isfp.m_userQuota) ? m_userQuota : isfp.m_userQuota;
p.m_machineQuota = (m_machineQuota > isfp.m_machineQuota) ? m_machineQuota : isfp.m_machineQuota;
p.m_expirationDays = (m_expirationDays > isfp.m_expirationDays) ? m_expirationDays : isfp.m_expirationDays;
p.m_permanentData = (m_permanentData || isfp.m_permanentData);
// UsageAllowed == Unrestricted is a special case handled by the property
p.UsageAllowed = (m_allowed > isfp.m_allowed) ? m_allowed : isfp.m_allowed;
return p;
}
[MonoTODO ("(2.0) new override - something must have been added ???")]
[ComVisible (false)]
public override SecurityElement ToXml ()
{
return base.ToXml ();
}
// IBuiltInPermission
int IBuiltInPermission.GetTokenIndex ()
{
return (int) BuiltInToken.IsolatedStorageFile;
}
// helpers
private IsolatedStorageFilePermission Cast (IPermission target)
{
if (target == null)
return null;
IsolatedStorageFilePermission isfp = (target as IsolatedStorageFilePermission);
if (isfp == null) {
ThrowInvalidPermission (target, typeof (IsolatedStorageFilePermission));
}
return isfp;
}
}
}

Some files were not shown because too many files have changed in this diff Show More