2004-08-08 Sebastien Pouliot <sebastien@ximian.com>
[mono.git] / mcs / class / corlib / System.Security.Policy / PermissionRequestEvidence.cs
1 //\r
2 // System.Security.Policy.PermissionRequestEvidence.cs\r
3 //\r
4 // Authors:\r
5 //      Nick Drochak (ndrochak@gol.com)\r
6 //\r
7 // (C) 2003 Nick Drochak\r
8 //\r
9
10 //
11 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
12 //
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
20 // 
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
23 // 
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 //
32 \r
33 using System.Security;\r
34 using System.Text;\r
35 \r
36 namespace System.Security.Policy\r
37 {\r
38         [Serializable]\r
39         public sealed class PermissionRequestEvidence : IBuiltInEvidence {\r
40                 PermissionSet requested, optional, denied;\r
41 \r
42                 public PermissionRequestEvidence(PermissionSet requested, \r
43                                 PermissionSet optional, PermissionSet denied) {\r
44                         this.requested = requested;\r
45                         this.optional = optional;\r
46                         this.denied = denied;\r
47                 }\r
48 \r
49                 public PermissionSet DeniedPermissions {\r
50                         get {return denied;}\r
51                 }\r
52 \r
53                 public PermissionSet OptionalPermissions {\r
54                         get {return optional;}\r
55                 }\r
56 \r
57                 public PermissionSet RequestedPermissions {\r
58                         get {return requested;}\r
59                 }\r
60 \r
61                 public PermissionRequestEvidence Copy ()\r
62                 {\r
63                         return new PermissionRequestEvidence (requested, optional, denied);\r
64                 }\r
65 \r
66                 public override string ToString () \r
67                 {\r
68                         SecurityElement se = new SecurityElement ("System.Security.Policy.PermissionRequestEvidence");\r
69                         se.AddAttribute ("version", "1");\r
70 \r
71                         if (requested != null) {\r
72                                 SecurityElement requestElement = new SecurityElement ("Request");\r
73                                 requestElement.AddChild (requested.ToXml ());\r
74                                 se.AddChild (requestElement);\r
75                         }\r
76                         if (optional != null) {\r
77                                 SecurityElement optionalElement = new SecurityElement ("Optional");\r
78                                 optionalElement.AddChild (optional.ToXml ());\r
79                                 se.AddChild (optionalElement);\r
80                         }\r
81                         if (denied != null) {\r
82                                 SecurityElement deniedElement = new SecurityElement ("Denied");\r
83                                 deniedElement.AddChild (denied.ToXml ());\r
84                                 se.AddChild (deniedElement);\r
85                         }\r
86                         return se.ToString ();\r
87                 }\r
88 \r
89                 // interface IBuiltInEvidence\r
90 \r
91                 [MonoTODO]\r
92                 int IBuiltInEvidence.GetRequiredSize (bool verbose) \r
93                 {\r
94                         return 0;\r
95                 }\r
96 \r
97                 [MonoTODO]\r
98                 int IBuiltInEvidence.InitFromBuffer (char [] buffer, int position) \r
99                 {\r
100                         return 0;\r
101                 }\r
102 \r
103                 [MonoTODO]\r
104                 int IBuiltInEvidence.OutputToBuffer (char [] buffer, int position, bool verbose) \r
105                 {\r
106                         return 0;\r
107                 }\r
108 \r
109         }\r
110 }