void IPolicyExportExtension.ExportPolicy(MetadataExporter exporter, PolicyConversionContext context)
        {
            if (exporter == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
            }

            if (context == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
            }

            if (context.BindingElements != null)
            {
                BindingElementCollection      bindingElements = context.BindingElements;
                ReliableSessionBindingElement settings        = bindingElements.Find <ReliableSessionBindingElement>();

                if (settings != null)
                {
                    // ReliableSession assertion
                    XmlElement assertion = settings.CreateReliabilityAssertion(exporter.PolicyVersion, bindingElements);
                    context.GetBindingAssertions().Add(assertion);
                }
            }
        }
        internal virtual void OnExportPolicy(MetadataExporter exporter, PolicyConversionContext policyContext)
        {
            string localName = null;

            switch (this.AuthenticationScheme)
            {
            case AuthenticationSchemes.Digest:
                localName = "DigestAuthentication";
                break;

            case AuthenticationSchemes.Negotiate:
                localName = "NegotiateAuthentication";
                break;

            case AuthenticationSchemes.Ntlm:
                localName = "NtlmAuthentication";
                break;

            case AuthenticationSchemes.Basic:
                localName = "BasicAuthentication";
                break;
            }
            if (localName != null)
            {
                policyContext.GetBindingAssertions().Add(new XmlDocument().CreateElement("http", localName, "http://schemas.microsoft.com/ws/06/2004/policy/http"));
            }
        }
        void IPolicyExportExtension.ExportPolicy(MetadataExporter exporter, PolicyConversionContext context)
        {
            if (exporter == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("exporter");
            }

            if (context == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
            }

            ICollection <XmlElement> policyAssertions = context.GetBindingAssertions();

            if (TransferModeHelper.IsRequestStreamed(this.TransferMode) ||
                TransferModeHelper.IsResponseStreamed(this.TransferMode))
            {
                policyAssertions.Add(new XmlDocument().CreateElement(TransportPolicyConstants.DotNetFramingPrefix,
                                                                     TransportPolicyConstants.StreamedName, TransportPolicyConstants.DotNetFramingNamespace));
            }

            bool createdNew;
            MessageEncodingBindingElement encodingBindingElement = FindMessageEncodingBindingElement(context.BindingElements, out createdNew);

            if (createdNew && encodingBindingElement is IPolicyExportExtension)
            {
                encodingBindingElement = new BinaryMessageEncodingBindingElement();
                ((IPolicyExportExtension)encodingBindingElement).ExportPolicy(exporter, context);
            }

            WsdlExporter.WSAddressingHelper.AddWSAddressingAssertion(exporter, context, encodingBindingElement.MessageVersion.Addressing);
        }
示例#4
0
        public override XmlElement CreateWsspHttpsTokenAssertion(MetadataExporter exporter, HttpsTransportBindingElement httpsBinding)
        {
            Fx.Assert(httpsBinding != null, "httpsBinding must not be null.");
            Fx.Assert(httpsBinding.AuthenticationScheme.IsSingleton(), "authenticationScheme must be a singleton value for security-mode TransportWithMessageCredential.");

            XmlElement result = CreateWsspAssertion(WSSecurityPolicy.HttpsTokenName);

            if (httpsBinding.RequireClientCertificate ||
                httpsBinding.AuthenticationScheme == AuthenticationSchemes.Basic ||
                httpsBinding.AuthenticationScheme == AuthenticationSchemes.Digest)
            {
                XmlElement policy = CreateWspPolicyWrapper(exporter);
                if (httpsBinding.RequireClientCertificate)
                {
                    policy.AppendChild(CreateWsspAssertion(WSSecurityPolicy.RequireClientCertificateName));
                }
                if (httpsBinding.AuthenticationScheme == AuthenticationSchemes.Basic)
                {
                    policy.AppendChild(CreateWsspAssertion(WSSecurityPolicy.HttpBasicAuthenticationName));
                }
                else if (httpsBinding.AuthenticationScheme == AuthenticationSchemes.Digest)
                {
                    policy.AppendChild(CreateWsspAssertion(WSSecurityPolicy.HttpDigestAuthenticationName));
                }
                result.AppendChild(policy);
            }
            return(result);
        }
        public override Collection <XmlElement> CreateWsspSupportingTokensAssertion(MetadataExporter exporter, Collection <SecurityTokenParameters> signed, Collection <SecurityTokenParameters> signedEncrypted, Collection <SecurityTokenParameters> endorsing, Collection <SecurityTokenParameters> signedEndorsing, Collection <SecurityTokenParameters> optionalSigned, Collection <SecurityTokenParameters> optionalSignedEncrypted, Collection <SecurityTokenParameters> optionalEndorsing, Collection <SecurityTokenParameters> optionalSignedEndorsing, AddressingVersion addressingVersion)
        {
            Collection <XmlElement> collection = new Collection <XmlElement>();
            XmlElement item = this.CreateWsspSignedSupportingTokensAssertion(exporter, signed, optionalSigned);

            if (item != null)
            {
                collection.Add(item);
            }
            item = this.CreateWsspSignedEncryptedSupportingTokensAssertion(exporter, signedEncrypted, optionalSignedEncrypted);
            if (item != null)
            {
                collection.Add(item);
            }
            item = base.CreateWsspEndorsingSupportingTokensAssertion(exporter, endorsing, optionalEndorsing, addressingVersion);
            if (item != null)
            {
                collection.Add(item);
            }
            item = base.CreateWsspSignedEndorsingSupportingTokensAssertion(exporter, signedEndorsing, optionalSignedEndorsing, addressingVersion);
            if (item != null)
            {
                collection.Add(item);
            }
            return(collection);
        }
