bool FilterCertificateByPolicy(MailAddress address, X509Certificate2 cert, IPolicyResolver resolver, bool incoming) { if (cert == null || resolver == null) { return(true); } IList <IPolicyExpression> exressions = (incoming) ? resolver.GetIncomingPolicy(address) : resolver.GetOutgoingPolicy(address); try { var policyFilter = PolicyFilter.Default; foreach (var expression in exressions) { if (!policyFilter.IsCompliant(cert, expression)) { return(false); } } } catch (PolicyRequiredException) // certificate { return(false); } catch (PolicyProcessException processException) { throw new AgentException(AgentError.InvalidPolicy, processException); } return(true); }
bool FilterCertificateByPolicy(MailAddress address, X509Certificate2 cert, IPolicyResolver resolver, bool incoming) { if (cert == null || resolver == null || m_policyFilter == null) { return true; } IList<IPolicyExpression> exressions = (incoming) ? resolver.GetIncomingPolicy(address) : resolver.GetOutgoingPolicy(address); try { foreach (var expression in exressions) { if (! m_policyFilter.IsCompliant(cert, expression)) { return false; } } } catch (PolicyRequiredException) // certificate { return false; } catch (PolicyProcessException processException) { throw new AgentException(AgentError.InvalidPolicy, processException); } return true; }
GetOutgoingPolicy(MailAddress address) { return(m_outgoingResolver.GetOutgoingPolicy(address)); }