mscorlib(4.0.0.0) API with additions
QualifiedAce.cs
3 
5 {
7  public abstract class QualifiedAce : KnownAce
8  {
9  private readonly bool _isCallback;
10 
11  private readonly AceQualifier _qualifier;
12 
13  private byte[] _opaque;
14 
17  public AceQualifier AceQualifier => _qualifier;
18 
22  public bool IsCallback => _isCallback;
23 
24  internal abstract int MaxOpaqueLengthInternal
25  {
26  get;
27  }
28 
31  public int OpaqueLength
32  {
33  get
34  {
35  if (_opaque != null)
36  {
37  return _opaque.Length;
38  }
39  return 0;
40  }
41  }
42 
43  private AceQualifier QualifierFromType(AceType type, out bool isCallback)
44  {
45  switch (type)
46  {
47  case AceType.AccessAllowed:
48  isCallback = false;
49  return AceQualifier.AccessAllowed;
50  case AceType.AccessDenied:
51  isCallback = false;
52  return AceQualifier.AccessDenied;
53  case AceType.SystemAudit:
54  isCallback = false;
55  return AceQualifier.SystemAudit;
56  case AceType.SystemAlarm:
57  isCallback = false;
58  return AceQualifier.SystemAlarm;
59  case AceType.AccessAllowedCallback:
60  isCallback = true;
61  return AceQualifier.AccessAllowed;
62  case AceType.AccessDeniedCallback:
63  isCallback = true;
64  return AceQualifier.AccessDenied;
65  case AceType.SystemAuditCallback:
66  isCallback = true;
67  return AceQualifier.SystemAudit;
68  case AceType.SystemAlarmCallback:
69  isCallback = true;
70  return AceQualifier.SystemAlarm;
71  case AceType.AccessAllowedObject:
72  isCallback = false;
73  return AceQualifier.AccessAllowed;
74  case AceType.AccessDeniedObject:
75  isCallback = false;
76  return AceQualifier.AccessDenied;
77  case AceType.SystemAuditObject:
78  isCallback = false;
79  return AceQualifier.SystemAudit;
80  case AceType.SystemAlarmObject:
81  isCallback = false;
82  return AceQualifier.SystemAlarm;
83  case AceType.AccessAllowedCallbackObject:
84  isCallback = true;
85  return AceQualifier.AccessAllowed;
86  case AceType.AccessDeniedCallbackObject:
87  isCallback = true;
88  return AceQualifier.AccessDenied;
89  case AceType.SystemAuditCallbackObject:
90  isCallback = true;
91  return AceQualifier.SystemAudit;
92  case AceType.SystemAlarmCallbackObject:
93  isCallback = true;
94  return AceQualifier.SystemAlarm;
95  default:
96  throw new SystemException();
97  }
98  }
99 
100  internal QualifiedAce(AceType type, AceFlags flags, int accessMask, SecurityIdentifier sid, byte[] opaque)
101  : base(type, flags, accessMask, sid)
102  {
103  _qualifier = QualifierFromType(type, out _isCallback);
104  SetOpaque(opaque);
105  }
106 
109  public byte[] GetOpaque()
110  {
111  return _opaque;
112  }
113 
116  public void SetOpaque(byte[] opaque)
117  {
118  if (opaque != null)
119  {
120  if (opaque.Length > MaxOpaqueLengthInternal)
121  {
122  throw new ArgumentOutOfRangeException("opaque", string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("ArgumentOutOfRange_ArrayLength"), 0, MaxOpaqueLengthInternal));
123  }
124  if (opaque.Length % 4 != 0)
125  {
126  throw new ArgumentOutOfRangeException("opaque", string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("ArgumentOutOfRange_ArrayLengthMultiple"), 4));
127  }
128  }
129  _opaque = opaque;
130  }
131  }
132 }
AceType AceType
Gets the type of this Access Control Entry (ACE).
Definition: GenericAce.cs:18
Serves as the base class for system exceptions namespace.
Definition: __Canon.cs:3
The exception that is thrown when the value of an argument is outside the allowable range of values a...
AceType
Defines the available access control entry (ACE) types.
Definition: AceType.cs:4
bool IsCallback
Specifies whether this T:System.Security.AccessControl.QualifiedAce object contains callback data.
Definition: QualifiedAce.cs:22
AceFlags AceFlags
Gets or sets the T:System.Security.AccessControl.AceFlags associated with this T:System....
Definition: GenericAce.cs:23
byte [] GetOpaque()
Returns the opaque callback data associated with this T:System.Security.AccessControl....
Provides information about, and means to manipulate, the current environment and platform....
Definition: Environment.cs:21
void SetOpaque(byte[] opaque)
Sets the opaque callback data associated with this T:System.Security.AccessControl....
Represents an Access Control Entry (ACE) that contains a qualifier. The qualifier,...
Definition: QualifiedAce.cs:7
static CultureInfo CurrentCulture
Gets or sets the T:System.Globalization.CultureInfo object that represents the culture used by the cu...
Definition: CultureInfo.cs:120
Encapsulates all Access Control Entry (ACE) types currently defined by Microsoft Corporation....
Definition: KnownAce.cs:6
AceQualifier
Specifies the function of an access control entry (ACE).
Definition: AceQualifier.cs:4
Represents a security identifier (SID) and provides marshaling and comparison operations for SIDs.
Provides information about a specific culture (called a locale for unmanaged code development)....
Definition: CultureInfo.cs:16
int OpaqueLength
Gets the length of the opaque callback data associated with this T:System.Security....
Definition: QualifiedAce.cs:32