示例#6
0
        public override XmlElement CreateWsspHttpsTokenAssertion(MetadataExporter exporter, HttpsTransportBindingElement httpsBinding)
        {
            XmlElement element = this.CreateWsspAssertion("HttpsToken");

            element.SetAttribute("RequireClientCertificate", httpsBinding.RequireClientCertificate ? "true" : "false");
            return(element);
        }
示例#7
0
        public override Collection <XmlElement> CreateWsspSupportingTokensAssertion(MetadataExporter exporter, Collection <SecurityTokenParameters> signed, Collection <SecurityTokenParameters> signedEncrypted, Collection <SecurityTokenParameters> endorsing, Collection <SecurityTokenParameters> signedEndorsing, Collection <SecurityTokenParameters> optionalSigned, Collection <SecurityTokenParameters> optionalSignedEncrypted, Collection <SecurityTokenParameters> optionalEndorsing, Collection <SecurityTokenParameters> optionalSignedEndorsing, AddressingVersion addressingVersion)
        {
            Collection <XmlElement> supportingTokenAssertions = new Collection <XmlElement>();

            // Signed Supporting Tokens
            XmlElement supportingTokenAssertion = CreateWsspSignedSupportingTokensAssertion(exporter, signed, optionalSigned);

            if (supportingTokenAssertion != null)
            {
                supportingTokenAssertions.Add(supportingTokenAssertion);
            }

            // Signed Encrypted Supporting Tokens
            supportingTokenAssertion = CreateWsspSignedEncryptedSupportingTokensAssertion(exporter, signedEncrypted, optionalSignedEncrypted);
            if (supportingTokenAssertion != null)
            {
                supportingTokenAssertions.Add(supportingTokenAssertion);
            }

            // Endorsing Supporting Tokens.
            supportingTokenAssertion = CreateWsspEndorsingSupportingTokensAssertion(exporter, endorsing, optionalEndorsing, addressingVersion);
            if (supportingTokenAssertion != null)
            {
                supportingTokenAssertions.Add(supportingTokenAssertion);
            }

            // Signed Endorsing Supporting Tokens.
            supportingTokenAssertion = CreateWsspSignedEndorsingSupportingTokensAssertion(exporter, signedEndorsing, optionalSignedEndorsing, addressingVersion);
            if (supportingTokenAssertion != null)
            {
                supportingTokenAssertions.Add(supportingTokenAssertion);
            }

            return(supportingTokenAssertions);
        }
        void IPolicyExportExtension.ExportPolicy(MetadataExporter exporter, PolicyConversionContext context)
        {
            if (context == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
            }

            if (context.BindingElements != null)
            {
                UseManagedPresentationBindingElement settings =
                    context.BindingElements.Find <UseManagedPresentationBindingElement>();

                if (settings != null)
                {
                    XmlDocument doc = new XmlDocument();

                    // UseUseManagedPresentation assertion
                    XmlElement assertion = doc.CreateElement(UseManagedPresentationPolicyStrings.UseManagedPresentationPrefix,
                                                             UseManagedPresentationPolicyStrings.RequireFederatedIdentityProvisioningName,
                                                             UseManagedPresentationPolicyStrings.UseManagedPresentationNamespace);

                    context.GetBindingAssertions().Add(assertion);
                }
            }
        }
        public override XmlElement CreateWsspHttpsTokenAssertion(MetadataExporter exporter, HttpsTransportBindingElement httpsBinding)
        {
            XmlElement result = CreateWsspAssertion(HttpsTokenName);

            result.SetAttribute(RequireClientCertificateName, httpsBinding.RequireClientCertificate ? TrueName : FalseName);
            return(result);
        }
