/// <summary> /// Retrieves a particular principal as being the "owner" of the item. /// </summary> /// <remarks>Required by OS X.</remarks> /// <returns> /// Item that represents owner of this item and implements <see cref="IPrincipalAsync"/>. /// </returns> public async Task <IPrincipalAsync> GetOwnerAsync() { return(context.FileOperation( this, () => { FileSecurity acl = File.GetAccessControl(fileSystemInfo.FullName); return AclFactory.GetPrincipalFromSid(acl.GetOwner(typeof(SecurityIdentifier)).Value, context); }, Privilege.Read)); }
/// <summary> /// Creates <see cref="IHierarchyItemAsync"/> instance by path. /// </summary> /// <param name="path">Item relative path including query string.</param> /// <returns>Instance of corresponding <see cref="IHierarchyItemAsync"/> or null if item is not found.</returns> public override async Task <IHierarchyItemAsync> GetHierarchyItemAsync(string path) { path = path.Trim(new[] { ' ', '/' }); //remove query string. int ind = path.IndexOf('?'); if (ind > -1) { path = path.Remove(ind); } IHierarchyItemAsync item = null; // Return items from [DAVLocation]/acl/ folder and subfolders. item = await AclFactory.GetAclItemAsync(this, path); if (item != null) { return(item); } // Return items from [DAVLocation]/calendars/ folder and subfolders. item = CalDavFactory.GetCalDavItem(this, path); if (item != null) { return(item); } // Return folder that corresponds to [DAVLocation] path. If no DavLocation is defined in config file this is a website root. item = DavLocationFolder.GetDavLocationFolder(this, path); if (item != null) { return(item); } item = await DavFolder.GetFolderAsync(this, path); if (item != null) { return(item); } item = await DavFile.GetFileAsync(this, path); if (item != null) { return(item); } Logger.LogDebug("Could not find item that corresponds to path: " + path); return(null); // no hierarchy item that corresponds to path parameter was found in the repository }
/// <summary> /// Resolves path to instance of <see cref="IHierarchyItem"/>. /// This method is called by WebDAV engine to resolve paths it encounters /// in request. /// </summary> /// <param name="path">Relative path to the item including query string.</param> /// <returns><see cref="IHierarchyItem"/> instance if item is found, <c>null</c> otherwise.</returns> public override async Task <IHierarchyItemAsync> GetHierarchyItemAsync(string path) { path = path.Trim(new[] { ' ', '/' }); //remove query string. int ind = path.IndexOf('?'); if (ind > -1) { path = path.Remove(ind); } IHierarchyItemAsync item = null; // Return items from [DAVLocation]/acl/ folder and subfolders. item = await AclFactory.GetAclItemAsync(this, path); if (item != null) { return(item); } // Return items from [DAVLocation]/addressbooks/ folder and subfolders. item = await CardDavFactory.GetCardDavItemAsync(this, path); if (item != null) { return(item); } // Return folder that corresponds to [DAVLocation] path. If no DavLocation section is defined in web.config/app.config [DAVLocation] is a website root. string davLocation = DavLocationFolder.DavLocationFolderPath.Trim('/'); if (davLocation.Equals(path, StringComparison.InvariantCultureIgnoreCase)) { return(new DavLocationFolder(this)); } // Return any folders above [DAVLocation] path. // Root folder with ICalendarDiscovery/IAddressbookDiscovery implementation is required for calendars and address books discovery by CalDAV/CardDAV clients. // All other folders are returned just for folders structure browsing convenience using WebDAV clients during dev time, not required by CalDAV/CardDAV clients. if (davLocation.StartsWith(path, StringComparison.InvariantCultureIgnoreCase)) { int childFolderPathLength = (davLocation + "/").IndexOf('/', path.Length + 1); string childFolderPath = davLocation.Substring(0, childFolderPathLength); return(new LogicalFolder(this, path, new [] { new LogicalFolder(this, childFolderPath) })); } Logger.LogDebug("Could not find item that corresponds to path: " + path); return(null); // no hierarchy item that corresponds to path parameter was found in the repository }
/// <summary> /// Returns instance of <see cref="IPrincipalAsync"/> which represents current user. /// </summary> /// <returns>Current user.</returns> /// <remarks> /// This method is usually called by the Engine when CalDAV/CardDAV client /// is trying to discover current user URL. /// </remarks> public async Task <IPrincipalAsync> GetCurrentUserPrincipalAsync() { // Typically there is no need to load all user properties here, only current // user ID (or name) is required to form the user URL: [DAVLocation]/acl/users/[UserID] return(AclFactory.GetPrincipalFromSid(context.WindowsIdentity.User.Value, context)); }