// Login Password
        public override string getPassword(Scheme scheme, int port, String hostName, String user)
        {
            Host host = new Host(ProtocolFactory.get().forScheme(scheme), hostName, port);

            host.getCredentials().setUsername(user);
            return(getPassword(host));
        }
示例#2
0
        static MainController()
        {
            StructureMapBootstrapper.Bootstrap();

            if (!(Debugger.IsAttached || Utils.IsRunningAsUWP))
            {
                // Add the event handler for handling UI thread exceptions to the event.
                System.Windows.Forms.Application.ThreadException += ExceptionHandler;

                // Set the unhandled exception mode to force all Windows Forms errors to go through
                // our handler.
                System.Windows.Forms.Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

                // Add the event handler for handling non-UI thread exceptions to the event.
                AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler;
            }
            //make sure that a language change takes effect after a restart only
            StartupLanguage = PreferencesFactory.get().getProperty("application.language");
            ProtocolFactory.get().register(new FTPProtocol(), new FTPTLSProtocol(), new SFTPProtocol(), new DAVProtocol(),
                                           new DAVSSLProtocol(), new SwiftProtocol(), new S3Protocol(), new GoogleStorageProtocol(),
                                           new AzureProtocol(), new IRODSProtocol(), new SpectraProtocol(), new B2Protocol(), new DriveProtocol(),
                                           new DropboxProtocol(), new HubicProtocol(), new LocalProtocol(), new OneDriveProtocol(), new SharepointProtocol(), new SharepointSiteProtocol(),
                                           new MantaProtocol(), new SDSProtocol(), new StoregateProtocol(), new BrickProtocol(), new NextcloudProtocol());
            ProtocolFactory.get().loadDefaultProfiles();
        }
        // Login Password
        public override void addPassword(Scheme scheme, int port, String hostName, String user, String password)
        {
            Host host = new Host(ProtocolFactory.get().forScheme(scheme), hostName, port);

            host.getCredentials().setUsername(user);
            PreferencesFactory.get().setProperty(new HostUrlProvider().get(host), DataProtector.Encrypt(password));
        }
示例#4
0
 public IDictionary <String, Bitmap> GetProtocolIcons()
 {
     if (null == _protocolIcons)
     {
         _protocolIcons = new Dictionary <string, Bitmap>();
         foreach (Protocol p in ProtocolFactory.get().find().toArray(new Protocol[] {}))
         {
             _protocolIcons[p.getIdentifier()] = IconForName(p.icon(), 16);
         }
     }
     return(_protocolIcons);
 }
示例#5
0
        public static Dictionary <string, Image> GetProtocolIcons()
        {
            var lookup   = new Dictionary <string, Image>();
            var iterator = ProtocolFactory.get().find().iterator();

            while (iterator.hasNext())
            {
                var protocol = (Protocol)iterator.next();
                if (!lookup.ContainsKey(protocol.disk()))
                {
                    lookup.Add(protocol.disk(), IconForName(protocol.icon(), 16));
                }
            }
            return(lookup);
        }