示例#10
0
        void IPolicyExportExtension.ExportPolicy(MetadataExporter exporter, PolicyConversionContext context)
        {
            bool flag;

            if (exporter == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("exporter");
            }
            if (context == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
            }
            ICollection <XmlElement> bindingAssertions = context.GetBindingAssertions();

            if (TransferModeHelper.IsRequestStreamed(this.TransferMode) || TransferModeHelper.IsResponseStreamed(this.TransferMode))
            {
                bindingAssertions.Add(new XmlDocument().CreateElement("msf", "Streamed", "http://schemas.microsoft.com/ws/2006/05/framing/policy"));
            }
            MessageEncodingBindingElement element = this.FindMessageEncodingBindingElement(context.BindingElements, out flag);

            if (flag && (element is IPolicyExportExtension))
            {
                element = new BinaryMessageEncodingBindingElement();
                ((IPolicyExportExtension)element).ExportPolicy(exporter, context);
            }
            WsdlExporter.WSAddressingHelper.AddWSAddressingAssertion(exporter, context, element.MessageVersion.Addressing);
        }
示例#11
0
        void IPolicyExportExtension.ExportPolicy(MetadataExporter exporter, PolicyConversionContext context)
        {
            if (exporter == null)
            {
                throw new ArgumentNullException("exporter");
            }

            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            ICollection <XmlElement> bindingAssertions = context.GetBindingAssertions();
            XmlDocument xmlDocument = new XmlDocument();

            bindingAssertions.Add(xmlDocument.CreateElement(
                                      SsbConstants.SsbNsPrefix, SsbConstants.SsbTransportAssertion, SsbConstants.SsbNs));

            bool createdNew = false;
            MessageEncodingBindingElement encodingBindingElement = context.BindingElements.Find <MessageEncodingBindingElement>();

            if (encodingBindingElement == null)
            {
                createdNew             = true;
                encodingBindingElement = SsbConstants.DefaultMessageEncodingBindingElement;
            }

            if (createdNew && encodingBindingElement is IPolicyExportExtension)
            {
                ((IPolicyExportExtension)encodingBindingElement).ExportPolicy(exporter, context);
            }

            AddWSAddressingAssertion(context, encodingBindingElement.MessageVersion.Addressing);
        }
        void IPolicyExportExtension.ExportPolicy(MetadataExporter exporter, PolicyConversionContext context)
        {
            if (exporter == null)
            {
                throw new ArgumentNullException("exporter");
            }
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            PolicyAssertionCollection assertions = context.GetBindingAssertions();
            XmlDocument doc = new XmlDocument();

            var messageEncodingElement = ExportAddressingPolicy(context);

            if (messageEncodingElement == null)
            {
                assertions.Add(doc.CreateElement(
                                   "msb", "BinaryEncoding",
                                   "http://schemas.microsoft.com/ws/06/2004/mspolicy/netbinary1"));
            }

            if (transfer_mode == TransferMode.Streamed || transfer_mode == TransferMode.StreamedRequest ||
                transfer_mode == TransferMode.StreamedResponse)
            {
                assertions.Add(doc.CreateElement("msf", "Streamed", "http://schemas.microsoft.com/ws/2006/05/framing/policy"));
            }
        }
