13 private StringExpressionSet m_read;
15 private StringExpressionSet m_write;
17 private StringExpressionSet m_create;
19 [OptionalField(VersionAdded = 2)]
20 private StringExpressionSet m_viewAcl;
22 [OptionalField(VersionAdded = 2)]
23 private StringExpressionSet m_changeAcl;
25 private bool m_unrestricted;
35 m_unrestricted =
true;
38 m_unrestricted =
false;
61 m_unrestricted =
false;
72 m_unrestricted =
false;
90 m_unrestricted =
false;
116 [SecuritySafeCritical]
119 VerifyAccess(access);
124 m_read =
new StringExpressionSet();
126 m_read.AddExpressions(pathList);
132 m_write =
new StringExpressionSet();
134 m_write.AddExpressions(pathList);
138 if (m_create ==
null)
140 m_create =
new StringExpressionSet();
142 m_create.AddExpressions(pathList);
146 if (m_viewAcl ==
null)
148 m_viewAcl =
new StringExpressionSet();
150 m_viewAcl.AddExpressions(pathList);
154 if (m_changeAcl ==
null)
156 m_changeAcl =
new StringExpressionSet();
158 m_changeAcl.AddExpressions(pathList);
168 [SecuritySafeCritical]
171 VerifyAccess(access);
172 ExclusiveAccess(access);
179 return m_read.UnsafeToString();
187 return m_write.UnsafeToString();
191 if (m_create ==
null)
195 return m_create.UnsafeToString();
214 if ((access & (access - 1)) != 0)
216 throw new ArgumentException(Environment.GetResourceString(
"Arg_EnumNotSingleFlag"));
220 private bool IsEmpty()
222 if (!m_unrestricted && (m_read ==
null || m_read.IsEmpty()) && (m_write ==
null || m_write.IsEmpty()) && (m_create ==
null || m_create.IsEmpty()) && (m_viewAcl ==
null || m_viewAcl.IsEmpty()))
224 if (m_changeAcl !=
null)
226 return m_changeAcl.IsEmpty();
238 return m_unrestricted;
246 [SecuritySafeCritical]
254 if (registryPermission ==
null)
266 if ((m_read ==
null || m_read.IsSubsetOf(registryPermission.m_read)) && (m_write ==
null || m_write.IsSubsetOf(registryPermission.m_write)) && (m_create ==
null || m_create.IsSubsetOf(registryPermission.m_create)) && (m_viewAcl ==
null || m_viewAcl.IsSubsetOf(registryPermission.m_viewAcl)))
268 if (m_changeAcl !=
null)
270 return m_changeAcl.IsSubsetOf(registryPermission.m_changeAcl);
281 [SecuritySafeCritical]
288 if (!VerifyType(target))
294 return target.
Copy();
301 StringExpressionSet stringExpressionSet = (m_read ==
null) ?
null : m_read.Intersect(registryPermission.m_read);
302 StringExpressionSet stringExpressionSet2 = (m_write ==
null) ?
null : m_write.Intersect(registryPermission.m_write);
303 StringExpressionSet stringExpressionSet3 = (m_create ==
null) ?
null : m_create.Intersect(registryPermission.m_create);
304 StringExpressionSet stringExpressionSet4 = (m_viewAcl ==
null) ?
null : m_viewAcl.Intersect(registryPermission.m_viewAcl);
305 StringExpressionSet stringExpressionSet5 = (m_changeAcl ==
null) ?
null : m_changeAcl.Intersect(registryPermission.m_changeAcl);
306 if ((stringExpressionSet ==
null || stringExpressionSet.IsEmpty()) && (stringExpressionSet2 ==
null || stringExpressionSet2.IsEmpty()) && (stringExpressionSet3 ==
null || stringExpressionSet3.IsEmpty()) && (stringExpressionSet4 ==
null || stringExpressionSet4.IsEmpty()) && (stringExpressionSet5 ==
null || stringExpressionSet5.IsEmpty()))
311 registryPermission2.m_unrestricted =
false;
312 registryPermission2.m_read = stringExpressionSet;
313 registryPermission2.m_write = stringExpressionSet2;
314 registryPermission2.m_create = stringExpressionSet3;
315 registryPermission2.m_viewAcl = stringExpressionSet4;
316 registryPermission2.m_changeAcl = stringExpressionSet5;
317 return registryPermission2;
324 [SecuritySafeCritical]
331 if (!VerifyType(other))
340 StringExpressionSet stringExpressionSet = (m_read ==
null) ? registryPermission.m_read : m_read.Union(registryPermission.m_read);
341 StringExpressionSet stringExpressionSet2 = (m_write ==
null) ? registryPermission.m_write : m_write.Union(registryPermission.m_write);
342 StringExpressionSet stringExpressionSet3 = (m_create ==
null) ? registryPermission.m_create : m_create.Union(registryPermission.m_create);
343 StringExpressionSet stringExpressionSet4 = (m_viewAcl ==
null) ? registryPermission.m_viewAcl : m_viewAcl.Union(registryPermission.m_viewAcl);
344 StringExpressionSet stringExpressionSet5 = (m_changeAcl ==
null) ? registryPermission.m_changeAcl : m_changeAcl.Union(registryPermission.m_changeAcl);
345 if ((stringExpressionSet ==
null || stringExpressionSet.IsEmpty()) && (stringExpressionSet2 ==
null || stringExpressionSet2.IsEmpty()) && (stringExpressionSet3 ==
null || stringExpressionSet3.IsEmpty()) && (stringExpressionSet4 ==
null || stringExpressionSet4.IsEmpty()) && (stringExpressionSet5 ==
null || stringExpressionSet5.IsEmpty()))
350 registryPermission2.m_unrestricted =
false;
351 registryPermission2.m_read = stringExpressionSet;
352 registryPermission2.m_write = stringExpressionSet2;
353 registryPermission2.m_create = stringExpressionSet3;
354 registryPermission2.m_viewAcl = stringExpressionSet4;
355 registryPermission2.m_changeAcl = stringExpressionSet5;
356 return registryPermission2;
366 registryPermission.m_unrestricted =
true;
370 registryPermission.m_unrestricted =
false;
373 registryPermission.m_read = m_read.Copy();
377 registryPermission.m_write = m_write.Copy();
379 if (m_create !=
null)
381 registryPermission.m_create = m_create.Copy();
383 if (m_viewAcl !=
null)
385 registryPermission.m_viewAcl = m_viewAcl.Copy();
387 if (m_changeAcl !=
null)
389 registryPermission.m_changeAcl = m_changeAcl.Copy();
392 return registryPermission;
397 [SecuritySafeCritical]
403 if (m_read !=
null && !m_read.IsEmpty())
407 if (m_write !=
null && !m_write.IsEmpty())
411 if (m_create !=
null && !m_create.IsEmpty())
415 if (m_viewAcl !=
null && !m_viewAcl.IsEmpty())
419 if (m_changeAcl !=
null && !m_changeAcl.IsEmpty())
428 return securityElement;
438 if (XMLUtil.IsUnrestricted(esd))
440 m_unrestricted =
true;
443 m_unrestricted =
false;
449 string text = esd.Attribute(
"Read");
452 m_read =
new StringExpressionSet(text);
454 text = esd.Attribute(
"Write");
457 m_write =
new StringExpressionSet(text);
459 text = esd.Attribute(
"Create");
462 m_create =
new StringExpressionSet(text);
464 text = esd.Attribute(
"ViewAccessControl");
467 m_viewAcl =
new StringExpressionSet(text);
469 text = esd.Attribute(
"ChangeAccessControl");
472 m_changeAcl =
new StringExpressionSet(text);
476 int IBuiltInPermission.GetTokenIndex()
478 return GetTokenIndex();
481 internal static int GetTokenIndex()
Allows a permission to expose an unrestricted state.
override IPermission Intersect(IPermission target)
Creates and returns a permission that is the intersection of the current permission and the specified...
RegistryPermission(RegistryPermissionAccess access, AccessControlActions control, string pathList)
Initializes a new instance of the T:System.Security.Permissions.RegistryPermission class with the spe...
override void FromXml(SecurityElement esd)
Reconstructs a permission with a specified state from an XML encoding.
RegistryPermission(RegistryPermissionAccess access, string pathList)
Initializes a new instance of the T:System.Security.Permissions.RegistryPermission class with the spe...
Controls the ability to access registry variables. This class cannot be inherited.
void AddPathList(RegistryPermissionAccess access, AccessControlActions control, string pathList)
Adds access for the specified registry variables to the existing state of the permission,...
override SecurityElement ToXml()
Creates an XML encoding of the permission and its current state.
IPermission Copy()
Creates and returns an identical copy of the current permission.
static string Escape(string str)
Replaces invalid XML characters in a string with their valid XML equivalent.
Provides information about, and means to manipulate, the current environment and platform....
Represents the XML object model for encoding security objects. This class cannot be inherited.
override IPermission Union(IPermission other)
Creates a permission that is the union of the current permission and the specified permission.
Defines the underlying structure of all code access permissions.
override bool IsSubsetOf(IPermission target)
Determines whether the current permission is a subset of the specified permission.
RegistryPermission(PermissionState state)
Initializes a new instance of the T:System.Security.Permissions.RegistryPermission class with either ...
Defines methods implemented by permission types.
AccessControlActions
Specifies the actions that are permitted for securable objects.
bool IsUnrestricted()
Returns a value indicating whether the current permission is unrestricted.
string GetPathList(RegistryPermissionAccess access)
Gets paths for all registry variables with the specified T:System.Security.Permissions....
The exception that is thrown when one of the arguments provided to a method is not valid.
PermissionState
Specifies whether a permission should have all or no access to resources at creation.
void SetPathList(RegistryPermissionAccess access, string pathList)
Sets new access for the specified registry variable names to the existing state of the permission.
void AddPathList(RegistryPermissionAccess access, string pathList)
Adds access for the specified registry variables to the existing state of the permission.
void AddAttribute(string name, string value)
Adds a name/value attribute to an XML element.
Specifies that the class can be serialized.
override IPermission Copy()
Creates and returns an identical copy of the current permission.
RegistryPermissionAccess
Specifies the permitted access to registry keys and values.