2 // System.Security.AccessControl.CommonObjectSecurity implementation
5 // Dick Porter <dick@ximian.com>
6 // Atsushi Enomoto <atsushi@ximian.com>
8 // Copyright (C) 2005-2007 Novell, Inc (http://www.novell.com)
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 using System.Collections.Generic;
33 namespace System.Security.AccessControl {
35 [MonoTODO ("required for NativeObjectSecurity - implementation is missing")]
36 public abstract class CommonObjectSecurity : ObjectSecurity {
38 protected CommonObjectSecurity (bool isContainer)
39 : base (isContainer, false)
43 List<AccessRule> access_rules = new List<AccessRule> ();
44 List<AuditRule> audit_rules = new List<AuditRule> ();
46 public AuthorizationRuleCollection GetAccessRules (bool includeExplicit, bool includeInherited, Type targetType)
48 throw new NotImplementedException ();
51 public AuthorizationRuleCollection GetAuditRules (bool includeExplicit, bool includeInherited, Type targetType)
53 throw new NotImplementedException ();
58 protected void AddAccessRule (AccessRule rule)
60 access_rules.Add (rule);
61 AccessRulesModified = true;
64 protected bool RemoveAccessRule (AccessRule rule)
66 throw new NotImplementedException ();
69 protected void RemoveAccessRuleAll (AccessRule rule)
71 throw new NotImplementedException ();
74 protected void RemoveAccessRuleSpecific (AccessRule rule)
76 throw new NotImplementedException ();
79 protected void ResetAccessRule (AccessRule rule)
81 throw new NotImplementedException ();
84 protected void SetAccessRule (AccessRule rule)
86 throw new NotImplementedException ();
89 protected override bool ModifyAccess (AccessControlModification modification, AccessRule rule, out bool modified)
91 foreach (AccessRule r in access_rules) {
94 switch (modification) {
95 case AccessControlModification.Add:
98 case AccessControlModification.Set:
101 case AccessControlModification.Reset:
102 ResetAccessRule (rule);
104 case AccessControlModification.Remove:
105 RemoveAccessRule (rule);
107 case AccessControlModification.RemoveAll:
108 RemoveAccessRuleAll (rule);
110 case AccessControlModification.RemoveSpecific:
111 RemoveAccessRuleSpecific (rule);
123 protected void AddAuditRule (AuditRule rule)
125 audit_rules.Add (rule);
126 AuditRulesModified = true;
129 protected bool RemoveAuditRule (AuditRule rule)
131 throw new NotImplementedException ();
134 protected void RemoveAuditRuleAll (AuditRule rule)
136 throw new NotImplementedException ();
139 protected void RemoveAuditRuleSpecific (AuditRule rule)
141 throw new NotImplementedException ();
144 protected void SetAuditRule (AuditRule rule)
146 throw new NotImplementedException ();
149 protected override bool ModifyAudit (AccessControlModification modification, AuditRule rule, out bool modified)
151 foreach (AuditRule r in audit_rules) {
154 switch (modification) {
155 case AccessControlModification.Add:
158 case AccessControlModification.Set:
161 //case AccessControlModification.Reset:
162 // ResetAuditRule (rule);
164 case AccessControlModification.Remove:
165 RemoveAuditRule (rule);
167 case AccessControlModification.RemoveAll:
168 RemoveAuditRuleAll (rule);
170 case AccessControlModification.RemoveSpecific:
171 RemoveAuditRuleSpecific (rule);
174 AuditRulesModified = true;