示例#13
0
        static void Main(string[] args)
        {
            try {
                ParseArguments(args);

                SAMLConfiguration samlConfiguration = LoadSAMLConfiguration();
                X509Certificate2  x509Certificate   = null;

                if (!string.IsNullOrEmpty(certificateFileName))
                {
                    x509Certificate = LoadCertificate();
                }

                EntityDescriptor entityDescriptor = MetadataExporter.Export(samlConfiguration, x509Certificate, partnerName);

                SaveMetadata(entityDescriptor);
            }

            catch (Exception exception) {
                Console.Error.WriteLine(exception.ToString());

                if (exception is ArgumentException)
                {
                    ShowUsage();
                }
            }
        }
示例#14
0
        void IPolicyExportExtension.ExportPolicy(MetadataExporter exporter, PolicyConversionContext context)
        {
            if (context == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
            }

            if (context.BindingElements != null)
            {
                OneWayBindingElement oneWay = context.BindingElements.Find <OneWayBindingElement>();

                if (oneWay != null)
                {
                    // base assertion
                    XmlDocument doc       = new XmlDocument();
                    XmlElement  assertion = doc.CreateElement(OneWayPolicyConstants.Prefix,
                                                              OneWayPolicyConstants.OneWay, OneWayPolicyConstants.Namespace);

                    if (oneWay.PacketRoutable)
                    {
                        // add nested packet routable assertion
                        XmlElement child = doc.CreateElement(OneWayPolicyConstants.Prefix, OneWayPolicyConstants.PacketRoutable, OneWayPolicyConstants.Namespace);
                        assertion.AppendChild(child);
                    }

                    context.GetBindingAssertions().Add(assertion);
                }
            }
        }
        void IPolicyExportExtension.ExportPolicy(MetadataExporter exporter, PolicyConversionContext context)
        {
            if (exporter == null)
            {
                throw new NullReferenceException("exporter");
            }

            if (context == null)
            {
                throw new NullReferenceException("context");
            }

            XmlElement mhscElement = xmlDocument.CreateElement(HttpCookiePolicyStrings.Prefix,
                                                               HttpCookiePolicyStrings.HttpCookiePolicyElement,
                                                               HttpCookiePolicyStrings.Namespace);

            if (exchangeTerminateMessage)
            {
                XmlAttribute attribute = xmlDocument.CreateAttribute(
                    HttpCookiePolicyStrings.ExchangeTerminateAttribute);

                attribute.Value = "true";

                mhscElement.Attributes.Append(attribute);
            }

            context.GetBindingAssertions().Add(mhscElement);
        }
示例#16
0
        /// <summary>
        /// Implement to include for exporting a custom policy assertion about bindings.
        /// </summary>
        /// <param name="exporter">The <see cref="T:System.ServiceModel.Description.MetadataExporter" /> that you can use to modify the exporting process.</param>
        /// <param name="context">The <see cref="T:System.ServiceModel.Description.PolicyConversionContext" /> that you can use to insert your custom policy assertion.</param>
        public void ExportPolicy(MetadataExporter exporter, PolicyConversionContext context)
        {
            if (exporter == null)
            {
                throw new ArgumentNullException("exporter");
            }

            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            bool createdNew = false;
            MessageEncodingBindingElement encodingBindingElement = context.BindingElements.Find <MessageEncodingBindingElement>();

            if (encodingBindingElement == null)
            {
                createdNew             = true;
                encodingBindingElement = new TextMessageEncodingBindingElement();
            }

            if (createdNew && encodingBindingElement is IPolicyExportExtension)
            {
                ((IPolicyExportExtension)encodingBindingElement).ExportPolicy(exporter, context);
            }

            AddWSAddressingAssertion(context, encodingBindingElement.MessageVersion.Addressing);
        }
        internal void OnExportPolicy(MetadataExporter exporter, PolicyConversionContext context)
        {
            string assertion = "";

            switch (this.Mode)
            {
            case SecurityMode.None:
                assertion = PeerTransportPolicyConstants.PeerTransportSecurityModeNone;
                break;

            case SecurityMode.Transport:
                assertion = PeerTransportPolicyConstants.PeerTransportSecurityModeTransport;
                break;

            case SecurityMode.Message:
                assertion = PeerTransportPolicyConstants.PeerTransportSecurityModeMessage;
                break;

            case SecurityMode.TransportWithMessageCredential:
                assertion = PeerTransportPolicyConstants.PeerTransportSecurityModeTransportWithMessageCredential;
                break;

            default:
                Fx.Assert("Unsupported value for PeerSecuritySettings.Mode");
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException());
            }
            XmlDocument doc     = new XmlDocument();
            XmlElement  element = doc.CreateElement(PeerTransportPolicyConstants.PeerTransportPrefix,
                                                    PeerTransportPolicyConstants.PeerTransportSecurityMode,
                                                    TransportPolicyConstants.PeerTransportUri);

            element.InnerText = assertion;
            context.GetBindingAssertions().Add(element);
            transportSecurity.OnExportPolicy(exporter, context);
        }
