2 // System.Security.NamedPermissionSet
5 // Dan Lewis (dihlewis@yahoo.co.uk)
6 // Sebastien Pouliot (spouliot@motus.com)
9 // Portions (C) 2003, 2004 Motus Technologies Inc. (http://www.motus.com)
13 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
15 // Permission is hereby granted, free of charge, to any person obtaining
16 // a copy of this software and associated documentation files (the
17 // "Software"), to deal in the Software without restriction, including
18 // without limitation the rights to use, copy, modify, merge, publish,
19 // distribute, sublicense, and/or sell copies of the Software, and to
20 // permit persons to whom the Software is furnished to do so, subject to
21 // the following conditions:
23 // The above copyright notice and this permission notice shall be
24 // included in all copies or substantial portions of the Software.
26 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
29 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
30 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
31 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
32 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
38 // Permission is hereby granted, free of charge, to any person obtaining
39 // a copy of this software and associated documentation files (the
40 // "Software"), to deal in the Software without restriction, including
41 // without limitation the rights to use, copy, modify, merge, publish,
42 // distribute, sublicense, and/or sell copies of the Software, and to
43 // permit persons to whom the Software is furnished to do so, subject to
44 // the following conditions:
46 // The above copyright notice and this permission notice shall be
47 // included in all copies or substantial portions of the Software.
49 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
50 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
51 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
52 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
53 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
54 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
55 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
59 using System.Security.Permissions;
61 namespace System.Security {
64 public sealed class NamedPermissionSet : PermissionSet {
66 // for PolicyLevel (to avoid validation duplication)
67 internal NamedPermissionSet () : base () {}
69 public NamedPermissionSet (string name, PermissionSet set) : base (set)
74 public NamedPermissionSet (string name, PermissionState state) : base (state)
79 public NamedPermissionSet (NamedPermissionSet set) : this (set.name, set) {}
81 public NamedPermissionSet (string name) : this (name, PermissionState.None) {}
85 public string Description {
86 get { return description; }
87 set { description = value; }
93 if ((value == null) || (value == String.Empty))
94 throw new ArgumentException ("invalid name");
99 public override PermissionSet Copy ()
101 return new NamedPermissionSet (this);
104 public NamedPermissionSet Copy (string name)
106 NamedPermissionSet nps = new NamedPermissionSet (this);
111 public override void FromXml (SecurityElement e)
113 FromXml (e, "NamedPermissionSet");
114 Name = (e.Attributes ["Name"] as string);
115 description = (e.Attributes ["Description"] as string);
116 if (description == null)
117 description = String.Empty;
120 public override SecurityElement ToXml ()
122 SecurityElement se = base.ToXml ();
124 se.AddAttribute ("Name", name);
125 if (description != null)
126 se.AddAttribute ("Description", description);
133 private string description;