public PreAuthenticatedRepository(IPackageRepository remote, ISupportAuthentication auth, NetworkCredential initialCredentials)
 {
     _remote            = remote;
     _auth              = auth;
     CurrentCredentials = _initialCredentials = initialCredentials;
     _credentialCookie  = auth.WithCredentials(initialCredentials);
 }
        IEnumerable<ICommandOutput> ValidateInputs()
        {
            // TODO: HACK HACK HACK
            var namedRepository = Remotes.PublishRepositories(Remote).SelectMany(_ => _).FirstOrDefault();

            if (namedRepository == null)
            {
                yield return new UnknownRemoteName(Remote);
                foreach (var _ in HintRemoteRepositories()) yield return _;
                yield break;
            }

            if ((Username != null && Password == null) || (Username == null && Password != null))
            {
                yield return new IncompleteCredentials();
                yield break;
            }

            bool hasAuth = Username != null && Password != null;
            if (hasAuth) _credentials = new NetworkCredential(Username, Password);
            _authenticationSupport = namedRepository.Feature<ISupportAuthentication>();
            if (hasAuth && _authenticationSupport == null)
            {
                yield return new RemoteAuthenticatioNotSupported(namedRepository);
                yield break;
            }

            _authenticationSupport = _authenticationSupport ?? new NullAuthentication();

            //_repositories = namedRepository.
            _remoteRepository = namedRepository;
            var publishingRepo = _remoteRepository.Feature<ISupportPublishing>();

            if (publishingRepo == null)
            {
                yield return new Error("Repository '{0}' doesn't support publishing.", namedRepository.Name);
                yield break;
            }
            if (Path != null)
            {
                var packageFile = FileSystem.GetFile(Path);
                if (!packageFile.Exists)
                {
                    yield return new FileNotFound(Path);
                    yield break;
                }
                _packageStream = packageFile.OpenRead;
                _packageFileName = packageFile.Name;
                // TODO: This looks iffy at best
                var package = new ZipFilePackage(packageFile);
                _packageName = package.Name;
                _packageVersion = package.SemanticVersion;
            }
            else if (Name != null)
            {
                // get latest version of the Named package
                if (!HostEnvironment.CurrentDirectoryRepository.PackagesByName.Contains(Name))
                {
                    yield return new Error("No package named '{0}' was found.", Name);
                    yield break;
                }
                var packageToCopy = HostEnvironment.CurrentDirectoryRepository.PackagesByName[Name].OrderByDescending(x => x.SemanticVersion).First();
                _packageStream = () => packageToCopy.Load().OpenStream();
                _packageFileName = packageToCopy.FullName + ".wrap";
                _packageName = packageToCopy.Name;
                _packageVersion = packageToCopy.SemanticVersion;
            }
            else
            {
                yield return new Error("Please specify either a file path using the -Path input, or a name using -Name.");
            }
        }
示例#3
0
        IEnumerable <ICommandOutput> ValidateInputs()
        {
            // TODO: HACK HACK HACK
            var namedRepository = Remotes.PublishRepositories(Remote).SelectMany(_ => _).FirstOrDefault();

            if (namedRepository == null)
            {
                yield return(new UnknownRemoteName(Remote));

                foreach (var _ in HintRemoteRepositories())
                {
                    yield return(_);
                }
                yield break;
            }

            if ((Username != null && Password == null) || (Username == null && Password != null))
            {
                yield return(new IncompleteCredentials());

                yield break;
            }

            bool hasAuth = Username != null && Password != null;

            if (hasAuth)
            {
                _credentials = new NetworkCredential(Username, Password);
            }
            _authenticationSupport = namedRepository.Feature <ISupportAuthentication>();
            if (hasAuth && _authenticationSupport == null)
            {
                yield return(new RemoteAuthenticatioNotSupported(namedRepository));

                yield break;
            }

            _authenticationSupport = _authenticationSupport ?? new NullAuthentication();

            //_repositories = namedRepository.
            _remoteRepository = namedRepository;
            var publishingRepo = _remoteRepository.Feature <ISupportPublishing>();

            if (publishingRepo == null)
            {
                yield return(new Error("Repository '{0}' doesn't support publishing.", namedRepository.Name));

                yield break;
            }
            if (Path != null)
            {
                var packageFile = FileSystem.GetFile(Path);
                if (!packageFile.Exists)
                {
                    yield return(new FileNotFound(Path));

                    yield break;
                }
                _packageStream   = packageFile.OpenRead;
                _packageFileName = packageFile.Name;
                // TODO: This looks iffy at best
                var package = new ZipPackage(packageFile);
                _packageName    = package.Name;
                _packageVersion = package.Version;
            }
            else if (Name != null)
            {
                // get latest version of the Named package
                if (!HostEnvironment.CurrentDirectoryRepository.PackagesByName.Contains(Name))
                {
                    yield return(new Error("No package named '{0}' was found.", Name));

                    yield break;
                }
                var packageToCopy = HostEnvironment.CurrentDirectoryRepository.PackagesByName[Name].OrderByDescending(x => x.Version).First();
                _packageStream   = () => packageToCopy.Load().OpenStream();
                _packageFileName = packageToCopy.FullName + ".wrap";
                _packageName     = packageToCopy.Name;
                _packageVersion  = packageToCopy.Version;
            }
            else
            {
                yield return(new Error("Please specify either a file path using the -Path input, or a name using -Name."));
            }
        }
