public StorageMultipartStreamProvider( IStorageService storage, ISchedulerService scheduler, FeedPrincipal principal) { this.storage = storage; this.scheduler = scheduler; this.principal = principal; packages = new Dictionary <IPackageStorageItem, MemoryStream>(); }
public static Task Signal(this ISchedulerService scheduler, FeedPrincipal principal, PackageState packageState, PackageName packageName) { return(scheduler.Signal(new PackageMessage { UserInfo = new UserInfo { UserName = principal.Identity.Name, UserHandle = principal.Identity.Handle }, FeedName = principal.FeedName, PackageState = packageState, PackageName = packageName })); }
private Task <IEnumerable <PackageName> > QueryForRetrying(FeedPrincipal principal) { switch (principal.AuthenticatedArea) { case AuthenticatedArea.RetryingOwn: return(storage.GetFeed(principal.FeedName).QueryPackages(principal.Identity.Name, principal.PackageState)); case AuthenticatedArea.RetryingAll: return(storage.GetFeed(principal.FeedName).QueryPackages(principal.PackageState)); default: throw new ArgumentOutOfRangeException("area", principal.AuthenticatedArea, null); } }
private async Task <bool> CopyToState(FeedPrincipal principal, PackageName packageName, PackageState newPackageState) { var package = storage.GetFeed(principal.FeedName).GetPackage(null, principal.PackageState, packageName); var newPackageItem = await package.Copy(newPackageState, packageName); if (newPackageItem == null) { return(false); } await scheduler.Signal(principal, newPackageState, packageName); return(true); }
private FeedPrincipal CreatePrincipal(HttpActionContext context) { var attribute = GetAttribute(context); var feedPrincipal = new FeedPrincipal { Identity = new SecurityIdentity(AuthenticationMode.None, null, null), AuthenticatedArea = attribute.Area, PackageState = PackageState.Succeded }; ParseParameter(context.ControllerContext.RouteData, attribute.Parameter, feedPrincipal); return(feedPrincipal); }
private Task <IEnumerable <PackageName> > Query(FeedPrincipal principal, string packageNamePrefix, SkipQueryOption skip, TopQueryOption top) { var feed = storage.GetFeed(principal.FeedName); switch (principal.AuthenticatedArea) { case AuthenticatedArea.QueryingOwn: return(skip != null && top != null ? feed.QueryPackages(principal.Identity.Name, principal.PackageState, packageNamePrefix, skip.Value, top.Value) : feed.QueryPackages(principal.Identity.Name, principal.PackageState)); case AuthenticatedArea.QueryingAll: return(skip != null && top != null ? feed.QueryPackages(principal.PackageState, packageNamePrefix, skip.Value, top.Value) : feed.QueryPackages(principal.PackageState)); default: throw new ArgumentOutOfRangeException("area", principal.AuthenticatedArea, null); } }
private static void ParseParameter(IHttpRouteData routeData, string parameter, FeedPrincipal principal) { if (!routeData.Values.ContainsKey(parameter)) { return; } var feedName = (string)routeData.Values[parameter]; var authenticatedArea = principal.AuthenticatedArea; var packageState = principal.PackageState; ParseParameter(ref feedName, ref authenticatedArea, ref packageState); principal.FeedName = feedName; principal.AuthenticatedArea = authenticatedArea; principal.PackageState = packageState; }
private AuthenticationMode GetMode(HttpActionContext context, FeedPrincipal feedPrincipal) { return(security.GetAuthenticationMode(feedPrincipal.AuthenticatedArea)); }