当前位置: 首页>>代码示例>>C#>>正文


C# Health.CreateResolver方法代码示例

本文整理汇总了C#中Health.CreateResolver方法的典型用法代码示例。如果您正苦于以下问题:C# Health.CreateResolver方法的具体用法?C# Health.CreateResolver怎么用?C# Health.CreateResolver使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Health的用法示例。


在下文中一共展示了Health.CreateResolver方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetValidCertForAddressFromStore

		///<summary>Set isAddressSpecific if you need to allow/prefer domain certificates over email address specific certificates.</summary>
		private static X509Certificate2 GetValidCertForAddressFromStore(Health.Direct.Common.Certificates.SystemX509Store store,string strAddressTest,bool isAddressSpecific) {
			//No need to check RemotingRole; no call to db.
			X509Certificate2Collection collectionCerts=null;
			MailAddress mailAddressQuery=new MailAddress(strAddressTest);
			Health.Direct.Common.Certificates.ICertificateResolver certResolverLocalCache=store.CreateResolver();
			if(certResolverLocalCache==null) {
				return null;
			}
			collectionCerts=certResolverLocalCache.GetCertificates(mailAddressQuery);
			if(collectionCerts==null) {
				return null;
			}
			List<X509Certificate2> listDomainCerts=new List<X509Certificate2>();
			List<X509Certificate2> listAddressCerts=new List<X509Certificate2>();
			for(int i=0;i<collectionCerts.Count;i++) {
				if(DateTime.Now<collectionCerts[i].NotBefore || DateTime.Now>collectionCerts[i].NotAfter) {
					//If the certificate is not yet valid or is expired, then ignore.
					continue;
				}
				string strCertSubjectName=collectionCerts[i].Subject.Trim().ToLower();
				if(strCertSubjectName.Contains("e="+strAddressTest.ToLower())) {//Address specific
					listAddressCerts.Add(collectionCerts[i]);
				}
				else {
					listDomainCerts.Add(collectionCerts[i]);
				}
			}
			if(!isAddressSpecific && listDomainCerts.Count>0) {//Domain certificates allowed/preferred and there is one.
				return listDomainCerts[0];
			}
			if(listAddressCerts.Count>0) {
				return listAddressCerts[0];
			}
			//A certificate was found in the local store, but it was a domain level certificate and was not for the specific address provided.
			return null;
		}
开发者ID:romeroyonatan,项目名称:opendental,代码行数:37,代码来源:EmailMessages.cs

示例2: GetValidCertForAddressFromStore

		///<summary>The strAddressTest can be either a full email address or a domain name.
		///Set isDomainIncluded to true if you would like to include domain level certificates in addition to the certificates which match the exact test address.  Exact address matches will be preferred over domain matches.
		///Otherwise, if isDomainIncluded is false, then only certificates which exactly match the test address will be included.</summary>
		private static X509Certificate2 GetValidCertForAddressFromStore(Health.Direct.Common.Certificates.SystemX509Store store,string strAddressTest,bool isDomainIncluded) {
			//No need to check RemotingRole; no call to db.
			X509Certificate2Collection collectionCerts=null;
			Health.Direct.Common.Certificates.ICertificateResolver certResolverLocalCache=store.CreateResolver();
			if(certResolverLocalCache==null) {
				return null;
			}
			strAddressTest=GetAddressSimple(strAddressTest);
			if(strAddressTest.Contains("@")) {//The specified address is one particular email address as opposed to a domain name.
				collectionCerts=certResolverLocalCache.GetCertificatesForDomain(strAddressTest);//Gets the certificates for the specified address, but does not get the certificates for the domain associated with the address.
				if(collectionCerts!=null) {
					for(int i=0;i<collectionCerts.Count;i++) {
						if(DateTime.Now<collectionCerts[i].NotBefore || DateTime.Now>collectionCerts[i].NotAfter) {
							continue;//If the certificate is not yet valid or is expired, then ignore.
						}
						return collectionCerts[i];
					}
				}
			}
			if(!isDomainIncluded) {
				return null;
			}
			string domain=GetDomainForAddress(strAddressTest);
			if(domain=="") {
				return null;
			}
			collectionCerts=certResolverLocalCache.GetCertificatesForDomain(domain);
			if(collectionCerts!=null) {
				for(int i=0;i<collectionCerts.Count;i++) {
					if(DateTime.Now<collectionCerts[i].NotBefore || DateTime.Now>collectionCerts[i].NotAfter) {
						continue;//If the certificate is not yet valid or is expired, then ignore.
					}
					return collectionCerts[i];
				}
			}
			return null;
		}
开发者ID:mnisl,项目名称:OD,代码行数:40,代码来源:EmailMessages.cs


注:本文中的Health.CreateResolver方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。