示例#6
0
        public IDictionary <String, Bitmap> GetProtocolImages(int size)
        {
            IDictionary <String, Bitmap> dict;

            if (!_protocolImages.TryGetValue(size, out dict))
            {
                dict = new Dictionary <string, Bitmap>();
                foreach (Protocol p in ProtocolFactory.get().find().toArray(new Protocol[] {}))
                {
                    dict[p.disk()] = IconForName(p.disk(), size);
                }
                _protocolImages.Add(size, dict);
            }
            return(dict);
        }
        public static ConnectionController Instance(WindowController parent)
        {
            ConnectionController c;

            if (!Controllers.TryGetValue(parent, out c))
            {
                c = new ConnectionController(new Host(ProtocolFactory.get().forName(PreferencesFactory.get().getProperty("connection.protocol.default"))));
                Controllers.Add(parent, c);
                parent.View.ViewClosedEvent += delegate
                {
                    Controllers.Remove(parent);
                    c.View.Close();
                };
            }
            return(c);
        }
        private void InitProtocols()
        {
            List <KeyValueIconTriple <Protocol, string> > protocols = new List <KeyValueIconTriple <Protocol, string> >();
            ProtocolFactory p = ProtocolFactory.get();

            foreach (Protocol protocol in p.find(new DefaultProtocolPredicate(
                                                     EnumSet.of(Protocol.Type.ftp, Protocol.Type.sftp, Protocol.Type.dav))).toArray(new Protocol[] { }))
            {
                protocols.Add(new KeyValueIconTriple <Protocol, string>(protocol, protocol.getDescription(),
                                                                        protocol.disk()));
            }

            foreach (Protocol protocol in p.find(new DefaultProtocolPredicate(
                                                     EnumSet.of(Protocol.Type.s3, Protocol.Type.swift, Protocol.Type.azure, Protocol.Type.b2,
                                                                Protocol.Type.googlestorage))).toArray(new Protocol[] { }))
            {
                protocols.Add(new KeyValueIconTriple <Protocol, string>(protocol, protocol.getDescription(),
                                                                        protocol.disk()));
            }

            foreach (Protocol protocol in p.find(new DefaultProtocolPredicate(
                                                     EnumSet.of(Protocol.Type.dropbox, Protocol.Type.box, Protocol.Type.onedrive, Protocol.Type.googledrive, Protocol.Type.nextcloud, Protocol.Type.owncloud, Protocol.Type.dracoon, Protocol.Type.brick)))
                     .toArray(new Protocol[] { }))
            {
                protocols.Add(new KeyValueIconTriple <Protocol, string>(protocol, protocol.getDescription(),
                                                                        protocol.disk()));
            }

            foreach (Protocol protocol in p.find(new DefaultProtocolPredicate(
                                                     EnumSet.of(Protocol.Type.file))).toArray(new Protocol[] { }))
            {
                protocols.Add(new KeyValueIconTriple <Protocol, string>(protocol, protocol.getDescription(),
                                                                        protocol.disk()));
            }

            foreach (Protocol protocol in p.find(new ProfileProtocolPredicate()).toArray(new Protocol[] { }))
            {
                protocols.Add(new KeyValueIconTriple <Protocol, string>(protocol, protocol.getDescription(),
                                                                        protocol.disk()));
            }
            protocols.Add(new KeyValueIconTriple <Protocol, string>(null,
                                                                    LocaleFactory.localizedString("More Options", "Bookmark") + '\u2026', null));

            View.PopulateProtocols(protocols);
        }
        // Generic Password
        public override string getPassword(String serviceName, String user)
        {
            String password = PreferencesFactory.get().getProperty($"{serviceName} - {user}");

            if (null == password)
            {
                // Legacy implementation
                Protocol ftp = ProtocolFactory.get().forScheme(Scheme.ftp);
                if (null == ftp)
                {
                    return(null);
                }
                Host host = new Host(ftp, serviceName);
                host.getCredentials().setUsername(user);
                return(getPassword(host));
            }
            return(DataProtector.Decrypt(password));
        }
示例#10
0
        private void InitProtocols()
        {
            List <KeyValueIconTriple <Protocol, string> > protocols = new List <KeyValueIconTriple <Protocol, string> >();
            ProtocolFactory p = ProtocolFactory.get();

            foreach (Protocol protocol in p.find(new DefaultProtocolPredicate(
                                                     EnumSet.of(Protocol.Type.ftp, Protocol.Type.sftp, Protocol.Type.dav))).toArray(new Protocol[] { }))
            {
                protocols.Add(new KeyValueIconTriple <Protocol, string>(protocol, protocol.getDescription(),
                                                                        protocol.disk()));
            }

            foreach (Protocol protocol in p.find(new DefaultProtocolPredicate(
                                                     EnumSet.of(Protocol.Type.s3, Protocol.Type.swift, Protocol.Type.azure, Protocol.Type.b2,
                                                                Protocol.Type.dracoon,
                                                                Protocol.Type.googlestorage))).toArray(new Protocol[] { }))
            {
                protocols.Add(new KeyValueIconTriple <Protocol, string>(protocol, protocol.getDescription(),
                                                                        protocol.disk()));
            }

            foreach (Protocol protocol in p.find(new DefaultProtocolPredicate(
                                                     EnumSet.of(Protocol.Type.dropbox, Protocol.Type.onedrive, Protocol.Type.googledrive, Protocol.Type.nextcloud)))
                     .toArray(new Protocol[] { }))
            {
                protocols.Add(new KeyValueIconTriple <Protocol, string>(protocol, protocol.getDescription(),
                                                                        protocol.disk()));
            }

            foreach (Protocol protocol in p.find(new DefaultProtocolPredicate(
                                                     EnumSet.of(Protocol.Type.file))).toArray(new Protocol[] { }))
            {
                protocols.Add(new KeyValueIconTriple <Protocol, string>(protocol, protocol.getDescription(),
                                                                        protocol.disk()));
            }

            foreach (Protocol protocol in p.find(new ProfileProtocolPredicate()).toArray(new Protocol[] { }))
            {
                protocols.Add(new KeyValueIconTriple <Protocol, string>(protocol, protocol.getDescription(),
                                                                        protocol.disk()));
            }

            View.PopulateProtocols(protocols);
        }
