public static async Task<IList<string>> CheckRegistrationAuthorizationForEdit(IRegistrationOwnership registrationOwnership, PackageIdentity packageIdentity)
        {
            IList<string> errors = new List<string>();

            if (!await registrationOwnership.HasNamespace(packageIdentity.Namespace))
            {
                errors.Add("user is not allowed to publish in this namespace");
                return errors;
            }

            if (await registrationOwnership.HasRegistration(packageIdentity.Namespace, packageIdentity.Id))
            {
                if (!await registrationOwnership.HasOwner(packageIdentity.Namespace, packageIdentity.Id))
                {
                    errors.Add("user does not have access to this registration");
                    return errors;
                }
            }
            else
            {
                errors.Add("this package does not exist in the ownership record");
            }

            return errors;
        }
        public static async Task<IList<string>> CheckRegistrationAuthorization(IRegistrationOwnership registrationOwnership, PackageIdentity packageIdentity)
        {
            IList<string> errors = new List<string>();

            if (!await registrationOwnership.HasNamespace(packageIdentity.Namespace))
            {
                errors.Add("user is not allowed to publish in this namespace");
                return errors;
            }

            if (await registrationOwnership.HasRegistration(packageIdentity.Namespace, packageIdentity.Id))
            {
                if (!await registrationOwnership.HasOwner(packageIdentity.Namespace, packageIdentity.Id))
                {
                    errors.Add("user does not have access to this registration");
                    return errors;
                }

                if (await registrationOwnership.HasVersion(packageIdentity.Namespace, packageIdentity.Id, packageIdentity.Version.ToString()))
                {
                    errors.Add("this package version already exists for this registration");
                    return errors;
                }
            }

            return errors;
        }
        public static async Task <IList <string> > CheckRegistrationAuthorization(IRegistrationOwnership registrationOwnership, PackageIdentity packageIdentity)
        {
            IList <string> errors = new List <string>();

            if (await registrationOwnership.HasRegistration(packageIdentity.Namespace, packageIdentity.Id))
            {
                if (!await registrationOwnership.HasOwner(packageIdentity.Namespace, packageIdentity.Id))
                {
                    errors.Add("user does not have access to this registration");
                    return(errors);
                }

                if (await registrationOwnership.HasVersion(packageIdentity.Namespace, packageIdentity.Id, packageIdentity.Version.ToString()))
                {
                    errors.Add("this package version already exists for this registration");
                    return(errors);
                }
            }

            return(errors);
        }
        async Task InvokeGET(IOwinContext context)
        {
            IRegistrationOwnership registrationOwnership = CreateRegistrationOwnership(context);

            switch (context.Request.Path.Value)
            {
            case "/":
            {
                await context.Response.WriteAsync("READY.");

                context.Response.StatusCode = (int)HttpStatusCode.OK;
                break;
            }

            case "/domains":
            {
                PublishImpl uploader = new ApiAppsPublishImpl(registrationOwnership);
                await uploader.GetDomains(context);

                break;
            }

            case "/tenants":
            {
                PublishImpl uploader = new ApiAppsPublishImpl(registrationOwnership);
                await uploader.GetTenants(context);

                break;
            }

            default:
            {
                await context.Response.WriteAsync("NotFound");

                context.Response.StatusCode = (int)HttpStatusCode.NotFound;
                break;
            }
            }
        }
        public static async Task<PublicationDetails> CreatePublicationDetails(IRegistrationOwnership registrationOwnership, PublicationVisibility publicationVisibility)
        {
            string userId = registrationOwnership.GetUserId();
            string userName = await registrationOwnership.GetPublisherName();
            string tenantId = registrationOwnership.GetTenantId();

            //TODO: requires Graph access
            string tenantName = string.Empty;
            //string tenantName = await _registrationOwnership.GetTenantName();

            //var client = await ServiceHelpers.GetActiveDirectoryClient();

            PublicationDetails publicationDetails = new PublicationDetails
            {
                Published = DateTime.UtcNow,
                Owner = OwnershipOwner.Create(ClaimsPrincipal.Current),
                TenantId = tenantId,
                TenantName = tenantName,
                Visibility = publicationVisibility
            };

            return publicationDetails;
        }
        public static async Task <PublicationDetails> CreatePublicationDetails(IRegistrationOwnership registrationOwnership, PublicationVisibility publicationVisibility)
        {
            string userId   = registrationOwnership.GetUserId();
            string userName = await registrationOwnership.GetPublisherName();

            string tenantId = registrationOwnership.GetTenantId();

            //TODO: requires Graph access
            string tenantName = string.Empty;
            //string tenantName = await _registrationOwnership.GetTenantName();

            //var client = await ServiceHelpers.GetActiveDirectoryClient();

            PublicationDetails publicationDetails = new PublicationDetails
            {
                Published  = DateTime.UtcNow,
                Owner      = OwnershipOwner.Create(ClaimsPrincipal.Current),
                TenantId   = tenantId,
                TenantName = tenantName,
                Visibility = publicationVisibility
            };

            return(publicationDetails);
        }
 public CheckAccessImpl(IRegistrationOwnership registrationOwnership)
 {
     _registrationOwnership = registrationOwnership;
 }
 public CheckAccessImpl(IRegistrationOwnership registrationOwnership)
 {
     _registrationOwnership = registrationOwnership;
 }
        async Task InvokePOST(IOwinContext context)
        {
            IRegistrationOwnership    registrationOwnership    = CreateRegistrationOwnership(context);
            ICategorizationPermission categorizationPermission = CategorizationPermission();

            switch (context.Request.Path.Value)
            {
            case "/apiapp/checkaccess":
            {
                CheckAccessImpl uploader = new CheckAccessImpl(registrationOwnership);
                await uploader.CheckAccess(context);

                break;
            }

            case "/apiapp/upload":
            {
                PublishImpl uploader = new ApiAppsPublishImpl(registrationOwnership, categorizationPermission);
                await uploader.Upload(context);

                break;
            }

            case "/apiapp/edit":
            {
                PublishImpl uploader = new ApiAppsPublishImpl(registrationOwnership, categorizationPermission);
                await uploader.Edit(context);

                break;
            }

            case "/delete":
            {
                DeleteImpl deleteImpl = new DeleteImpl(registrationOwnership);
                await deleteImpl.Delete(context);

                break;
            }

            case "/tenant/enable":
            {
                PublishImpl uploader = new ApiAppsPublishImpl(registrationOwnership);
                await uploader.TenantEnable(context);

                break;
            }

            case "/tenant/disable":
            {
                PublishImpl uploader = new ApiAppsPublishImpl(registrationOwnership);
                await uploader.TenantDisable(context);

                break;
            }

            case "/catalog/powershell":
            {
                PublishImpl uploader = new PowerShellPublishImpl(registrationOwnership);
                await uploader.Upload(context);

                break;
            }

            default:
            {
                await context.Response.WriteAsync("NotFound");

                context.Response.StatusCode = (int)HttpStatusCode.NotFound;
                break;
            }
            }
        }
 public DeleteImpl(IRegistrationOwnership registrationOwnership)
 {
     _registrationOwnership = registrationOwnership;
 }
 public AgreementImpl(IRegistrationOwnership registrationOwnership)
 {
     _registrationOwnership = registrationOwnership;
 }
        public static async Task <IList <string> > CheckRegistrationAuthorizationForEdit(IRegistrationOwnership registrationOwnership, PackageIdentity packageIdentity)
        {
            IList <string> errors = new List <string>();

            if (await registrationOwnership.HasRegistration(packageIdentity.Namespace, packageIdentity.Id))
            {
                if (!await registrationOwnership.HasOwner(packageIdentity.Namespace, packageIdentity.Id))
                {
                    errors.Add("user does not have access to this registration");
                    return(errors);
                }
            }
            else
            {
                errors.Add("this package does not exist in the ownership record");
            }

            return(errors);
        }
 protected PublishImpl(IRegistrationOwnership registrationOwnership)
 {
     _registrationOwnership = registrationOwnership;
 }
 public ApiAppsPublishImpl(IRegistrationOwnership registrationOwnership, ICategorizationPermission categorizationPermission)
     : base(registrationOwnership)
 {
     _categorizationPermission = categorizationPermission;
 }
 public ApiAppsPublishImpl(IRegistrationOwnership registrationOwnership)
     : base(registrationOwnership)
 {
 }
 public NuSpecJsonPublishImpl(IRegistrationOwnership registrationOwnership)
     : base(registrationOwnership)
 {
 }
 public PowerShellPublishImpl(IRegistrationOwnership registrationOwnership) : base(registrationOwnership)
 {
 }
 public ApiAppsPublishImpl(IRegistrationOwnership registrationOwnership)
     : base(registrationOwnership)
 {
 }
 public ApiAppsPublishImpl(IRegistrationOwnership registrationOwnership, ICategorizationPermission categorizationPermission, Uri imagesUri)
     : base(registrationOwnership)
 {
     _categorizationPermission = categorizationPermission;
     _imagesUri = imagesUri;
 }
Esempio n. 20
0
 public NuSpecJsonPublishImpl(IRegistrationOwnership registrationOwnership)
     : base(registrationOwnership)
 {
 }
Esempio n. 21
0
 public DeleteImpl(IRegistrationOwnership registrationOwnership)
 {
     _registrationOwnership = registrationOwnership;
 }
 protected PublishImpl(IRegistrationOwnership registrationOwnership)
 {
     _registrationOwnership = registrationOwnership;
 }
 public PowerShellPublishImpl(IRegistrationOwnership registrationOwnership) : base(registrationOwnership)
 {
 }