Welcome to mirror list, hosted at ThFree Co, Russian Federation.

AllMembershipCondition.cs « System.Security.Policy « corlib « class « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 858ef857c00a3f3e1caec10407cb3baa90eadf23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//
// System.Security.Policy.AllMembershipCondition.cs
//
// Author:
//   Ajay kumar Dwivedi (adwiv@yahoo.com)
//

using System;
using System.Security;


namespace System.Security.Policy
{
	/// <summary>
	/// Summary description for AllMembershipCondition.
	/// </summary>
	[Serializable]
	public sealed class AllMembershipCondition : IMembershipCondition,
		ISecurityEncodable, ISecurityPolicyEncodable
	{
		// Tag for Xml Data
		private static readonly string XmlTag = "IMembershipCondition";

		public AllMembershipCondition()
		{}

		//Always returns true
		public bool Check(Evidence evidence)
		{
			return true;
		}

		public IMembershipCondition Copy()
		{
			return new AllMembershipCondition();
		}

		public override bool Equals(object o)
		{
			if(o is System.Security.Policy.AllMembershipCondition)
				return true;
			return false;
		}
 
		public void FromXml(SecurityElement e)
		{
			FromXml(e, null);
		}

		//Fixme: is there a need for all this????
		public void FromXml(SecurityElement e, PolicyLevel level)
		{
			if(e == null)
				throw new ArgumentNullException("e");
			if(e.Tag != XmlTag)
				throw new ArgumentException("e","The Tag of SecurityElement must be "
					+ AllMembershipCondition.XmlTag);
		}

		//What's the use of a hashcode here. Equals is always true.
		public override int GetHashCode()
		{
			return 0;
		}

		public override string ToString()
		{
			return "All Code";
		}

		public SecurityElement ToXml()
		{
			return ToXml(null);
		}

		public SecurityElement ToXml(PolicyLevel level)
		{
			SecurityElement se = new SecurityElement(XmlTag);
			Type type = this.GetType();
			string classString = type.FullName + ", " + type.Assembly;
			se.AddAttribute("class",classString);
			se.AddAttribute("version","1");
			return se;
		}
	}
}