コード例 #1
0
        private Caller GetCaller(string company, string key)
        {
            var configuration = configurationFactory.Create(company);

            try
            {
                var caller = factory.GetUserByKey(company, "NuGet", key);

                if (caller != null)
                {
                    return(caller);
                }

                if (string.IsNullOrEmpty(configuration.GatewayLogin) || string.IsNullOrEmpty(configuration.GatewayPassword))
                {
                    throw new Exception("Wrong key or missing gateway configuration");
                }

                using (var backend = factory.Create(company, configuration.GatewayLogin, "API", configuration.GatewayPassword))
                    return(backend.CreateUserByKey(company, "NuGet", key));
            }
            catch (Exception exception)
            {
                throw new ClientException("User authentication failure", exception);
            }
        }
コード例 #2
0
        public ActionResult Index(string company, string login, string password, string name, string hash, string name1)
        {
            if ("Public".Equals(company, StringComparison.OrdinalIgnoreCase))
            {
                company = "Public";
            }

            if (string.IsNullOrEmpty(login) && string.IsNullOrEmpty(password))
            {
                var configuration = configurationFactory.Create(company);
                login    = configuration.PublicLogin;
                password = configuration.PublicPassword;
            }

            string extension = Path.GetExtension(name);

            var routeValue = new RouteValueDictionary(new { company, login, password, name, hash, name1 });

            if (string.Equals(".pdb", extension, StringComparison.InvariantCultureIgnoreCase))
            {
                return(new TransferToRouteResult("Pdb", routeValue));
            }
            else if (string.Equals(".exe", extension, StringComparison.InvariantCultureIgnoreCase) || string.Equals(".dll", extension, StringComparison.InvariantCultureIgnoreCase))
            {
                return(new TransferToRouteResult("Bin", routeValue));
            }

            Response.StatusCode = 404;
            return(Content(string.Format("{0} not supported", extension)));
        }
コード例 #3
0
        public ActionResult Index(string company, string login, string password, string name, string hash, string name1)
        {
            if ("Public".Equals(company, StringComparison.OrdinalIgnoreCase))
            {
                company = "Public";
            }

            if (string.IsNullOrEmpty(login) && string.IsNullOrEmpty(password))
            {
                var configuration = configurationFactory.Create(company);
                login    = configuration.PublicLogin;
                password = configuration.PublicPassword;
            }

            if (!name1.EndsWith(".pd_", StringComparison.InvariantCultureIgnoreCase))
            {
                Response.StatusCode = 404;
                return(Content("Supported only compresioned files (.pd_)"));
            }

            //Ktoś ma małą literką numer kompilacji
            hash = hash.ToUpper();

            string imageName = Path.GetFileNameWithoutExtension(name);

            using (var backend = factory.Create(company, login, "VisualStudio", password))
            {
                var imageFile = backend.GetImageFile(imageName, hash);

                if (imageFile != null)
                {
                    return(HandleFound(backend, company, login, password, imageFile));
                }
            }

            if (company != "Public")
            {
                var configuration = new AppSettingsConfiguration("Public");

                using (var backend = factory.Create("Public", configuration.PublicLogin, "VisualStudio", configuration.PublicPassword))
                {
                    var imageFile = backend.GetImageFile(imageName, hash);

                    if (imageFile != null)
                    {
                        return(HandleFound(backend, company, login, password, imageFile));
                    }
                }
            }

            using (var backend = factory.Create(company, login, "VisualStudio", password))
                return(HandleNotFound(backend, name, hash, imageName));
        }
コード例 #4
0
        private void SynchronizePermissions(Caller caller, string company, PackageProject packageProject)
        {
            var permission = GetProjectPermission(caller, company, packageProject);

            if (permission.HasValue)
            {
                var configuration = configurationFactory.Create(company);

                if (string.IsNullOrEmpty(configuration.GatewayLogin) || string.IsNullOrEmpty(configuration.GatewayPassword))
                {
                    throw new Exception("Missing gateway configuration");
                }

                using (var session = backendFactory.Create(new Caller {
                    Company = company, Name = configuration.GatewayLogin, KeyType = "API", KeyValue = configuration.GatewayPassword
                }))
                {
                    var project = new Project {
                        Company = company, Repository = packageProject.Repository, Name = packageProject.Name
                    };

                    if (permission.Value)
                    {
                        try
                        {
                            session.CreateProject(project);
                        }
                        catch (Exception)
                        {
                            //ignore if exists
                        }
                    }

                    try
                    {
                        session.SetProjectPermissions(new User {
                            Company = caller.Company, Name = caller.Name
                        }, project, new Permission {
                            Grant = false, Read = false, Write = permission.Value
                        });
                    }
                    catch (Exception)
                    {
                        //ignore if not exists
                    }

                    if (!permission.Value)
                    {
                        throw new Exception("External permission source denied publish access");
                    }
                }
            }
        }
コード例 #5
0
        public ActionResult Index(string company, string login, string password, string computerName, string computerUser, string imageName, string pdbHash, string sourcePath)
        {
            if ("Public".Equals(company, StringComparison.OrdinalIgnoreCase))
            {
                company = "Public";
            }

            if (string.IsNullOrEmpty(login) && string.IsNullOrEmpty(password))
            {
                var configuration = configurationFactory.Create(company);
                login    = configuration.PublicLogin;
                password = configuration.PublicPassword;
            }

            //TODO: mamy na to test?
            //Ktoœ ma ma³¹ literk¹ numer kompilacji
            pdbHash = pdbHash.ToUpper();

            using (var backend = factory.Create(company, login, "VisualStudio", password))
            {
                var imageFile = backend.GetImageFile(imageName, pdbHash);

                if (imageFile == null)
                {
                    backend.LogImageFileNotFound(imageName, pdbHash);
                    Response.StatusCode = 404;
                    return(Content(string.Format("{0} ({1}) not found", imageName, pdbHash)));
                }

                var sourceFile = new SourceFile
                {
                    Company    = company,
                    Repository = imageFile.Repository,
                    Project    = imageFile.Project,
                    Version    = imageFile.Version,
                    Mode       = imageFile.Mode,
                    Platform   = imageFile.Platform,
                    ImageName  = imageName,
                    Path       = sourcePath
                };
                var link = backend.GetSourceFileLink(ref sourceFile);

                if (link == null)
                {
                    Response.StatusCode = 404;
                    return(Content("Source file not found"));
                }

                backend.LogSourceFileFound(sourceFile, computerName, computerUser);
                return(Redirect(link));
            }
        }