import typing, clr, abc
from System.Security.Principal import IdentityReference
from System.Collections import ReadOnlyCollectionBase
from System import Array_1

class AccessControlModification(typing.SupportsInt):
    @typing.overload
    def __init__(self, value : int) -> None: ...
    @typing.overload
    def __init__(self, value : int, force_if_true: bool) -> None: ...
    def __int__(self) -> int: ...
    
    # Values:
    Add : AccessControlModification # 0
    Set : AccessControlModification # 1
    Reset : AccessControlModification # 2
    Remove : AccessControlModification # 3
    RemoveAll : AccessControlModification # 4
    RemoveSpecific : AccessControlModification # 5


class AccessControlSections(typing.SupportsInt):
    @typing.overload
    def __init__(self, value : int) -> None: ...
    @typing.overload
    def __init__(self, value : int, force_if_true: bool) -> None: ...
    def __int__(self) -> int: ...
    
    # Values:
    None_ : AccessControlSections # 0
    Audit : AccessControlSections # 1
    Access : AccessControlSections # 2
    Owner : AccessControlSections # 4
    Group : AccessControlSections # 8
    All : AccessControlSections # 15


class AccessControlType(typing.SupportsInt):
    @typing.overload
    def __init__(self, value : int) -> None: ...
    @typing.overload
    def __init__(self, value : int, force_if_true: bool) -> None: ...
    def __int__(self) -> int: ...
    
    # Values:
    Allow : AccessControlType # 0
    Deny : AccessControlType # 1


class AccessRule(AuthorizationRule):
    @property
    def AccessControlType(self) -> AccessControlType: ...
    @property
    def IdentityReference(self) -> IdentityReference: ...
    @property
    def InheritanceFlags(self) -> InheritanceFlags: ...
    @property
    def IsInherited(self) -> bool: ...
    @property
    def PropagationFlags(self) -> PropagationFlags: ...


class AuditFlags(typing.SupportsInt):
    @typing.overload
    def __init__(self, value : int) -> None: ...
    @typing.overload
    def __init__(self, value : int, force_if_true: bool) -> None: ...
    def __int__(self) -> int: ...
    
    # Values:
    None_ : AuditFlags # 0
    Success : AuditFlags # 1
    Failure : AuditFlags # 2


class AuditRule(AuthorizationRule):
    @property
    def AuditFlags(self) -> AuditFlags: ...
    @property
    def IdentityReference(self) -> IdentityReference: ...
    @property
    def InheritanceFlags(self) -> InheritanceFlags: ...
    @property
    def IsInherited(self) -> bool: ...
    @property
    def PropagationFlags(self) -> PropagationFlags: ...


class AuthorizationRule(abc.ABC):
    @property
    def IdentityReference(self) -> IdentityReference: ...
    @property
    def InheritanceFlags(self) -> InheritanceFlags: ...
    @property
    def IsInherited(self) -> bool: ...
    @property
    def PropagationFlags(self) -> PropagationFlags: ...


class AuthorizationRuleCollection(ReadOnlyCollectionBase):
    def __init__(self) -> None: ...
    @property
    def Count(self) -> int: ...
    @property
    def Item(self) -> AuthorizationRule: ...
    def AddRule(self, rule: AuthorizationRule) -> None: ...
    def CopyTo(self, rules: Array_1[AuthorizationRule], index: int) -> None: ...


class CommonObjectSecurity(ObjectSecurity):
    @property
    def AccessRightType(self) -> typing.Type[typing.Any]: ...
    @property
    def AccessRuleType(self) -> typing.Type[typing.Any]: ...
    @property
    def AreAccessRulesCanonical(self) -> bool: ...
    @property
    def AreAccessRulesProtected(self) -> bool: ...
    @property
    def AreAuditRulesCanonical(self) -> bool: ...
    @property
    def AreAuditRulesProtected(self) -> bool: ...
    @property
    def AuditRuleType(self) -> typing.Type[typing.Any]: ...
    def GetAccessRules(self, includeExplicit: bool, includeInherited: bool, targetType: typing.Type[typing.Any]) -> AuthorizationRuleCollection: ...
    def GetAuditRules(self, includeExplicit: bool, includeInherited: bool, targetType: typing.Type[typing.Any]) -> AuthorizationRuleCollection: ...


class InheritanceFlags(typing.SupportsInt):
    @typing.overload
    def __init__(self, value : int) -> None: ...
    @typing.overload
    def __init__(self, value : int, force_if_true: bool) -> None: ...
    def __int__(self) -> int: ...
    
    # Values:
    None_ : InheritanceFlags # 0
    ContainerInherit : InheritanceFlags # 1
    ObjectInherit : InheritanceFlags # 2


