/// <summary> /// Deseralizes an access control list string into a list of PathAccessControlEntries. /// </summary> /// <param name="s">The string to parse.</param> /// <returns>A List of <see cref="PathAccessControlItem"/>.</returns> public static IList <PathAccessControlItem> ParseAccessControlList(string s) { if (s == null) { return(null); } string[] strings = s.Split(','); List <PathAccessControlItem> accessControlList = new List <PathAccessControlItem>(); foreach (string entry in strings) { accessControlList.Add(PathAccessControlItem.Parse(entry)); } return(accessControlList); }
/// <summary> /// Parses the provided string into a <see cref="PathAccessControlItem"/> /// </summary> /// <param name="s">The string representation of the access control list.</param> /// <returns>A <see cref="PathAccessControlItem"/>.</returns> public static PathAccessControlItem Parse(string s) { if (s == null) { return(null); } PathAccessControlItem entry = new PathAccessControlItem(); string[] parts = s.Split(':'); int indexOffset = 0; if (parts.Length < 3 || parts.Length > 4) { throw DataLakeErrors.PathAccessControlItemStringInvalidLength(s); } if (parts.Length == 4) { if (!parts[0].Equals("default", StringComparison.OrdinalIgnoreCase)) { throw DataLakeErrors.PathAccessControlItemStringInvalidPrefix(s); } entry.DefaultScope = true; indexOffset = 1; } entry.AccessControlType = ParseAccesControlType(parts[indexOffset]); if (!string.IsNullOrEmpty(parts[1 + indexOffset])) { entry.EntityId = parts[1 + indexOffset]; } entry.Permissions = PathAccessControlExtensions.ParseSymbolicRolePermissions(parts[2 + indexOffset], false); return(entry); }