Exemplo n.º 1
0
        /// <summary>
        /// 获取签名密码
        /// </summary>
        /// <param name="digitalSignatureFile">数字证书文件</param>
        /// <returns>私钥</returns>
        public static string GetSignedPassword(string digitalSignatureFile)
        {
            // 0:这里需要处理异常信息
            // 1:定义私钥
            string signedPassword = string.Empty;
            // 2:读取证书文件
            string digitalSignature = FileUtil.ReadBinaryFile(digitalSignatureFile);
            // 3:解密文件
            string xmlFile = SecretUtil.Decrypt(digitalSignature);
            // 4:按XML文件读取
            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.LoadXml(xmlFile);
            signedPassword = xmlDocument.SelectSingleNode("//DigitalSignature/Key").Attributes["SignedPassword"].Value;
            return(signedPassword);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取私钥
        /// </summary>
        /// <param name="digitalSignatureFile">数字证书文件</param>
        /// <param name="signedPassword">签名密码</param>
        /// <returns>私钥</returns>
        public static string GetPrivateKey(string digitalSignatureFile, string signedPassword)
        {
            // 0:这里需要处理异常信息
            // 1:定义私钥
            string privateKey = string.Empty;
            // 2:读取证书文件
            string digitalSignature = FileUtil.ReadBinaryFile(digitalSignatureFile);
            // 3:解密文件
            string xmlFile = SecretUtil.Decrypt(digitalSignature);
            // 4:按XML文件读取
            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.LoadXml(xmlFile);
            string keySignedPassword = xmlDocument.SelectSingleNode("//DigitalSignature/Key").Attributes["SignedPassword"].Value;

            // 5:若签名密码不对,不应该能读取私钥
            if (md5(signedPassword, 32).Equals(keySignedPassword))
            {
                privateKey = xmlDocument.SelectSingleNode("//DigitalSignature/Key").Attributes["PrivateKey"].Value;
            }
            return(privateKey);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 从配置信息获取配置信息
        /// </summary>
        /// <param name="configuration">配置</param>
        public static void GetConfig()
        {
            // 客户信息配置
            BaseSystemInfo.CustomerCompanyName = ConfigurationManager.AppSettings["CustomerCompanyName"];
            BaseSystemInfo.ConfigurationFrom   = BaseConfiguration.GetConfiguration(ConfigurationManager.AppSettings["ConfigurationFrom"]);
            BaseSystemInfo.SoftName            = ConfigurationManager.AppSettings["SoftName"];
            BaseSystemInfo.SoftFullName        = ConfigurationManager.AppSettings["SoftFullName"];
            BaseSystemInfo.RootMenuCode        = ConfigurationManager.AppSettings["RootMenuCode"];
            // BaseSystemInfo.CurrentLanguage = ConfigurationManager.AppSettings[BaseConfiguration.CURRENT_LANGUAGE];
            // BaseSystemInfo.Version = ConfigurationManager.AppSettings[BaseConfiguration.VERSION];

            // BaseSystemInfo.UseModulePermission = (ConfigurationManager.AppSettings[BaseConfiguration.USE_MODULE_PERMISSION].ToUpper(), true.ToString().ToUpper(), true);
            // BaseSystemInfo.UsePermissionScope = (ConfigurationManager.AppSettings[BaseConfiguration.USE_PERMISSIONS_COPE].ToUpper(), true.ToString().ToUpper(), true);
            // BaseSystemInfo.UseTablePermission = (ConfigurationManager.AppSettings[BaseConfiguration.USE_TABLE_PERMISSION].ToUpper(), true.ToString().ToUpper(), true);

            // BaseSystemInfo.Service = ConfigurationManager.AppSettings[BaseConfiguration.SERVICE];
            // BaseSystemInfo.RecordLog = (ConfigurationManager.AppSettings[BaseConfiguration.RECORD_LOG].ToUpper(), true.ToString().ToUpper(), true);

            if (ConfigurationManager.AppSettings["ServerEncryptPassword"] != null)
            {
                BaseSystemInfo.ServerEncryptPassword = ConfigurationManager.AppSettings["ServerEncryptPassword"].ToUpper().Equals(true.ToString().ToUpper());
            }
            if (ConfigurationManager.AppSettings["ClientEncryptPassword"] != null)
            {
                BaseSystemInfo.ClientEncryptPassword = ConfigurationManager.AppSettings["ClientEncryptPassword"].ToUpper().Equals(true.ToString().ToUpper());
            }

            if (ConfigurationManager.AppSettings["CheckIPAddress"] != null)
            {
                BaseSystemInfo.CheckIPAddress = ConfigurationManager.AppSettings["CheckIPAddress"].ToUpper().Equals(true.ToString().ToUpper());
            }

            // BaseSystemInfo.AutoLogOn = (ConfigurationManager.AppSettings[BaseConfiguration.AUTO_LOGON].ToUpper(), true.ToString().ToUpper(), true);
            // BaseSystemInfo.LogOnAssembly = ConfigurationManager.AppSettings[BaseConfiguration.LOGON_ASSEMBLY];
            // BaseSystemInfo.LogOnForm = ConfigurationManager.AppSettings[BaseConfiguration.LOGON_FORM];
            // BaseSystemInfo.MainForm = ConfigurationManager.AppSettings[BaseConfiguration.MAIN_FORM];

            BaseSystemInfo.CheckOnLine = ConfigurationManager.AppSettings["CheckOnLine"].ToUpper().Equals(true.ToString().ToUpper());
            // BaseSystemInfo.LoadAllUser = (ConfigurationManager.AppSettings[BaseConfiguration.LOAD_All_USER].ToUpper(), true.ToString().ToUpper(), true);
            // BaseSystemInfo.AllowUserRegister = (ConfigurationManager.AppSettings[BaseConfiguration.ALLOW_USER_REGISTER].ToUpper(), true.ToString().ToUpper(), true);

            // 数据库连接
            if (ConfigurationManager.AppSettings["UserCenterDbType"] != null)
            {
                BaseSystemInfo.UserCenterDbType = BaseConfiguration.GetDataBaseType(ConfigurationManager.AppSettings["UserCenterDbType"]);
            }
            if (ConfigurationManager.AppSettings["BusinessDbType"] != null)
            {
                BaseSystemInfo.BusinessDbType = BaseConfiguration.GetDataBaseType(ConfigurationManager.AppSettings["BusinessDbType"]);
            }
            if (ConfigurationManager.AppSettings["WorkFlowDbType"] != null)
            {
                BaseSystemInfo.WorkFlowDbType = BaseConfiguration.GetDataBaseType(ConfigurationManager.AppSettings["WorkFlowDbType"]);
            }
            BaseSystemInfo.EncryptDbConnection          = ConfigurationManager.AppSettings["EncryptDbConnection"].ToUpper().Equals(true.ToString().ToUpper());
            BaseSystemInfo.BusinessDbConnectionString   = ConfigurationManager.AppSettings["BusinessDbConnection"];
            BaseSystemInfo.UserCenterDbConnectionString = ConfigurationManager.AppSettings["UserCenterDbConnection"];
            BaseSystemInfo.WorkFlowDbConnectionString   = ConfigurationManager.AppSettings["WorkFlowDbConnection"];
            // 对加密的数据库连接进行解密操作
            if (BaseSystemInfo.EncryptDbConnection)
            {
                BaseSystemInfo.BusinessDbConnection   = SecretUtil.Decrypt(BaseSystemInfo.BusinessDbConnectionString);
                BaseSystemInfo.UserCenterDbConnection = SecretUtil.Decrypt(BaseSystemInfo.UserCenterDbConnectionString);
                BaseSystemInfo.WorkFlowDbConnection   = SecretUtil.Decrypt(BaseSystemInfo.WorkFlowDbConnectionString);
            }
            else
            {
                BaseSystemInfo.BusinessDbConnection   = ConfigurationManager.AppSettings["BusinessDbConnection"];
                BaseSystemInfo.UserCenterDbConnection = ConfigurationManager.AppSettings["UserCenterDbConnection"];
                BaseSystemInfo.WorkFlowDbConnection   = ConfigurationManager.AppSettings["WorkFlowDbConnection"];
            }

            BaseSystemInfo.RegisterKey = ConfigurationManager.AppSettings["RegisterKey"];
        }