This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum AclType | |
{ | |
User, | |
Group, | |
Other, | |
Mask | |
} | |
public enum AclScope | |
{ | |
Access, | |
Default | |
} | |
[FlagsAttribute] | |
public enum GrantType : short | |
{ | |
None = 0, | |
Read = 1, | |
Write = 2, | |
Execute = 4 | |
}; | |
public class AclEntry | |
{ | |
public AclEntry(AclScope scope, AclType type, string upnOrObjectId, GrantType grant) | |
{ | |
Scope = scope; | |
AclType = type; | |
UpnOrObjectId = upnOrObjectId; | |
Grant = grant; | |
} | |
public AclScope Scope { get; private set; } | |
public AclType AclType { get; private set; } | |
public string UpnOrObjectId { get; private set; } | |
public GrantType Grant { get; private set; } | |
public string GetGrantPosixFormat() | |
{ | |
return $"{(this.Grant.HasFlag(GrantType.Read) ? 'r' : '-')}{(this.Grant.HasFlag(GrantType.Write) ? 'w' : '-')}{(this.Grant.HasFlag(GrantType.Execute) ? 'x' : '-')}"; | |
} | |
public override string ToString() | |
{ | |
return $"{(this.Scope == AclScope.Default ? "default:" : string.Empty)}{this.AclType.ToString().ToLowerInvariant()}:{this.UpnOrObjectId}:{GetGrantPosixFormat()}"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment