2 // System.Security.Policy.PermissionRequestEvidence.cs
\r
5 // Nick Drochak (ndrochak@gol.com)
\r
7 // (C) 2003 Nick Drochak
\r
11 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
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:
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
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.
33 using System.Security;
\r
36 namespace System.Security.Policy
\r
39 public sealed class PermissionRequestEvidence : IBuiltInEvidence {
\r
40 PermissionSet requested, optional, denied;
\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
49 public PermissionSet DeniedPermissions {
\r
50 get {return denied;}
\r
53 public PermissionSet OptionalPermissions {
\r
54 get {return optional;}
\r
57 public PermissionSet RequestedPermissions {
\r
58 get {return requested;}
\r
61 public PermissionRequestEvidence Copy ()
\r
63 return new PermissionRequestEvidence (requested, optional, denied);
\r
66 public override string ToString ()
\r
68 SecurityElement se = new SecurityElement ("System.Security.Policy.PermissionRequestEvidence");
\r
69 se.AddAttribute ("version", "1");
\r
71 if (requested != null) {
\r
72 SecurityElement requestElement = new SecurityElement ("Request");
\r
73 requestElement.AddChild (requested.ToXml ());
\r
74 se.AddChild (requestElement);
\r
76 if (optional != null) {
\r
77 SecurityElement optionalElement = new SecurityElement ("Optional");
\r
78 optionalElement.AddChild (optional.ToXml ());
\r
79 se.AddChild (optionalElement);
\r
81 if (denied != null) {
\r
82 SecurityElement deniedElement = new SecurityElement ("Denied");
\r
83 deniedElement.AddChild (denied.ToXml ());
\r
84 se.AddChild (deniedElement);
\r
86 return se.ToString ();
\r
89 // interface IBuiltInEvidence
\r
92 int IBuiltInEvidence.GetRequiredSize (bool verbose)
\r
98 int IBuiltInEvidence.InitFromBuffer (char [] buffer, int position)
\r
104 int IBuiltInEvidence.OutputToBuffer (char [] buffer, int position, bool verbose)
\r