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.
30 using System
.Collections
.Generic
;
32 namespace System
.Security
.AccessControl
{
34 [MonoTODO ("required for NativeObjectSecurity - implementation is missing")]
35 public abstract class CommonObjectSecurity
: ObjectSecurity
{
37 protected CommonObjectSecurity (bool isContainer
)
38 : base (isContainer
, false)
42 List
<AccessRule
> access_rules
= new List
<AccessRule
> ();
43 List
<AuditRule
> audit_rules
= new List
<AuditRule
> ();
45 public AuthorizationRuleCollection
GetAccessRules (bool includeExplicit
, bool includeInherited
, Type targetType
)
47 throw new NotImplementedException ();
50 public AuthorizationRuleCollection
GetAuditRules (bool includeExplicit
, bool includeInherited
, Type targetType
)
52 throw new NotImplementedException ();
57 protected void AddAccessRule (AccessRule rule
)
59 access_rules
.Add (rule
);
60 AccessRulesModified
= true;
63 protected bool RemoveAccessRule (AccessRule rule
)
65 throw new NotImplementedException ();
68 protected void RemoveAccessRuleAll (AccessRule rule
)
70 throw new NotImplementedException ();
73 protected void RemoveAccessRuleSpecific (AccessRule rule
)
75 throw new NotImplementedException ();
78 protected void ResetAccessRule (AccessRule rule
)
80 throw new NotImplementedException ();
83 protected void SetAccessRule (AccessRule rule
)
85 throw new NotImplementedException ();
88 protected override bool ModifyAccess (AccessControlModification modification
, AccessRule rule
, out bool modified
)
90 foreach (AccessRule r
in access_rules
) {
93 switch (modification
) {
94 case AccessControlModification
.Add
:
97 case AccessControlModification
.Set
:
100 case AccessControlModification
.Reset
:
101 ResetAccessRule (rule
);
103 case AccessControlModification
.Remove
:
104 RemoveAccessRule (rule
);
106 case AccessControlModification
.RemoveAll
:
107 RemoveAccessRuleAll (rule
);
109 case AccessControlModification
.RemoveSpecific
:
110 RemoveAccessRuleSpecific (rule
);
122 protected void AddAuditRule (AuditRule rule
)
124 audit_rules
.Add (rule
);
125 AuditRulesModified
= true;
128 protected bool RemoveAuditRule (AuditRule rule
)
130 throw new NotImplementedException ();
133 protected void RemoveAuditRuleAll (AuditRule rule
)
135 throw new NotImplementedException ();
138 protected void RemoveAuditRuleSpecific (AuditRule rule
)
140 throw new NotImplementedException ();
143 protected void SetAuditRule (AuditRule rule
)
145 throw new NotImplementedException ();
148 protected override bool ModifyAudit (AccessControlModification modification
, AuditRule rule
, out bool modified
)
150 foreach (AuditRule r
in audit_rules
) {
153 switch (modification
) {
154 case AccessControlModification
.Add
:
157 case AccessControlModification
.Set
:
160 //case AccessControlModification.Reset:
161 // ResetAuditRule (rule);
163 case AccessControlModification
.Remove
:
164 RemoveAuditRule (rule
);
166 case AccessControlModification
.RemoveAll
:
167 RemoveAuditRuleAll (rule
);
169 case AccessControlModification
.RemoveSpecific
:
170 RemoveAuditRuleSpecific (rule
);
173 AuditRulesModified
= true;