示例#18
0
        //<snippet14>
        #region IPolicyExporter Members
        public void ExportPolicy(MetadataExporter exporter, PolicyConversionContext policyContext)
        {
            if (exporter == null)
            {
                throw new NullReferenceException("The MetadataExporter object passed to the ExporterBindingElement is null.");
            }
            if (policyContext == null)
            {
                throw new NullReferenceException("The PolicyConversionContext object passed to the ExporterBindingElement is null.");
            }

            XmlElement elem = doc.CreateElement(name1, ns1);

            elem.InnerText = "My custom text.";
            XmlAttribute att = doc.CreateAttribute("MyCustomAttribute", ns1);

            att.Value = "ExampleValue";
            elem.Attributes.Append(att);
            XmlElement subElement = doc.CreateElement("MyCustomSubElement", ns1);

            subElement.InnerText = "Custom Subelement Text.";
            elem.AppendChild(subElement);
            policyContext.GetBindingAssertions().Add(elem);
            Console.WriteLine("The custom policy exporter was called.");
        }
示例#19
0
        private static EntityDescriptor ExportServiceProviderMetadata(SAMLConfiguration samlConfiguration)
        {
            Console.Write("X.509 signature certificate .CER file [None]: ");
            string           fileName             = Console.ReadLine();
            X509Certificate2 signatureCertificate = LoadCertificate(fileName);

            Console.Write("X.509 encryption certificate .CER file [None]: ");
            fileName = Console.ReadLine();
            X509Certificate2 encryptionCertificate = LoadCertificate(fileName);

            Console.Write("Assertion Consumer Service URL: ");
            string assertionConsumerServiceURL = Console.ReadLine();

            if (string.IsNullOrEmpty(assertionConsumerServiceURL))
            {
                throw new ArgumentException("An assertion consumer service URL must be specified.");
            }

            Console.Write("Single Logout Service URL [None]: ");
            string singleLogoutServiceURL = Console.ReadLine();

            Console.Write("Partner Identity Provider Name [None]: ");
            string partnerName = Console.ReadLine();

            return(MetadataExporter.Export(samlConfiguration, signatureCertificate, encryptionCertificate, assertionConsumerServiceURL, singleLogoutServiceURL, partnerName));
        }
示例#20
0
        internal void OnExportPolicy(MetadataExporter exporter, PolicyConversionContext context)
        {
            string assertion = "";

            switch (this.CredentialType)
            {
            case PeerTransportCredentialType.Password:
                assertion = PeerTransportPolicyConstants.PeerTransportCredentialTypePassword;
                break;

            case PeerTransportCredentialType.Certificate:
                assertion = PeerTransportPolicyConstants.PeerTransportCredentialTypeCertificate;
                break;

            default:
                Fx.Assert("Unsupported value for PeerTransportSecuritySettings.CredentialType");
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException());
            }
            XmlDocument doc     = new XmlDocument();
            XmlElement  element = doc.CreateElement(PeerTransportPolicyConstants.PeerTransportPrefix,
                                                    PeerTransportPolicyConstants.PeerTransportCredentialType,
                                                    TransportPolicyConstants.PeerTransportUri);

            element.InnerText = assertion;
            context.GetBindingAssertions().Add(element);
        }
