public static bool TryGetObjectAccessControl(this StoragePermissions permissions, StorageActor actor, out ObjectAccessControl ac) { if (permissions == StoragePermissions.None) { ac = null; return(false); } ac = new ObjectAccessControl(); ac.Role = permissions == StoragePermissions.Read ? "READER" : "OWNER"; switch (actor.ActorType) { case StorageActorType.Authenticated: ac.Entity = "allAuthenticatedUsers"; break; case StorageActorType.Public: ac.Entity = "allUsers"; break; case StorageActorType.User: ac.Entity = $"user-{actor.Id}"; ac.EntityId = actor.Id; break; case StorageActorType.Group: ac.Entity = $"group-{actor.Id}"; ac.EntityId = actor.Id; break; default: ac = null; return(false); } return(true); }
private SharedAccessBlobPermissions GetBlobAccessPermissions(StoragePermissions storagePermissions) { SharedAccessBlobPermissions permissions = storagePermissionsMapping .Aggregate(SharedAccessBlobPermissions.None, (a, kvp) => (storagePermissions & kvp.Key) == kvp.Key ? a |= kvp.Value : a); return(permissions); }
private async Task<StorageToken> GetStorageToken(IMobileServiceClient client, MobileServiceFile file, StoragePermissions permissions) { var tokenRequest = new StorageTokenRequest(); tokenRequest.Permissions = permissions; tokenRequest.TargetFile = file; string route = string.Format("/tables/{0}/{1}/StorageToken", file.TableName, file.ParentId); return await this.client.InvokeApiAsync<StorageTokenRequest, StorageToken>(route, tokenRequest); }
public static FilePermissions FromOwnerPermissions(StoragePermissions sp) { var p = default(FilePermissions); if (sp.HasFlag(StoragePermissions.Read)) { p |= FilePermissions.S_IRUSR; } if (sp.HasFlag(StoragePermissions.Write)) { p |= FilePermissions.S_IWUSR; } if (sp.HasFlag(StoragePermissions.Execute)) { p |= FilePermissions.S_IXUSR; } return(p); }
public static FilePermissions FromGroupPermissions(StoragePermissions sp) { var p = default(FilePermissions); if (sp.HasFlag(StoragePermissions.Read)) { p |= FilePermissions.S_IRGRP; } if (sp.HasFlag(StoragePermissions.Write)) { p |= FilePermissions.S_IWGRP; } if (sp.HasFlag(StoragePermissions.Execute)) { p |= FilePermissions.S_IXGRP; } return(p); }
/// <summary> /// Initializes a new instance of a <see cref="StorageToken"/>. /// </summary> /// <param name="resourceUri">The resource URI this token applies to.</param> /// <param name="entityId">The entity ID that owns the file or resource this token applies to.</param> /// <param name="permissions">The permissions supported by this token.</param> /// <param name="scope">The scope this token applies to.</param> /// <param name="rawToken">The raw token representation for the storage provider this token applies to.</param> public StorageToken(Uri resourceUri, string entityId, StoragePermissions permissions, StorageTokenScope scope, string rawToken) { if (resourceUri == null) { throw new ArgumentNullException(nameof(resourceUri)); } if (string.IsNullOrEmpty(entityId)) { throw new ArgumentException($"The argument '{nameof(entityId)}' may not be an empty or null string."); } if (string.IsNullOrEmpty(rawToken)) { throw new ArgumentException($"The argument '{nameof(rawToken)}' may not be an empty or null string."); } ResourceUri = resourceUri; EntityId = entityId; Permissions = permissions; Scope = scope; RawToken = rawToken; }
/// <summary> /// Converts the <see cref="sourceValue" /> parameter to the <see cref="destinationType" /> parameter using <see cref="formatProvider" /// /> and <see cref="ignoreCase" /> /// </summary> /// <param name="sourceValue">the <see cref="System.Object"/> to convert from</param> /// <param name="destinationType">the <see cref="System.Type" /> to convert to</param> /// <param name="formatProvider">not used by this TypeConverter.</param> /// <param name="ignoreCase">when set to <c>true</c>, will ignore the case when converting.</param> /// <returns> /// an instance of <see cref="StoragePermissions" />, or <c>null</c> if there is no suitable conversion. /// </returns> public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => StoragePermissions.CreateFrom(sourceValue);
private async Task<StorageToken> GetStorageToken(IMobileServiceClient client, MobileServiceFileMetadata metadata, StoragePermissions permissions) { return await GetStorageToken(client, MobileServiceFile.FromMetadata(metadata), permissions); }
public async Task<Uri> GetFileUriAsync(MobileServiceFile file, StoragePermissions permissions) { StorageToken token = await GetStorageToken(this.client, file, permissions); return await this.storageProvider.GetFileUriAsync(token, file.Name); }
private async Task <StorageToken> GetStorageToken(IMobileServiceClient client, MobileServiceFileMetadata metadata, StoragePermissions permissions) { return(await GetStorageToken(client, MobileServiceFile.FromMetadata(metadata), permissions)); }
public async Task <Uri> GetFileUriAsync(MobileServiceFile file, StoragePermissions permissions) { StorageToken token = await GetStorageToken(this.client, file, permissions); return(await this.storageProvider.GetFileUriAsync(token, file.Name)); }
public static IStorageSecurity UpdateGroupPermissions(this IStorageSecurity security, string id, StoragePermissions permissions) => security.UpdatePermissions(StorageActor.Group(id), permissions);
public static IStorageSecurity UpdateAuthenticatedPermissions(this IStorageSecurity security, StoragePermissions permissions) => security.UpdatePermissions(StorageActor.Authenticated, permissions);
public static IStorageSecurity UpdatePublicPermissions(this IStorageSecurity security, StoragePermissions permissions) => security.UpdatePermissions(StorageActor.Public, permissions);
/// <summary> /// Retrieves the location of the logs /// </summary> /// <param name="logs">The list of individual logs to be stored</param> /// <param name="job">The <see cref="AlgorithmNodePacket"/> used to generate the url to the logs</param> /// <param name="permissions">The <see cref="StoragePermissions"/> for the file</param> /// <param name="async">Bool indicating whether the method to <see cref="Store"/> should be async</param> /// <returns>The location where the logs can be accessed</returns> /// <remarks>Since the logs are stored on disc during local backtest, this method simply returns the location of those logs /// TODO: Get the filename of the logs instead of hard coding it. /// </remarks> public virtual string StoreLogs(List <string> logs, AlgorithmNodePacket job, StoragePermissions permissions, bool async = false) { return(Path.Combine(Directory.GetCurrentDirectory(), "log.txt")); }
/// <summary> /// Store logs with these authentication type /// </summary> public virtual void Store(string data, string location, StoragePermissions permissions, bool async = false) { // }
private async Task <StorageToken> GetStorageToken(IMobileServiceClient client, MobileServiceFile file, StoragePermissions permissions) { var tokenRequest = new StorageTokenRequest(); tokenRequest.Permissions = permissions; tokenRequest.TargetFile = file; string route = string.Format("/tables/{0}/{1}/StorageToken", file.TableName, file.ParentId); return(await this.client.InvokeApiAsync <StorageTokenRequest, StorageToken>(route, tokenRequest)); }
public async static Task <Uri> GetFileUri <T>(this IMobileServiceTable <T> table, MobileServiceFile file, StoragePermissions permissions) { IMobileServiceFilesClient filesClient = GetFilesClient(table.MobileServiceClient); return(await filesClient.GetFileUriAsync(file, permissions)); }