コード例 #1
0
        public string login()
        {
            objUserData                   = new UserData();
            CommonAPI.LoginInfo           = objUserData;
            objUserData.uuid              = Guid.NewGuid().ToString();
            objUserData.WorkStationSerial = Tools.generateWorkStationGUID();

            SymmetricCryptography symmetricCryptography_0;            //加密器

            symmetricCryptography_0 = new SymmetricCryptography(SymmetricProvider.Rijndael);
            byte[] key = null;
            byte[] iV  = null;

            //系统默认是根据uuid 生成一个算法key的,或者简单理解为uuid就是加密和解密的密码
            CommonAPI.GenerateKey(objUserData.uuid, ref key, ref iV, SymmetricProvider.Rijndael);
            symmetricCryptography_0.Key = key;
            symmetricCryptography_0.IV  = iV;


            objUserData.UserId     = symmetricCryptography_0.EncryptString(m_strUser);         //demo
            objUserData.Password   = symmetricCryptography_0.EncryptString(m_strPassword);     //DEMO
            objUserData.AppServer  = m_strServer;
            objUserData.LanguageID = "zh-CN";
            objUserData.cSubID     = "DP";
            objUserData.operDate   = m_strDate;

            objUserData.DataSource = m_strDataSource;

            Debugger.Log(0, null, UserDataTools.userData2String(objUserData));
            var paras       = new CommonParameters();
            var loginHeader = new LoginedDataHead();

            loginHeader.ChangePwd          = false;
            loginHeader.KickOutWorkStation = false;
            loginHeader.NewPassword        = symmetricCryptography_0.EncryptString("");     //DEMO

            paras.Para1 = "TARGET\\ENTERPRISEPORTAL.EXE";
            paras.Para2 = true;
            paras.Para3 = loginHeader;

            try {
                credit.BFDispatch("Authenticate", objUserData, ref paras);

                if (!string.IsNullOrEmpty(paras.Para1))
                {
                    return(paras.Para1);
                }
            } catch (CustomError cEx) {
                //MessageBox.Show(cEx.Message);
                throw;
            } finally {
            }
        }