示例#4
0
        IEnumerable<ICommandOutput> ValidateInputs()
        {
            var namedRepository = GetRemoteRepository(Remote);

            if (namedRepository == null)
            {
                yield return new Errors.UnknownRemoteRepository(Remote);
                foreach (var _ in HintRemoteRepositories()) yield return _;
                yield break;
            }

            if (User != null && Pwd == null)
            {
                yield return new Errors.IncompleteAuthentication();
                yield break;
            }

            _authenticationSupport = namedRepository as ISupportAuthentication;

            if (_authenticationSupport == null)
            {
                yield return new Warning("Remote repository '{0}' does not support authentication, ignoring authentication info.", namedRepository.Name);
                _authenticationSupport = new NullAuthentication();
            }

            _remoteRepository = namedRepository as ISupportPublishing;

            if (_remoteRepository == null)
            {
                yield return new Error("Repository '{0}' doesn't support publishing.", namedRepository.Name);
                yield break;
            }
            if (Path != null)
            {
                var packageFile = FileSystem.GetFile(Path);
                if (!packageFile.Exists)
                {
                    yield return new Errors.FileNotFound(Path);
                    yield break;
                }
                else
                {
                    _packageStream = () => packageFile.OpenRead();
                    _packageFileName = packageFile.Name;
                    var package = new CachedZipPackage(null, packageFile, null, null);
                    _packageName = package.Name;
                    _packageVersion = package.Version;
                }
            }
            else if (Name != null)
            {
                // get latest version of the Named package
                if (!HostEnvironment.CurrentDirectoryRepository.PackagesByName.Contains(Name))
                {
                    yield return new Error("No package named '{0}' was found.", Name);
                    yield break;
                }
                var packageToCopy = HostEnvironment.CurrentDirectoryRepository.PackagesByName[Name].OrderByDescending(x => x.Version).First();
                _packageStream = () => packageToCopy.Load().OpenStream();
                _packageFileName = packageToCopy.FullName + ".wrap";
                _packageName = packageToCopy.Name;
                _packageVersion = packageToCopy.Version;
            }
            else
            {
                yield return new Error("Please specify either a file path using the -Path input, or a name using -Name.");
            }
        }
示例#5
0
        IEnumerable <ICommandOutput> ValidateInputs()
        {
            var namedRepository = GetRemoteRepository(Remote);

            if (namedRepository == null)
            {
                yield return(new Errors.UnknownRemoteRepository(Remote));

                foreach (var _ in HintRemoteRepositories())
                {
                    yield return(_);
                }
                yield break;
            }

            if (User != null && Pwd == null)
            {
                yield return(new Errors.IncompleteAuthentication());

                yield break;
            }

            _authenticationSupport = namedRepository as ISupportAuthentication;

            if (_authenticationSupport == null)
            {
                yield return(new Warning("Remote repository '{0}' does not support authentication, ignoring authentication info.", namedRepository.Name));

                _authenticationSupport = new NullAuthentication();
            }

            _remoteRepository = namedRepository as ISupportPublishing;

            if (_remoteRepository == null)
            {
                yield return(new Error("Repository '{0}' doesn't support publishing.", namedRepository.Name));

                yield break;
            }
            if (Path != null)
            {
                var packageFile = FileSystem.GetFile(Path);
                if (!packageFile.Exists)
                {
                    yield return(new Errors.FileNotFound(Path));

                    yield break;
                }
                else
                {
                    _packageStream   = () => packageFile.OpenRead();
                    _packageFileName = packageFile.Name;
                    var package = new CachedZipPackage(null, packageFile, null);
                    _packageName    = package.Name;
                    _packageVersion = package.Version;
                }
            }
            else if (Name != null)
            {
                // get latest version of the Named package
                if (!HostEnvironment.CurrentDirectoryRepository.PackagesByName.Contains(Name))
                {
                    yield return(new Error("No package named '{0}' was found.", Name));

                    yield break;
                }
                var packageToCopy = HostEnvironment.CurrentDirectoryRepository.PackagesByName[Name].OrderByDescending(x => x.Version).First();
                _packageStream   = () => packageToCopy.Load().OpenStream();
                _packageFileName = packageToCopy.FullName + ".wrap";
                _packageName     = packageToCopy.Name;
                _packageVersion  = packageToCopy.Version;
            }
            else
            {
                yield return(new Error("Please specify either a file path using the -Path input, or a name using -Name."));
            }
        }