示例#11
0
        void ICyberduck.RegisterProfile(string profilePath)
        {
            Local    f       = LocalFactory.get(profilePath);
            Protocol profile = (Protocol)ProfileReaderFactory.get().read(f);

            if (null == profile)
            {
                return;
            }
            if (profile.isEnabled())
            {
                ProtocolFactory.get().register(profile);
                Host host = new Host(profile, profile.getDefaultHostname(), profile.getDefaultPort());
                NewBrowser().AddBookmark(host);
                // Register in application support
                Local profiles =
                    LocalFactory.get(SupportDirectoryFinderFactory.get().find(),
                                     PreferencesFactory.get().getProperty("profiles.folder.name"));
                profiles.mkdir();
                f.copy(LocalFactory.get(profiles, f.getName()));
            }
        }
示例#12
0
 private void CommandsAfterLaunch(IList <string> args)
 {
     if (args.Count > 0)
     {
         string arg = args[0];
         Logger.debug("applicationOpenFile:" + arg);
         Local f = LocalFactory.get(arg);
         if (f.exists())
         {
             if ("cyberducklicense".Equals(f.getExtension()))
             {
                 License license = LicenseFactory.get(f);
                 if (license.verify(new DisabledLicenseVerifierCallback()))
                 {
                     f.copy(LocalFactory.get(PreferencesFactory.get().getProperty("application.support.path"),
                                             f.getName()));
                     _bc.InfoBox(license.ToString(),
                                 LocaleFactory.localizedString(
                                     "Thanks for your support! Your contribution helps to further advance development to make Cyberduck even better.",
                                     "License"),
                                 LocaleFactory.localizedString(
                                     "Your registration key has been copied to the Application Support folder.",
                                     "License"),
                                 String.Format("{0}", LocaleFactory.localizedString("Continue", "License")), null, false);
                     foreach (BrowserController controller in new List <BrowserController>(Browsers))
                     {
                         controller.RemoveDonateButton();
                     }
                 }
                 else
                 {
                     _bc.WarningBox(LocaleFactory.localizedString("Not a valid registration key", "License"),
                                    LocaleFactory.localizedString("Not a valid registration key", "License"),
                                    LocaleFactory.localizedString("This registration key does not appear to be valid.",
                                                                  "License"), null,
                                    String.Format("{0}", LocaleFactory.localizedString("Continue", "License")), false,
                                    ProviderHelpServiceFactory.get().help(), delegate { });
                 }
             }
             else if ("cyberduckprofile".Equals(f.getExtension()))
             {
                 Protocol profile = (Protocol)ProfileReaderFactory.get().read(f);
                 if (null == profile)
                 {
                     return;
                 }
                 if (profile.isEnabled())
                 {
                     ProtocolFactory.get().register(profile);
                     Host host = new Host(profile, profile.getDefaultHostname(), profile.getDefaultPort());
                     NewBrowser().AddBookmark(host);
                     // Register in application support
                     Local profiles =
                         LocalFactory.get(PreferencesFactory.get().getProperty("application.support.path"),
                                          PreferencesFactory.get().getProperty("profiles.folder.name"));
                     profiles.mkdir();
                     f.copy(LocalFactory.get(profiles, f.getName()));
                 }
             }
             else if ("duck".Equals(f.getExtension()))
             {
                 Host bookmark = (Host)HostReaderFactory.get().read(f);
                 if (null == bookmark)
                 {
                     return;
                 }
                 NewBrowser().Mount(bookmark);
             }
         }
         else
         {
             // it might be an URL
             if (Uri.IsWellFormedUriString(arg, UriKind.Absolute))
             {
                 Host h = HostParser.parse(arg);
                 if (AbstractPath.Type.file == _detector.detect(h.getDefaultPath()))
                 {
                     Path file = new Path(h.getDefaultPath(), EnumSet.of(AbstractPath.Type.file));
                     // wait until transferCollection is loaded
                     transfersSemaphore.Wait();
                     TransferController.Instance.StartTransfer(new DownloadTransfer(h, file,
                                                                                    LocalFactory.get(PreferencesFactory.get().getProperty("queue.download.folder"),
                                                                                                     file.getName())));
                 }
                 else
                 {
                     foreach (BrowserController b in Browsers)
                     {
                         if (b.IsMounted())
                         {
                             if (
                                 new HostUrlProvider().get(b.Session.getHost())
                                 .Equals(new HostUrlProvider().get(h)))
                             {
                                 b.View.BringToFront();
                                 return;
                             }
                         }
                     }
                     NewBrowser().Mount(h);
                 }
             }
         }
     }
 }