// Ajay kumar Dwivedi (adwiv@yahoo.com)
// Sebastien Pouliot <sebastien@ximian.com>
//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.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
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using System.Runtime.InteropServices;
+
namespace System.Security.Policy {
[Serializable]
+#if NET_2_0
+ [ComVisible (true)]
+#endif
public sealed class AllMembershipCondition : IMembershipCondition, IConstantMembershipCondition {
private readonly int version = 1;
// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) 2002 Jackson Harper, All rights reserved.
-// Copyright (C) 2004 Novell, Inc (http://www.novell.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
using System.Globalization;
using System.IO;
+using System.Runtime.InteropServices;
using System.Text;
using Mono.Security;
namespace System.Security.Policy {
[Serializable]
+#if NET_2_0
+ [ComVisible (true)]
+#endif
public sealed class ApplicationDirectory : IBuiltInEvidence {
private string directory;
public override bool Equals (object other)
{
- if (null != other && (other is ApplicationDirectory)) {
- ApplicationDirectory compare = (ApplicationDirectory) other;
-// FIXME: to duplicate (faulty ?) MS behaviour (see FDBK14362)
+ ApplicationDirectory compare = (other as ApplicationDirectory);
+ if (compare != null) {
+ // MS "by design" behaviour (see FDBK14362)
ThrowOnInvalid (compare.directory);
// no C14N or other mojo here (it's done elsewhere)
return (directory == compare.directory);
public override string ToString ()
{
-// FIXME: to duplicate (faulty ?) MS behaviour (see FDBK14362)
+ // MS "by design" behaviour (see FDBK14362)
ThrowOnInvalid (Directory);
SecurityElement element = new SecurityElement ("System.Security.Policy.ApplicationDirectory");
element.AddAttribute ("version", "1");
// Sebastien Pouliot <sebastien@ximian.com>
//\r
// (C) 2002 Nick Drochak, All rights reserved.\r
-// Copyright (C) 2004 Novell, Inc (http://www.novell.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
using System.Globalization;
using System.IO;
using System.Reflection;
+using System.Runtime.InteropServices;
using Mono.Security;
\r
namespace System.Security.Policy {\r
\r
[Serializable]\r
+#if NET_2_0
+ [ComVisible (true)]
+#endif
public sealed class ApplicationDirectoryMembershipCondition : IConstantMembershipCondition, IMembershipCondition {\r
private readonly int version = 1;
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.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
#if NET_2_0
-using System.Collections;
-using System.Globalization;
+using System.Runtime.InteropServices;
using System.Security.Permissions;
namespace System.Security.Policy {
- public sealed class ApplicationSecurityInfo : ISecurityEncodable, ISecurityPolicyEncodable {
+ [ComVisible (true)]
+ public sealed class ApplicationSecurityInfo {
private ActivationContext _context;
private Evidence _evidence;
_deployid = value;
}
}
-
- // methods
-
- [MonoTODO]
- public override bool Equals (object obj)
- {
- if (obj == null)
- return false;
- ApplicationSecurityInfo asi = (obj as ApplicationSecurityInfo);
- if (asi == null)
- return false;
- // TODO
- return false;
- }
-
- public void FromXml (SecurityElement element)
- {
- FromXml (element, null);
- }
-
- [MonoTODO]
- public void FromXml (SecurityElement element, PolicyLevel level)
- {
- throw new NotImplementedException ();
- }
-
- [MonoTODO]
- public override int GetHashCode ()
- {
- return base.GetHashCode ();
- }
-
- [MonoTODO]
- public bool IsInApplication (Evidence evidence)
- {
- if (evidence == null)
- return false; // ???
-
- IEnumerator e = evidence.GetHostEnumerator ();
- while (e.MoveNext ()) {
- }
-
- e = evidence.GetAssemblyEnumerator ();
- while (e.MoveNext ()) {
- }
-
- // we found them all!
- return true;
- }
-
- public SecurityElement ToXml ()
- {
- return ToXml (null);
- }
-
- [MonoTODO]
- public SecurityElement ToXml (PolicyLevel level)
- {
- throw new NotImplementedException ();
- }
}
}
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.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
#if NET_2_0
-using System.Collections;
+using System.Runtime.InteropServices;
namespace System.Security.Policy {
- [Serializable]
+ [ComVisible (true)]
public static class ApplicationSecurityManager {
private const string config = "ApplicationTrust.config";
static private IApplicationTrustManager _appTrustManager;
- static private ITrustManager _trustManager;
- static private IDictionary _globalApps;
- static private IDictionary _userApps;
- static private ApplicationTrustCollection _machineAppTrusts;
static private ApplicationTrustCollection _userAppTrusts;
// properties
get { return _appTrustManager; }
}
- [MonoTODO]
- public static IDictionary GlobalApplications {
- get { return _globalApps; }
- set { _globalApps = value; }
- }
-
- [MonoTODO]
- public static string GlobalApplicationsLocation {
- get { throw new NotImplementedException (); }
- }
-
- [MonoTODO]
- public static ApplicationTrustCollection MachineApplicationTrusts {
- get { return _machineAppTrusts; }
- }
-
- [MonoTODO]
- public static IDictionary UserApplications {
- get { return _userApps; }
- set { _userApps = value; }
- }
-
- [MonoTODO]
- public static string UserApplicationsLocation {
- get { throw new NotImplementedException (); }
- }
-
[MonoTODO]
public static ApplicationTrustCollection UserApplicationTrusts {
get { return _userAppTrusts; }
throw new ArgumentNullException ("activationContext");
throw new NotImplementedException ();
}
-
- [MonoTODO]
- public static void Persist ()
- {
- throw new NotImplementedException ();
- }
-
- [MonoTODO]
- public static PolicyStatement Resolve (Evidence evidence)
- {
- throw new NotImplementedException ();
- }
}
}
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.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
#if NET_2_0
-using System.Collections;
+using System.Runtime.InteropServices;
namespace System.Security.Policy {
- public sealed class ApplicationTrust : ISecurityEncodable, ISecurityPolicyEncodable {
+ [ComVisible (true)]
+ public sealed class ApplicationTrust : ISecurityEncodable {
private ApplicationIdentity _appid;
private PolicyStatement _defaultPolicy;
set { _persist = value; }
}
- [MonoTODO ("incomplete")]
- public override bool Equals (object obj)
- {
- if (obj == null)
- return false;
- ApplicationTrust at = (obj as ApplicationTrust);
- if (at == null)
- return false;
-
- // TODO
- return false;
- }
-
[MonoTODO ("incomplete")]
public void FromXml (SecurityElement element)
{
throw new NotImplementedException ();
}
- [MonoTODO ("incomplete - is PolicyLevel used ?")]
- public void FromXml (SecurityElement element, PolicyLevel level)
- {
- FromXml (element);
- }
-
- public override int GetHashCode ()
- {
- return base.GetHashCode ();
- }
-
[MonoTODO ("incomplete")]
public SecurityElement ToXml ()
{
throw new NotImplementedException ();
}
-
- [MonoTODO ("incomplete - is PolicyLevel used ?")]
- public SecurityElement ToXml (PolicyLevel level)
- {
- return ToXml ();
- }
}
}
using System.Collections;
using System.Globalization;
+using System.Runtime.InteropServices;
namespace System.Security.Policy {
+ [ComVisible (true)]
public sealed class ApplicationTrustCollection : ICollection, IEnumerable {
private ArrayList _list;
- internal ApplicationTrustCollection ()
+ public ApplicationTrustCollection ()
{
_list = new ArrayList ();
}
- // constants
+ // constants (from beta1 - still useful ?)
- public const string ApplicationTrustProperty = "ApplicationTrust";
- public const string InstallReferenceIdentifier = "{3f471841-eef2-47d6-89c0-d028f03a4ad5}";
+// public const string ApplicationTrustProperty = "ApplicationTrust";
+// public const string InstallReferenceIdentifier = "{3f471841-eef2-47d6-89c0-d028f03a4ad5}";
// properties
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.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
#if NET_2_0
using System.Collections;
+using System.Runtime.InteropServices;
namespace System.Security.Policy {
+ [ComVisible (true)]
public sealed class ApplicationTrustEnumerator : IEnumerator {
private IEnumerator e;
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.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
#if NET_2_0
-using System;
+using System.Runtime.InteropServices;
namespace System.Security.Policy {
- [Serializable]
+ [ComVisible (true)]
public enum ApplicationVersionMatch {
MatchExactVersion,
MatchAllVersions
+2005-04-25 Sebastien Pouliot <sebastien@ximian.com>
+
+ * AllMembershipCondition.cs: Added [ComVisible (true)] in NET_2_0 to
+ match beta2.
+ * ApplicationDirectory.cs: Added [ComVisible (true)] in NET_2_0 to
+ match beta2. Removed FIXME - confirmed as "by design" by MS.
+ * ApplicationDirectoryMembershipCondition.cs: Added [ComVisible (true)]
+ in NET_2_0 to match beta2.
+ * ApplicationSecurityInfo.cs: Updated to match beta2.
+ * ApplicationSecurityManager.cs: Updated to match beta2.
+ * ApplicationTrust.cs: Updated to match beta2.
+ * ApplicationTrustCollection.cs: Updated to match beta2.
+ * ApplicationTrustEnumerator.cs: Added [ComVisible (true)] to match
+ beta2.
+ * ApplicationVersionMatch.cs: Added [ComVisible (true)] to match beta2.
+ * CodeConnectAccess.cs: Added [ComVisible (true)] to match beta2.
+ * CodeGroup.cs: Added [ComVisible (true)] in NET_2_0 to match beta2.
+ Reworked Equals to avoid multiple typecast.
+ * Evidence.cs: Updated to match beta2. Now use internal method
+ Assembly.UnprotectedGetName during security manager initialization.
+ * FileCodeGroup.cs: Added [ComVisible (true)] in NET_2_0 to match
+ beta2. Removed Scope property (didn't survive beta2).
+ * FirstMatchCodeGroup.cs: Added [ComVisible (true)] in NET_2_0 to
+ match beta2.
+ * Gac.cs: Renamed class to GacInstalled. Added [ComVisible (true)] to
+ match beta2.
+ * GacMembershipCondition.cs: Added [ComVisible (true)] in NET_2_0 to
+ match beta2.
+ * Hash.cs: Added [ComVisible (true)] in NET_2_0 to match beta2.
+ * HashMembershipCondition.cs: Added [ComVisible (true)] in NET_2_0 to
+ match beta2. Reworked Equals to avoid multiple typecast.
+ * IApplicationTrustManager.cs: Added [ComVisible (true)] to match
+ beta2.
+ * IIdentityPermissionFactory.cs: Added [ComVisible (true)] in NET_2_0
+ to match beta2.
+ * IMembershipCondition.cs: Added [ComVisible (true)] in NET_2_0 to
+ match beta2.
+ * NetCodeGroup.cs: Added [ComVisible (true)] in NET_2_0 to match
+ beta2. Removed Scope property (didn't survive beta2).
+ * PermissionRequestEvidence.cs: Added [ComVisible (true)] in NET_2_0
+ to match beta2.
+ * PolicyException.cs: Added [ComVisible (true)] in NET_2_0 to match
+ beta2.
+ * PolicyLevel.cs: Added [ComVisible (true)] in NET_2_0 to match beta2.
+ * PolicyStatementAttribute.cs: Added [ComVisible (true)] in NET_2_0 to
+ match beta2.
+ * PolicyStatement.cs: Added [ComVisible (true)] in NET_2_0 to match
+ beta2.
+ * ProvideAssemblyEvidenceEventArgs.cs: Added [ComVisible (true)] to
+ match beta2.
+ * Publisher.cs: Added [ComVisible (true)] in NET_2_0 to match beta2.
+ Reworked Equals to avoid multiple typecast.
+ * PublisherMembershipCondition.cs: Added [ComVisible (true)] in
+ NET_2_0 to match beta2. Reworked Equals to avoid multiple typecast.
+ * Site.cs: Added [ComVisible (true)] in NET_2_0 to match beta2. Fixed
+ allowed characters accepted in site names (different in 2.0 from 1.x).
+ * SiteMembershipCondition.cs: Added [ComVisible (true)] in NET_2_0 to
+ match beta2.
+ * StrongName.cs: Added [ComVisible (true)] in NET_2_0 to match beta2.
+ * StrongNameMembershipCondition.cs: Added [ComVisible (true)] in
+ NET_2_0 to match beta2.
+ * TrustManagerContext.cs: Updated to match beta2.
+ * TrustManagerUIContext.cs: Added [ComVisible (true)] to match beta2.
+ * UnionCodeGroup.cs: Added [ComVisible (true)] in NET_2_0 to match
+ beta2.
+ * Url.cs: Added [ComVisible (true)] in NET_2_0 to match beta2. Fixed
+ the difference in Url matching between 1.x and 2.0. Reworked Equals to
+ avoid multiple typecast.
+ * UrlMembershipCondition.cs: Added [ComVisible (true)] in NET_2_0 to
+ match beta2. Fixed the difference in Url matching between 1.x and 2.0.
+ * Zone.cs: Added [ComVisible (true)] in NET_2_0 to match beta2.
+ Reworked Equals to avoid multiple typecast.
+ * ZoneMembershipCondition.cs: Added [ComVisible (true)] in NET_2_0 to
+ match beta2.
+
2005-04-05 Sebastien Pouliot <sebastien@ximian.com>
* Hash.cs: Added Assert for FileIOPermission to GetData so it's
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.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
#if NET_2_0
-using System;
using System.Globalization;
+using System.Runtime.InteropServices;
namespace System.Security.Policy {
[Serializable]
+ [ComVisible (true)]
public class CodeConnectAccess {
public static readonly string AnyScheme = "*";
// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) 2001 Nick Drochak, All rights reserved.
-// Copyright (C) 2004 Novell, Inc (http://www.novell.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
using System.Collections;
using System.Globalization;
using System.Reflection;
+using System.Runtime.InteropServices;
using System.Security.Permissions;
namespace System.Security.Policy {
[Serializable]
+#if NET_2_0
+ [ComVisible (true)]
+#endif
public abstract class CodeGroup {
PolicyStatement m_policy;
IMembershipCondition m_membershipCondition;
public override bool Equals (object o)
{
- if (!(o is CodeGroup))
+ CodeGroup cg = (o as CodeGroup);
+ if (cg == null)
return false;
- return Equals ((CodeGroup)o, false);
+ return Equals (cg, false);
}
public bool Equals (CodeGroup cg, bool compareChildren)
[Serializable]
[MonoTODO ("Fix serialization compatibility with MS.NET")]
+#if NET_2_0
+ [ComVisible (true)]
+#endif
public sealed class Evidence : ICollection, IEnumerable {
private bool _locked;
}
// strongnamed assemblies gets a StrongName evidence
- AssemblyName an = a.GetName ();
+ AssemblyName an = a.UnprotectedGetName ();
byte[] pk = an.GetPublicKey ();
if ((pk != null) && (pk.Length > 0)) {
StrongNamePublicKeyBlob blob = new StrongNamePublicKeyBlob (pk);
#if NET_2_0
// assemblies loaded from the GAC also get a Gac evidence (new in Fx 2.0)
if (a.GlobalAssemblyCache) {
- e.AddHost (new Gac ());
+ e.AddHost (new GacInstalled ());
}
// the current HostSecurityManager may add/remove some evidence
AppDomainManager dommgr = AppDomain.CurrentDomain.DomainManager;
if (dommgr != null) {
- if ((dommgr.HostSecurityManager.Flags & HostSecurityManagerFlags.HostAssemblyEvidence) ==
- HostSecurityManagerFlags.HostAssemblyEvidence) {
+ if ((dommgr.HostSecurityManager.Flags & HostSecurityManagerOptions.HostAssemblyEvidence) ==
+ HostSecurityManagerOptions.HostAssemblyEvidence) {
e = dommgr.HostSecurityManager.ProvideAssemblyEvidence (a, e);
}
}
// Nick Drochak (ndrochak@gol.com)
//
// (C) 2001 Nick Drochak, All rights reserved.
-// Copyright (C) 2004 Novell, Inc (http://www.novell.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
namespace System.Security.Policy {
[Serializable]
+#if NET_2_0
+ [ComVisible (true)]
+#endif
public sealed class FileCodeGroup : CodeGroup {
private FileIOPermissionAccess m_access;
-#if NET_2_0
- private CodeGroupGrantScope _scope = CodeGroupGrantScope.Assembly;
-#endif
public FileCodeGroup (IMembershipCondition membershipCondition, FileIOPermissionAccess access)
: base (membershipCondition, null)
get { return "Same directory FileIO - " + m_access.ToString (); }
}
-#if NET_2_0
- [ComVisible (false)]
- public CodeGroupGrantScope Scope {
- get { return _scope; }
- set { _scope = value; }
- }
-#endif
-
public override bool Equals (object o)
{
if (!(o is FileCodeGroup))
// Jackson Harper (Jackson@LatitudeGeo.com)
//
// (C) 2002 Jackson Harper, All rights reserved.
-// Copyright (C) 2004 Novell, Inc (http://www.novell.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
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using System.Runtime.InteropServices;
+
namespace System.Security.Policy {
[Serializable]
+#if NET_2_0
+ [ComVisible (true)]
+#endif
public sealed class FirstMatchCodeGroup : CodeGroup {
public FirstMatchCodeGroup (IMembershipCondition membershipCondition, PolicyStatement policy)
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.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
#if NET_2_0
using System.Security.Permissions;
+using System.Runtime.InteropServices;
namespace System.Security.Policy {
[Serializable]
- public sealed class Gac : IIdentityPermissionFactory, IBuiltInEvidence {
+#if NET_2_0
+ [ComVisible (true)]
+#endif
+ public sealed class GacInstalled : IIdentityPermissionFactory, IBuiltInEvidence {
- public Gac ()
+ public GacInstalled ()
{
}
public object Copy ()
{
- return (object) new Gac ();
+ return (object) new GacInstalled ();
}
public IPermission CreateIdentityPermission (Evidence evidence)
{
if (o == null)
return false;
- return (o is Gac);
+ return (o is GacInstalled);
}
public override int GetHashCode ()
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.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
using System.Collections;
using System.Security.Permissions;
+using System.Runtime.InteropServices;
namespace System.Security.Policy {
[Serializable]
+#if NET_2_0
+ [ComVisible (true)]
+#endif
public sealed class GacMembershipCondition : IMembershipCondition, IConstantMembershipCondition {
private readonly int version = 1;
// true only if Gac is in host-supplied evidences
IEnumerator e = evidence.GetHostEnumerator ();
while (e.MoveNext ()) {
- if (e.Current is Gac)
+ if (e.Current is GacInstalled)
return true;
}
return false;
//
using System.IO;
-using System.Text;
using System.Reflection;
+using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Security.Cryptography;
using System.Security.Permissions;
+using System.Text;
namespace System.Security.Policy {
-#if !NET_2_0
+[Serializable]
+#if NET_2_0
+[ComVisible (true)]
+#else
[MonoTODO("This doesn't match the MS version perfectly.")]
// but it does seems to works exactly like Fx 2.0 beta 1 !?!?!
#endif
-
-[Serializable]
public sealed class Hash : ISerializable, IBuiltInEvidence {
private Assembly assembly;
// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) 2002 Jackson Harper, All rights reserved
-// Copyright (C) 2004 Novell, Inc (http://www.novell.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
using System.Collections;
using System.Globalization;
using System.Reflection;
+using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Security.Cryptography;
[Serializable]
#if NET_2_0
+ [ComVisible (true)]
public sealed class HashMembershipCondition : IMembershipCondition, IDeserializationCallback, ISerializable {
#else
public sealed class HashMembershipCondition : IMembershipCondition {
public override bool Equals (object o)
{
- HashMembershipCondition other;
- if (!(o is HashMembershipCondition))
+ HashMembershipCondition other = (o as HashMembershipCondition);
+ if (other == null)
return false;
- other = (HashMembershipCondition)o;
-
return ((other.HashAlgorithm == hash_algorithm) &&
Compare (hash_value, other.hash_value));
}
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.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
#if NET_2_0
-using System;
+using System.Runtime.InteropServices;
namespace System.Security.Policy {
+ [ComVisible (true)]
public interface IApplicationTrustManager : ISecurityEncodable {
ApplicationTrust DetermineApplicationTrust (ActivationContext activationContext, TrustManagerContext context);
+//
// System.Security.Policy.IIdentityPermissionFactory\r
//\r
// Nick Drochak (ndrochak@gol.com)\r
//\r
// (C) 2001 Nick Drochak\r
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.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
// 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;
+\r
+namespace System.Security.Policy {
+\r
+#if NET_2_0
+ [ComVisible (true)]
+#endif
+ public interface IIdentityPermissionFactory {
\r
-namespace System.Security.Policy\r
-{\r
- public interface IIdentityPermissionFactory\r
- {\r
IPermission CreateIdentityPermission(Evidence evidence);\r
}\r
}\r
+//
// System.Security.Policy.IMembershipCondition.cs\r
//\r
// Nick Drochak (ndrochak@gol.com)\r
//\r
// (C) 2001 Nick Drochak\r
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.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
// 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;
\r
-namespace System.Security.Policy\r
-{\r
- public interface IMembershipCondition : ISecurityEncodable, ISecurityPolicyEncodable\r
- {\r
- bool Check (Evidence evidence);\r
- IMembershipCondition Copy ();\r
+namespace System.Security.Policy {\r
+
+#if NET_2_0
+ [ComVisible (true)]
+#endif
+ public interface IMembershipCondition : ISecurityEncodable, ISecurityPolicyEncodable {\r
+
+ bool Check (Evidence evidence);\r
+ IMembershipCondition Copy ();\r
+
#if !BOOTSTRAP_WITH_OLDLIB
- bool Equals (object obj);\r
- string ToString ();\r
+ bool Equals (object obj);\r
+ string ToString ();\r
#endif
- }\r
+ }\r
}\r
-\r
// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) 2002 Jackson Harper, All rights reserved
-// Copyright (C) 2004 Novell, Inc (http://www.novell.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
namespace System.Security.Policy {
[Serializable]
+#if NET_2_0
+ [ComVisible (true)]
+#endif
public sealed class NetCodeGroup : CodeGroup {
#if NET_2_0
public static readonly string AbsentOriginScheme = String.Empty;
public static readonly string AnyOtherOriginScheme = "*";
- private CodeGroupGrantScope _scope = CodeGroupGrantScope.Assembly;
private Hashtable _rules = new Hashtable ();
private int _hashcode;
#endif
#endif
}
-#if NET_2_0
- [ComVisible (false)]
- public CodeGroupGrantScope Scope {
- get { return _scope; }
- set { _scope = value; }
- }
-#endif
//
// Public Methods
#endif
}
}
-
// Sebastien Pouliot <sebastien@ximian.com>
//\r
// (C) 2003 Nick Drochak\r
-// Copyright (C) 2004 Novell, Inc (http://www.novell.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
// 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;
\r
namespace System.Security.Policy {
\r
[Serializable]\r
+#if NET_2_0
+ [ComVisible (true)]
+#endif
public sealed class PermissionRequestEvidence : IBuiltInEvidence {
\r
private PermissionSet requested, optional, denied;\r
\r
// interface IBuiltInEvidence\r
\r
- [MonoTODO]\r
int IBuiltInEvidence.GetRequiredSize (bool verbose) \r
{
int size = verbose ? 3 : 1;
// Duncan Mak (duncan@ximian.com)
//
// 2002 (C) Ximian, Inc. http://www.ximian.com
-// Copyright (C) 2004 Novell, Inc (http://www.novell.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
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-using System;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
namespace System.Security.Policy {
- [Serializable]
+ [Serializable]
#if NET_2_0
- public class PolicyException : SystemException, _Exception {
+ [ComVisible (true)]
+ public class PolicyException : SystemException, _Exception {
#else
- public class PolicyException : SystemException {
+ public class PolicyException : SystemException {
#endif
- // Constructors
- public PolicyException ()
- : base (Locale.GetText ("Cannot run because of policy."))
- {
- }
+ // Constructors
+ public PolicyException ()
+ : base (Locale.GetText ("Cannot run because of policy."))
+ {
+ }
- public PolicyException (string message)
- : base (message)
- {
- }
+ public PolicyException (string message)
+ : base (message)
+ {
+ }
- protected PolicyException (SerializationInfo info,
- StreamingContext context)
- : base (info, context)
- {
- }
+ protected PolicyException (SerializationInfo info, StreamingContext context)
+ : base (info, context)
+ {
+ }
- public PolicyException (string message, Exception innerException)
- :base (message, innerException)
- {
- }
-
- }
+ public PolicyException (string message, Exception innerException)
+ :base (message, innerException)
+ {
+ }
+ }
}
// (C) 2001 Nick Drochak
// (C) 2003 Duncan Mak, Ximian Inc.
// Portions (C) 2004 Motus Technologies Inc. (http://www.motus.com)
-// Copyright (C) 2004 Novell, Inc (http://www.novell.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
namespace System.Security.Policy {
[Serializable]
+#if NET_2_0
+ [ComVisible (true)]
+#endif
public sealed class PolicyLevel {
string label;
// Sebastien Pouliot <sebastien@ximian.com>
//\r
// (C) 2002\r
-// Copyright (C) 2004 Novell, Inc (http://www.novell.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
namespace System.Security.Policy {\r
\r
[Serializable]\r
+#if NET_2_0
+ [ComVisible (true)]
+#endif
public sealed class PolicyStatement : ISecurityEncodable, ISecurityPolicyEncodable {
private PermissionSet perms;\r
+//
// System.Security.Policy.PolicyStatementAttribute
//
-// Nick Drochak (ndrochak@gol.com)
+// Author:
+// Nick Drochak (ndrochak@gol.com)
//
// (C) 2001 Nick Drochak
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.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
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace System.Security.Policy
-{
+using System.Runtime.InteropServices;
+
+namespace System.Security.Policy {
+
[Flags]
[Serializable]
- public enum PolicyStatementAttribute {
+#if NET_2_0
+ [ComVisible (true)]
+#endif
+ public enum PolicyStatementAttribute {
Nothing = 0,
Exclusive = 1,
LevelFinal = 2,
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.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
#if NET_2_0
-using System;
using System.Reflection;
+using System.Runtime.InteropServices;
namespace System.Security.Policy {
+ [ComVisible (true)]
public class ProvideAssemblyEvidenceEventArgs : EventArgs {
private Assembly _assembly;
public Evidence Evidence {
get { return _evidence; }
- set { _evidence = value; }
}
}
}
// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
-// Copyright (C) 2004 Novell, Inc (http://www.novell.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
using System.Security.Cryptography.X509Certificates;
using System.Security.Permissions;
+using System.Runtime.InteropServices;
namespace System.Security.Policy {
-[Serializable]
-public sealed class Publisher : IIdentityPermissionFactory, IBuiltInEvidence {
+ [Serializable]
+#if NET_2_0
+ [ComVisible (true)]
+#endif
+ public sealed class Publisher : IIdentityPermissionFactory, IBuiltInEvidence {
- private X509Certificate m_cert;
+ private X509Certificate m_cert;
- public Publisher (X509Certificate cert)
- {
- if (cert == null)
- throw new ArgumentNullException ("cert");
+ public Publisher (X509Certificate cert)
+ {
+ if (cert == null)
+ throw new ArgumentNullException ("cert");
#if NET_2_0
- if (cert.GetHashCode () == 0)
- throw new ArgumentException ("cert");
+ if (cert.GetHashCode () == 0)
+ throw new ArgumentException ("cert");
#endif
- m_cert = cert;
- }
+ m_cert = cert;
+ }
- public X509Certificate Certificate {
- get {
- if (m_cert.GetHashCode () == 0) {
+ public X509Certificate Certificate {
+ get {
+ if (m_cert.GetHashCode () == 0) {
#if NET_2_0
- throw new ArgumentException ("m_cert");
+ throw new ArgumentException ("m_cert");
#else
- throw new NullReferenceException ("m_cert");
-#endif
+ throw new NullReferenceException ("m_cert");
+#endif
+ }
+ return m_cert;
}
- return m_cert;
}
- }
- public object Copy ()
- {
- return new Publisher (m_cert);
- }
+ public object Copy ()
+ {
+ return new Publisher (m_cert);
+ }
- public IPermission CreateIdentityPermission (Evidence evidence)
- {
- return new PublisherIdentityPermission (m_cert);
- }
+ public IPermission CreateIdentityPermission (Evidence evidence)
+ {
+ return new PublisherIdentityPermission (m_cert);
+ }
- public override bool Equals (object o)
- {
- if (!(o is Publisher))
- throw new ArgumentException ("not a Publisher");
- return m_cert.Equals ((o as Publisher).Certificate);
- }
+ public override bool Equals (object o)
+ {
+ Publisher p = (o as Publisher);
+ if (p == null)
+ throw new ArgumentException ("not a Publisher");
+ return m_cert.Equals (p.Certificate);
+ }
- public override int GetHashCode ()
- {
- return m_cert.GetHashCode ();
- }
+ public override int GetHashCode ()
+ {
+ return m_cert.GetHashCode ();
+ }
- public override string ToString ()
- {
- SecurityElement se = new SecurityElement ("System.Security.Policy.Publisher");
- se.AddAttribute ("version", "1");
- SecurityElement cert = new SecurityElement ("X509v3Certificate");
- string data = m_cert.GetRawCertDataString ();
- if (data != null)
- cert.Text = data;
- se.AddChild (cert);
- return se.ToString ();
- }
+ public override string ToString ()
+ {
+ SecurityElement se = new SecurityElement ("System.Security.Policy.Publisher");
+ se.AddAttribute ("version", "1");
+ SecurityElement cert = new SecurityElement ("X509v3Certificate");
+ string data = m_cert.GetRawCertDataString ();
+ if (data != null)
+ cert.Text = data;
+ se.AddChild (cert);
+ return se.ToString ();
+ }
- // interface IBuiltInEvidence
+ // interface IBuiltInEvidence
- [MonoTODO]
- int IBuiltInEvidence.GetRequiredSize (bool verbose)
- {
- return (verbose ? 3 : 1) + m_cert.GetRawCertData ().Length;
- }
+ [MonoTODO]
+ int IBuiltInEvidence.GetRequiredSize (bool verbose)
+ {
+ return (verbose ? 3 : 1) + m_cert.GetRawCertData ().Length;
+ }
- [MonoTODO]
- int IBuiltInEvidence.InitFromBuffer (char [] buffer, int position)
- {
- return 0;
- }
+ [MonoTODO]
+ int IBuiltInEvidence.InitFromBuffer (char [] buffer, int position)
+ {
+ return 0;
+ }
- [MonoTODO]
- int IBuiltInEvidence.OutputToBuffer (char [] buffer, int position, bool verbose)
- {
- return 0;
+ [MonoTODO]
+ int IBuiltInEvidence.OutputToBuffer (char [] buffer, int position, bool verbose)
+ {
+ return 0;
+ }
}
}
-
-}
// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
-// Copyright (C) 2004 Novell, Inc (http://www.novell.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
using System.Collections;
using System.Security.Cryptography.X509Certificates;
+using System.Runtime.InteropServices;
using Mono.Security.Cryptography;
namespace System.Security.Policy {
[Serializable]
+#if NET_2_0
+ [ComVisible (true)]
+#endif
public sealed class PublisherMembershipCondition : IConstantMembershipCondition, IMembershipCondition {
private readonly int version = 1;
{
}
- // LAMESPEC: Undocumented ArgumentNullException exception
public PublisherMembershipCondition (X509Certificate certificate)
{
if (certificate == null)
x509 = certificate;
}
- // LAMESPEC: Undocumented ArgumentNullException exception
public X509Certificate Certificate {
get { return x509; }
set {
public override bool Equals (object o)
{
- if (!(o is PublisherMembershipCondition))
+ PublisherMembershipCondition pmc = (o as PublisherMembershipCondition);
+ if (pmc == null)
return false;
- return x509.Equals ((o as PublisherMembershipCondition).Certificate);
+ return x509.Equals (pmc.Certificate);
}
public void FromXml (SecurityElement e)
//
// (C) 2003 Ximian, Inc (http://www.ximian.com)
// Portions (C) 2004 Motus Technologies Inc. (http://www.motus.com)
-// Copyright (C) 2004 Novell, Inc (http://www.novell.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
using System.Globalization;
using System.Security.Permissions;
+using System.Runtime.InteropServices;
using Mono.Security;
namespace System.Security.Policy {
- [Serializable]
- public sealed class Site: IIdentityPermissionFactory, IBuiltInEvidence {
+ [Serializable]
+#if NET_2_0
+ [ComVisible (true)]
+#endif
+ public sealed class Site: IIdentityPermissionFactory, IBuiltInEvidence {
internal string origin_site;
continue;
foreach (char c in part) {
int x = Convert.ToInt32 (c);
+#if NET_2_0
+ bool result = ((x == 33) || (x == 45) // !-
+ || (x >= 35 && x <= 41) // #$%&'()
+ || (x >= 48 && x <= 57) // 0-9
+ || (x >= 64 && x <= 90) // @,A-Z
+ || (x >= 94 && x <= 95) // ^_
+ || (x >= 97 && x <= 123) // a-z{
+ || (x >= 125 && x <= 126)); // }~
+#else
bool result = ((x == 45) // -
|| (x >= 47 && x <= 57) // /,0-9
|| (x >= 64 && x <= 90) // @,A-Z
|| (x == 95) // _
|| (x >= 97 && x <= 122)); // a-z
+#endif
if (!result)
return false;
}
// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) 2004 Motus Technologies Inc. (http://www.motus.com)
-// Copyright (C) 2004 Novell, Inc (http://www.novell.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
using System.Collections;
using System.Globalization;
+using System.Runtime.InteropServices;
namespace System.Security.Policy {
[Serializable]
+#if NET_2_0
+ [ComVisible (true)]
+#endif
public sealed class SiteMembershipCondition : IMembershipCondition, IConstantMembershipCondition {
private readonly int version = 1;
// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) 2002 Motus Technologies Inc. (http://www.motus.com)
-// Copyright (C) 2004 Novell, Inc (http://www.novell.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
//
using System.Security.Permissions;
+using System.Runtime.InteropServices;
namespace System.Security.Policy {
[Serializable]
+#if NET_2_0
+[ComVisible (true)]
+#endif
public sealed class StrongName : IIdentityPermissionFactory, IBuiltInEvidence {
private StrongNamePublicKeyBlob publickey;
// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) 2003 Duncan Mak, Ximian Inc.
-// Copyright (C) 2004 Novell, Inc (http://www.novell.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
using System.Globalization;
using System.Security.Permissions;
+using System.Runtime.InteropServices;
namespace System.Security.Policy {
[Serializable]
+#if NET_2_0
+ [ComVisible (true)]
+#endif
public sealed class StrongNameMembershipCondition : IMembershipCondition, IConstantMembershipCondition {
private readonly int version = 1;
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.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
#if NET_2_0
-using System;
using System.Collections;
+using System.Runtime.InteropServices;
namespace System.Security.Policy {
+ [ComVisible (true)]
public class TrustManagerContext {
- private bool _debug;
private bool _ignorePersistedDecision;
private bool _noPrompt;
private bool _keepAlive;
private bool _persist;
+ private ApplicationIdentity _previousId;
private TrustManagerUIContext _ui;
[MonoTODO]
public TrustManagerContext (TrustManagerUIContext uiContext)
{
- _debug = false;
_ignorePersistedDecision = false;
_noPrompt = false;
_keepAlive = false;
_ui = uiContext;
}
- public bool Debug {
- get { return _debug; }
- set { _debug = value; }
- }
-
- public bool IgnorePersistedDecision {
+ public virtual bool IgnorePersistedDecision {
get { return _ignorePersistedDecision; }
set { _ignorePersistedDecision = value; }
}
- public bool NoPrompt {
- get { return _noPrompt; }
- set { _noPrompt = value; }
- }
-
- public bool KeepAlive {
+ public virtual bool KeepAlive {
get { return _keepAlive; }
set { _keepAlive = value; }
}
- public bool Persist {
+ public virtual bool NoPrompt {
+ get { return _noPrompt; }
+ set { _noPrompt = value; }
+ }
+
+ public virtual bool Persist {
get { return _persist; }
set { _persist = value; }
}
- public TrustManagerUIContext UIContext {
+ public virtual ApplicationIdentity PreviousApplicationIdentity {
+ get { return _previousId; }
+ set { _previousId = value; }
+ }
+
+ public virtual TrustManagerUIContext UIContext {
get { return _ui; }
set { _ui = value; }
}
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.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
#if NET_2_0
-using System;
-using System.Collections;
+using System.Runtime.InteropServices;
namespace System.Security.Policy {
- [Serializable]
+ [ComVisible (true)]
public enum TrustManagerUIContext {
Install,
Upgrade,
// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) 2003 Ximian, Inc (http://www.ximian.com)
-// Copyright (C) 2004 Novell, Inc (http://www.novell.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
using System.Globalization;
using System.Security.Permissions;
+using System.Runtime.InteropServices;
namespace System.Security.Policy {
[Serializable]
+#if NET_2_0
+ [ComVisible (true)]
+#endif
public sealed class UnionCodeGroup : CodeGroup {
public UnionCodeGroup (IMembershipCondition membershipCondition, PolicyStatement policyStatement)
//
// (C) 2003 Ximian, Inc (http://www.ximian.com)
// (C) 2004 Motus Technologies Inc. (http://www.motus.com)
-// Copyright (C) 2004 Novell, Inc (http://www.novell.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
//
using System.Globalization;
+using System.Runtime.InteropServices;
using System.Security.Permissions;
using Mono.Security;
namespace System.Security.Policy {
- [Serializable]
+ [Serializable]
+#if NET_2_0
+ [ComVisible (true)]
+#endif
public sealed class Url: IIdentityPermissionFactory, IBuiltInEvidence {
private string origin_url;
public override bool Equals (object o)
{
- if (o is System.Security.Policy.Url)
- return (String.Compare (((Url) o).Value, Value, true, CultureInfo.InvariantCulture) == 0);
- return false;
+ Url u = (o as System.Security.Policy.Url);
+ if (u == null)
+ return false;
+
+ string url1 = u.Value;
+ string url2 = origin_url;
+#if NET_2_0
+ if (url1.IndexOf (Uri.SchemeDelimiter) < 0)
+ url1 = "file://" + url1;
+ if (url2.IndexOf (Uri.SchemeDelimiter) < 0)
+ url2 = "file://" + url2;
+#endif
+ return (String.Compare (url1, url2, true, CultureInfo.InvariantCulture) == 0);
}
public override int GetHashCode ()
{
- return origin_url.GetHashCode ();
+ string s = origin_url;
+#if NET_2_0
+ if (s.IndexOf (Uri.SchemeDelimiter) < 0)
+ s = "file://" + s;
+#endif
+ return s.GetHashCode ();
}
public override string ToString ()
}
// internal
+#if NET_2_0
+ private string Prepare (string url)
+ {
+ if (url == null)
+ throw new ArgumentNullException ("Url");
+ if (url == String.Empty)
+ throw new FormatException (Locale.GetText ("Invalid (empty) Url"));
- internal string Prepare (string url)
+ int protocolPos = url.IndexOf (Uri.SchemeDelimiter); // '://'
+ if (protocolPos > 0) {
+ if (url.StartsWith ("file://")) {
+ // convert file url into uppercase
+ url = "file://" + url.Substring (7);
+ }
+ // don't escape and don't reduce (e.g. '.' and '..')
+ Uri uri = new Uri (url, false, false);
+ url = uri.ToString ();
+ }
+
+ int lastpos = url.Length - 1;
+ if (url [lastpos] == '/')
+ url = url.Substring (0, lastpos);
+
+ return url;
+ }
+#else
+ private string Prepare (string url)
{
if (url == null)
throw new ArgumentNullException ("Url");
if (url == String.Empty)
throw new FormatException (Locale.GetText ("Invalid (empty) Url"));
- // is a protocol specified
int protocolPos = url.IndexOf (Uri.SchemeDelimiter); // '://'
if (protocolPos > 0) {
if (url.StartsWith ("file://")) {
// convert file url into uppercase
url = "file://" + url.Substring (7).ToUpperInvariant ();
- }
- else {
+ } else {
// add a trailing slash if none (lonely one) is present
if (url.LastIndexOf ("/") == protocolPos + 2)
url += "/";
}
- }
- else {
+ } else {
// add file scheme (default) and convert url to uppercase
url = "file://" + url.ToUpperInvariant ();
}
return url;
}
+#endif
}
}
//
// (C) 2003, Ximian Inc.
// (C) 2004 Motus Technologies Inc. (http://www.motus.com)
-// Copyright (C) 2004 Novell, Inc (http://www.novell.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
using System.Collections;
using System.Globalization;
+using System.Runtime.InteropServices;
+
+using Mono.Security;
namespace System.Security.Policy {
[Serializable]
- public sealed class UrlMembershipCondition : IMembershipCondition, IConstantMembershipCondition {
+#if NET_2_0
+ [ComVisible (true)]
+#endif
+ public sealed class UrlMembershipCondition : IMembershipCondition, IConstantMembershipCondition {
private readonly int version = 1;
private Url url;
+ private string userUrl;
public UrlMembershipCondition (string url)
{
+ if (url == null)
+ throw new ArgumentNullException ("url");
+#if NET_2_0
+ CheckUrl (url);
+ userUrl = url;
+ this.url = new Url (url);
+#else
this.url = new Url (url);
+ userUrl = this.url.Value;
+#endif
}
- internal UrlMembershipCondition (Url url)
+ internal UrlMembershipCondition (Url url, string userUrl)
{
// as the Url object has already been validated there's no
// need to restart the whole process by converting to string
this.url = (Url) url.Copy ();
+ this.userUrl = userUrl;
}
// properties
public string Url {
- get { return url.Value; }
+ get {
+ if (userUrl == null)
+ userUrl = url.Value;
+ return userUrl;
+ }
set { url = new Url (value); }
}
public IMembershipCondition Copy ()
{
- return new UrlMembershipCondition (url);
+ return new UrlMembershipCondition (url, userUrl);
}
public override bool Equals (object o)
{
- if (o is UrlMembershipCondition) {
- string u = url.Value;
- int wildcard = u.LastIndexOf ("*"); // partial match with a wildcard at the end
- if (wildcard == -1)
- wildcard = u.Length; // exact match
-
- return (String.Compare (u, 0, (o as UrlMembershipCondition).Url,
- 0, wildcard, true, CultureInfo.InvariantCulture) == 0);
+ UrlMembershipCondition umc = (o as UrlMembershipCondition);
+ if (o == null)
+ return false;
+
+ string u = url.Value;
+ int length = u.Length; // exact match
+
+ // partial match with a wildcard at the end
+ if (u [length - 1] == '*') {
+ length--;
+ // in this case the last / could be ommited
+ if (u [length - 1] == '/')
+ length--;
}
- return false;
+
+ return (String.Compare (u, 0, umc.Url, 0, length, true, CultureInfo.InvariantCulture) == 0);
}
public void FromXml (SecurityElement element)
MembershipConditionHelper.CheckSecurityElement (element, "element", version, version);
string u = element.Attribute ("Url");
+#if NET_2_0
+ if (u != null) {
+ CheckUrl (u);
+ url = new Url (u);
+ } else {
+ url = null;
+ }
+#else
url = (u == null) ? null : new Url (u);
+#endif
+ userUrl = u;
}
public override int GetHashCode ()
public override string ToString ()
{
- return "Url - " + url.Value;
+ return "Url - " + Url;
}
public SecurityElement ToXml ()
{
// PolicyLevel isn't used as there's no need to resolve NamedPermissionSet references
SecurityElement se = MembershipConditionHelper.Element (typeof (UrlMembershipCondition), version);
- se.AddAttribute ("Url", url.Value);
+ se.AddAttribute ("Url", userUrl);
return se;
}
+
+ // internal stuff
+
+#if NET_2_0
+ internal void CheckUrl (string url)
+ {
+ // In .NET 1.x Url class checked the validity of the
+ // URL but that's no more the case in 2.x - but we
+ // still need the check done here
+ int protocolPos = url.IndexOf (Uri.SchemeDelimiter);
+ string u = (protocolPos < 0) ? "file://" + url : url;
+
+ Uri uri = new Uri (u, false, false);
+ // no * except for the "lone star" case
+ if (uri.Host.IndexOf ('*') >= 1) {
+ string msg = Locale.GetText ("Invalid * character in url");
+ throw new ArgumentException (msg, "name");
+ }
+ }
+#endif
}
}
// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) 2002 Ximian, Inc (http://www.ximian.com)
-// Copyright (C) 2004 Novell, Inc (http://www.novell.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
using System.IO;
using System.Globalization;
using System.Security.Permissions;
+using System.Runtime.InteropServices;
using Mono.Security;
namespace System.Security.Policy {
[Serializable]
+#if NET_2_0
+ [ComVisible (true)]
+#endif
public sealed class Zone : IIdentityPermissionFactory, IBuiltInEvidence {
- SecurityZone zone;
+
+ private SecurityZone zone;
public Zone (SecurityZone zone)
{
public override bool Equals (object o)
{
- if (!(o is Zone))
+ Zone z = (o as Zone);
+ if (z == null)
return false;
- return (((Zone) o).zone == zone);
+ return (z.zone == zone);
}
public override int GetHashCode ()
return 3;
}
- int IBuiltInEvidence.InitFromBuffer (char [] buffer, int position) {
+ int IBuiltInEvidence.InitFromBuffer (char [] buffer, int position)
+ {
int new_zone = (int) buffer [position++];
new_zone += buffer [position++];
return position;
}
}
}
-
// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) 2003, Ximian Inc.
-// Copyright (C) 2004 Novell, Inc (http://www.novell.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
using System.Collections;
using System.Globalization;
+using System.Runtime.InteropServices;
namespace System.Security.Policy {
[Serializable]
- public sealed class ZoneMembershipCondition : IMembershipCondition, IConstantMembershipCondition {
+#if NET_2_0
+ [ComVisible (true)]
+#endif
+ public sealed class ZoneMembershipCondition : IMembershipCondition, IConstantMembershipCondition {
private readonly int version = 1;