Esempio n. 1
0
 internal UserAuthPassword(UserInfo userinfo)
 {
     m_userinfo = userinfo;
 }
Esempio n. 2
0
 public void setUserInfo(UserInfo userinfo)
 {
     this.m_userinfo = userinfo;
 }
Esempio n. 3
0
 internal UserAuthPublicKey(UserInfo userinfo)
 {
     m_userinfo = userinfo;
 }
Esempio n. 4
0
 internal UserAuthNone(UserInfo userinfo)
 {
     m_userinfo = userinfo;
 }
Esempio n. 5
0
 public abstract void add(string host, byte[] key, UserInfo ui);
Esempio n. 6
0
        public override void add(string host, byte[] key, UserInfo userinfo)
        {
            HostKey hk;
            HostKey.HostKeyTypes type = getType(key);
            for (int i = 0; i < m_pool.Count; i++)
            {
                hk = m_pool[i];
                if (isIncluded(hk.m_host, host) && hk.m_type == type)
                {
                    /*
                            if(Util.array_equals(hk.key, key)){ return; }
                            if(hk.host.equals(host)){
                            hk.key=key;
                            return;
                        }
                        else{
                            hk.host=deleteSubString(hk.host, host);
                        break;
                        }
                    */
                }
            }
            hk = new HostKey(host, type, key);
            m_pool.Add(hk);

            string bar = getKnownHostsRepositoryID();
            if (userinfo != null &&
                bar != null)
            {
                bool foo = true;
                FileInfo goo = new FileInfo(bar);
                if (!goo.Exists)
                {
                    foo = false;
                    if (userinfo != null)
                    {
                        foo = userinfo.promptYesNo(
                            bar + " does not exist.\n" +
                            "Are you sure you want to create it?"
                            );
                        DirectoryInfo dir = goo.Directory;
                        if (foo && dir != null && !dir.Exists)
                        {
                            foo = userinfo.promptYesNo(
                                "The parent directory " + dir.Name + " does not exist.\n" +
                                "Are you sure you want to create it?"
                                );
                            if (foo)
                            {
                                try
                                {
                                    dir.Create(); userinfo.showMessage(dir.Name + " has been succesfully created.\nPlease check its access permission.");
                                }
                                catch
                                {
                                    userinfo.showMessage(dir.Name + " has not been created.");
                                    foo = false;
                                }
                            }
                        }
                        if (goo == null) foo = false;
                    }
                }
                if (foo)
                {
                    try
                    {
                        sync(bar);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("sync known_hosts: " + e);
                    }
                }
            }
        }