Exemplo n.º 1
0
        private void Test()
        {
            string url = this.ConvertDSNS(txtAccessPoint.Text);

            Connection con = new Connection();

            con.EnableSecureTunnel = true;

            SecurityToken st;

            if (rbBasic.Checked)
            {
                st = new BasicSecurityToken(txtBasicAccount.Text, txtBasicPassword.Text);
            }
            else
            {
                Connection c = new Connection();
                c.EnableSecureTunnel = true;
                c.Connect(txtIssuer.Text, "", txtIssuerAccount.Text, txtIssuerPassword.Text);
                Envelope env = c.SendRequest("DS.Base.GetPassportToken", new Envelope());
                st = new PassportSecurityToken(env.Body.XmlString);
            }

            con.Connect(url, txtContract.Text, st);
        }
        internal static Connection DeployConnect(XmlElement siteElement)
        {
            XmlHelper h           = new XmlHelper(siteElement);
            string    accesspoint = h.GetText("AccessPoint");
            string    contract    = h.GetText("Contract");
            string    authType    = h.GetText("Authentication/@Type").ToLower();
            string    username    = h.GetText("Authentication/UserName");
            string    password    = h.GetText("Authentication/Password");
            string    issuer      = h.GetText("Authentication/Issuer");

            string url = ConvertDSNS(accesspoint);

            Connection con = new Connection();

            con.EnableSecureTunnel = true;

            SecurityToken st;

            if (authType == "basic")
            {
                st = new BasicSecurityToken(username, password);
            }
            else
            {
                Connection c = new Connection();
                c.EnableSecureTunnel = true;
                c.Connect(issuer, "", username, password);
                Envelope env = c.SendRequest("DS.Base.GetPassportToken", new Envelope());
                st = new PassportSecurityToken(env.Body.XmlString);
            }

            con.Connect(url, contract, st);
            return(con);
        }
Exemplo n.º 3
0
        internal void ConnectModuleServer()
        {
            this.ModuleConnection               = new Connection();
            ModuleConnection.EnableSession      = true;
            ModuleConnection.EnableSecureTunnel = true;

            Envelope rsp = this.GreeningConnection.SendRequest("DS.Base.GetPassportToken", new Envelope());
            PassportSecurityToken stt = new PassportSecurityToken(rsp.Body.XmlString);

            ModuleConnection.Connect(_moduleURL, "developer", stt);
        }
        internal SecurityToken GetSecurityToken()
        {
            if (!chkPassport.Checked)
            {
                return(new BasicSecurityToken(txtUser.Text, txtPwd.Text));
            }
            else
            {
                Connection greenCon = new Connection();
                greenCon.EnableSecureTunnel = true;
                greenCon.EnableSession      = true;
                greenCon.Connect(txtProvider.Text, string.Empty, txtUser.Text.Trim(), txtPwd.Text);

                Envelope rsp = greenCon.SendRequest("DS.Base.GetPassportToken", new Envelope());
                txtPassport.Text = rsp.Body.XmlString;
                xmlSyntaxLanguage1.FormatDocument(txtPassport.Document);
                PassportSecurityToken stt = new PassportSecurityToken(rsp.Body.XmlString);
                return(stt);
            }
        }
Exemplo n.º 5
0
        private void Login()
        {
            string greeningURL = "http://10.1.1.163/greening2/shared";
            string moduleURL   = "http://10.1.1.163/modules/shared";

            XmlDocument doc      = new XmlDocument();
            string      filename = Path.Combine(Environment.CurrentDirectory, "Setup.config");

            this.ShowMessage("載入設定檔");

            if (File.Exists(filename))
            {
                doc.Load(filename);
                XmlHelper config = new XmlHelper(doc.DocumentElement);
                greeningURL = config.GetText("GreeningAccessPoint");
                moduleURL   = config.GetText("ModuleAccessPoint");
            }

            try
            {
                this.ShowMessage("登入 ischool ....");
                Connection greenCon = new Connection();
                greenCon.EnableSecureTunnel = true;
                greenCon.EnableSession      = false;
                try
                {
                    greenCon.Connect(greeningURL, "user", txtUser.Text.Trim(), txtPassword.Text);
                }
                catch (Exception ex)
                {
                    throw new Exception("ischool Account 認證失敗" + ex.Message);
                }

                Envelope rsp = greenCon.SendRequest("DS.Base.GetPassportToken", new Envelope());
                PassportSecurityToken stt = new PassportSecurityToken(rsp.Body.XmlString);

                XmlHelper h1 = new XmlHelper(rsp.Body);
                string    id = h1.GetText("Content/Attributes/ID");

                string     ftpUser     = string.Empty;
                string     ftpPassword = string.Empty;
                string     ftpUrl      = string.Empty;
                bool       succeedLoginModuleService = false;
                Connection modCon = null;
                try
                {
                    this.ShowMessage("載入線上儲存空間設定...");

                    modCon = new Connection();
                    modCon.EnableSession      = true;
                    modCon.EnableSecureTunnel = true;

                    modCon.Connect(moduleURL, "developer", stt);

                    Envelope  env = modCon.SendRequest("GetFTPInfo", new Envelope());
                    XmlHelper h   = new XmlHelper(env.Body);
                    ftpUser     = TripleDESHelper.Decrypt(h.GetText("User"), USE_KEY);
                    ftpPassword = TripleDESHelper.Decrypt(h.GetText("Password"), USE_KEY);
                    ftpUrl      = TripleDESHelper.Decrypt(h.GetText("FTP"), USE_KEY);
                    succeedLoginModuleService = true;
                }
                catch
                {
                    this.ShowMessage("載入失敗!");
                    succeedLoginModuleService = false;
                }
                string pwd = string.Empty;
                if (chkRemember.Checked)
                {
                    pwd = txtPassword.Text;
                }
                MainForm.Storage.SetPropertyValues("LoginName", txtUser.Text, pwd);
                MainForm.Storage.SetProperty("LastLoginName", txtUser.Text);
                MainForm.Storage.SetProperty("LastLoginPassword", pwd);
                MainForm.Storage.SetProperty("RememberPassword", chkRemember.Checked.ToString().ToLower());

                if (Logined != null)
                {
                    this.ShowMessage("登入開發站台...");
                    LoginEventArgs arg = new LoginEventArgs();
                    arg.FtpPassword        = ftpPassword;
                    arg.FtpUser            = ftpUser;
                    arg.FtpURL             = ftpUrl;
                    arg.GreeningConnection = greenCon;
                    arg.ModuleConnection   = modCon;
                    arg.SetModuleConnectionInfo(moduleURL);
                    arg.LoginUser          = txtUser.Text;
                    arg.GreeningID         = id;
                    arg.SucceedModuleLogin = succeedLoginModuleService;

                    this.ShowMessage("載入開發站台資訊");
                    Logined.Invoke(this, arg);
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                this.ShowMessage("※請輸入 ischool Account 密碼");
            }
        }