示例#21
0
        private XmlElement CreateWsspSignedEncryptedSupportingTokensAssertion(MetadataExporter exporter, Collection <SecurityTokenParameters> signedEncrypted, Collection <SecurityTokenParameters> optionalSignedEncrypted)
        {
            XmlElement result;

            if ((signedEncrypted == null || signedEncrypted.Count == 0) &&
                (optionalSignedEncrypted == null || optionalSignedEncrypted.Count == 0))
            {
                result = null;
            }
            else
            {
                XmlElement policy = CreateWspPolicyWrapper(exporter);

                if (signedEncrypted != null)
                {
                    foreach (SecurityTokenParameters p in signedEncrypted)
                    {
                        policy.AppendChild(CreateTokenAssertion(exporter, p));
                    }
                }
                if (optionalSignedEncrypted != null)
                {
                    foreach (SecurityTokenParameters p in optionalSignedEncrypted)
                    {
                        policy.AppendChild(CreateTokenAssertion(exporter, p, true));
                    }
                }

                result = CreateWsspAssertion(SignedEncryptedSupportingTokensName);
                result.AppendChild(policy);
            }

            return(result);
        }
示例#22
0
        void IPolicyExportExtension.ExportPolicy(
            MetadataExporter exporter,
            PolicyConversionContext context)
        {
            if (exporter == null)
            {
                throw new ArgumentNullException("exporter");
            }
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            PolicyAssertionCollection assertions = context.GetBindingAssertions();
            XmlDocument doc = new XmlDocument();

            assertions.Add(doc.CreateElement("wsaw", "UsingAddressing", "http://www.w3.org/2006/05/addressing/wsdl"));

            switch (auth_scheme)
            {
            case AuthenticationSchemes.Basic:
            case AuthenticationSchemes.Digest:
            case AuthenticationSchemes.Negotiate:
            case AuthenticationSchemes.Ntlm:
                assertions.Add(doc.CreateElement("http",
                                                 auth_scheme.ToString() + "Authentication",
                                                 "http://schemas.microsoft.com/ws/06/2004/policy/http"));
                break;
            }
        }
示例#23
0
        internal void OnExportPolicy(MetadataExporter exporter, PolicyConversionContext context)
        {
            string str = "";

            switch (this.Mode)
            {
            case SecurityMode.None:
                str = "PeerTransportSecurityModeNone";
                break;

            case SecurityMode.Transport:
                str = "PeerTransportSecurityModeTransport";
                break;

            case SecurityMode.Message:
                str = "PeerTransportSecurityModeMessage";
                break;

            case SecurityMode.TransportWithMessageCredential:
                str = "PeerTransportSecurityModeTransportWithMessageCredential";
                break;

            default:
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException());
            }
            XmlElement item = new XmlDocument().CreateElement("pc", "PeerTransportSecurityMode", "http://schemas.microsoft.com/soap/peer");

            item.InnerText = str;
            context.GetBindingAssertions().Add(item);
            this.transportSecurity.OnExportPolicy(exporter, context);
        }
示例#24
0
 void IPolicyExportExtension.ExportPolicy(MetadataExporter exporter, PolicyConversionContext context)
 {
     if (context == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
     }
 }
示例#25
0
        void IPolicyExportExtension.ExportPolicy(MetadataExporter exporter, PolicyConversionContext context)
        {
            if (exporter == null)
            {
                throw new ArgumentNullException("exporter");
            }
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            PolicyAssertionCollection assertions = context.GetBindingAssertions();
            var doc = new System.Xml.XmlDocument();

            ExportAddressingPolicy(context);
            switch (auth_scheme)
            {
            case AuthenticationSchemes.Basic:
            case AuthenticationSchemes.Digest:
            case AuthenticationSchemes.Negotiate:
            case AuthenticationSchemes.Ntlm:
                assertions.Add(doc.CreateElement("http", auth_scheme.ToString() + "Authentication", "http://schemas.microsoft.com/ws/06/2004/policy/http"));
                break;
            }
            var transportProvider = this as ITransportTokenAssertionProvider;

            if (transportProvider != null)
            {
                var token = transportProvider.GetTransportTokenAssertion();
                assertions.Add(CreateTransportBinding(token));
            }
        }
