/// <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); }
/// <summary> /// 获得新的数据库连接 /// </summary> /// <param name="connectionString">数据库连接字符串</param> /// <returns>数据库连接</returns> public virtual IDbConnection Open(string connectionString) { // 写入调试信息 #if (DEBUG) int milliStart = Environment.TickCount; Trace.WriteLine(DateTime.Now.ToString(BaseSystemInfo.TimeFormat) + " :Begin: " + MethodBase.GetCurrentMethod().ReflectedType.Name + "." + MethodBase.GetCurrentMethod().Name); #endif // 这里数据库连接打开的时候,就判断注册属性的有效性 if (!SecretUtil.CheckRegister()) { // 若没有进行注册,让程序无法打开数据库比较好。 connectionString = string.Empty; // 抛出异常信息显示给客户 throw new Exception(BaseSystemInfo.RegisterException); } // 若是空的话才打开 if (this.dbConnection == null || this.dbConnection.State == ConnectionState.Closed) { this.ConnectionString = connectionString; this.dbConnection = GetInstance().CreateConnection(); this.dbConnection.ConnectionString = this.ConnectionString; this.dbConnection.Open(); // 创建对象 // this.dbCommand = this.DbConnection.CreateCommand(); // this.dbCommand.Connection = this.dbConnection; // this.dbDataAdapter = this.dbProviderFactory.CreateDataAdapter(); // this.dbDataAdapter.SelectCommand = this.dbCommand; // 写入调试信息 #if (DEBUG) int milliEnd = Environment.TickCount; Trace.WriteLine(DateTime.Now.ToString(BaseSystemInfo.TimeFormat) + " Ticks: " + TimeSpan.FromMilliseconds(milliEnd - milliStart).ToString() + " :End: " + MethodBase.GetCurrentMethod().ReflectedType.Name + "." + MethodBase.GetCurrentMethod().Name); #endif } return(this.dbConnection); }
/// <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); }
/// <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"]; }