class NativeObjectSecurity(CommonObjectSecurity):
    @property
    def AccessRightType(self) -> typing.Type[typing.Any]: ...
    @property
    def AccessRuleType(self) -> typing.Type[typing.Any]: ...
    @property
    def AreAccessRulesCanonical(self) -> bool: ...
    @property
    def AreAccessRulesProtected(self) -> bool: ...
    @property
    def AreAuditRulesCanonical(self) -> bool: ...
    @property
    def AreAuditRulesProtected(self) -> bool: ...
    @property
    def AuditRuleType(self) -> typing.Type[typing.Any]: ...


class ObjectSecurity(abc.ABC):
    @property
    def AccessRightType(self) -> typing.Type[typing.Any]: ...
    @property
    def AccessRuleType(self) -> typing.Type[typing.Any]: ...
    @property
    def AreAccessRulesCanonical(self) -> bool: ...
    @property
    def AreAccessRulesProtected(self) -> bool: ...
    @property
    def AreAuditRulesCanonical(self) -> bool: ...
    @property
    def AreAuditRulesProtected(self) -> bool: ...
    @property
    def AuditRuleType(self) -> typing.Type[typing.Any]: ...
    @abc.abstractmethod
    def AccessRuleFactory(self, identityReference: IdentityReference, accessMask: int, isInherited: bool, inheritanceFlags: InheritanceFlags, propagationFlags: PropagationFlags, type: AccessControlType) -> AccessRule: ...
    @abc.abstractmethod
    def AuditRuleFactory(self, identityReference: IdentityReference, accessMask: int, isInherited: bool, inheritanceFlags: InheritanceFlags, propagationFlags: PropagationFlags, flags: AuditFlags) -> AuditRule: ...
    def GetGroup(self, targetType: typing.Type[typing.Any]) -> IdentityReference: ...
    def GetOwner(self, targetType: typing.Type[typing.Any]) -> IdentityReference: ...
    def GetSecurityDescriptorBinaryForm(self) -> Array_1[int]: ...
    def GetSecurityDescriptorSddlForm(self, includeSections: AccessControlSections) -> str: ...
    @staticmethod
    def IsSddlConversionSupported() -> bool: ...
    def ModifyAccessRule(self, modification: AccessControlModification, rule: AccessRule, modified: clr.Reference[bool]) -> bool: ...
    def ModifyAuditRule(self, modification: AccessControlModification, rule: AuditRule, modified: clr.Reference[bool]) -> bool: ...
    def PurgeAccessRules(self, identity: IdentityReference) -> None: ...
    def PurgeAuditRules(self, identity: IdentityReference) -> None: ...
    def SetAccessRuleProtection(self, isProtected: bool, preserveInheritance: bool) -> None: ...
    def SetAuditRuleProtection(self, isProtected: bool, preserveInheritance: bool) -> None: ...
    def SetGroup(self, identity: IdentityReference) -> None: ...
    def SetOwner(self, identity: IdentityReference) -> None: ...
    # Skipped SetSecurityDescriptorBinaryForm due to it being static, abstract and generic.

    SetSecurityDescriptorBinaryForm : SetSecurityDescriptorBinaryForm_MethodGroup
    class SetSecurityDescriptorBinaryForm_MethodGroup:
        @typing.overload
        def __call__(self, binaryForm: Array_1[int]) -> None:...
        @typing.overload
        def __call__(self, binaryForm: Array_1[int], includeSections: AccessControlSections) -> None:...

    # Skipped SetSecurityDescriptorSddlForm due to it being static, abstract and generic.

    SetSecurityDescriptorSddlForm : SetSecurityDescriptorSddlForm_MethodGroup
    class SetSecurityDescriptorSddlForm_MethodGroup:
        @typing.overload
        def __call__(self, sddlForm: str) -> None:...
        @typing.overload
        def __call__(self, sddlForm: str, includeSections: AccessControlSections) -> None:...



class PropagationFlags(typing.SupportsInt):
    @typing.overload
    def __init__(self, value : int) -> None: ...
    @typing.overload
    def __init__(self, value : int, force_if_true: bool) -> None: ...
    def __int__(self) -> int: ...
    
    # Values:
    None_ : PropagationFlags # 0
    NoPropagateInherit : PropagationFlags # 1
    InheritOnly : PropagationFlags # 2

