protected override void configure(OpenSshConfig.Host hc, Session session)
 {
     if (!hc.isBatchMode())
     {
     #warning need something to replace jgit gui infrastructure as gitsharp is library only
         throw new NotImplementedException("GUI Configuration is not available");
     }
 }
Esempio n. 2
0
 private OpenSshConfig getConfig()
 {
     if (config == null)
     {
         config = OpenSshConfig.get();
     }
     return(config);
 }
Esempio n. 3
0
        /// <summary>
        /// Obtain the user's configuration data.
        /// <para/>
        /// The configuration file is always returned to the caller, even if no file
        /// exists in the user's home directory at the time the call was made. Lookup
        /// requests are cached and are automatically updated if the user modifies
        /// the configuration file since the last time it was cached.
        /// </summary>
        /// <returns>a caching reader of the user's configuration file.</returns>
        public static OpenSshConfig get()
        {
            DirectoryInfo home = FS.userHome() ?? new DirectoryInfo(Path.GetFullPath("."));

            FileInfo config = PathUtil.CombineFilePath(home, ".ssh" + Path.DirectorySeparatorChar + "config");
            var osc = new OpenSshConfig(home, config);
            osc.refresh();
            return osc;
        }
Esempio n. 4
0
        public static OpenSshConfig get()
        {
            DirectoryInfo home = FS.userHome() ?? new DirectoryInfo(Path.GetFullPath("."));

            FileInfo      config = new FileInfo(Path.Combine(home.FullName, ".ssh" + Path.DirectorySeparatorChar + "config"));
            OpenSshConfig osc    = new OpenSshConfig(home, config);

            osc.refresh();
            return(osc);
        }
Esempio n. 5
0
        public override void setUp()
        {
            base.setUp();

            _home = new DirectoryInfo(Path.Combine(trash.FullName, "home"));
            _configFile = new FileInfo(Path.Combine(_home.FullName, ".ssh"));
            Directory.CreateDirectory(_configFile.FullName);

            _configFile = new FileInfo(Path.Combine(_configFile.FullName, "config"));

            // can't do
            //Environment.UserName = "******";

            _osc = new OpenSshConfig(_home, _configFile);
        }
 protected override void configure(OpenSshConfig.Host hc, Session session)
 {
     // No additional configuration required.
 }
Esempio n. 7
0
 private OpenSshConfig getConfig()
 {
     if (_config == null)
         _config = OpenSshConfig.get();
     return _config;
 }
Esempio n. 8
0
        /// <summary>
        /// Obtain the JSch used to create new sessions.
        /// </summary>
        /// <param name="hc">host configuration</param>
        /// <returns>the JSch instance to use.</returns>
        protected JSch getJSch(OpenSshConfig.Host hc)
        {
            if (hc == null)
                throw new System.ArgumentNullException("hc");

            JSch def = getDefaultJSch();
            FileInfo identityFile = hc.getIdentityFile();
            if (identityFile == null)
                return def;

            string identityKey = identityFile.FullName;
            JSch jsch;
            if(!_byIdentityFile.TryGetValue(identityKey, out jsch))
            {
                jsch = new JSch();
                jsch.setHostKeyRepository(def.getHostKeyRepository());
                jsch.addIdentity(identityKey);
                _byIdentityFile.Add(identityKey, jsch);
            }
            return jsch;
        }
Esempio n. 9
0
 /// <summary>
 /// Provide additional configuration for the session based on the host
 /// information. This method could be used to supply {@link UserInfo}.
 /// </summary>
 /// <param name="hc">host configuration</param>
 /// <param name="session">session to configure</param>
 protected abstract void configure(OpenSshConfig.Host hc, Session session);
Esempio n. 10
0
 /// <summary>
 /// Create a new JSch session for the requested address.
 /// </summary>
 /// <param name="hc">host configuration</param>
 /// <param name="user">login to authenticate as.</param>
 /// <param name="host">server name to connect to.</param>
 /// <param name="port">port number of the SSH daemon (typically 22).</param>
 /// <returns>new session instance, but otherwise unconfigured.</returns>
 protected Session createSession(OpenSshConfig.Host hc, string user, string host, int port)
 {
     return getJSch(hc).getSession(user, host, port);
 }
        /// <summary>
        /// Obtain the JSch used to create new sessions.
        /// </summary>
        /// <param name="hc">host configuration</param>
        /// <returns>the JSch instance to use.</returns>
        protected SecureShell getJSch(OpenSshConfig.Host hc)
        {
            if (hc == null)
                throw new System.ArgumentNullException("hc");

            SecureShell def = getDefaultJSch();
            FileInfo identityFile = hc.getIdentityFile();
            if (identityFile == null)
                return def;

            string identityKey = identityFile.FullName;
            SecureShell jsch = _byIdentityFile[identityKey];
            if (jsch == null)
            {
                jsch = new SecureShell();
                jsch.SetHostKeyRepository(def.GetHostKeyRepository());
                jsch.AddIdentity(identityKey);
                _byIdentityFile.Add(identityKey, jsch);
            }
            return jsch;
        }
        protected JSch getJSch(OpenSshConfig.Host hc)
        {
            JSch def = getDefaultJSch();
            FileInfo identityFile = hc.getIdentityFile();
            if (identityFile == null)
                return def;

            string identityKey = Path.GetFullPath(identityFile.ToString());
            JSch jsch = byIdentityFile[identityKey];
            if (jsch == null)
            {
                jsch = new JSch();
                jsch.setHostKeyRepository(def.getHostKeyRepository());
                jsch.addIdentity(identityKey);
                byIdentityFile.Add(identityKey, jsch);
            }
            return jsch;
        }