mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-18 17:02:10 -10:00
Details worth being aware of, that aren't well documented in MS.NET:
(1) The Rights property is just a casted AccessMask.
I've checked this by testing with MS.NET -- if you use AccessRule<Test>
with an arbitrary struct Test { }, MS.NET has an InvalidCastException
on the Rights getter if you create with ObjectSecurity's factory method
(which is passed an int), and in the constructor if you use AccessRule's
constructor.
(2) The string constructor overloads call 'new NTAccount(identity)'.
What these methods do for AccessRule is not documented by MS.NET,
but this *is* documented for SemaphoreAccessRule, and my testing
with C# shows AccessRule does the same thing. So, I've implemented
this behavior to match.
I will submit a separate patch afterwards to make AuthorizationRule's
accept NTAccount, which is required for the string overloads to work.
Contrary to the MS.NET *documentation* (which Mono follows), AuthorizationRule
actually accepts NTAccount as well as (the documented) SecurityIdentifier.
I verified this by deriving a class from AuthorizationRule.
71 lines
2.4 KiB
C#
71 lines
2.4 KiB
C#
// System.Security.AccessControl.AccessRule<T>
|
|
//
|
|
// Copyright 2012 James F. Bellinger
|
|
//
|
|
// Permission is hereby granted, free of charge, to any person obtaining
|
|
// a copy of this software and associated documentation files (the
|
|
// "Software"), to deal in the Software without restriction, including
|
|
// without limitation the rights to use, copy, modify, merge, publish,
|
|
// distribute, sublicense, and/or sell copies of the Software, and to
|
|
// permit persons to whom the Software is furnished to do so, subject to
|
|
// the following conditions:
|
|
//
|
|
// The above copyright notice and this permission notice shall be
|
|
// included in all copies or substantial portions of the Software.
|
|
//
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
#if NET_4_0
|
|
|
|
using System;
|
|
using System.Security.Principal;
|
|
|
|
namespace System.Security.AccessControl
|
|
{
|
|
public class AccessRule<T> : AccessRule where T : struct
|
|
{
|
|
public AccessRule (string identity, T rights, AccessControlType type)
|
|
: this (new NTAccount (identity), rights, type)
|
|
{
|
|
|
|
}
|
|
|
|
public AccessRule (IdentityReference identity, T rights, AccessControlType type)
|
|
: this (identity, rights, InheritanceFlags.None, PropagationFlags.None, type)
|
|
{
|
|
|
|
}
|
|
|
|
public AccessRule (string identity, T rights, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, AccessControlType type)
|
|
: this (new NTAccount (identity), rights, inheritanceFlags, propagationFlags, type)
|
|
{
|
|
|
|
}
|
|
|
|
public AccessRule (IdentityReference identity, T rights, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, AccessControlType type)
|
|
: this (identity, (int)(object)rights, false, inheritanceFlags, propagationFlags, type)
|
|
{
|
|
|
|
}
|
|
|
|
internal AccessRule (IdentityReference identity, int rights, bool isInherited, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, AccessControlType type)
|
|
: base (identity, rights, isInherited, inheritanceFlags, propagationFlags, type)
|
|
{
|
|
|
|
}
|
|
|
|
public T Rights {
|
|
get { return (T)(object)AccessMask; }
|
|
}
|
|
}
|
|
}
|
|
|
|
#endif
|
|
|