示例#26
0
        void IPolicyExportExtension.ExportPolicy(MetadataExporter exporter, PolicyConversionContext context)
        {
            if (context == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
            }

            if (context.BindingElements != null)
            {
                PrivacyNoticeBindingElement settings =
                    context.BindingElements.Find <PrivacyNoticeBindingElement>();

                if (settings != null)
                {
                    XmlDocument doc = new XmlDocument();

                    // PrivacyNotice assertion
                    XmlElement assertion = doc.CreateElement(PrivacyNoticePolicyStrings.PrivacyNoticePrefix,
                                                             PrivacyNoticePolicyStrings.PrivacyNoticeName,
                                                             PrivacyNoticePolicyStrings.PrivacyNoticeNamespace);

                    assertion.InnerText = settings.Url.ToString();
                    assertion.SetAttribute(PrivacyNoticePolicyStrings.PrivacyNoticeVersionAttributeName, PrivacyNoticePolicyStrings.PrivacyNoticeNamespace, XmlConvert.ToString(settings.Version));

                    context.GetBindingAssertions().Add(assertion);
                }
            }
        }
        private XmlElement CreateWsspSignedEncryptedSupportingTokensAssertion(MetadataExporter exporter, Collection <SecurityTokenParameters> signedEncrypted, Collection <SecurityTokenParameters> optionalSignedEncrypted)
        {
            if (((signedEncrypted == null) || (signedEncrypted.Count == 0)) && ((optionalSignedEncrypted == null) || (optionalSignedEncrypted.Count == 0)))
            {
                return(null);
            }
            XmlElement newChild = this.CreateWspPolicyWrapper(exporter, new XmlElement[0]);

            if (signedEncrypted != null)
            {
                foreach (SecurityTokenParameters parameters in signedEncrypted)
                {
                    newChild.AppendChild(this.CreateTokenAssertion(exporter, parameters));
                }
            }
            if (optionalSignedEncrypted != null)
            {
                foreach (SecurityTokenParameters parameters2 in optionalSignedEncrypted)
                {
                    newChild.AppendChild(this.CreateTokenAssertion(exporter, parameters2, true));
                }
            }
            XmlElement element = this.CreateWsspAssertion("SignedEncryptedSupportingTokens");

            element.AppendChild(newChild);
            return(element);
        }
        void IPolicyExportExtension.ExportPolicy(MetadataExporter exporter,
                                                 PolicyConversionContext context)
        {
            PolicyAssertionCollection assertions = context.GetBindingAssertions();
            XmlDocument doc = new XmlDocument();

            assertions.Add(doc.CreateElement("msb", "BinaryEncoding", "http://schemas.microsoft.com/ws/06/2004/mspolicy/netbinary1"));
        }
        public override XmlElement CreateWsspSecureConversationTokenAssertion(MetadataExporter exporter, SecureConversationSecurityTokenParameters parameters)
        {
            XmlElement tokenAssertion = this.CreateWsspAssertion("SecureConversationToken");

            this.SetIncludeTokenValue(tokenAssertion, parameters.InclusionMode);
            tokenAssertion.AppendChild(this.CreateWspPolicyWrapper(exporter, new XmlElement[] { this.CreateWsspRequireDerivedKeysAssertion(parameters.RequireDerivedKeys), this.CreateWsspMustNotSendCancelAssertion(parameters.RequireCancellation), this.CreateWsspBootstrapPolicyAssertion(exporter, parameters.BootstrapSecurityBindingElement), this.CreateWsspMustNotSendAmendAssertion(), (!parameters.RequireCancellation || !parameters.CanRenewSession) ? this.CreateWsspMustNotSendRenewAssertion() : null }));
            return(tokenAssertion);
        }
        public override XmlElement CreateMsspSslContextTokenAssertion(MetadataExporter exporter, SslSecurityTokenParameters parameters)
        {
            XmlElement tokenAssertion = this.CreateMsspAssertion("SslContextToken");

            this.SetIncludeTokenValue(tokenAssertion, parameters.InclusionMode);
            tokenAssertion.AppendChild(this.CreateWspPolicyWrapper(exporter, new XmlElement[] { this.CreateWsspRequireDerivedKeysAssertion(parameters.RequireDerivedKeys), this.CreateWsspMustNotSendCancelAssertion(false), this.CreateMsspRequireClientCertificateAssertion(parameters.RequireClientCertificate), this.CreateWsspMustNotSendAmendAssertion(), this.CreateWsspMustNotSendRenewAssertion() }));
            return(tokenAssertion);
        }