void IPolicyImportExtension.ImportPolicy(MetadataImporter importer, PolicyConversionContext policyContext) { if (importer == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("importer"); } if (policyContext == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("policyContext"); } WSSecurityPolicy securityPolicy; if (WSSecurityPolicy.TryGetSecurityPolicyDriver(policyContext.GetBindingAssertions(), out securityPolicy)) { if ((importer.State != null) && (!importer.State.ContainsKey(MaxPolicyRedirectionsKey))) { importer.State.Add(MaxPolicyRedirectionsKey, this.MaxPolicyRedirections); } SecurityBindingElement sbe = null; bool success = this.TryImportSymmetricSecurityBindingElement(importer, policyContext, out sbe); if (!success) { success = this.TryImportAsymmetricSecurityBindingElement(importer, policyContext, out sbe); } if (!success) { success = this.TryImportTransportSecurityBindingElement(importer, policyContext, out sbe, false); } else { // We already have found and imported the message security binding element above. Hence this could be the dual mode security. // Now let us see if there is HttpsTransportBinding assertion also below it .This is to avoid the // warning messages while importing wsdl representing the message security over Https transport security scenario. See Bug:136416. SecurityBindingElement tbe = null; this.TryImportTransportSecurityBindingElement(importer, policyContext, out tbe, true); } if (sbe != null) { SecurityElement config = new SecurityElement(); config.InitializeFrom(sbe, false); if (config.HasImportFailed) { #pragma warning suppress 56506 importer.Errors.Add(new MetadataConversionError(SR.GetString(SR.SecurityBindingElementCannotBeExpressedInConfig), true)); } } } }
void IPolicyImportExtension.ImportPolicy(MetadataImporter importer, PolicyConversionContext policyContext) { WSSecurityPolicy policy; if (importer == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("importer"); } if (policyContext == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("policyContext"); } if (WSSecurityPolicy.TryGetSecurityPolicyDriver(policyContext.GetBindingAssertions(), out policy)) { if ((importer.State != null) && !importer.State.ContainsKey("MaxPolicyRedirections")) { importer.State.Add("MaxPolicyRedirections", this.MaxPolicyRedirections); } SecurityBindingElement sbe = null; bool flag = this.TryImportSymmetricSecurityBindingElement(importer, policyContext, out sbe); if (!flag) { flag = this.TryImportTransportSecurityBindingElement(importer, policyContext, out sbe); } if (!flag) { this.TryImportAsymmetricSecurityBindingElement(importer, policyContext, out sbe); } if (sbe != null) { SecurityElement element2 = new SecurityElement(); element2.InitializeFrom(sbe, false); if (element2.HasImportFailed) { importer.Errors.Add(new MetadataConversionError(System.ServiceModel.SR.GetString("SecurityBindingElementCannotBeExpressedInConfig"), true)); } } } }