コード例 #2
0
ファイル: UserDataTools.cs プロジェクト: zzlufida/MiniU8Login
        // UFSoft.U8.Framework.Login.UI.clsLogin
        public static UserData DeUserData(string cryptuuid, string s, string string_17)
        {
            UserData userData = null;

            if (s.Length != 0)
            {
                byte[] iV  = null;
                byte[] key = null;
                SymmetricCryptography symm = new SymmetricCryptography(SymmetricProvider.Rijndael);
                CommonAPI.GenerateKey(cryptuuid, ref key, ref iV, SymmetricProvider.Rijndael);
                symm.Key = key;
                symm.IV  = iV;
                StringReader  stringReader  = new StringReader(s);
                XmlTextReader xmlTextReader = CustomTypeAlias.CreateXmlReader(stringReader);
                userData = new UserData();
                while (xmlTextReader.Read())
                {
                    if (xmlTextReader.NodeType == XmlNodeType.Element && xmlTextReader.LocalName == "Entry")
                    {
                        userData.UserId            = symm.DecryptString(xmlTextReader.GetAttribute("user"));
                        userData.Password          = symm.DecryptString(xmlTextReader.GetAttribute("data"));
                        userData.AccID             = symm.DecryptString(xmlTextReader.GetAttribute("accid"));
                        userData.AppServer         = symm.DecryptString(xmlTextReader.GetAttribute("appserver"));
                        userData.cSubID            = symm.DecryptString(xmlTextReader.GetAttribute("subid"));
                        userData.iYear             = symm.DecryptString(xmlTextReader.GetAttribute("iyear"));
                        userData.ConnString        = symm.DecryptString(xmlTextReader.GetAttribute("connstring"));
                        userData.operDate          = symm.DecryptString(xmlTextReader.GetAttribute("operdate"));
                        userData.DataSource        = symm.DecryptString(xmlTextReader.GetAttribute("datasource"));
                        userData.LanguageID        = symm.DecryptString(xmlTextReader.GetAttribute("languageid"));
                        userData.WorkStationSerial = symm.DecryptString(xmlTextReader.GetAttribute("workstationserial"));
                        userData.RightServer       = symm.DecryptString(xmlTextReader.GetAttribute("rightserver"));
                        userData.IsCompanyVer      = bool.Parse(symm.DecryptString(xmlTextReader.GetAttribute("iscompanyver")));
                        userData.SecondConnString  = (Hashtable)CustomXmlSerializer.Deserialize(symm.DecryptString(xmlTextReader.GetAttribute("secondconnstring")), "Hashtable");
                        userData.EmployeeId        = symm.DecryptString(xmlTextReader.GetAttribute("employeeid"));
                        userData.IsAdmin           = bool.Parse(symm.DecryptString(xmlTextReader.GetAttribute("isadmin")));
                        userData.UserName          = symm.DecryptString(xmlTextReader.GetAttribute("username"));
                        userData.AccName           = symm.DecryptString(xmlTextReader.GetAttribute("accname"));
                        userData.EntTypeID         = symm.DecryptString(xmlTextReader.GetAttribute("enttypeid"));
                        userData.iMonth            = int.Parse(symm.DecryptString(xmlTextReader.GetAttribute("imonth")));
                        userData.AppServerSerial   = symm.DecryptString(xmlTextReader.GetAttribute("appServerserial"));
                        userData.Roles             = symm.DecryptString(xmlTextReader.GetAttribute("roles"));
                        userData.ProtocolPort      = (Hashtable)CustomXmlSerializer.Deserialize(symm.DecryptString(xmlTextReader.GetAttribute("protocolport")), "protocolport");
                        userData.BarCode           = symm.DecryptString(xmlTextReader.GetAttribute("barcode"));
                        userData.Customer          = symm.DecryptString(xmlTextReader.GetAttribute("customer"));
                        userData.AuthenMode        = int.Parse(symm.DecryptString(xmlTextReader.GetAttribute("authenmode")));
                        userData.AuthenExtraInfo   = symm.DecryptString(xmlTextReader.GetAttribute("authenextrainfo"));
                        userData.IndustryType      = symm.DecryptString(xmlTextReader.GetAttribute("industrytype"));
                        userData.iBeginYear        = symm.DecryptString(xmlTextReader.GetAttribute("ibeginyear"));
                        userData.AIOServer         = symm.DecryptString(xmlTextReader.GetAttribute("aiosrv"));

                        if (xmlTextReader.GetAttribute("crmsrv") != null && FIELDMAP.ContainsKey("CrmServer"))
                        {
                            //userData.CrmServer = symm.DecryptString(xmlTextReader.GetAttribute("crmsrv"));

                            FIELDMAP["CrmServer"].SetValue(userData, symm.DecryptString(xmlTextReader.GetAttribute("crmsrv")));
                        }


                        if (xmlTextReader.GetAttribute("utusrv") != null && FIELDMAP.ContainsKey("UTUServer"))
                        {
                            //userData.UTUServer = symm.DecryptString(xmlTextReader.GetAttribute("utusrv"));

                            FIELDMAP["UTUServer"].SetValue(userData, symm.DecryptString(xmlTextReader.GetAttribute("utusrv")));
                        }


                        if (xmlTextReader.GetAttribute("remind") != null && FIELDMAP.ContainsKey("isRemind"))
                        {
                            FIELDMAP["isRemind"].SetValue(userData, bool.Parse(symm.DecryptString(xmlTextReader.GetAttribute("remind"))));
                        }
                        if (xmlTextReader.GetAttribute("usermode") != null && FIELDMAP.ContainsKey("UserMode"))
                        {
                            FIELDMAP["UserMode"].SetValue(userData, int.Parse(symm.DecryptString(xmlTextReader.GetAttribute("usermode"))));
                        }
                        if (xmlTextReader.GetAttribute("sps") != null && FIELDMAP.ContainsKey("ValidateSPS"))
                        {
                            FIELDMAP["ValidateSPS"].SetValue(userData, bool.Parse(symm.DecryptString(xmlTextReader.GetAttribute("sps"))));
                        }
                        if (xmlTextReader.GetAttribute("sysdate") != null && FIELDMAP.ContainsKey("sysdate"))
                        {
                            FIELDMAP["sysdate"].SetValue(userData, symm.DecryptString(xmlTextReader.GetAttribute("sysdate")));
                        }

                        if (string.IsNullOrEmpty(string_17))
                        {
                            userData.Auditor = new AuditorContext {
                                AuditorId   = userData.UserId,
                                AuditorName = userData.UserName
                            };
                        }
                        else
                        {
                            userData.Auditor = (AuditorContext)CustomXmlSerializer.Deserialize(symm.DecryptString(string_17), "AuditorContext");
                        }

                        xmlTextReader.Close();
                        stringReader.Close();
                    }
                }
            }
            userData.uuid = cryptuuid;
            return(userData);
        }